babylon.module.d.ts 6.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770
  1. declare module "babylonjs/types" {
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @returns true if the loader can load the specified file
  1065. */
  1066. canLoad(extension: string): boolean;
  1067. /**
  1068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module "babylonjs/Engines/IPipelineContext" {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _getVertexShaderCode(): string | null;
  1100. /** @hidden */
  1101. _getFragmentShaderCode(): string | null;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module "babylonjs/Meshes/dataBuffer" {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. get underlyingResource(): any;
  1125. }
  1126. }
  1127. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1141. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1142. /** @hidden */
  1143. export interface ProcessingOptions {
  1144. defines: string[];
  1145. indexParameters: any;
  1146. isFragment: boolean;
  1147. shouldUseHighPrecisionShader: boolean;
  1148. supportsUniformBuffers: boolean;
  1149. shadersRepository: string;
  1150. includesShadersStore: {
  1151. [key: string]: string;
  1152. };
  1153. processor?: IShaderProcessor;
  1154. version: string;
  1155. platformName: string;
  1156. lookForClosingBracketForUniformBuffer?: boolean;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1160. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1188. /** @hidden */
  1189. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1190. process(preprocessors: {
  1191. [key: string]: string;
  1192. }, options: ProcessingOptions): string;
  1193. }
  1194. }
  1195. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1196. /** @hidden */
  1197. export class ShaderDefineExpression {
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. private static _OperatorPriority;
  1202. private static _Stack;
  1203. static postfixToInfix(postfix: string[]): string;
  1204. static infixToPostfix(infix: string): string[];
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1208. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderCodeTestNode extends ShaderCodeNode {
  1212. testExpression: ShaderDefineExpression;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. not: boolean;
  1224. constructor(define: string, not?: boolean);
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1234. leftOperand: ShaderDefineExpression;
  1235. rightOperand: ShaderDefineExpression;
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1242. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1243. /** @hidden */
  1244. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1256. define: string;
  1257. operand: string;
  1258. testValue: string;
  1259. constructor(define: string, operand: string, testValue: string);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module "babylonjs/Offline/IOfflineProvider" {
  1266. /**
  1267. * Class used to enable access to offline support
  1268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1269. */
  1270. export interface IOfflineProvider {
  1271. /**
  1272. * Gets a boolean indicating if scene must be saved in the database
  1273. */
  1274. enableSceneOffline: boolean;
  1275. /**
  1276. * Gets a boolean indicating if textures must be saved in the database
  1277. */
  1278. enableTexturesOffline: boolean;
  1279. /**
  1280. * Open the offline support and make it available
  1281. * @param successCallback defines the callback to call on success
  1282. * @param errorCallback defines the callback to call on error
  1283. */
  1284. open(successCallback: () => void, errorCallback: () => void): void;
  1285. /**
  1286. * Loads an image from the offline support
  1287. * @param url defines the url to load from
  1288. * @param image defines the target DOM image
  1289. */
  1290. loadImage(url: string, image: HTMLImageElement): void;
  1291. /**
  1292. * Loads a file from offline support
  1293. * @param url defines the URL to load from
  1294. * @param sceneLoaded defines a callback to call on success
  1295. * @param progressCallBack defines a callback to call when progress changed
  1296. * @param errorCallback defines a callback to call on error
  1297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1298. */
  1299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1300. }
  1301. }
  1302. declare module "babylonjs/Misc/filesInputStore" {
  1303. /**
  1304. * Class used to help managing file picking and drag'n'drop
  1305. * File Storage
  1306. */
  1307. export class FilesInputStore {
  1308. /**
  1309. * List of files ready to be loaded
  1310. */
  1311. static FilesToLoad: {
  1312. [key: string]: File;
  1313. };
  1314. }
  1315. }
  1316. declare module "babylonjs/Misc/retryStrategy" {
  1317. import { WebRequest } from "babylonjs/Misc/webRequest";
  1318. /**
  1319. * Class used to define a retry strategy when error happens while loading assets
  1320. */
  1321. export class RetryStrategy {
  1322. /**
  1323. * Function used to defines an exponential back off strategy
  1324. * @param maxRetries defines the maximum number of retries (3 by default)
  1325. * @param baseInterval defines the interval between retries
  1326. * @returns the strategy function to use
  1327. */
  1328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/baseError" {
  1332. /**
  1333. * @ignore
  1334. * Application error to support additional information when loading a file
  1335. */
  1336. export abstract class BaseError extends Error {
  1337. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/fileTools" {
  1341. import { WebRequest } from "babylonjs/Misc/webRequest";
  1342. import { Nullable } from "babylonjs/types";
  1343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1345. import { BaseError } from "babylonjs/Misc/baseError";
  1346. /** @ignore */
  1347. export class LoadFileError extends BaseError {
  1348. request?: WebRequest;
  1349. file?: File;
  1350. /**
  1351. * Creates a new LoadFileError
  1352. * @param message defines the message of the error
  1353. * @param request defines the optional web request
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, object?: WebRequest | File);
  1357. }
  1358. /** @ignore */
  1359. export class RequestFileError extends BaseError {
  1360. request: WebRequest;
  1361. /**
  1362. * Creates a new LoadFileError
  1363. * @param message defines the message of the error
  1364. * @param request defines the optional web request
  1365. */
  1366. constructor(message: string, request: WebRequest);
  1367. }
  1368. /** @ignore */
  1369. export class ReadFileError extends BaseError {
  1370. file: File;
  1371. /**
  1372. * Creates a new ReadFileError
  1373. * @param message defines the message of the error
  1374. * @param file defines the optional file
  1375. */
  1376. constructor(message: string, file: File);
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export class FileTools {
  1382. /**
  1383. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1384. */
  1385. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1386. /**
  1387. * Gets or sets the base URL to use to load assets
  1388. */
  1389. static BaseUrl: string;
  1390. /**
  1391. * Default behaviour for cors in the application.
  1392. * It can be a string if the expected behavior is identical in the entire app.
  1393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1394. */
  1395. static CorsBehavior: string | ((url: string | string[]) => string);
  1396. /**
  1397. * Gets or sets a function used to pre-process url before using them to load assets
  1398. */
  1399. static PreprocessUrl: (url: string) => string;
  1400. /**
  1401. * Removes unwanted characters from an url
  1402. * @param url defines the url to clean
  1403. * @returns the cleaned url
  1404. */
  1405. private static _CleanUrl;
  1406. /**
  1407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1408. * @param url define the url we are trying
  1409. * @param element define the dom element where to configure the cors policy
  1410. */
  1411. static SetCorsBehavior(url: string | string[], element: {
  1412. crossOrigin: string | null;
  1413. }): void;
  1414. /**
  1415. * Loads an image as an HTMLImageElement.
  1416. * @param input url string, ArrayBuffer, or Blob to load
  1417. * @param onLoad callback called when the image successfully loads
  1418. * @param onError callback called when the image fails to load
  1419. * @param offlineProvider offline provider for caching
  1420. * @param mimeType optional mime type
  1421. * @returns the HTMLImageElement of the loaded image
  1422. */
  1423. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1424. /**
  1425. * Reads a file from a File object
  1426. * @param file defines the file to load
  1427. * @param onSuccess defines the callback to call when data is loaded
  1428. * @param onProgress defines the callback to call during loading process
  1429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1430. * @param onError defines the callback to call when an error occurs
  1431. * @returns a file request object
  1432. */
  1433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1434. /**
  1435. * Loads a file from a url
  1436. * @param url url to load
  1437. * @param onSuccess callback called when the file successfully loads
  1438. * @param onProgress callback called while file is loading (if the server supports this mode)
  1439. * @param offlineProvider defines the offline provider for caching
  1440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1441. * @param onError callback called when the file fails to load
  1442. * @returns a file request object
  1443. */
  1444. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1445. /**
  1446. * Loads a file
  1447. * @param url url to load
  1448. * @param onSuccess callback called when the file successfully loads
  1449. * @param onProgress callback called while file is loading (if the server supports this mode)
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @param onOpened callback called when the web request is opened
  1453. * @returns a file request object
  1454. */
  1455. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1456. /**
  1457. * Checks if the loaded document was accessed via `file:`-Protocol.
  1458. * @returns boolean
  1459. */
  1460. static IsFileURL(): boolean;
  1461. }
  1462. }
  1463. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1464. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1465. import { WebRequest } from "babylonjs/Misc/webRequest";
  1466. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1467. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1469. /** @hidden */
  1470. export class ShaderProcessor {
  1471. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1472. private static _ProcessPrecision;
  1473. private static _ExtractOperation;
  1474. private static _BuildSubExpression;
  1475. private static _BuildExpression;
  1476. private static _MoveCursorWithinIf;
  1477. private static _MoveCursor;
  1478. private static _EvaluatePreProcessors;
  1479. private static _PreparePreProcessors;
  1480. private static _ProcessShaderConversion;
  1481. private static _ProcessIncludes;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. * @hidden
  1492. */
  1493. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1494. }
  1495. }
  1496. declare module "babylonjs/Maths/math.like" {
  1497. import { float, int, DeepImmutable } from "babylonjs/types";
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor4Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. a: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor3Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector4Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. w: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector3Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector2Like {
  1536. x: float;
  1537. y: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IMatrixLike {
  1543. toArray(): DeepImmutable<Float32Array>;
  1544. updateFlag: int;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IViewportLike {
  1550. x: float;
  1551. y: float;
  1552. width: float;
  1553. height: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IPlaneLike {
  1559. normal: IVector3Like;
  1560. d: float;
  1561. normalize(): void;
  1562. }
  1563. }
  1564. declare module "babylonjs/Materials/iEffectFallbacks" {
  1565. import { Effect } from "babylonjs/Materials/effect";
  1566. /**
  1567. * Interface used to define common properties for effect fallbacks
  1568. */
  1569. export interface IEffectFallbacks {
  1570. /**
  1571. * Removes the defines that should be removed when falling back.
  1572. * @param currentDefines defines the current define statements for the shader.
  1573. * @param effect defines the current effect we try to compile
  1574. * @returns The resulting defines with defines of the current rank removed.
  1575. */
  1576. reduce(currentDefines: string, effect: Effect): string;
  1577. /**
  1578. * Removes the fallback from the bound mesh.
  1579. */
  1580. unBindMesh(): void;
  1581. /**
  1582. * Checks to see if more fallbacks are still availible.
  1583. */
  1584. hasMoreFallbacks: boolean;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1588. /**
  1589. * Class used to evalaute queries containing `and` and `or` operators
  1590. */
  1591. export class AndOrNotEvaluator {
  1592. /**
  1593. * Evaluate a query
  1594. * @param query defines the query to evaluate
  1595. * @param evaluateCallback defines the callback used to filter result
  1596. * @returns true if the query matches
  1597. */
  1598. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1599. private static _HandleParenthesisContent;
  1600. private static _SimplifyNegation;
  1601. }
  1602. }
  1603. declare module "babylonjs/Misc/tags" {
  1604. /**
  1605. * Class used to store custom tags
  1606. */
  1607. export class Tags {
  1608. /**
  1609. * Adds support for tags on the given object
  1610. * @param obj defines the object to use
  1611. */
  1612. static EnableFor(obj: any): void;
  1613. /**
  1614. * Removes tags support
  1615. * @param obj defines the object to use
  1616. */
  1617. static DisableFor(obj: any): void;
  1618. /**
  1619. * Gets a boolean indicating if the given object has tags
  1620. * @param obj defines the object to use
  1621. * @returns a boolean
  1622. */
  1623. static HasTags(obj: any): boolean;
  1624. /**
  1625. * Gets the tags available on a given object
  1626. * @param obj defines the object to use
  1627. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1628. * @returns the tags
  1629. */
  1630. static GetTags(obj: any, asString?: boolean): any;
  1631. /**
  1632. * Adds tags to an object
  1633. * @param obj defines the object to use
  1634. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1635. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1636. */
  1637. static AddTagsTo(obj: any, tagsString: string): void;
  1638. /**
  1639. * @hidden
  1640. */
  1641. static _AddTagTo(obj: any, tag: string): void;
  1642. /**
  1643. * Removes specific tags from a specific object
  1644. * @param obj defines the object to use
  1645. * @param tagsString defines the tags to remove
  1646. */
  1647. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _RemoveTagFrom(obj: any, tag: string): void;
  1652. /**
  1653. * Defines if tags hosted on an object match a given query
  1654. * @param obj defines the object to use
  1655. * @param tagsQuery defines the tag query
  1656. * @returns a boolean
  1657. */
  1658. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1659. }
  1660. }
  1661. declare module "babylonjs/Maths/math.scalar" {
  1662. /**
  1663. * Scalar computation library
  1664. */
  1665. export class Scalar {
  1666. /**
  1667. * Two pi constants convenient for computation.
  1668. */
  1669. static TwoPi: number;
  1670. /**
  1671. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. * @param a number
  1673. * @param b number
  1674. * @param epsilon (default = 1.401298E-45)
  1675. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1676. */
  1677. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1678. /**
  1679. * Returns a string : the upper case translation of the number i to hexadecimal.
  1680. * @param i number
  1681. * @returns the upper case translation of the number i to hexadecimal.
  1682. */
  1683. static ToHex(i: number): string;
  1684. /**
  1685. * Returns -1 if value is negative and +1 is value is positive.
  1686. * @param value the value
  1687. * @returns the value itself if it's equal to zero.
  1688. */
  1689. static Sign(value: number): number;
  1690. /**
  1691. * Returns the value itself if it's between min and max.
  1692. * Returns min if the value is lower than min.
  1693. * Returns max if the value is greater than max.
  1694. * @param value the value to clmap
  1695. * @param min the min value to clamp to (default: 0)
  1696. * @param max the max value to clamp to (default: 1)
  1697. * @returns the clamped value
  1698. */
  1699. static Clamp(value: number, min?: number, max?: number): number;
  1700. /**
  1701. * the log2 of value.
  1702. * @param value the value to compute log2 of
  1703. * @returns the log2 of value.
  1704. */
  1705. static Log2(value: number): number;
  1706. /**
  1707. * Loops the value, so that it is never larger than length and never smaller than 0.
  1708. *
  1709. * This is similar to the modulo operator but it works with floating point numbers.
  1710. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1711. * With t = 5 and length = 2.5, the result would be 0.0.
  1712. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1713. * @param value the value
  1714. * @param length the length
  1715. * @returns the looped value
  1716. */
  1717. static Repeat(value: number, length: number): number;
  1718. /**
  1719. * Normalize the value between 0.0 and 1.0 using min and max values
  1720. * @param value value to normalize
  1721. * @param min max to normalize between
  1722. * @param max min to normalize between
  1723. * @returns the normalized value
  1724. */
  1725. static Normalize(value: number, min: number, max: number): number;
  1726. /**
  1727. * Denormalize the value from 0.0 and 1.0 using min and max values
  1728. * @param normalized value to denormalize
  1729. * @param min max to denormalize between
  1730. * @param max min to denormalize between
  1731. * @returns the denormalized value
  1732. */
  1733. static Denormalize(normalized: number, min: number, max: number): number;
  1734. /**
  1735. * Calculates the shortest difference between two given angles given in degrees.
  1736. * @param current current angle in degrees
  1737. * @param target target angle in degrees
  1738. * @returns the delta
  1739. */
  1740. static DeltaAngle(current: number, target: number): number;
  1741. /**
  1742. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1743. * @param tx value
  1744. * @param length length
  1745. * @returns The returned value will move back and forth between 0 and length
  1746. */
  1747. static PingPong(tx: number, length: number): number;
  1748. /**
  1749. * Interpolates between min and max with smoothing at the limits.
  1750. *
  1751. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1752. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1753. * @param from from
  1754. * @param to to
  1755. * @param tx value
  1756. * @returns the smooth stepped value
  1757. */
  1758. static SmoothStep(from: number, to: number, tx: number): number;
  1759. /**
  1760. * Moves a value current towards target.
  1761. *
  1762. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1763. * Negative values of maxDelta pushes the value away from target.
  1764. * @param current current value
  1765. * @param target target value
  1766. * @param maxDelta max distance to move
  1767. * @returns resulting value
  1768. */
  1769. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1770. /**
  1771. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1772. *
  1773. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1774. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1775. * @param current current value
  1776. * @param target target value
  1777. * @param maxDelta max distance to move
  1778. * @returns resulting angle
  1779. */
  1780. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1781. /**
  1782. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static Lerp(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static LerpAngle(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1800. * @param a start value
  1801. * @param b target value
  1802. * @param value value between a and b
  1803. * @returns the inverseLerp value
  1804. */
  1805. static InverseLerp(a: number, b: number, value: number): number;
  1806. /**
  1807. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1808. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1809. * @param value1 spline value
  1810. * @param tangent1 spline value
  1811. * @param value2 spline value
  1812. * @param tangent2 spline value
  1813. * @param amount input value
  1814. * @returns hermite result
  1815. */
  1816. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1817. /**
  1818. * Returns a random float number between and min and max values
  1819. * @param min min value of random
  1820. * @param max max value of random
  1821. * @returns random value
  1822. */
  1823. static RandomRange(min: number, max: number): number;
  1824. /**
  1825. * This function returns percentage of a number in a given range.
  1826. *
  1827. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1828. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1829. * @param number to convert to percentage
  1830. * @param min min range
  1831. * @param max max range
  1832. * @returns the percentage
  1833. */
  1834. static RangeToPercent(number: number, min: number, max: number): number;
  1835. /**
  1836. * This function returns number that corresponds to the percentage in a given range.
  1837. *
  1838. * PercentToRange(0.34,0,100) will return 34.
  1839. * @param percent to convert to number
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the number
  1843. */
  1844. static PercentToRange(percent: number, min: number, max: number): number;
  1845. /**
  1846. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1847. * @param angle The angle to normalize in radian.
  1848. * @return The converted angle.
  1849. */
  1850. static NormalizeRadians(angle: number): number;
  1851. }
  1852. }
  1853. declare module "babylonjs/Maths/math.constants" {
  1854. /**
  1855. * Constant used to convert a value to gamma space
  1856. * @ignorenaming
  1857. */
  1858. export const ToGammaSpace: number;
  1859. /**
  1860. * Constant used to convert a value to linear space
  1861. * @ignorenaming
  1862. */
  1863. export const ToLinearSpace = 2.2;
  1864. /**
  1865. * Constant used to define the minimal number value in Babylon.js
  1866. * @ignorenaming
  1867. */
  1868. let Epsilon: number;
  1869. export { Epsilon };
  1870. }
  1871. declare module "babylonjs/Maths/math.viewport" {
  1872. /**
  1873. * Class used to represent a viewport on screen
  1874. */
  1875. export class Viewport {
  1876. /** viewport left coordinate */
  1877. x: number;
  1878. /** viewport top coordinate */
  1879. y: number;
  1880. /**viewport width */
  1881. width: number;
  1882. /** viewport height */
  1883. height: number;
  1884. /**
  1885. * Creates a Viewport object located at (x, y) and sized (width, height)
  1886. * @param x defines viewport left coordinate
  1887. * @param y defines viewport top coordinate
  1888. * @param width defines the viewport width
  1889. * @param height defines the viewport height
  1890. */
  1891. constructor(
  1892. /** viewport left coordinate */
  1893. x: number,
  1894. /** viewport top coordinate */
  1895. y: number,
  1896. /**viewport width */
  1897. width: number,
  1898. /** viewport height */
  1899. height: number);
  1900. /**
  1901. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1902. * @param renderWidth defines the rendering width
  1903. * @param renderHeight defines the rendering height
  1904. * @returns a new Viewport
  1905. */
  1906. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1907. /**
  1908. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1909. * @param renderWidth defines the rendering width
  1910. * @param renderHeight defines the rendering height
  1911. * @param ref defines the target viewport
  1912. * @returns the current viewport
  1913. */
  1914. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1915. /**
  1916. * Returns a new Viewport copied from the current one
  1917. * @returns a new Viewport
  1918. */
  1919. clone(): Viewport;
  1920. }
  1921. }
  1922. declare module "babylonjs/Misc/arrayTools" {
  1923. /**
  1924. * Class containing a set of static utilities functions for arrays.
  1925. */
  1926. export class ArrayTools {
  1927. /**
  1928. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1929. * @param size the number of element to construct and put in the array
  1930. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1931. * @returns a new array filled with new objects
  1932. */
  1933. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1934. }
  1935. }
  1936. declare module "babylonjs/Maths/math.plane" {
  1937. import { DeepImmutable } from "babylonjs/types";
  1938. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1939. /**
  1940. * Represens a plane by the equation ax + by + cz + d = 0
  1941. */
  1942. export class Plane {
  1943. private static _TmpMatrix;
  1944. /**
  1945. * Normal of the plane (a,b,c)
  1946. */
  1947. normal: Vector3;
  1948. /**
  1949. * d component of the plane
  1950. */
  1951. d: number;
  1952. /**
  1953. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1954. * @param a a component of the plane
  1955. * @param b b component of the plane
  1956. * @param c c component of the plane
  1957. * @param d d component of the plane
  1958. */
  1959. constructor(a: number, b: number, c: number, d: number);
  1960. /**
  1961. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1962. */
  1963. asArray(): number[];
  1964. /**
  1965. * @returns a new plane copied from the current Plane.
  1966. */
  1967. clone(): Plane;
  1968. /**
  1969. * @returns the string "Plane".
  1970. */
  1971. getClassName(): string;
  1972. /**
  1973. * @returns the Plane hash code.
  1974. */
  1975. getHashCode(): number;
  1976. /**
  1977. * Normalize the current Plane in place.
  1978. * @returns the updated Plane.
  1979. */
  1980. normalize(): Plane;
  1981. /**
  1982. * Applies a transformation the plane and returns the result
  1983. * @param transformation the transformation matrix to be applied to the plane
  1984. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1985. */
  1986. transform(transformation: DeepImmutable<Matrix>): Plane;
  1987. /**
  1988. * Compute the dot product between the point and the plane normal
  1989. * @param point point to calculate the dot product with
  1990. * @returns the dot product (float) of the point coordinates and the plane normal.
  1991. */
  1992. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1993. /**
  1994. * Updates the current Plane from the plane defined by the three given points.
  1995. * @param point1 one of the points used to contruct the plane
  1996. * @param point2 one of the points used to contruct the plane
  1997. * @param point3 one of the points used to contruct the plane
  1998. * @returns the updated Plane.
  1999. */
  2000. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2001. /**
  2002. * Checks if the plane is facing a given direction
  2003. * @param direction the direction to check if the plane is facing
  2004. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2005. * @returns True is the vector "direction" is the same side than the plane normal.
  2006. */
  2007. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2008. /**
  2009. * Calculates the distance to a point
  2010. * @param point point to calculate distance to
  2011. * @returns the signed distance (float) from the given point to the Plane.
  2012. */
  2013. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2014. /**
  2015. * Creates a plane from an array
  2016. * @param array the array to create a plane from
  2017. * @returns a new Plane from the given array.
  2018. */
  2019. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2020. /**
  2021. * Creates a plane from three points
  2022. * @param point1 point used to create the plane
  2023. * @param point2 point used to create the plane
  2024. * @param point3 point used to create the plane
  2025. * @returns a new Plane defined by the three given points.
  2026. */
  2027. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2028. /**
  2029. * Creates a plane from an origin point and a normal
  2030. * @param origin origin of the plane to be constructed
  2031. * @param normal normal of the plane to be constructed
  2032. * @returns a new Plane the normal vector to this plane at the given origin point.
  2033. * Note : the vector "normal" is updated because normalized.
  2034. */
  2035. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Calculates the distance from a plane and a point
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @param point point to calculate distance to
  2041. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2042. */
  2043. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2044. }
  2045. }
  2046. declare module "babylonjs/Maths/math.vector" {
  2047. import { Viewport } from "babylonjs/Maths/math.viewport";
  2048. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2049. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2050. import { Plane } from "babylonjs/Maths/math.plane";
  2051. /**
  2052. * Class representing a vector containing 2 coordinates
  2053. */
  2054. export class Vector2 {
  2055. /** defines the first coordinate */
  2056. x: number;
  2057. /** defines the second coordinate */
  2058. y: number;
  2059. /**
  2060. * Creates a new Vector2 from the given x and y coordinates
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. */
  2064. constructor(
  2065. /** defines the first coordinate */
  2066. x?: number,
  2067. /** defines the second coordinate */
  2068. y?: number);
  2069. /**
  2070. * Gets a string with the Vector2 coordinates
  2071. * @returns a string with the Vector2 coordinates
  2072. */
  2073. toString(): string;
  2074. /**
  2075. * Gets class name
  2076. * @returns the string "Vector2"
  2077. */
  2078. getClassName(): string;
  2079. /**
  2080. * Gets current vector hash code
  2081. * @returns the Vector2 hash code as a number
  2082. */
  2083. getHashCode(): number;
  2084. /**
  2085. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2086. * @param array defines the source array
  2087. * @param index defines the offset in source array
  2088. * @returns the current Vector2
  2089. */
  2090. toArray(array: FloatArray, index?: number): Vector2;
  2091. /**
  2092. * Copy the current vector to an array
  2093. * @returns a new array with 2 elements: the Vector2 coordinates.
  2094. */
  2095. asArray(): number[];
  2096. /**
  2097. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2098. * @param source defines the source Vector2
  2099. * @returns the current updated Vector2
  2100. */
  2101. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2102. /**
  2103. * Sets the Vector2 coordinates with the given floats
  2104. * @param x defines the first coordinate
  2105. * @param y defines the second coordinate
  2106. * @returns the current updated Vector2
  2107. */
  2108. copyFromFloats(x: number, y: number): Vector2;
  2109. /**
  2110. * Sets the Vector2 coordinates with the given floats
  2111. * @param x defines the first coordinate
  2112. * @param y defines the second coordinate
  2113. * @returns the current updated Vector2
  2114. */
  2115. set(x: number, y: number): Vector2;
  2116. /**
  2117. * Add another vector with the current one
  2118. * @param otherVector defines the other vector
  2119. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2120. */
  2121. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2122. /**
  2123. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2124. * @param otherVector defines the other vector
  2125. * @param result defines the target vector
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2129. /**
  2130. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2131. * @param otherVector defines the other vector
  2132. * @returns the current updated Vector2
  2133. */
  2134. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2135. /**
  2136. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2137. * @param otherVector defines the other vector
  2138. * @returns a new Vector2
  2139. */
  2140. addVector3(otherVector: Vector3): Vector2;
  2141. /**
  2142. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2143. * @param otherVector defines the other vector
  2144. * @returns a new Vector2
  2145. */
  2146. subtract(otherVector: Vector2): Vector2;
  2147. /**
  2148. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2149. * @param otherVector defines the other vector
  2150. * @param result defines the target vector
  2151. * @returns the unmodified current Vector2
  2152. */
  2153. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2154. /**
  2155. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2156. * @param otherVector defines the other vector
  2157. * @returns the current updated Vector2
  2158. */
  2159. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2160. /**
  2161. * Multiplies in place the current Vector2 coordinates by the given ones
  2162. * @param otherVector defines the other vector
  2163. * @returns the current updated Vector2
  2164. */
  2165. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2166. /**
  2167. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2168. * @param otherVector defines the other vector
  2169. * @returns a new Vector2
  2170. */
  2171. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2174. * @param otherVector defines the other vector
  2175. * @param result defines the target vector
  2176. * @returns the unmodified current Vector2
  2177. */
  2178. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2179. /**
  2180. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns a new Vector2
  2184. */
  2185. multiplyByFloats(x: number, y: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2
  2190. */
  2191. divide(otherVector: Vector2): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Divides the current Vector2 coordinates by the given ones
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 with current Vector2 negated coordinates
  2207. * @returns a new Vector2
  2208. */
  2209. negate(): Vector2;
  2210. /**
  2211. * Negate this vector in place
  2212. * @returns this
  2213. */
  2214. negateInPlace(): Vector2;
  2215. /**
  2216. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2217. * @param result defines the Vector3 object where to store the result
  2218. * @returns the current Vector2
  2219. */
  2220. negateToRef(result: Vector2): Vector2;
  2221. /**
  2222. * Multiply the Vector2 coordinates by scale
  2223. * @param scale defines the scaling factor
  2224. * @returns the current updated Vector2
  2225. */
  2226. scaleInPlace(scale: number): Vector2;
  2227. /**
  2228. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2229. * @param scale defines the scaling factor
  2230. * @returns a new Vector2
  2231. */
  2232. scale(scale: number): Vector2;
  2233. /**
  2234. * Scale the current Vector2 values by a factor to a given Vector2
  2235. * @param scale defines the scale factor
  2236. * @param result defines the Vector2 object where to store the result
  2237. * @returns the unmodified current Vector2
  2238. */
  2239. scaleToRef(scale: number, result: Vector2): Vector2;
  2240. /**
  2241. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2242. * @param scale defines the scale factor
  2243. * @param result defines the Vector2 object where to store the result
  2244. * @returns the unmodified current Vector2
  2245. */
  2246. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2247. /**
  2248. * Gets a boolean if two vectors are equals
  2249. * @param otherVector defines the other vector
  2250. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2251. */
  2252. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets a boolean if two vectors are equals (using an epsilon value)
  2255. * @param otherVector defines the other vector
  2256. * @param epsilon defines the minimal distance to consider equality
  2257. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2258. */
  2259. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2260. /**
  2261. * Gets a new Vector2 from current Vector2 floored values
  2262. * @returns a new Vector2
  2263. */
  2264. floor(): Vector2;
  2265. /**
  2266. * Gets a new Vector2 from current Vector2 floored values
  2267. * @returns a new Vector2
  2268. */
  2269. fract(): Vector2;
  2270. /**
  2271. * Gets the length of the vector
  2272. * @returns the vector length (float)
  2273. */
  2274. length(): number;
  2275. /**
  2276. * Gets the vector squared length
  2277. * @returns the vector squared length (float)
  2278. */
  2279. lengthSquared(): number;
  2280. /**
  2281. * Normalize the vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. normalize(): Vector2;
  2285. /**
  2286. * Gets a new Vector2 copied from the Vector2
  2287. * @returns a new Vector2
  2288. */
  2289. clone(): Vector2;
  2290. /**
  2291. * Gets a new Vector2(0, 0)
  2292. * @returns a new Vector2
  2293. */
  2294. static Zero(): Vector2;
  2295. /**
  2296. * Gets a new Vector2(1, 1)
  2297. * @returns a new Vector2
  2298. */
  2299. static One(): Vector2;
  2300. /**
  2301. * Gets a new Vector2 set from the given index element of the given array
  2302. * @param array defines the data source
  2303. * @param offset defines the offset in the data source
  2304. * @returns a new Vector2
  2305. */
  2306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2307. /**
  2308. * Sets "result" from the given index element of the given array
  2309. * @param array defines the data source
  2310. * @param offset defines the offset in the data source
  2311. * @param result defines the target vector
  2312. */
  2313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2314. /**
  2315. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2316. * @param value1 defines 1st point of control
  2317. * @param value2 defines 2nd point of control
  2318. * @param value3 defines 3rd point of control
  2319. * @param value4 defines 4th point of control
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * 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".
  2326. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2327. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2328. * @param value defines the value to clamp
  2329. * @param min defines the lower limit
  2330. * @param max defines the upper limit
  2331. * @returns a new Vector2
  2332. */
  2333. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2334. /**
  2335. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2336. * @param value1 defines the 1st control point
  2337. * @param tangent1 defines the outgoing tangent
  2338. * @param value2 defines the 2nd control point
  2339. * @param tangent2 defines the incoming tangent
  2340. * @param amount defines the interpolation factor
  2341. * @returns a new Vector2
  2342. */
  2343. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2344. /**
  2345. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2346. * @param start defines the start vector
  2347. * @param end defines the end vector
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Gets the dot product of the vector "left" and the vector "right"
  2354. * @param left defines first vector
  2355. * @param right defines second vector
  2356. * @returns the dot product (float)
  2357. */
  2358. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2359. /**
  2360. * Returns a new Vector2 equal to the normalized given vector
  2361. * @param vector defines the vector to normalize
  2362. * @returns a new Vector2
  2363. */
  2364. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2365. /**
  2366. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2367. * @param left defines 1st vector
  2368. * @param right defines 2nd vector
  2369. * @returns a new Vector2
  2370. */
  2371. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2372. /**
  2373. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2374. * @param left defines 1st vector
  2375. * @param right defines 2nd vector
  2376. * @returns a new Vector2
  2377. */
  2378. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2379. /**
  2380. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2381. * @param vector defines the vector to transform
  2382. * @param transformation defines the matrix to apply
  2383. * @returns a new Vector2
  2384. */
  2385. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2386. /**
  2387. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2388. * @param vector defines the vector to transform
  2389. * @param transformation defines the matrix to apply
  2390. * @param result defines the target vector
  2391. */
  2392. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2393. /**
  2394. * Determines if a given vector is included in a triangle
  2395. * @param p defines the vector to test
  2396. * @param p0 defines 1st triangle point
  2397. * @param p1 defines 2nd triangle point
  2398. * @param p2 defines 3rd triangle point
  2399. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2400. */
  2401. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2402. /**
  2403. * Gets the distance between the vectors "value1" and "value2"
  2404. * @param value1 defines first vector
  2405. * @param value2 defines second vector
  2406. * @returns the distance between vectors
  2407. */
  2408. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2409. /**
  2410. * Returns the squared distance between the vectors "value1" and "value2"
  2411. * @param value1 defines first vector
  2412. * @param value2 defines second vector
  2413. * @returns the squared distance between vectors
  2414. */
  2415. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2416. /**
  2417. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2418. * @param value1 defines first vector
  2419. * @param value2 defines second vector
  2420. * @returns a new Vector2
  2421. */
  2422. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2423. /**
  2424. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2425. * @param p defines the middle point
  2426. * @param segA defines one point of the segment
  2427. * @param segB defines the other point of the segment
  2428. * @returns the shortest distance
  2429. */
  2430. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2431. }
  2432. /**
  2433. * Class used to store (x,y,z) vector representation
  2434. * A Vector3 is the main object used in 3D geometry
  2435. * It can represent etiher the coordinates of a point the space, either a direction
  2436. * Reminder: js uses a left handed forward facing system
  2437. */
  2438. export class Vector3 {
  2439. /**
  2440. * Defines the first coordinates (on X axis)
  2441. */
  2442. x: number;
  2443. /**
  2444. * Defines the second coordinates (on Y axis)
  2445. */
  2446. y: number;
  2447. /**
  2448. * Defines the third coordinates (on Z axis)
  2449. */
  2450. z: number;
  2451. private static _UpReadOnly;
  2452. private static _ZeroReadOnly;
  2453. /**
  2454. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2455. * @param x defines the first coordinates (on X axis)
  2456. * @param y defines the second coordinates (on Y axis)
  2457. * @param z defines the third coordinates (on Z axis)
  2458. */
  2459. constructor(
  2460. /**
  2461. * Defines the first coordinates (on X axis)
  2462. */
  2463. x?: number,
  2464. /**
  2465. * Defines the second coordinates (on Y axis)
  2466. */
  2467. y?: number,
  2468. /**
  2469. * Defines the third coordinates (on Z axis)
  2470. */
  2471. z?: number);
  2472. /**
  2473. * Creates a string representation of the Vector3
  2474. * @returns a string with the Vector3 coordinates.
  2475. */
  2476. toString(): string;
  2477. /**
  2478. * Gets the class name
  2479. * @returns the string "Vector3"
  2480. */
  2481. getClassName(): string;
  2482. /**
  2483. * Creates the Vector3 hash code
  2484. * @returns a number which tends to be unique between Vector3 instances
  2485. */
  2486. getHashCode(): number;
  2487. /**
  2488. * Creates an array containing three elements : the coordinates of the Vector3
  2489. * @returns a new array of numbers
  2490. */
  2491. asArray(): number[];
  2492. /**
  2493. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2494. * @param array defines the destination array
  2495. * @param index defines the offset in the destination array
  2496. * @returns the current Vector3
  2497. */
  2498. toArray(array: FloatArray, index?: number): Vector3;
  2499. /**
  2500. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2501. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2502. */
  2503. toQuaternion(): Quaternion;
  2504. /**
  2505. * Adds the given vector to the current Vector3
  2506. * @param otherVector defines the second operand
  2507. * @returns the current updated Vector3
  2508. */
  2509. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Adds the given coordinates to the current Vector3
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the resulting Vector3
  2522. */
  2523. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Subtract the given vector from the current Vector3
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2537. /**
  2538. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2539. * @param otherVector defines the second operand
  2540. * @returns the resulting Vector3
  2541. */
  2542. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the resulting Vector3
  2556. */
  2557. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2567. /**
  2568. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2569. * @returns a new Vector3
  2570. */
  2571. negate(): Vector3;
  2572. /**
  2573. * Negate this vector in place
  2574. * @returns this
  2575. */
  2576. negateInPlace(): Vector3;
  2577. /**
  2578. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2579. * @param result defines the Vector3 object where to store the result
  2580. * @returns the current Vector3
  2581. */
  2582. negateToRef(result: Vector3): Vector3;
  2583. /**
  2584. * Multiplies the Vector3 coordinates by the float "scale"
  2585. * @param scale defines the multiplier factor
  2586. * @returns the current updated Vector3
  2587. */
  2588. scaleInPlace(scale: number): Vector3;
  2589. /**
  2590. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2591. * @param scale defines the multiplier factor
  2592. * @returns a new Vector3
  2593. */
  2594. scale(scale: number): Vector3;
  2595. /**
  2596. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2597. * @param scale defines the multiplier factor
  2598. * @param result defines the Vector3 object where to store the result
  2599. * @returns the current Vector3
  2600. */
  2601. scaleToRef(scale: number, result: Vector3): Vector3;
  2602. /**
  2603. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2604. * @param scale defines the scale factor
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the unmodified current Vector3
  2607. */
  2608. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2609. /**
  2610. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2611. * @param origin defines the origin of the projection ray
  2612. * @param plane defines the plane to project to
  2613. * @returns the projected vector3
  2614. */
  2615. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2616. /**
  2617. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2618. * @param origin defines the origin of the projection ray
  2619. * @param plane defines the plane to project to
  2620. * @param result defines the Vector3 where to store the result
  2621. */
  2622. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2623. /**
  2624. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2625. * @param otherVector defines the second operand
  2626. * @returns true if both vectors are equals
  2627. */
  2628. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2629. /**
  2630. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2631. * @param otherVector defines the second operand
  2632. * @param epsilon defines the minimal distance to define values as equals
  2633. * @returns true if both vectors are distant less than epsilon
  2634. */
  2635. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2636. /**
  2637. * Returns true if the current Vector3 coordinates equals the given floats
  2638. * @param x defines the x coordinate of the operand
  2639. * @param y defines the y coordinate of the operand
  2640. * @param z defines the z coordinate of the operand
  2641. * @returns true if both vectors are equals
  2642. */
  2643. equalsToFloats(x: number, y: number, z: number): boolean;
  2644. /**
  2645. * Multiplies the current Vector3 coordinates by the given ones
  2646. * @param otherVector defines the second operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2650. /**
  2651. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2652. * @param otherVector defines the second operand
  2653. * @returns the new Vector3
  2654. */
  2655. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2658. * @param otherVector defines the second operand
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2663. /**
  2664. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2665. * @param x defines the x coordinate of the operand
  2666. * @param y defines the y coordinate of the operand
  2667. * @param z defines the z coordinate of the operand
  2668. * @returns the new Vector3
  2669. */
  2670. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2673. * @param otherVector defines the second operand
  2674. * @returns the new Vector3
  2675. */
  2676. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2677. /**
  2678. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2679. * @param otherVector defines the second operand
  2680. * @param result defines the Vector3 object where to store the result
  2681. * @returns the current Vector3
  2682. */
  2683. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2684. /**
  2685. * Divides the current Vector3 coordinates by the given ones.
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. divideInPlace(otherVector: Vector3): Vector3;
  2690. /**
  2691. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2692. * @param other defines the second operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2698. * @param other defines the second operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2702. /**
  2703. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2720. * Check if is non uniform within a certain amount of decimal places to account for this
  2721. * @param epsilon the amount the values can differ
  2722. * @returns if the the vector is non uniform to a certain number of decimal places
  2723. */
  2724. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2725. /**
  2726. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2727. */
  2728. get isNonUniform(): boolean;
  2729. /**
  2730. * Gets a new Vector3 from current Vector3 floored values
  2731. * @returns a new Vector3
  2732. */
  2733. floor(): Vector3;
  2734. /**
  2735. * Gets a new Vector3 from current Vector3 floored values
  2736. * @returns a new Vector3
  2737. */
  2738. fract(): Vector3;
  2739. /**
  2740. * Gets the length of the Vector3
  2741. * @returns the length of the Vector3
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Gets the squared length of the Vector3
  2746. * @returns squared length of the Vector3
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalize the current Vector3.
  2751. * Please note that this is an in place operation.
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalize(): Vector3;
  2755. /**
  2756. * Reorders the x y z properties of the vector in place
  2757. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2758. * @returns the current updated vector
  2759. */
  2760. reorderInPlace(order: string): this;
  2761. /**
  2762. * Rotates the vector around 0,0,0 by a quaternion
  2763. * @param quaternion the rotation quaternion
  2764. * @param result vector to store the result
  2765. * @returns the resulting vector
  2766. */
  2767. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2768. /**
  2769. * Rotates a vector around a given point
  2770. * @param quaternion the rotation quaternion
  2771. * @param point the point to rotate around
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2776. /**
  2777. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2778. * The cross product is then orthogonal to both current and "other"
  2779. * @param other defines the right operand
  2780. * @returns the cross product
  2781. */
  2782. cross(other: Vector3): Vector3;
  2783. /**
  2784. * Normalize the current Vector3 with the given input length.
  2785. * Please note that this is an in place operation.
  2786. * @param len the length of the vector
  2787. * @returns the current updated Vector3
  2788. */
  2789. normalizeFromLength(len: number): Vector3;
  2790. /**
  2791. * Normalize the current Vector3 to a new vector
  2792. * @returns the new Vector3
  2793. */
  2794. normalizeToNew(): Vector3;
  2795. /**
  2796. * Normalize the current Vector3 to the reference
  2797. * @param reference define the Vector3 to update
  2798. * @returns the updated Vector3
  2799. */
  2800. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2801. /**
  2802. * Creates a new Vector3 copied from the current Vector3
  2803. * @returns the new Vector3
  2804. */
  2805. clone(): Vector3;
  2806. /**
  2807. * Copies the given vector coordinates to the current Vector3 ones
  2808. * @param source defines the source Vector3
  2809. * @returns the current updated Vector3
  2810. */
  2811. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2812. /**
  2813. * Copies the given floats to the current Vector3 coordinates
  2814. * @param x defines the x coordinate of the operand
  2815. * @param y defines the y coordinate of the operand
  2816. * @param z defines the z coordinate of the operand
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFromFloats(x: number, y: number, z: number): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. set(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given float to the current Vector3 coordinates
  2830. * @param v defines the x, y and z coordinates of the operand
  2831. * @returns the current updated Vector3
  2832. */
  2833. setAll(v: number): Vector3;
  2834. /**
  2835. * Get the clip factor between two vectors
  2836. * @param vector0 defines the first operand
  2837. * @param vector1 defines the second operand
  2838. * @param axis defines the axis to use
  2839. * @param size defines the size along the axis
  2840. * @returns the clip factor
  2841. */
  2842. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2843. /**
  2844. * Get angle between two vectors
  2845. * @param vector0 angle between vector0 and vector1
  2846. * @param vector1 angle between vector0 and vector1
  2847. * @param normal direction of the normal
  2848. * @return the angle between vector0 and vector1
  2849. */
  2850. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2851. /**
  2852. * Returns a new Vector3 set from the index "offset" of the given array
  2853. * @param array defines the source array
  2854. * @param offset defines the offset in the source array
  2855. * @returns the new Vector3
  2856. */
  2857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2860. * @param array defines the source array
  2861. * @param offset defines the offset in the source array
  2862. * @returns the new Vector3
  2863. * @deprecated Please use FromArray instead.
  2864. */
  2865. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2873. /**
  2874. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2875. * @param array defines the source array
  2876. * @param offset defines the offset in the source array
  2877. * @param result defines the Vector3 where to store the result
  2878. * @deprecated Please use FromArrayToRef instead.
  2879. */
  2880. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the given floats.
  2883. * @param x defines the x coordinate of the source
  2884. * @param y defines the y coordinate of the source
  2885. * @param z defines the z coordinate of the source
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2891. * @returns a new empty Vector3
  2892. */
  2893. static Zero(): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2896. * @returns a new unit Vector3
  2897. */
  2898. static One(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2901. * @returns a new up Vector3
  2902. */
  2903. static Up(): Vector3;
  2904. /**
  2905. * Gets a up Vector3 that must not be updated
  2906. */
  2907. static get UpReadOnly(): DeepImmutable<Vector3>;
  2908. /**
  2909. * Gets a zero Vector3 that must not be updated
  2910. */
  2911. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2912. /**
  2913. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2914. * @returns a new down Vector3
  2915. */
  2916. static Down(): Vector3;
  2917. /**
  2918. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2919. * @param rightHandedSystem is the scene right-handed (negative z)
  2920. * @returns a new forward Vector3
  2921. */
  2922. static Forward(rightHandedSystem?: boolean): Vector3;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2925. * @param rightHandedSystem is the scene right-handed (negative-z)
  2926. * @returns a new forward Vector3
  2927. */
  2928. static Backward(rightHandedSystem?: boolean): Vector3;
  2929. /**
  2930. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2931. * @returns a new right Vector3
  2932. */
  2933. static Right(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2936. * @returns a new left Vector3
  2937. */
  2938. static Left(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2941. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2942. * @param vector defines the Vector3 to transform
  2943. * @param transformation defines the transformation matrix
  2944. * @returns the transformed Vector3
  2945. */
  2946. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2957. * This method computes tranformed coordinates only, not transformed direction vectors
  2958. * @param x define the x coordinate of the source vector
  2959. * @param y define the y coordinate of the source vector
  2960. * @param z define the z coordinate of the source vector
  2961. * @param transformation defines the transformation matrix
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2967. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2968. * @param vector defines the Vector3 to transform
  2969. * @param transformation defines the transformation matrix
  2970. * @returns the new Vector3
  2971. */
  2972. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2973. /**
  2974. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @param result defines the Vector3 where to store the result
  2979. */
  2980. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param x define the x coordinate of the source vector
  2985. * @param y define the y coordinate of the source vector
  2986. * @param z define the z coordinate of the source vector
  2987. * @param transformation defines the transformation matrix
  2988. * @param result defines the Vector3 where to store the result
  2989. */
  2990. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2991. /**
  2992. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2993. * @param value1 defines the first control point
  2994. * @param value2 defines the second control point
  2995. * @param value3 defines the third control point
  2996. * @param value4 defines the fourth control point
  2997. * @param amount defines the amount on the spline to use
  2998. * @returns the new Vector3
  2999. */
  3000. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3001. /**
  3002. * 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"
  3003. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3004. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3005. * @param value defines the current value
  3006. * @param min defines the lower range value
  3007. * @param max defines the upper range value
  3008. * @returns the new Vector3
  3009. */
  3010. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * 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"
  3013. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3014. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3015. * @param value defines the current value
  3016. * @param min defines the lower range value
  3017. * @param max defines the upper range value
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3021. /**
  3022. * Checks if a given vector is inside a specific range
  3023. * @param v defines the vector to test
  3024. * @param min defines the minimum range
  3025. * @param max defines the maximum range
  3026. */
  3027. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3028. /**
  3029. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3030. * @param value1 defines the first control point
  3031. * @param tangent1 defines the first tangent vector
  3032. * @param value2 defines the second control point
  3033. * @param tangent2 defines the second tangent vector
  3034. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3035. * @returns the new Vector3
  3036. */
  3037. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3040. * @param start defines the start value
  3041. * @param end defines the end value
  3042. * @param amount max defines amount between both (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3054. /**
  3055. * Returns the dot product (float) between the vectors "left" and "right"
  3056. * @param left defines the left operand
  3057. * @param right defines the right operand
  3058. * @returns the dot product
  3059. */
  3060. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3061. /**
  3062. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3063. * The cross product is then orthogonal to both "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the cross product
  3067. */
  3068. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3069. /**
  3070. * Sets the given vector "result" with the cross product of "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @param result defines the Vector3 where to store the result
  3075. */
  3076. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3077. /**
  3078. * Returns a new Vector3 as the normalization of the given vector
  3079. * @param vector defines the Vector3 to normalize
  3080. * @returns the new Vector3
  3081. */
  3082. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3083. /**
  3084. * Sets the given vector "result" with the normalization of the given first vector
  3085. * @param vector defines the Vector3 to normalize
  3086. * @param result defines the Vector3 where to store the result
  3087. */
  3088. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3089. /**
  3090. * Project a Vector3 onto screen space
  3091. * @param vector defines the Vector3 to project
  3092. * @param world defines the world matrix to use
  3093. * @param transform defines the transform (view x projection) matrix to use
  3094. * @param viewport defines the screen viewport to use
  3095. * @returns the new Vector3
  3096. */
  3097. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3098. /** @hidden */
  3099. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3100. /**
  3101. * Unproject from screen space to object space
  3102. * @param source defines the screen space Vector3 to use
  3103. * @param viewportWidth defines the current width of the viewport
  3104. * @param viewportHeight defines the current height of the viewport
  3105. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3106. * @param transform defines the transform (view x projection) matrix to use
  3107. * @returns the new Vector3
  3108. */
  3109. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3110. /**
  3111. * Unproject from screen space to object space
  3112. * @param source defines the screen space Vector3 to use
  3113. * @param viewportWidth defines the current width of the viewport
  3114. * @param viewportHeight defines the current height of the viewport
  3115. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3116. * @param view defines the view matrix to use
  3117. * @param projection defines the projection matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @param result defines the Vector3 where to store the result
  3130. */
  3131. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param sourceX defines the screen space x coordinate to use
  3135. * @param sourceY defines the screen space y coordinate to use
  3136. * @param sourceZ defines the screen space z coordinate to use
  3137. * @param viewportWidth defines the current width of the viewport
  3138. * @param viewportHeight defines the current height of the viewport
  3139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3140. * @param view defines the view matrix to use
  3141. * @param projection defines the projection matrix to use
  3142. * @param result defines the Vector3 where to store the result
  3143. */
  3144. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3145. /**
  3146. * Gets the minimal coordinate values between two Vector3
  3147. * @param left defines the first operand
  3148. * @param right defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Gets the maximal coordinate values between two Vector3
  3154. * @param left defines the first operand
  3155. * @param right defines the second operand
  3156. * @returns the new Vector3
  3157. */
  3158. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Returns the distance between the vectors "value1" and "value2"
  3161. * @param value1 defines the first operand
  3162. * @param value2 defines the second operand
  3163. * @returns the distance
  3164. */
  3165. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3166. /**
  3167. * Returns the squared distance between the vectors "value1" and "value2"
  3168. * @param value1 defines the first operand
  3169. * @param value2 defines the second operand
  3170. * @returns the squared distance
  3171. */
  3172. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3173. /**
  3174. * Returns a new Vector3 located at the center between "value1" and "value2"
  3175. * @param value1 defines the first operand
  3176. * @param value2 defines the second operand
  3177. * @returns the new Vector3
  3178. */
  3179. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3180. /**
  3181. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3182. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3183. * to something in order to rotate it from its local system to the given target system
  3184. * Note: axis1, axis2 and axis3 are normalized during this operation
  3185. * @param axis1 defines the first axis
  3186. * @param axis2 defines the second axis
  3187. * @param axis3 defines the third axis
  3188. * @returns a new Vector3
  3189. */
  3190. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @param ref defines the Vector3 where to store the result
  3197. */
  3198. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3199. }
  3200. /**
  3201. * Vector4 class created for EulerAngle class conversion to Quaternion
  3202. */
  3203. export class Vector4 {
  3204. /** x value of the vector */
  3205. x: number;
  3206. /** y value of the vector */
  3207. y: number;
  3208. /** z value of the vector */
  3209. z: number;
  3210. /** w value of the vector */
  3211. w: number;
  3212. /**
  3213. * Creates a Vector4 object from the given floats.
  3214. * @param x x value of the vector
  3215. * @param y y value of the vector
  3216. * @param z z value of the vector
  3217. * @param w w value of the vector
  3218. */
  3219. constructor(
  3220. /** x value of the vector */
  3221. x: number,
  3222. /** y value of the vector */
  3223. y: number,
  3224. /** z value of the vector */
  3225. z: number,
  3226. /** w value of the vector */
  3227. w: number);
  3228. /**
  3229. * Returns the string with the Vector4 coordinates.
  3230. * @returns a string containing all the vector values
  3231. */
  3232. toString(): string;
  3233. /**
  3234. * Returns the string "Vector4".
  3235. * @returns "Vector4"
  3236. */
  3237. getClassName(): string;
  3238. /**
  3239. * Returns the Vector4 hash code.
  3240. * @returns a unique hash code
  3241. */
  3242. getHashCode(): number;
  3243. /**
  3244. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3245. * @returns the resulting array
  3246. */
  3247. asArray(): number[];
  3248. /**
  3249. * Populates the given array from the given index with the Vector4 coordinates.
  3250. * @param array array to populate
  3251. * @param index index of the array to start at (default: 0)
  3252. * @returns the Vector4.
  3253. */
  3254. toArray(array: FloatArray, index?: number): Vector4;
  3255. /**
  3256. * Adds the given vector to the current Vector4.
  3257. * @param otherVector the vector to add
  3258. * @returns the updated Vector4.
  3259. */
  3260. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3263. * @param otherVector the vector to add
  3264. * @returns the resulting vector
  3265. */
  3266. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3269. * @param otherVector the vector to add
  3270. * @param result the vector to store the result
  3271. * @returns the current Vector4.
  3272. */
  3273. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3274. /**
  3275. * Subtract in place the given vector from the current Vector4.
  3276. * @param otherVector the vector to subtract
  3277. * @returns the updated Vector4.
  3278. */
  3279. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3280. /**
  3281. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3282. * @param otherVector the vector to add
  3283. * @returns the new vector with the result
  3284. */
  3285. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3286. /**
  3287. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3288. * @param otherVector the vector to subtract
  3289. * @param result the vector to store the result
  3290. * @returns the current Vector4.
  3291. */
  3292. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3293. /**
  3294. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3295. */
  3296. /**
  3297. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3298. * @param x value to subtract
  3299. * @param y value to subtract
  3300. * @param z value to subtract
  3301. * @param w value to subtract
  3302. * @returns new vector containing the result
  3303. */
  3304. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3305. /**
  3306. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3307. * @param x value to subtract
  3308. * @param y value to subtract
  3309. * @param z value to subtract
  3310. * @param w value to subtract
  3311. * @param result the vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3315. /**
  3316. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3317. * @returns a new vector with the negated values
  3318. */
  3319. negate(): Vector4;
  3320. /**
  3321. * Negate this vector in place
  3322. * @returns this
  3323. */
  3324. negateInPlace(): Vector4;
  3325. /**
  3326. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3327. * @param result defines the Vector3 object where to store the result
  3328. * @returns the current Vector4
  3329. */
  3330. negateToRef(result: Vector4): Vector4;
  3331. /**
  3332. * Multiplies the current Vector4 coordinates by scale (float).
  3333. * @param scale the number to scale with
  3334. * @returns the updated Vector4.
  3335. */
  3336. scaleInPlace(scale: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3339. * @param scale the number to scale with
  3340. * @returns a new vector with the result
  3341. */
  3342. scale(scale: number): Vector4;
  3343. /**
  3344. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3345. * @param scale the number to scale with
  3346. * @param result a vector to store the result in
  3347. * @returns the current Vector4.
  3348. */
  3349. scaleToRef(scale: number, result: Vector4): Vector4;
  3350. /**
  3351. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3352. * @param scale defines the scale factor
  3353. * @param result defines the Vector4 object where to store the result
  3354. * @returns the unmodified current Vector4
  3355. */
  3356. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3357. /**
  3358. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3359. * @param otherVector the vector to compare against
  3360. * @returns true if they are equal
  3361. */
  3362. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3363. /**
  3364. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3365. * @param otherVector vector to compare against
  3366. * @param epsilon (Default: very small number)
  3367. * @returns true if they are equal
  3368. */
  3369. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3370. /**
  3371. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3372. * @param x x value to compare against
  3373. * @param y y value to compare against
  3374. * @param z z value to compare against
  3375. * @param w w value to compare against
  3376. * @returns true if equal
  3377. */
  3378. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3379. /**
  3380. * Multiplies in place the current Vector4 by the given one.
  3381. * @param otherVector vector to multiple with
  3382. * @returns the updated Vector4.
  3383. */
  3384. multiplyInPlace(otherVector: Vector4): Vector4;
  3385. /**
  3386. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3387. * @param otherVector vector to multiple with
  3388. * @returns resulting new vector
  3389. */
  3390. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3393. * @param otherVector vector to multiple with
  3394. * @param result vector to store the result
  3395. * @returns the current Vector4.
  3396. */
  3397. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3400. * @param x x value multiply with
  3401. * @param y y value multiply with
  3402. * @param z z value multiply with
  3403. * @param w w value multiply with
  3404. * @returns resulting new vector
  3405. */
  3406. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3407. /**
  3408. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3409. * @param otherVector vector to devide with
  3410. * @returns resulting new vector
  3411. */
  3412. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3415. * @param otherVector vector to devide with
  3416. * @param result vector to store the result
  3417. * @returns the current Vector4.
  3418. */
  3419. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3420. /**
  3421. * Divides the current Vector3 coordinates by the given ones.
  3422. * @param otherVector vector to devide with
  3423. * @returns the updated Vector3.
  3424. */
  3425. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3428. * @param other defines the second operand
  3429. * @returns the current updated Vector4
  3430. */
  3431. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3434. * @param other defines the second operand
  3435. * @returns the current updated Vector4
  3436. */
  3437. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3438. /**
  3439. * Gets a new Vector4 from current Vector4 floored values
  3440. * @returns a new Vector4
  3441. */
  3442. floor(): Vector4;
  3443. /**
  3444. * Gets a new Vector4 from current Vector3 floored values
  3445. * @returns a new Vector4
  3446. */
  3447. fract(): Vector4;
  3448. /**
  3449. * Returns the Vector4 length (float).
  3450. * @returns the length
  3451. */
  3452. length(): number;
  3453. /**
  3454. * Returns the Vector4 squared length (float).
  3455. * @returns the length squared
  3456. */
  3457. lengthSquared(): number;
  3458. /**
  3459. * Normalizes in place the Vector4.
  3460. * @returns the updated Vector4.
  3461. */
  3462. normalize(): Vector4;
  3463. /**
  3464. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3465. * @returns this converted to a new vector3
  3466. */
  3467. toVector3(): Vector3;
  3468. /**
  3469. * Returns a new Vector4 copied from the current one.
  3470. * @returns the new cloned vector
  3471. */
  3472. clone(): Vector4;
  3473. /**
  3474. * Updates the current Vector4 with the given one coordinates.
  3475. * @param source the source vector to copy from
  3476. * @returns the updated Vector4.
  3477. */
  3478. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Updates the current Vector4 coordinates with the given floats.
  3481. * @param x float to copy from
  3482. * @param y float to copy from
  3483. * @param z float to copy from
  3484. * @param w float to copy from
  3485. * @returns the updated Vector4.
  3486. */
  3487. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3488. /**
  3489. * Updates the current Vector4 coordinates with the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @returns the updated Vector4.
  3495. */
  3496. set(x: number, y: number, z: number, w: number): Vector4;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y, z and w coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set from the starting index of the given array.
  3505. * @param array the array to pull values from
  3506. * @param offset the offset into the array to start at
  3507. * @returns the new vector
  3508. */
  3509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3510. /**
  3511. * Updates the given vector "result" from the starting index of the given array.
  3512. * @param array the array to pull values from
  3513. * @param offset the offset into the array to start at
  3514. * @param result the vector to store the result in
  3515. */
  3516. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3517. /**
  3518. * Updates the given vector "result" from the starting index of the given Float32Array.
  3519. * @param array the array to pull values from
  3520. * @param offset the offset into the array to start at
  3521. * @param result the vector to store the result in
  3522. */
  3523. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3524. /**
  3525. * Updates the given vector "result" coordinates from the given floats.
  3526. * @param x float to set from
  3527. * @param y float to set from
  3528. * @param z float to set from
  3529. * @param w float to set from
  3530. * @param result the vector to the floats in
  3531. */
  3532. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3533. /**
  3534. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3535. * @returns the new vector
  3536. */
  3537. static Zero(): Vector4;
  3538. /**
  3539. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3540. * @returns the new vector
  3541. */
  3542. static One(): Vector4;
  3543. /**
  3544. * Returns a new normalized Vector4 from the given one.
  3545. * @param vector the vector to normalize
  3546. * @returns the vector
  3547. */
  3548. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3549. /**
  3550. * Updates the given vector "result" from the normalization of the given one.
  3551. * @param vector the vector to normalize
  3552. * @param result the vector to store the result in
  3553. */
  3554. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3555. /**
  3556. * Returns a vector with the minimum values from the left and right vectors
  3557. * @param left left vector to minimize
  3558. * @param right right vector to minimize
  3559. * @returns a new vector with the minimum of the left and right vector values
  3560. */
  3561. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a vector with the maximum values from the left and right vectors
  3564. * @param left left vector to maximize
  3565. * @param right right vector to maximize
  3566. * @returns a new vector with the maximum of the left and right vector values
  3567. */
  3568. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3569. /**
  3570. * Returns the distance (float) between the vectors "value1" and "value2".
  3571. * @param value1 value to calulate the distance between
  3572. * @param value2 value to calulate the distance between
  3573. * @return the distance between the two vectors
  3574. */
  3575. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3576. /**
  3577. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3578. * @param value1 value to calulate the distance between
  3579. * @param value2 value to calulate the distance between
  3580. * @return the distance between the two vectors squared
  3581. */
  3582. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3583. /**
  3584. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3585. * @param value1 value to calulate the center between
  3586. * @param value2 value to calulate the center between
  3587. * @return the center between the two vectors
  3588. */
  3589. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3590. /**
  3591. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3592. * This methods computes transformed normalized direction vectors only.
  3593. * @param vector the vector to transform
  3594. * @param transformation the transformation matrix to apply
  3595. * @returns the new vector
  3596. */
  3597. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3598. /**
  3599. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @param result the vector to store the result in
  3604. */
  3605. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param x value to transform
  3610. * @param y value to transform
  3611. * @param z value to transform
  3612. * @param w value to transform
  3613. * @param transformation the transformation matrix to apply
  3614. * @param result the vector to store the results in
  3615. */
  3616. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3617. /**
  3618. * Creates a new Vector4 from a Vector3
  3619. * @param source defines the source data
  3620. * @param w defines the 4th component (default is 0)
  3621. * @returns a new Vector4
  3622. */
  3623. static FromVector3(source: Vector3, w?: number): Vector4;
  3624. }
  3625. /**
  3626. * Class used to store quaternion data
  3627. * @see https://en.wikipedia.org/wiki/Quaternion
  3628. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3629. */
  3630. export class Quaternion {
  3631. /** defines the first component (0 by default) */
  3632. x: number;
  3633. /** defines the second component (0 by default) */
  3634. y: number;
  3635. /** defines the third component (0 by default) */
  3636. z: number;
  3637. /** defines the fourth component (1.0 by default) */
  3638. w: number;
  3639. /**
  3640. * Creates a new Quaternion from the given floats
  3641. * @param x defines the first component (0 by default)
  3642. * @param y defines the second component (0 by default)
  3643. * @param z defines the third component (0 by default)
  3644. * @param w defines the fourth component (1.0 by default)
  3645. */
  3646. constructor(
  3647. /** defines the first component (0 by default) */
  3648. x?: number,
  3649. /** defines the second component (0 by default) */
  3650. y?: number,
  3651. /** defines the third component (0 by default) */
  3652. z?: number,
  3653. /** defines the fourth component (1.0 by default) */
  3654. w?: number);
  3655. /**
  3656. * Gets a string representation for the current quaternion
  3657. * @returns a string with the Quaternion coordinates
  3658. */
  3659. toString(): string;
  3660. /**
  3661. * Gets the class name of the quaternion
  3662. * @returns the string "Quaternion"
  3663. */
  3664. getClassName(): string;
  3665. /**
  3666. * Gets a hash code for this quaternion
  3667. * @returns the quaternion hash code
  3668. */
  3669. getHashCode(): number;
  3670. /**
  3671. * Copy the quaternion to an array
  3672. * @returns a new array populated with 4 elements from the quaternion coordinates
  3673. */
  3674. asArray(): number[];
  3675. /**
  3676. * Check if two quaternions are equals
  3677. * @param otherQuaternion defines the second operand
  3678. * @return true if the current quaternion and the given one coordinates are strictly equals
  3679. */
  3680. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3683. * @param otherQuaternion defines the other quaternion
  3684. * @param epsilon defines the minimal distance to consider equality
  3685. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3686. */
  3687. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3688. /**
  3689. * Clone the current quaternion
  3690. * @returns a new quaternion copied from the current one
  3691. */
  3692. clone(): Quaternion;
  3693. /**
  3694. * Copy a quaternion to the current one
  3695. * @param other defines the other quaternion
  3696. * @returns the updated current quaternion
  3697. */
  3698. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Updates the current quaternion with the given float coordinates
  3701. * @param x defines the x coordinate
  3702. * @param y defines the y coordinate
  3703. * @param z defines the z coordinate
  3704. * @param w defines the w coordinate
  3705. * @returns the updated current quaternion
  3706. */
  3707. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3708. /**
  3709. * Updates the current quaternion from the given float coordinates
  3710. * @param x defines the x coordinate
  3711. * @param y defines the y coordinate
  3712. * @param z defines the z coordinate
  3713. * @param w defines the w coordinate
  3714. * @returns the updated current quaternion
  3715. */
  3716. set(x: number, y: number, z: number, w: number): Quaternion;
  3717. /**
  3718. * Adds two quaternions
  3719. * @param other defines the second operand
  3720. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3721. */
  3722. add(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Add a quaternion to the current one
  3725. * @param other defines the quaternion to add
  3726. * @returns the current quaternion
  3727. */
  3728. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3729. /**
  3730. * Subtract two quaternions
  3731. * @param other defines the second operand
  3732. * @returns a new quaternion as the subtraction result of the given one from the current one
  3733. */
  3734. subtract(other: Quaternion): Quaternion;
  3735. /**
  3736. * Multiplies the current quaternion by a scale factor
  3737. * @param value defines the scale factor
  3738. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3739. */
  3740. scale(value: number): Quaternion;
  3741. /**
  3742. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3743. * @param scale defines the scale factor
  3744. * @param result defines the Quaternion object where to store the result
  3745. * @returns the unmodified current quaternion
  3746. */
  3747. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3748. /**
  3749. * Multiplies in place the current quaternion by a scale factor
  3750. * @param value defines the scale factor
  3751. * @returns the current modified quaternion
  3752. */
  3753. scaleInPlace(value: number): Quaternion;
  3754. /**
  3755. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3756. * @param scale defines the scale factor
  3757. * @param result defines the Quaternion object where to store the result
  3758. * @returns the unmodified current quaternion
  3759. */
  3760. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3761. /**
  3762. * Multiplies two quaternions
  3763. * @param q1 defines the second operand
  3764. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3765. */
  3766. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3767. /**
  3768. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3769. * @param q1 defines the second operand
  3770. * @param result defines the target quaternion
  3771. * @returns the current quaternion
  3772. */
  3773. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3774. /**
  3775. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3776. * @param q1 defines the second operand
  3777. * @returns the currentupdated quaternion
  3778. */
  3779. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3780. /**
  3781. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3782. * @param ref defines the target quaternion
  3783. * @returns the current quaternion
  3784. */
  3785. conjugateToRef(ref: Quaternion): Quaternion;
  3786. /**
  3787. * Conjugates in place (1-q) the current quaternion
  3788. * @returns the current updated quaternion
  3789. */
  3790. conjugateInPlace(): Quaternion;
  3791. /**
  3792. * Conjugates in place (1-q) the current quaternion
  3793. * @returns a new quaternion
  3794. */
  3795. conjugate(): Quaternion;
  3796. /**
  3797. * Gets length of current quaternion
  3798. * @returns the quaternion length (float)
  3799. */
  3800. length(): number;
  3801. /**
  3802. * Normalize in place the current quaternion
  3803. * @returns the current updated quaternion
  3804. */
  3805. normalize(): Quaternion;
  3806. /**
  3807. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3808. * @param order is a reserved parameter and is ignore for now
  3809. * @returns a new Vector3 containing the Euler angles
  3810. */
  3811. toEulerAngles(order?: string): Vector3;
  3812. /**
  3813. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3814. * @param result defines the vector which will be filled with the Euler angles
  3815. * @param order is a reserved parameter and is ignore for now
  3816. * @returns the current unchanged quaternion
  3817. */
  3818. toEulerAnglesToRef(result: Vector3): Quaternion;
  3819. /**
  3820. * Updates the given rotation matrix with the current quaternion values
  3821. * @param result defines the target matrix
  3822. * @returns the current unchanged quaternion
  3823. */
  3824. toRotationMatrix(result: Matrix): Quaternion;
  3825. /**
  3826. * Updates the current quaternion from the given rotation matrix values
  3827. * @param matrix defines the source matrix
  3828. * @returns the current updated quaternion
  3829. */
  3830. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3831. /**
  3832. * Creates a new quaternion from a rotation matrix
  3833. * @param matrix defines the source matrix
  3834. * @returns a new quaternion created from the given rotation matrix values
  3835. */
  3836. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3837. /**
  3838. * Updates the given quaternion with the given rotation matrix values
  3839. * @param matrix defines the source matrix
  3840. * @param result defines the target quaternion
  3841. */
  3842. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3843. /**
  3844. * Returns the dot product (float) between the quaternions "left" and "right"
  3845. * @param left defines the left operand
  3846. * @param right defines the right operand
  3847. * @returns the dot product
  3848. */
  3849. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3850. /**
  3851. * Checks if the two quaternions are close to each other
  3852. * @param quat0 defines the first quaternion to check
  3853. * @param quat1 defines the second quaternion to check
  3854. * @returns true if the two quaternions are close to each other
  3855. */
  3856. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates an empty quaternion
  3859. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3860. */
  3861. static Zero(): Quaternion;
  3862. /**
  3863. * Inverse a given quaternion
  3864. * @param q defines the source quaternion
  3865. * @returns a new quaternion as the inverted current quaternion
  3866. */
  3867. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3868. /**
  3869. * Inverse a given quaternion
  3870. * @param q defines the source quaternion
  3871. * @param result the quaternion the result will be stored in
  3872. * @returns the result quaternion
  3873. */
  3874. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3875. /**
  3876. * Creates an identity quaternion
  3877. * @returns the identity quaternion
  3878. */
  3879. static Identity(): Quaternion;
  3880. /**
  3881. * Gets a boolean indicating if the given quaternion is identity
  3882. * @param quaternion defines the quaternion to check
  3883. * @returns true if the quaternion is identity
  3884. */
  3885. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3886. /**
  3887. * Creates a quaternion from a rotation around an axis
  3888. * @param axis defines the axis to use
  3889. * @param angle defines the angle to use
  3890. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3891. */
  3892. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3893. /**
  3894. * Creates a rotation around an axis and stores it into the given quaternion
  3895. * @param axis defines the axis to use
  3896. * @param angle defines the angle to use
  3897. * @param result defines the target quaternion
  3898. * @returns the target quaternion
  3899. */
  3900. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3901. /**
  3902. * Creates a new quaternion from data stored into an array
  3903. * @param array defines the data source
  3904. * @param offset defines the offset in the source array where the data starts
  3905. * @returns a new quaternion
  3906. */
  3907. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3908. /**
  3909. * Updates the given quaternion "result" from the starting index of the given array.
  3910. * @param array the array to pull values from
  3911. * @param offset the offset into the array to start at
  3912. * @param result the quaternion to store the result in
  3913. */
  3914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3915. /**
  3916. * Create a quaternion from Euler rotation angles
  3917. * @param x Pitch
  3918. * @param y Yaw
  3919. * @param z Roll
  3920. * @returns the new Quaternion
  3921. */
  3922. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3923. /**
  3924. * Updates a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @param result the quaternion to store the result
  3929. * @returns the updated quaternion
  3930. */
  3931. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3932. /**
  3933. * Create a quaternion from Euler rotation vector
  3934. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3935. * @returns the new Quaternion
  3936. */
  3937. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3938. /**
  3939. * Updates a quaternion from Euler rotation vector
  3940. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3941. * @param result the quaternion to store the result
  3942. * @returns the updated quaternion
  3943. */
  3944. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3945. /**
  3946. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3947. * @param yaw defines the rotation around Y axis
  3948. * @param pitch defines the rotation around X axis
  3949. * @param roll defines the rotation around Z axis
  3950. * @returns the new quaternion
  3951. */
  3952. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3953. /**
  3954. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @param result defines the target quaternion
  3959. */
  3960. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3961. /**
  3962. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3963. * @param alpha defines the rotation around first axis
  3964. * @param beta defines the rotation around second axis
  3965. * @param gamma defines the rotation around third axis
  3966. * @returns the new quaternion
  3967. */
  3968. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @param result defines the target quaternion
  3975. */
  3976. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3977. /**
  3978. * 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)
  3979. * @param axis1 defines the first axis
  3980. * @param axis2 defines the second axis
  3981. * @param axis3 defines the third axis
  3982. * @returns the new quaternion
  3983. */
  3984. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3985. /**
  3986. * 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
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @param ref defines the target quaternion
  3991. */
  3992. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3993. /**
  3994. * Interpolates between two quaternions
  3995. * @param left defines first quaternion
  3996. * @param right defines second quaternion
  3997. * @param amount defines the gradient to use
  3998. * @returns the new interpolated quaternion
  3999. */
  4000. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4001. /**
  4002. * Interpolates between two quaternions and stores it into a target quaternion
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @param result defines the target quaternion
  4007. */
  4008. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4009. /**
  4010. * Interpolate between two quaternions using Hermite interpolation
  4011. * @param value1 defines first quaternion
  4012. * @param tangent1 defines the incoming tangent
  4013. * @param value2 defines second quaternion
  4014. * @param tangent2 defines the outgoing tangent
  4015. * @param amount defines the target quaternion
  4016. * @returns the new interpolated quaternion
  4017. */
  4018. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4019. }
  4020. /**
  4021. * Class used to store matrix data (4x4)
  4022. */
  4023. export class Matrix {
  4024. private static _updateFlagSeed;
  4025. private static _identityReadOnly;
  4026. private _isIdentity;
  4027. private _isIdentityDirty;
  4028. private _isIdentity3x2;
  4029. private _isIdentity3x2Dirty;
  4030. /**
  4031. * Gets the update flag of the matrix which is an unique number for the matrix.
  4032. * It will be incremented every time the matrix data change.
  4033. * You can use it to speed the comparison between two versions of the same matrix.
  4034. */
  4035. updateFlag: number;
  4036. private readonly _m;
  4037. /**
  4038. * Gets the internal data of the matrix
  4039. */
  4040. get m(): DeepImmutable<Float32Array>;
  4041. /** @hidden */
  4042. _markAsUpdated(): void;
  4043. /** @hidden */
  4044. private _updateIdentityStatus;
  4045. /**
  4046. * Creates an empty matrix (filled with zeros)
  4047. */
  4048. constructor();
  4049. /**
  4050. * Check if the current matrix is identity
  4051. * @returns true is the matrix is the identity matrix
  4052. */
  4053. isIdentity(): boolean;
  4054. /**
  4055. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4056. * @returns true is the matrix is the identity matrix
  4057. */
  4058. isIdentityAs3x2(): boolean;
  4059. /**
  4060. * Gets the determinant of the matrix
  4061. * @returns the matrix determinant
  4062. */
  4063. determinant(): number;
  4064. /**
  4065. * Returns the matrix as a Float32Array
  4066. * @returns the matrix underlying array
  4067. */
  4068. toArray(): DeepImmutable<Float32Array>;
  4069. /**
  4070. * Returns the matrix as a Float32Array
  4071. * @returns the matrix underlying array.
  4072. */
  4073. asArray(): DeepImmutable<Float32Array>;
  4074. /**
  4075. * Inverts the current matrix in place
  4076. * @returns the current inverted matrix
  4077. */
  4078. invert(): Matrix;
  4079. /**
  4080. * Sets all the matrix elements to zero
  4081. * @returns the current matrix
  4082. */
  4083. reset(): Matrix;
  4084. /**
  4085. * Adds the current matrix with a second one
  4086. * @param other defines the matrix to add
  4087. * @returns a new matrix as the addition of the current matrix and the given one
  4088. */
  4089. add(other: DeepImmutable<Matrix>): Matrix;
  4090. /**
  4091. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4092. * @param other defines the matrix to add
  4093. * @param result defines the target matrix
  4094. * @returns the current matrix
  4095. */
  4096. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4097. /**
  4098. * Adds in place the given matrix to the current matrix
  4099. * @param other defines the second operand
  4100. * @returns the current updated matrix
  4101. */
  4102. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4103. /**
  4104. * Sets the given matrix to the current inverted Matrix
  4105. * @param other defines the target matrix
  4106. * @returns the unmodified current matrix
  4107. */
  4108. invertToRef(other: Matrix): Matrix;
  4109. /**
  4110. * add a value at the specified position in the current Matrix
  4111. * @param index the index of the value within the matrix. between 0 and 15.
  4112. * @param value the value to be added
  4113. * @returns the current updated matrix
  4114. */
  4115. addAtIndex(index: number, value: number): Matrix;
  4116. /**
  4117. * mutiply the specified position in the current Matrix by a value
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. multiplyAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * Inserts the translation vector (using 3 floats) in the current matrix
  4125. * @param x defines the 1st component of the translation
  4126. * @param y defines the 2nd component of the translation
  4127. * @param z defines the 3rd component of the translation
  4128. * @returns the current updated matrix
  4129. */
  4130. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4131. /**
  4132. * Adds the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Inserts the translation vector in the current matrix
  4141. * @param vector3 defines the translation to insert
  4142. * @returns the current updated matrix
  4143. */
  4144. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4145. /**
  4146. * Gets the translation value of the current matrix
  4147. * @returns a new Vector3 as the extracted translation from the matrix
  4148. */
  4149. getTranslation(): Vector3;
  4150. /**
  4151. * Fill a Vector3 with the extracted translation from the matrix
  4152. * @param result defines the Vector3 where to store the translation
  4153. * @returns the current matrix
  4154. */
  4155. getTranslationToRef(result: Vector3): Matrix;
  4156. /**
  4157. * Remove rotation and scaling part from the matrix
  4158. * @returns the updated matrix
  4159. */
  4160. removeRotationAndScaling(): Matrix;
  4161. /**
  4162. * Multiply two matrices
  4163. * @param other defines the second operand
  4164. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4165. */
  4166. multiply(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Copy the current matrix from the given one
  4169. * @param other defines the source matrix
  4170. * @returns the current updated matrix
  4171. */
  4172. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4173. /**
  4174. * Populates the given array from the starting index with the current matrix values
  4175. * @param array defines the target array
  4176. * @param offset defines the offset in the target array where to start storing values
  4177. * @returns the current matrix
  4178. */
  4179. copyToArray(array: Float32Array, offset?: number): Matrix;
  4180. /**
  4181. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4182. * @param other defines the second operand
  4183. * @param result defines the matrix where to store the multiplication
  4184. * @returns the current matrix
  4185. */
  4186. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4187. /**
  4188. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the array where to store the multiplication
  4191. * @param offset defines the offset in the target array where to start storing values
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4195. /**
  4196. * Check equality between this matrix and a second one
  4197. * @param value defines the second matrix to compare
  4198. * @returns true is the current matrix and the given one values are strictly equal
  4199. */
  4200. equals(value: DeepImmutable<Matrix>): boolean;
  4201. /**
  4202. * Clone the current matrix
  4203. * @returns a new matrix from the current matrix
  4204. */
  4205. clone(): Matrix;
  4206. /**
  4207. * Returns the name of the current matrix class
  4208. * @returns the string "Matrix"
  4209. */
  4210. getClassName(): string;
  4211. /**
  4212. * Gets the hash code of the current matrix
  4213. * @returns the hash code
  4214. */
  4215. getHashCode(): number;
  4216. /**
  4217. * Decomposes the current Matrix into a translation, rotation and scaling components
  4218. * @param scale defines the scale vector3 given as a reference to update
  4219. * @param rotation defines the rotation quaternion given as a reference to update
  4220. * @param translation defines the translation vector3 given as a reference to update
  4221. * @returns true if operation was successful
  4222. */
  4223. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4224. /**
  4225. * Gets specific row of the matrix
  4226. * @param index defines the number of the row to get
  4227. * @returns the index-th row of the current matrix as a new Vector4
  4228. */
  4229. getRow(index: number): Nullable<Vector4>;
  4230. /**
  4231. * Sets the index-th row of the current matrix to the vector4 values
  4232. * @param index defines the number of the row to set
  4233. * @param row defines the target vector4
  4234. * @returns the updated current matrix
  4235. */
  4236. setRow(index: number, row: Vector4): Matrix;
  4237. /**
  4238. * Compute the transpose of the matrix
  4239. * @returns the new transposed matrix
  4240. */
  4241. transpose(): Matrix;
  4242. /**
  4243. * Compute the transpose of the matrix and store it in a given matrix
  4244. * @param result defines the target matrix
  4245. * @returns the current matrix
  4246. */
  4247. transposeToRef(result: Matrix): Matrix;
  4248. /**
  4249. * Sets the index-th row of the current matrix with the given 4 x float values
  4250. * @param index defines the row index
  4251. * @param x defines the x component to set
  4252. * @param y defines the y component to set
  4253. * @param z defines the z component to set
  4254. * @param w defines the w component to set
  4255. * @returns the updated current matrix
  4256. */
  4257. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4258. /**
  4259. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4260. * @param scale defines the scale factor
  4261. * @returns a new matrix
  4262. */
  4263. scale(scale: number): Matrix;
  4264. /**
  4265. * Scale the current matrix values by a factor to a given result matrix
  4266. * @param scale defines the scale factor
  4267. * @param result defines the matrix to store the result
  4268. * @returns the current matrix
  4269. */
  4270. scaleToRef(scale: number, result: Matrix): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor and add the result to a given matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the Matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4280. * @param ref matrix to store the result
  4281. */
  4282. toNormalMatrix(ref: Matrix): void;
  4283. /**
  4284. * Gets only rotation part of the current matrix
  4285. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4286. */
  4287. getRotationMatrix(): Matrix;
  4288. /**
  4289. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4290. * @param result defines the target matrix to store data to
  4291. * @returns the current matrix
  4292. */
  4293. getRotationMatrixToRef(result: Matrix): Matrix;
  4294. /**
  4295. * Toggles model matrix from being right handed to left handed in place and vice versa
  4296. */
  4297. toggleModelMatrixHandInPlace(): void;
  4298. /**
  4299. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4300. */
  4301. toggleProjectionMatrixHandInPlace(): void;
  4302. /**
  4303. * Creates a matrix from an array
  4304. * @param array defines the source array
  4305. * @param offset defines an offset in the source array
  4306. * @returns a new Matrix set from the starting index of the given array
  4307. */
  4308. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4309. /**
  4310. * Copy the content of an array into a given matrix
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @param result defines the target matrix
  4314. */
  4315. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4316. /**
  4317. * Stores an array into a matrix after having multiplied each component by a given factor
  4318. * @param array defines the source array
  4319. * @param offset defines the offset in the source array
  4320. * @param scale defines the scaling factor
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4324. /**
  4325. * Gets an identity matrix that must not be updated
  4326. */
  4327. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4328. /**
  4329. * Stores a list of values (16) inside a given matrix
  4330. * @param initialM11 defines 1st value of 1st row
  4331. * @param initialM12 defines 2nd value of 1st row
  4332. * @param initialM13 defines 3rd value of 1st row
  4333. * @param initialM14 defines 4th value of 1st row
  4334. * @param initialM21 defines 1st value of 2nd row
  4335. * @param initialM22 defines 2nd value of 2nd row
  4336. * @param initialM23 defines 3rd value of 2nd row
  4337. * @param initialM24 defines 4th value of 2nd row
  4338. * @param initialM31 defines 1st value of 3rd row
  4339. * @param initialM32 defines 2nd value of 3rd row
  4340. * @param initialM33 defines 3rd value of 3rd row
  4341. * @param initialM34 defines 4th value of 3rd row
  4342. * @param initialM41 defines 1st value of 4th row
  4343. * @param initialM42 defines 2nd value of 4th row
  4344. * @param initialM43 defines 3rd value of 4th row
  4345. * @param initialM44 defines 4th value of 4th row
  4346. * @param result defines the target matrix
  4347. */
  4348. 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;
  4349. /**
  4350. * Creates new matrix from a list of values (16)
  4351. * @param initialM11 defines 1st value of 1st row
  4352. * @param initialM12 defines 2nd value of 1st row
  4353. * @param initialM13 defines 3rd value of 1st row
  4354. * @param initialM14 defines 4th value of 1st row
  4355. * @param initialM21 defines 1st value of 2nd row
  4356. * @param initialM22 defines 2nd value of 2nd row
  4357. * @param initialM23 defines 3rd value of 2nd row
  4358. * @param initialM24 defines 4th value of 2nd row
  4359. * @param initialM31 defines 1st value of 3rd row
  4360. * @param initialM32 defines 2nd value of 3rd row
  4361. * @param initialM33 defines 3rd value of 3rd row
  4362. * @param initialM34 defines 4th value of 3rd row
  4363. * @param initialM41 defines 1st value of 4th row
  4364. * @param initialM42 defines 2nd value of 4th row
  4365. * @param initialM43 defines 3rd value of 4th row
  4366. * @param initialM44 defines 4th value of 4th row
  4367. * @returns the new matrix
  4368. */
  4369. 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;
  4370. /**
  4371. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4372. * @param scale defines the scale vector3
  4373. * @param rotation defines the rotation quaternion
  4374. * @param translation defines the translation vector3
  4375. * @returns a new matrix
  4376. */
  4377. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @param result defines the target matrix
  4384. */
  4385. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4386. /**
  4387. * Creates a new identity matrix
  4388. * @returns a new identity matrix
  4389. */
  4390. static Identity(): Matrix;
  4391. /**
  4392. * Creates a new identity matrix and stores the result in a given matrix
  4393. * @param result defines the target matrix
  4394. */
  4395. static IdentityToRef(result: Matrix): void;
  4396. /**
  4397. * Creates a new zero matrix
  4398. * @returns a new zero matrix
  4399. */
  4400. static Zero(): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the X axis
  4403. * @param angle defines the angle (in radians) to use
  4404. * @return the new matrix
  4405. */
  4406. static RotationX(angle: number): Matrix;
  4407. /**
  4408. * Creates a new matrix as the invert of a given matrix
  4409. * @param source defines the source matrix
  4410. * @returns the new matrix
  4411. */
  4412. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4413. /**
  4414. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4415. * @param angle defines the angle (in radians) to use
  4416. * @param result defines the target matrix
  4417. */
  4418. static RotationXToRef(angle: number, result: Matrix): void;
  4419. /**
  4420. * Creates a new rotation matrix for "angle" radians around the Y axis
  4421. * @param angle defines the angle (in radians) to use
  4422. * @return the new matrix
  4423. */
  4424. static RotationY(angle: number): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4427. * @param angle defines the angle (in radians) to use
  4428. * @param result defines the target matrix
  4429. */
  4430. static RotationYToRef(angle: number, result: Matrix): void;
  4431. /**
  4432. * Creates a new rotation matrix for "angle" radians around the Z axis
  4433. * @param angle defines the angle (in radians) to use
  4434. * @return the new matrix
  4435. */
  4436. static RotationZ(angle: number): Matrix;
  4437. /**
  4438. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4439. * @param angle defines the angle (in radians) to use
  4440. * @param result defines the target matrix
  4441. */
  4442. static RotationZToRef(angle: number, result: Matrix): void;
  4443. /**
  4444. * Creates a new rotation matrix for "angle" radians around the given axis
  4445. * @param axis defines the axis to use
  4446. * @param angle defines the angle (in radians) to use
  4447. * @return the new matrix
  4448. */
  4449. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @param result defines the target matrix
  4455. */
  4456. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4457. /**
  4458. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4459. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4460. * @param from defines the vector to align
  4461. * @param to defines the vector to align to
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4465. /**
  4466. * Creates a rotation matrix
  4467. * @param yaw defines the yaw angle in radians (Y axis)
  4468. * @param pitch defines the pitch angle in radians (X axis)
  4469. * @param roll defines the roll angle in radians (X axis)
  4470. * @returns the new rotation matrix
  4471. */
  4472. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4473. /**
  4474. * Creates a rotation matrix and stores it in a given matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @param result defines the target matrix
  4479. */
  4480. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4481. /**
  4482. * Creates a scaling matrix
  4483. * @param x defines the scale factor on X axis
  4484. * @param y defines the scale factor on Y axis
  4485. * @param z defines the scale factor on Z axis
  4486. * @returns the new matrix
  4487. */
  4488. static Scaling(x: number, y: number, z: number): Matrix;
  4489. /**
  4490. * Creates a scaling matrix and stores it in a given matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @param result defines the target matrix
  4495. */
  4496. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4497. /**
  4498. * Creates a translation matrix
  4499. * @param x defines the translation on X axis
  4500. * @param y defines the translation on Y axis
  4501. * @param z defines the translationon Z axis
  4502. * @returns the new matrix
  4503. */
  4504. static Translation(x: number, y: number, z: number): Matrix;
  4505. /**
  4506. * Creates a translation matrix and stores it in a given matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @param result defines the target matrix
  4511. */
  4512. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4513. /**
  4514. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4515. * @param startValue defines the start value
  4516. * @param endValue defines the end value
  4517. * @param gradient defines the gradient factor
  4518. * @returns the new matrix
  4519. */
  4520. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4521. /**
  4522. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @param result defines the Matrix object where to store data
  4527. */
  4528. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4529. /**
  4530. * Builds a new matrix whose values are computed by:
  4531. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4532. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4533. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4534. * @param startValue defines the first matrix
  4535. * @param endValue defines the second matrix
  4536. * @param gradient defines the gradient between the two matrices
  4537. * @returns the new matrix
  4538. */
  4539. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4540. /**
  4541. * Update a matrix to values which are computed by:
  4542. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4543. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4544. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4545. * @param startValue defines the first matrix
  4546. * @param endValue defines the second matrix
  4547. * @param gradient defines the gradient between the two matrices
  4548. * @param result defines the target matrix
  4549. */
  4550. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4551. /**
  4552. * 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"
  4553. * This function works in left handed mode
  4554. * @param eye defines the final position of the entity
  4555. * @param target defines where the entity should look at
  4556. * @param up defines the up vector for the entity
  4557. * @returns the new matrix
  4558. */
  4559. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4560. /**
  4561. * 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".
  4562. * This function works in left handed mode
  4563. * @param eye defines the final position of the entity
  4564. * @param target defines where the entity should look at
  4565. * @param up defines the up vector for the entity
  4566. * @param result defines the target matrix
  4567. */
  4568. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4569. /**
  4570. * 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"
  4571. * This function works in right handed mode
  4572. * @param eye defines the final position of the entity
  4573. * @param target defines where the entity should look at
  4574. * @param up defines the up vector for the entity
  4575. * @returns the new matrix
  4576. */
  4577. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * 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".
  4580. * This function works in right handed mode
  4581. * @param eye defines the final position of the entity
  4582. * @param target defines where the entity should look at
  4583. * @param up defines the up vector for the entity
  4584. * @param result defines the target matrix
  4585. */
  4586. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4587. /**
  4588. * Create a left-handed orthographic projection matrix
  4589. * @param width defines the viewport width
  4590. * @param height defines the viewport height
  4591. * @param znear defines the near clip plane
  4592. * @param zfar defines the far clip plane
  4593. * @returns a new matrix as a left-handed orthographic projection matrix
  4594. */
  4595. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4596. /**
  4597. * Store a left-handed orthographic projection to a given matrix
  4598. * @param width defines the viewport width
  4599. * @param height defines the viewport height
  4600. * @param znear defines the near clip plane
  4601. * @param zfar defines the far clip plane
  4602. * @param result defines the target matrix
  4603. */
  4604. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4605. /**
  4606. * Create a left-handed orthographic projection matrix
  4607. * @param left defines the viewport left coordinate
  4608. * @param right defines the viewport right coordinate
  4609. * @param bottom defines the viewport bottom coordinate
  4610. * @param top defines the viewport top coordinate
  4611. * @param znear defines the near clip plane
  4612. * @param zfar defines the far clip plane
  4613. * @returns a new matrix as a left-handed orthographic projection matrix
  4614. */
  4615. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4616. /**
  4617. * Stores a left-handed orthographic projection into a given matrix
  4618. * @param left defines the viewport left coordinate
  4619. * @param right defines the viewport right coordinate
  4620. * @param bottom defines the viewport bottom coordinate
  4621. * @param top defines the viewport top coordinate
  4622. * @param znear defines the near clip plane
  4623. * @param zfar defines the far clip plane
  4624. * @param result defines the target matrix
  4625. */
  4626. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4627. /**
  4628. * Creates a right-handed orthographic projection matrix
  4629. * @param left defines the viewport left coordinate
  4630. * @param right defines the viewport right coordinate
  4631. * @param bottom defines the viewport bottom coordinate
  4632. * @param top defines the viewport top coordinate
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a right-handed orthographic projection matrix
  4636. */
  4637. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a right-handed orthographic projection into a given matrix
  4640. * @param left defines the viewport left coordinate
  4641. * @param right defines the viewport right coordinate
  4642. * @param bottom defines the viewport bottom coordinate
  4643. * @param top defines the viewport top coordinate
  4644. * @param znear defines the near clip plane
  4645. * @param zfar defines the far clip plane
  4646. * @param result defines the target matrix
  4647. */
  4648. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4649. /**
  4650. * Creates a left-handed perspective projection matrix
  4651. * @param width defines the viewport width
  4652. * @param height defines the viewport height
  4653. * @param znear defines the near clip plane
  4654. * @param zfar defines the far clip plane
  4655. * @returns a new matrix as a left-handed perspective projection matrix
  4656. */
  4657. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4658. /**
  4659. * Creates a left-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a left-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a left-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Creates a right-handed perspective projection matrix
  4689. * @param fov defines the horizontal field of view
  4690. * @param aspect defines the aspect ratio
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @returns a new matrix as a right-handed perspective projection matrix
  4694. */
  4695. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4696. /**
  4697. * Stores a right-handed perspective projection into a given matrix
  4698. * @param fov defines the horizontal field of view
  4699. * @param aspect defines the aspect ratio
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @param result defines the target matrix
  4703. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4704. */
  4705. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4706. /**
  4707. * Stores a right-handed perspective projection into a given matrix
  4708. * @param fov defines the horizontal field of view
  4709. * @param aspect defines the aspect ratio
  4710. * @param znear defines the near clip plane
  4711. * @param zfar not used as infinity is used as far clip
  4712. * @param result defines the target matrix
  4713. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4714. */
  4715. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4716. /**
  4717. * Stores a perspective projection for WebVR info a given matrix
  4718. * @param fov defines the field of view
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @param result defines the target matrix
  4722. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4723. */
  4724. static PerspectiveFovWebVRToRef(fov: {
  4725. upDegrees: number;
  4726. downDegrees: number;
  4727. leftDegrees: number;
  4728. rightDegrees: number;
  4729. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4730. /**
  4731. * Computes a complete transformation matrix
  4732. * @param viewport defines the viewport to use
  4733. * @param world defines the world matrix
  4734. * @param view defines the view matrix
  4735. * @param projection defines the projection matrix
  4736. * @param zmin defines the near clip plane
  4737. * @param zmax defines the far clip plane
  4738. * @returns the transformation matrix
  4739. */
  4740. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4741. /**
  4742. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4743. * @param matrix defines the matrix to use
  4744. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4745. */
  4746. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4747. /**
  4748. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4749. * @param matrix defines the matrix to use
  4750. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4751. */
  4752. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4753. /**
  4754. * Compute the transpose of a given matrix
  4755. * @param matrix defines the matrix to transpose
  4756. * @returns the new matrix
  4757. */
  4758. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4759. /**
  4760. * Compute the transpose of a matrix and store it in a target matrix
  4761. * @param matrix defines the matrix to transpose
  4762. * @param result defines the target matrix
  4763. */
  4764. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4765. /**
  4766. * Computes a reflection matrix from a plane
  4767. * @param plane defines the reflection plane
  4768. * @returns a new matrix
  4769. */
  4770. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4771. /**
  4772. * Computes a reflection matrix from a plane
  4773. * @param plane defines the reflection plane
  4774. * @param result defines the target matrix
  4775. */
  4776. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4777. /**
  4778. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4779. * @param xaxis defines the value of the 1st axis
  4780. * @param yaxis defines the value of the 2nd axis
  4781. * @param zaxis defines the value of the 3rd axis
  4782. * @param result defines the target matrix
  4783. */
  4784. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4785. /**
  4786. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4787. * @param quat defines the quaternion to use
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4791. }
  4792. /**
  4793. * @hidden
  4794. */
  4795. export class TmpVectors {
  4796. static Vector2: Vector2[];
  4797. static Vector3: Vector3[];
  4798. static Vector4: Vector4[];
  4799. static Quaternion: Quaternion[];
  4800. static Matrix: Matrix[];
  4801. }
  4802. }
  4803. declare module "babylonjs/Maths/math.path" {
  4804. import { DeepImmutable, Nullable } from "babylonjs/types";
  4805. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4806. /**
  4807. * Defines potential orientation for back face culling
  4808. */
  4809. export enum Orientation {
  4810. /**
  4811. * Clockwise
  4812. */
  4813. CW = 0,
  4814. /** Counter clockwise */
  4815. CCW = 1
  4816. }
  4817. /** Class used to represent a Bezier curve */
  4818. export class BezierCurve {
  4819. /**
  4820. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4821. * @param t defines the time
  4822. * @param x1 defines the left coordinate on X axis
  4823. * @param y1 defines the left coordinate on Y axis
  4824. * @param x2 defines the right coordinate on X axis
  4825. * @param y2 defines the right coordinate on Y axis
  4826. * @returns the interpolated value
  4827. */
  4828. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4829. }
  4830. /**
  4831. * Defines angle representation
  4832. */
  4833. export class Angle {
  4834. private _radians;
  4835. /**
  4836. * Creates an Angle object of "radians" radians (float).
  4837. * @param radians the angle in radians
  4838. */
  4839. constructor(radians: number);
  4840. /**
  4841. * Get value in degrees
  4842. * @returns the Angle value in degrees (float)
  4843. */
  4844. degrees(): number;
  4845. /**
  4846. * Get value in radians
  4847. * @returns the Angle value in radians (float)
  4848. */
  4849. radians(): number;
  4850. /**
  4851. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4852. * @param a defines first vector
  4853. * @param b defines second vector
  4854. * @returns a new Angle
  4855. */
  4856. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4857. /**
  4858. * Gets a new Angle object from the given float in radians
  4859. * @param radians defines the angle value in radians
  4860. * @returns a new Angle
  4861. */
  4862. static FromRadians(radians: number): Angle;
  4863. /**
  4864. * Gets a new Angle object from the given float in degrees
  4865. * @param degrees defines the angle value in degrees
  4866. * @returns a new Angle
  4867. */
  4868. static FromDegrees(degrees: number): Angle;
  4869. }
  4870. /**
  4871. * This represents an arc in a 2d space.
  4872. */
  4873. export class Arc2 {
  4874. /** Defines the start point of the arc */
  4875. startPoint: Vector2;
  4876. /** Defines the mid point of the arc */
  4877. midPoint: Vector2;
  4878. /** Defines the end point of the arc */
  4879. endPoint: Vector2;
  4880. /**
  4881. * Defines the center point of the arc.
  4882. */
  4883. centerPoint: Vector2;
  4884. /**
  4885. * Defines the radius of the arc.
  4886. */
  4887. radius: number;
  4888. /**
  4889. * Defines the angle of the arc (from mid point to end point).
  4890. */
  4891. angle: Angle;
  4892. /**
  4893. * Defines the start angle of the arc (from start point to middle point).
  4894. */
  4895. startAngle: Angle;
  4896. /**
  4897. * Defines the orientation of the arc (clock wise/counter clock wise).
  4898. */
  4899. orientation: Orientation;
  4900. /**
  4901. * Creates an Arc object from the three given points : start, middle and end.
  4902. * @param startPoint Defines the start point of the arc
  4903. * @param midPoint Defines the midlle point of the arc
  4904. * @param endPoint Defines the end point of the arc
  4905. */
  4906. constructor(
  4907. /** Defines the start point of the arc */
  4908. startPoint: Vector2,
  4909. /** Defines the mid point of the arc */
  4910. midPoint: Vector2,
  4911. /** Defines the end point of the arc */
  4912. endPoint: Vector2);
  4913. }
  4914. /**
  4915. * Represents a 2D path made up of multiple 2D points
  4916. */
  4917. export class Path2 {
  4918. private _points;
  4919. private _length;
  4920. /**
  4921. * If the path start and end point are the same
  4922. */
  4923. closed: boolean;
  4924. /**
  4925. * Creates a Path2 object from the starting 2D coordinates x and y.
  4926. * @param x the starting points x value
  4927. * @param y the starting points y value
  4928. */
  4929. constructor(x: number, y: number);
  4930. /**
  4931. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4932. * @param x the added points x value
  4933. * @param y the added points y value
  4934. * @returns the updated Path2.
  4935. */
  4936. addLineTo(x: number, y: number): Path2;
  4937. /**
  4938. * 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.
  4939. * @param midX middle point x value
  4940. * @param midY middle point y value
  4941. * @param endX end point x value
  4942. * @param endY end point y value
  4943. * @param numberOfSegments (default: 36)
  4944. * @returns the updated Path2.
  4945. */
  4946. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4947. /**
  4948. * Closes the Path2.
  4949. * @returns the Path2.
  4950. */
  4951. close(): Path2;
  4952. /**
  4953. * Gets the sum of the distance between each sequential point in the path
  4954. * @returns the Path2 total length (float).
  4955. */
  4956. length(): number;
  4957. /**
  4958. * Gets the points which construct the path
  4959. * @returns the Path2 internal array of points.
  4960. */
  4961. getPoints(): Vector2[];
  4962. /**
  4963. * Retreives the point at the distance aways from the starting point
  4964. * @param normalizedLengthPosition the length along the path to retreive the point from
  4965. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4966. */
  4967. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4968. /**
  4969. * Creates a new path starting from an x and y position
  4970. * @param x starting x value
  4971. * @param y starting y value
  4972. * @returns a new Path2 starting at the coordinates (x, y).
  4973. */
  4974. static StartingAt(x: number, y: number): Path2;
  4975. }
  4976. /**
  4977. * Represents a 3D path made up of multiple 3D points
  4978. */
  4979. export class Path3D {
  4980. /**
  4981. * an array of Vector3, the curve axis of the Path3D
  4982. */
  4983. path: Vector3[];
  4984. private _curve;
  4985. private _distances;
  4986. private _tangents;
  4987. private _normals;
  4988. private _binormals;
  4989. private _raw;
  4990. private _alignTangentsWithPath;
  4991. private readonly _pointAtData;
  4992. /**
  4993. * new Path3D(path, normal, raw)
  4994. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4995. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4996. * @param path an array of Vector3, the curve axis of the Path3D
  4997. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4998. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4999. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5000. */
  5001. constructor(
  5002. /**
  5003. * an array of Vector3, the curve axis of the Path3D
  5004. */
  5005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5006. /**
  5007. * Returns the Path3D array of successive Vector3 designing its curve.
  5008. * @returns the Path3D array of successive Vector3 designing its curve.
  5009. */
  5010. getCurve(): Vector3[];
  5011. /**
  5012. * Returns the Path3D array of successive Vector3 designing its curve.
  5013. * @returns the Path3D array of successive Vector3 designing its curve.
  5014. */
  5015. getPoints(): Vector3[];
  5016. /**
  5017. * @returns the computed length (float) of the path.
  5018. */
  5019. length(): number;
  5020. /**
  5021. * Returns an array populated with tangent vectors on each Path3D curve point.
  5022. * @returns an array populated with tangent vectors on each Path3D curve point.
  5023. */
  5024. getTangents(): Vector3[];
  5025. /**
  5026. * Returns an array populated with normal vectors on each Path3D curve point.
  5027. * @returns an array populated with normal vectors on each Path3D curve point.
  5028. */
  5029. getNormals(): Vector3[];
  5030. /**
  5031. * Returns an array populated with binormal vectors on each Path3D curve point.
  5032. * @returns an array populated with binormal vectors on each Path3D curve point.
  5033. */
  5034. getBinormals(): Vector3[];
  5035. /**
  5036. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5037. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5038. */
  5039. getDistances(): number[];
  5040. /**
  5041. * Returns an interpolated point along this path
  5042. * @param position the position of the point along this path, from 0.0 to 1.0
  5043. * @returns a new Vector3 as the point
  5044. */
  5045. getPointAt(position: number): Vector3;
  5046. /**
  5047. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5048. * @param position the position of the point along this path, from 0.0 to 1.0
  5049. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5050. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5051. */
  5052. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5053. /**
  5054. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5057. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5058. */
  5059. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5060. /**
  5061. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5062. * @param position the position of the point along this path, from 0.0 to 1.0
  5063. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5064. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5065. */
  5066. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5067. /**
  5068. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5069. * @param position the position of the point along this path, from 0.0 to 1.0
  5070. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5071. */
  5072. getDistanceAt(position: number): number;
  5073. /**
  5074. * Returns the array index of the previous point of an interpolated point along this path
  5075. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5076. * @returns the array index
  5077. */
  5078. getPreviousPointIndexAt(position: number): number;
  5079. /**
  5080. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5081. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5082. * @returns the sub position
  5083. */
  5084. getSubPositionAt(position: number): number;
  5085. /**
  5086. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5087. * @param target the vector of which to get the closest position to
  5088. * @returns the position of the closest virtual point on this path to the target vector
  5089. */
  5090. getClosestPositionTo(target: Vector3): number;
  5091. /**
  5092. * Returns a sub path (slice) of this path
  5093. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5094. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5095. * @returns a sub path (slice) of this path
  5096. */
  5097. slice(start?: number, end?: number): Path3D;
  5098. /**
  5099. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5100. * @param path path which all values are copied into the curves points
  5101. * @param firstNormal which should be projected onto the curve
  5102. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5103. * @returns the same object updated.
  5104. */
  5105. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5106. private _compute;
  5107. private _getFirstNonNullVector;
  5108. private _getLastNonNullVector;
  5109. private _normalVector;
  5110. /**
  5111. * Updates the point at data for an interpolated point along this curve
  5112. * @param position the position of the point along this curve, from 0.0 to 1.0
  5113. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5114. * @returns the (updated) point at data
  5115. */
  5116. private _updatePointAtData;
  5117. /**
  5118. * Updates the point at data from the specified parameters
  5119. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5120. * @param point the interpolated point
  5121. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5122. */
  5123. private _setPointAtData;
  5124. /**
  5125. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5126. */
  5127. private _updateInterpolationMatrix;
  5128. }
  5129. /**
  5130. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5131. * A Curve3 is designed from a series of successive Vector3.
  5132. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5133. */
  5134. export class Curve3 {
  5135. private _points;
  5136. private _length;
  5137. /**
  5138. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5139. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5140. * @param v1 (Vector3) the control point
  5141. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5142. * @param nbPoints (integer) the wanted number of points in the curve
  5143. * @returns the created Curve3
  5144. */
  5145. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5146. /**
  5147. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5148. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5149. * @param v1 (Vector3) the first control point
  5150. * @param v2 (Vector3) the second control point
  5151. * @param v3 (Vector3) the end point of the Cubic Bezier
  5152. * @param nbPoints (integer) the wanted number of points in the curve
  5153. * @returns the created Curve3
  5154. */
  5155. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5156. /**
  5157. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5158. * @param p1 (Vector3) the origin point of the Hermite Spline
  5159. * @param t1 (Vector3) the tangent vector at the origin point
  5160. * @param p2 (Vector3) the end point of the Hermite Spline
  5161. * @param t2 (Vector3) the tangent vector at the end point
  5162. * @param nbPoints (integer) the wanted number of points in the curve
  5163. * @returns the created Curve3
  5164. */
  5165. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5166. /**
  5167. * Returns a Curve3 object along a CatmullRom Spline curve :
  5168. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5169. * @param nbPoints (integer) the wanted number of points between each curve control points
  5170. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5174. /**
  5175. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5176. * A Curve3 is designed from a series of successive Vector3.
  5177. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5178. * @param points points which make up the curve
  5179. */
  5180. constructor(points: Vector3[]);
  5181. /**
  5182. * @returns the Curve3 stored array of successive Vector3
  5183. */
  5184. getPoints(): Vector3[];
  5185. /**
  5186. * @returns the computed length (float) of the curve.
  5187. */
  5188. length(): number;
  5189. /**
  5190. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5191. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5192. * curveA and curveB keep unchanged.
  5193. * @param curve the curve to continue from this curve
  5194. * @returns the newly constructed curve
  5195. */
  5196. continue(curve: DeepImmutable<Curve3>): Curve3;
  5197. private _computeLength;
  5198. }
  5199. }
  5200. declare module "babylonjs/Animations/easing" {
  5201. /**
  5202. * This represents the main contract an easing function should follow.
  5203. * Easing functions are used throughout the animation system.
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export interface IEasingFunction {
  5207. /**
  5208. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5209. * of the easing function.
  5210. * The link below provides some of the most common examples of easing functions.
  5211. * @see https://easings.net/
  5212. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5213. * @returns the corresponding value on the curve defined by the easing function
  5214. */
  5215. ease(gradient: number): number;
  5216. }
  5217. /**
  5218. * Base class used for every default easing function.
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class EasingFunction implements IEasingFunction {
  5222. /**
  5223. * Interpolation follows the mathematical formula associated with the easing function.
  5224. */
  5225. static readonly EASINGMODE_EASEIN: number;
  5226. /**
  5227. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5228. */
  5229. static readonly EASINGMODE_EASEOUT: number;
  5230. /**
  5231. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5232. */
  5233. static readonly EASINGMODE_EASEINOUT: number;
  5234. private _easingMode;
  5235. /**
  5236. * Sets the easing mode of the current function.
  5237. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5238. */
  5239. setEasingMode(easingMode: number): void;
  5240. /**
  5241. * Gets the current easing mode.
  5242. * @returns the easing mode
  5243. */
  5244. getEasingMode(): number;
  5245. /**
  5246. * @hidden
  5247. */
  5248. easeInCore(gradient: number): number;
  5249. /**
  5250. * Given an input gradient between 0 and 1, this returns the corresponding value
  5251. * of the easing function.
  5252. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5253. * @returns the corresponding value on the curve defined by the easing function
  5254. */
  5255. ease(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a circle shape (see link below).
  5259. * @see https://easings.net/#easeInCirc
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class CircleEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a ease back shape (see link below).
  5268. * @see https://easings.net/#easeInBack
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class BackEase extends EasingFunction implements IEasingFunction {
  5272. /** Defines the amplitude of the function */
  5273. amplitude: number;
  5274. /**
  5275. * Instantiates a back ease easing
  5276. * @see https://easings.net/#easeInBack
  5277. * @param amplitude Defines the amplitude of the function
  5278. */
  5279. constructor(
  5280. /** Defines the amplitude of the function */
  5281. amplitude?: number);
  5282. /** @hidden */
  5283. easeInCore(gradient: number): number;
  5284. }
  5285. /**
  5286. * Easing function with a bouncing shape (see link below).
  5287. * @see https://easings.net/#easeInBounce
  5288. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5289. */
  5290. export class BounceEase extends EasingFunction implements IEasingFunction {
  5291. /** Defines the number of bounces */
  5292. bounces: number;
  5293. /** Defines the amplitude of the bounce */
  5294. bounciness: number;
  5295. /**
  5296. * Instantiates a bounce easing
  5297. * @see https://easings.net/#easeInBounce
  5298. * @param bounces Defines the number of bounces
  5299. * @param bounciness Defines the amplitude of the bounce
  5300. */
  5301. constructor(
  5302. /** Defines the number of bounces */
  5303. bounces?: number,
  5304. /** Defines the amplitude of the bounce */
  5305. bounciness?: number);
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a power of 3 shape (see link below).
  5311. * @see https://easings.net/#easeInCubic
  5312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class CubicEase extends EasingFunction implements IEasingFunction {
  5315. /** @hidden */
  5316. easeInCore(gradient: number): number;
  5317. }
  5318. /**
  5319. * Easing function with an elastic shape (see link below).
  5320. * @see https://easings.net/#easeInElastic
  5321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5322. */
  5323. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5324. /** Defines the number of oscillations*/
  5325. oscillations: number;
  5326. /** Defines the amplitude of the oscillations*/
  5327. springiness: number;
  5328. /**
  5329. * Instantiates an elastic easing function
  5330. * @see https://easings.net/#easeInElastic
  5331. * @param oscillations Defines the number of oscillations
  5332. * @param springiness Defines the amplitude of the oscillations
  5333. */
  5334. constructor(
  5335. /** Defines the number of oscillations*/
  5336. oscillations?: number,
  5337. /** Defines the amplitude of the oscillations*/
  5338. springiness?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with an exponential shape (see link below).
  5344. * @see https://easings.net/#easeInExpo
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5348. /** Defines the exponent of the function */
  5349. exponent: number;
  5350. /**
  5351. * Instantiates an exponential easing function
  5352. * @see https://easings.net/#easeInExpo
  5353. * @param exponent Defines the exponent of the function
  5354. */
  5355. constructor(
  5356. /** Defines the exponent of the function */
  5357. exponent?: number);
  5358. /** @hidden */
  5359. easeInCore(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with a power shape (see link below).
  5363. * @see https://easings.net/#easeInQuad
  5364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class PowerEase extends EasingFunction implements IEasingFunction {
  5367. /** Defines the power of the function */
  5368. power: number;
  5369. /**
  5370. * Instantiates an power base easing function
  5371. * @see https://easings.net/#easeInQuad
  5372. * @param power Defines the power of the function
  5373. */
  5374. constructor(
  5375. /** Defines the power of the function */
  5376. power?: number);
  5377. /** @hidden */
  5378. easeInCore(gradient: number): number;
  5379. }
  5380. /**
  5381. * Easing function with a power of 2 shape (see link below).
  5382. * @see https://easings.net/#easeInQuad
  5383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5384. */
  5385. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5386. /** @hidden */
  5387. easeInCore(gradient: number): number;
  5388. }
  5389. /**
  5390. * Easing function with a power of 4 shape (see link below).
  5391. * @see https://easings.net/#easeInQuart
  5392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5393. */
  5394. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5395. /** @hidden */
  5396. easeInCore(gradient: number): number;
  5397. }
  5398. /**
  5399. * Easing function with a power of 5 shape (see link below).
  5400. * @see https://easings.net/#easeInQuint
  5401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5402. */
  5403. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5404. /** @hidden */
  5405. easeInCore(gradient: number): number;
  5406. }
  5407. /**
  5408. * Easing function with a sin shape (see link below).
  5409. * @see https://easings.net/#easeInSine
  5410. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5411. */
  5412. export class SineEase extends EasingFunction implements IEasingFunction {
  5413. /** @hidden */
  5414. easeInCore(gradient: number): number;
  5415. }
  5416. /**
  5417. * Easing function with a bezier shape (see link below).
  5418. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5420. */
  5421. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5422. /** Defines the x component of the start tangent in the bezier curve */
  5423. x1: number;
  5424. /** Defines the y component of the start tangent in the bezier curve */
  5425. y1: number;
  5426. /** Defines the x component of the end tangent in the bezier curve */
  5427. x2: number;
  5428. /** Defines the y component of the end tangent in the bezier curve */
  5429. y2: number;
  5430. /**
  5431. * Instantiates a bezier function
  5432. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5433. * @param x1 Defines the x component of the start tangent in the bezier curve
  5434. * @param y1 Defines the y component of the start tangent in the bezier curve
  5435. * @param x2 Defines the x component of the end tangent in the bezier curve
  5436. * @param y2 Defines the y component of the end tangent in the bezier curve
  5437. */
  5438. constructor(
  5439. /** Defines the x component of the start tangent in the bezier curve */
  5440. x1?: number,
  5441. /** Defines the y component of the start tangent in the bezier curve */
  5442. y1?: number,
  5443. /** Defines the x component of the end tangent in the bezier curve */
  5444. x2?: number,
  5445. /** Defines the y component of the end tangent in the bezier curve */
  5446. y2?: number);
  5447. /** @hidden */
  5448. easeInCore(gradient: number): number;
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/math.color" {
  5452. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to hold a RBG color
  5455. */
  5456. export class Color3 {
  5457. /**
  5458. * Defines the red component (between 0 and 1, default is 0)
  5459. */
  5460. r: number;
  5461. /**
  5462. * Defines the green component (between 0 and 1, default is 0)
  5463. */
  5464. g: number;
  5465. /**
  5466. * Defines the blue component (between 0 and 1, default is 0)
  5467. */
  5468. b: number;
  5469. /**
  5470. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5471. * @param r defines the red component (between 0 and 1, default is 0)
  5472. * @param g defines the green component (between 0 and 1, default is 0)
  5473. * @param b defines the blue component (between 0 and 1, default is 0)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number);
  5488. /**
  5489. * Creates a string with the Color3 current values
  5490. * @returns the string representation of the Color3 object
  5491. */
  5492. toString(): string;
  5493. /**
  5494. * Returns the string "Color3"
  5495. * @returns "Color3"
  5496. */
  5497. getClassName(): string;
  5498. /**
  5499. * Compute the Color3 hash code
  5500. * @returns an unique number that can be used to hash Color3 objects
  5501. */
  5502. getHashCode(): number;
  5503. /**
  5504. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color3 object
  5508. */
  5509. toArray(array: FloatArray, index?: number): Color3;
  5510. /**
  5511. * Returns a new Color4 object from the current Color3 and the given alpha
  5512. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5513. * @returns a new Color4 object
  5514. */
  5515. toColor4(alpha?: number): Color4;
  5516. /**
  5517. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5518. * @returns the new array
  5519. */
  5520. asArray(): number[];
  5521. /**
  5522. * Returns the luminance value
  5523. * @returns a float value
  5524. */
  5525. toLuminance(): number;
  5526. /**
  5527. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5528. * @param otherColor defines the second operand
  5529. * @returns the new Color3 object
  5530. */
  5531. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5532. /**
  5533. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5534. * @param otherColor defines the second operand
  5535. * @param result defines the Color3 object where to store the result
  5536. * @returns the current Color3
  5537. */
  5538. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5539. /**
  5540. * Determines equality between Color3 objects
  5541. * @param otherColor defines the second operand
  5542. * @returns true if the rgb values are equal to the given ones
  5543. */
  5544. equals(otherColor: DeepImmutable<Color3>): boolean;
  5545. /**
  5546. * Determines equality between the current Color3 object and a set of r,b,g values
  5547. * @param r defines the red component to check
  5548. * @param g defines the green component to check
  5549. * @param b defines the blue component to check
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equalsFloats(r: number, g: number, b: number): boolean;
  5553. /**
  5554. * Multiplies in place each rgb value by scale
  5555. * @param scale defines the scaling factor
  5556. * @returns the updated Color3
  5557. */
  5558. scale(scale: number): Color3;
  5559. /**
  5560. * Multiplies the rgb values by scale and stores the result into "result"
  5561. * @param scale defines the scaling factor
  5562. * @param result defines the Color3 object where to store the result
  5563. * @returns the unmodified current Color3
  5564. */
  5565. scaleToRef(scale: number, result: Color3): Color3;
  5566. /**
  5567. * Scale the current Color3 values by a factor and add the result to a given Color3
  5568. * @param scale defines the scale factor
  5569. * @param result defines color to store the result into
  5570. * @returns the unmodified current Color3
  5571. */
  5572. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5573. /**
  5574. * Clamps the rgb values by the min and max values and stores the result into "result"
  5575. * @param min defines minimum clamping value (default is 0)
  5576. * @param max defines maximum clamping value (default is 1)
  5577. * @param result defines color to store the result into
  5578. * @returns the original Color3
  5579. */
  5580. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5581. /**
  5582. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5583. * @param otherColor defines the second operand
  5584. * @returns the new Color3
  5585. */
  5586. add(otherColor: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5589. * @param otherColor defines the second operand
  5590. * @param result defines Color3 object to store the result into
  5591. * @returns the unmodified current Color3
  5592. */
  5593. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5594. /**
  5595. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5596. * @param otherColor defines the second operand
  5597. * @returns the new Color3
  5598. */
  5599. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5600. /**
  5601. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5602. * @param otherColor defines the second operand
  5603. * @param result defines Color3 object to store the result into
  5604. * @returns the unmodified current Color3
  5605. */
  5606. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5607. /**
  5608. * Copy the current object
  5609. * @returns a new Color3 copied the current one
  5610. */
  5611. clone(): Color3;
  5612. /**
  5613. * Copies the rgb values from the source in the current Color3
  5614. * @param source defines the source Color3 object
  5615. * @returns the updated Color3 object
  5616. */
  5617. copyFrom(source: DeepImmutable<Color3>): Color3;
  5618. /**
  5619. * Updates the Color3 rgb values from the given floats
  5620. * @param r defines the red component to read from
  5621. * @param g defines the green component to read from
  5622. * @param b defines the blue component to read from
  5623. * @returns the current Color3 object
  5624. */
  5625. copyFromFloats(r: number, g: number, b: number): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. set(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Compute the Color3 hexadecimal code as a string
  5636. * @returns a string containing the hexadecimal representation of the Color3 object
  5637. */
  5638. toHexString(): string;
  5639. /**
  5640. * Computes a new Color3 converted from the current one to linear space
  5641. * @returns a new Color3 object
  5642. */
  5643. toLinearSpace(): Color3;
  5644. /**
  5645. * Converts current color in rgb space to HSV values
  5646. * @returns a new color3 representing the HSV values
  5647. */
  5648. toHSV(): Color3;
  5649. /**
  5650. * Converts current color in rgb space to HSV values
  5651. * @param result defines the Color3 where to store the HSV values
  5652. */
  5653. toHSVToRef(result: Color3): void;
  5654. /**
  5655. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5656. * @param convertedColor defines the Color3 object where to store the linear space version
  5657. * @returns the unmodified Color3
  5658. */
  5659. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5660. /**
  5661. * Computes a new Color3 converted from the current one to gamma space
  5662. * @returns a new Color3 object
  5663. */
  5664. toGammaSpace(): Color3;
  5665. /**
  5666. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5667. * @param convertedColor defines the Color3 object where to store the gamma space version
  5668. * @returns the unmodified Color3
  5669. */
  5670. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5671. private static _BlackReadOnly;
  5672. /**
  5673. * Convert Hue, saturation and value to a Color3 (RGB)
  5674. * @param hue defines the hue
  5675. * @param saturation defines the saturation
  5676. * @param value defines the value
  5677. * @param result defines the Color3 where to store the RGB values
  5678. */
  5679. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5680. /**
  5681. * Creates a new Color3 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color3 object
  5684. */
  5685. static FromHexString(hex: string): Color3;
  5686. /**
  5687. * Creates a new Color3 from the starting index of the given array
  5688. * @param array defines the source array
  5689. * @param offset defines an offset in the source array
  5690. * @returns a new Color3 object
  5691. */
  5692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5693. /**
  5694. * Creates a new Color3 from integer values (< 256)
  5695. * @param r defines the red component to read from (value between 0 and 255)
  5696. * @param g defines the green component to read from (value between 0 and 255)
  5697. * @param b defines the blue component to read from (value between 0 and 255)
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromInts(r: number, g: number, b: number): Color3;
  5701. /**
  5702. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5703. * @param start defines the start Color3 value
  5704. * @param end defines the end Color3 value
  5705. * @param amount defines the gradient value between start and end
  5706. * @returns a new Color3 object
  5707. */
  5708. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param left defines the start value
  5712. * @param right defines the end value
  5713. * @param amount defines the gradient factor
  5714. * @param result defines the Color3 object where to store the result
  5715. */
  5716. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5717. /**
  5718. * Returns a Color3 value containing a red color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Red(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a green color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Green(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a blue color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Blue(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a black color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Black(): Color3;
  5737. /**
  5738. * Gets a Color3 value containing a black color that must not be updated
  5739. */
  5740. static get BlackReadOnly(): DeepImmutable<Color3>;
  5741. /**
  5742. * Returns a Color3 value containing a white color
  5743. * @returns a new Color3 object
  5744. */
  5745. static White(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a purple color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Purple(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a magenta color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Magenta(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a yellow color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Yellow(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a gray color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Gray(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a teal color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Teal(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a random color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Random(): Color3;
  5776. }
  5777. /**
  5778. * Class used to hold a RBGA color
  5779. */
  5780. export class Color4 {
  5781. /**
  5782. * Defines the red component (between 0 and 1, default is 0)
  5783. */
  5784. r: number;
  5785. /**
  5786. * Defines the green component (between 0 and 1, default is 0)
  5787. */
  5788. g: number;
  5789. /**
  5790. * Defines the blue component (between 0 and 1, default is 0)
  5791. */
  5792. b: number;
  5793. /**
  5794. * Defines the alpha component (between 0 and 1, default is 1)
  5795. */
  5796. a: number;
  5797. /**
  5798. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5799. * @param r defines the red component (between 0 and 1, default is 0)
  5800. * @param g defines the green component (between 0 and 1, default is 0)
  5801. * @param b defines the blue component (between 0 and 1, default is 0)
  5802. * @param a defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. constructor(
  5805. /**
  5806. * Defines the red component (between 0 and 1, default is 0)
  5807. */
  5808. r?: number,
  5809. /**
  5810. * Defines the green component (between 0 and 1, default is 0)
  5811. */
  5812. g?: number,
  5813. /**
  5814. * Defines the blue component (between 0 and 1, default is 0)
  5815. */
  5816. b?: number,
  5817. /**
  5818. * Defines the alpha component (between 0 and 1, default is 1)
  5819. */
  5820. a?: number);
  5821. /**
  5822. * Adds in place the given Color4 values to the current Color4 object
  5823. * @param right defines the second operand
  5824. * @returns the current updated Color4 object
  5825. */
  5826. addInPlace(right: DeepImmutable<Color4>): Color4;
  5827. /**
  5828. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5829. * @returns the new array
  5830. */
  5831. asArray(): number[];
  5832. /**
  5833. * Stores from the starting index in the given array the Color4 successive values
  5834. * @param array defines the array where to store the r,g,b components
  5835. * @param index defines an optional index in the target array to define where to start storing values
  5836. * @returns the current Color4 object
  5837. */
  5838. toArray(array: number[], index?: number): Color4;
  5839. /**
  5840. * Determines equality between Color4 objects
  5841. * @param otherColor defines the second operand
  5842. * @returns true if the rgba values are equal to the given ones
  5843. */
  5844. equals(otherColor: DeepImmutable<Color4>): boolean;
  5845. /**
  5846. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5847. * @param right defines the second operand
  5848. * @returns a new Color4 object
  5849. */
  5850. add(right: DeepImmutable<Color4>): Color4;
  5851. /**
  5852. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5853. * @param right defines the second operand
  5854. * @returns a new Color4 object
  5855. */
  5856. subtract(right: DeepImmutable<Color4>): Color4;
  5857. /**
  5858. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5859. * @param right defines the second operand
  5860. * @param result defines the Color4 object where to store the result
  5861. * @returns the current Color4 object
  5862. */
  5863. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5864. /**
  5865. * Creates a new Color4 with the current Color4 values multiplied by scale
  5866. * @param scale defines the scaling factor to apply
  5867. * @returns a new Color4 object
  5868. */
  5869. scale(scale: number): Color4;
  5870. /**
  5871. * Multiplies the current Color4 values by scale and stores the result in "result"
  5872. * @param scale defines the scaling factor to apply
  5873. * @param result defines the Color4 object where to store the result
  5874. * @returns the current unmodified Color4
  5875. */
  5876. scaleToRef(scale: number, result: Color4): Color4;
  5877. /**
  5878. * Scale the current Color4 values by a factor and add the result to a given Color4
  5879. * @param scale defines the scale factor
  5880. * @param result defines the Color4 object where to store the result
  5881. * @returns the unmodified current Color4
  5882. */
  5883. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5884. /**
  5885. * Clamps the rgb values by the min and max values and stores the result into "result"
  5886. * @param min defines minimum clamping value (default is 0)
  5887. * @param max defines maximum clamping value (default is 1)
  5888. * @param result defines color to store the result into.
  5889. * @returns the cuurent Color4
  5890. */
  5891. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5892. /**
  5893. * Multipy an Color4 value by another and return a new Color4 object
  5894. * @param color defines the Color4 value to multiply by
  5895. * @returns a new Color4 object
  5896. */
  5897. multiply(color: Color4): Color4;
  5898. /**
  5899. * Multipy a Color4 value by another and push the result in a reference value
  5900. * @param color defines the Color4 value to multiply by
  5901. * @param result defines the Color4 to fill the result in
  5902. * @returns the result Color4
  5903. */
  5904. multiplyToRef(color: Color4, result: Color4): Color4;
  5905. /**
  5906. * Creates a string with the Color4 current values
  5907. * @returns the string representation of the Color4 object
  5908. */
  5909. toString(): string;
  5910. /**
  5911. * Returns the string "Color4"
  5912. * @returns "Color4"
  5913. */
  5914. getClassName(): string;
  5915. /**
  5916. * Compute the Color4 hash code
  5917. * @returns an unique number that can be used to hash Color4 objects
  5918. */
  5919. getHashCode(): number;
  5920. /**
  5921. * Creates a new Color4 copied from the current one
  5922. * @returns a new Color4 object
  5923. */
  5924. clone(): Color4;
  5925. /**
  5926. * Copies the given Color4 values into the current one
  5927. * @param source defines the source Color4 object
  5928. * @returns the current updated Color4 object
  5929. */
  5930. copyFrom(source: Color4): Color4;
  5931. /**
  5932. * Copies the given float values into the current one
  5933. * @param r defines the red component to read from
  5934. * @param g defines the green component to read from
  5935. * @param b defines the blue component to read from
  5936. * @param a defines the alpha component to read from
  5937. * @returns the current updated Color4 object
  5938. */
  5939. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5940. /**
  5941. * Copies the given float values into the current one
  5942. * @param r defines the red component to read from
  5943. * @param g defines the green component to read from
  5944. * @param b defines the blue component to read from
  5945. * @param a defines the alpha component to read from
  5946. * @returns the current updated Color4 object
  5947. */
  5948. set(r: number, g: number, b: number, a: number): Color4;
  5949. /**
  5950. * Compute the Color4 hexadecimal code as a string
  5951. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5952. * @returns a string containing the hexadecimal representation of the Color4 object
  5953. */
  5954. toHexString(returnAsColor3?: boolean): string;
  5955. /**
  5956. * Computes a new Color4 converted from the current one to linear space
  5957. * @returns a new Color4 object
  5958. */
  5959. toLinearSpace(): Color4;
  5960. /**
  5961. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5962. * @param convertedColor defines the Color4 object where to store the linear space version
  5963. * @returns the unmodified Color4
  5964. */
  5965. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5966. /**
  5967. * Computes a new Color4 converted from the current one to gamma space
  5968. * @returns a new Color4 object
  5969. */
  5970. toGammaSpace(): Color4;
  5971. /**
  5972. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5973. * @param convertedColor defines the Color4 object where to store the gamma space version
  5974. * @returns the unmodified Color4
  5975. */
  5976. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 from the string containing valid hexadecimal values
  5979. * @param hex defines a string containing valid hexadecimal values
  5980. * @returns a new Color4 object
  5981. */
  5982. static FromHexString(hex: string): Color4;
  5983. /**
  5984. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5985. * @param left defines the start value
  5986. * @param right defines the end value
  5987. * @param amount defines the gradient factor
  5988. * @returns a new Color4 object
  5989. */
  5990. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5991. /**
  5992. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @param result defines the Color4 object where to store data
  5997. */
  5998. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5999. /**
  6000. * Creates a new Color4 from a Color3 and an alpha value
  6001. * @param color3 defines the source Color3 to read from
  6002. * @param alpha defines the alpha component (1.0 by default)
  6003. * @returns a new Color4 object
  6004. */
  6005. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6006. /**
  6007. * Creates a new Color4 from the starting index element of the given array
  6008. * @param array defines the source array to read from
  6009. * @param offset defines the offset in the source array
  6010. * @returns a new Color4 object
  6011. */
  6012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6013. /**
  6014. * Creates a new Color3 from integer values (< 256)
  6015. * @param r defines the red component to read from (value between 0 and 255)
  6016. * @param g defines the green component to read from (value between 0 and 255)
  6017. * @param b defines the blue component to read from (value between 0 and 255)
  6018. * @param a defines the alpha component to read from (value between 0 and 255)
  6019. * @returns a new Color3 object
  6020. */
  6021. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6022. /**
  6023. * Check the content of a given array and convert it to an array containing RGBA data
  6024. * If the original array was already containing count * 4 values then it is returned directly
  6025. * @param colors defines the array to check
  6026. * @param count defines the number of RGBA data to expect
  6027. * @returns an array containing count * 4 values (RGBA)
  6028. */
  6029. static CheckColors4(colors: number[], count: number): number[];
  6030. }
  6031. /**
  6032. * @hidden
  6033. */
  6034. export class TmpColors {
  6035. static Color3: Color3[];
  6036. static Color4: Color4[];
  6037. }
  6038. }
  6039. declare module "babylonjs/Animations/animationKey" {
  6040. /**
  6041. * Defines an interface which represents an animation key frame
  6042. */
  6043. export interface IAnimationKey {
  6044. /**
  6045. * Frame of the key frame
  6046. */
  6047. frame: number;
  6048. /**
  6049. * Value at the specifies key frame
  6050. */
  6051. value: any;
  6052. /**
  6053. * The input tangent for the cubic hermite spline
  6054. */
  6055. inTangent?: any;
  6056. /**
  6057. * The output tangent for the cubic hermite spline
  6058. */
  6059. outTangent?: any;
  6060. /**
  6061. * The animation interpolation type
  6062. */
  6063. interpolation?: AnimationKeyInterpolation;
  6064. }
  6065. /**
  6066. * Enum for the animation key frame interpolation type
  6067. */
  6068. export enum AnimationKeyInterpolation {
  6069. /**
  6070. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6071. */
  6072. STEP = 1
  6073. }
  6074. }
  6075. declare module "babylonjs/Animations/animationRange" {
  6076. /**
  6077. * Represents the range of an animation
  6078. */
  6079. export class AnimationRange {
  6080. /**The name of the animation range**/
  6081. name: string;
  6082. /**The starting frame of the animation */
  6083. from: number;
  6084. /**The ending frame of the animation*/
  6085. to: number;
  6086. /**
  6087. * Initializes the range of an animation
  6088. * @param name The name of the animation range
  6089. * @param from The starting frame of the animation
  6090. * @param to The ending frame of the animation
  6091. */
  6092. constructor(
  6093. /**The name of the animation range**/
  6094. name: string,
  6095. /**The starting frame of the animation */
  6096. from: number,
  6097. /**The ending frame of the animation*/
  6098. to: number);
  6099. /**
  6100. * Makes a copy of the animation range
  6101. * @returns A copy of the animation range
  6102. */
  6103. clone(): AnimationRange;
  6104. }
  6105. }
  6106. declare module "babylonjs/Animations/animationEvent" {
  6107. /**
  6108. * Composed of a frame, and an action function
  6109. */
  6110. export class AnimationEvent {
  6111. /** The frame for which the event is triggered **/
  6112. frame: number;
  6113. /** The event to perform when triggered **/
  6114. action: (currentFrame: number) => void;
  6115. /** Specifies if the event should be triggered only once**/
  6116. onlyOnce?: boolean | undefined;
  6117. /**
  6118. * Specifies if the animation event is done
  6119. */
  6120. isDone: boolean;
  6121. /**
  6122. * Initializes the animation event
  6123. * @param frame The frame for which the event is triggered
  6124. * @param action The event to perform when triggered
  6125. * @param onlyOnce Specifies if the event should be triggered only once
  6126. */
  6127. constructor(
  6128. /** The frame for which the event is triggered **/
  6129. frame: number,
  6130. /** The event to perform when triggered **/
  6131. action: (currentFrame: number) => void,
  6132. /** Specifies if the event should be triggered only once**/
  6133. onlyOnce?: boolean | undefined);
  6134. /** @hidden */
  6135. _clone(): AnimationEvent;
  6136. }
  6137. }
  6138. declare module "babylonjs/Behaviors/behavior" {
  6139. import { Nullable } from "babylonjs/types";
  6140. /**
  6141. * Interface used to define a behavior
  6142. */
  6143. export interface Behavior<T> {
  6144. /** gets or sets behavior's name */
  6145. name: string;
  6146. /**
  6147. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6148. */
  6149. init(): void;
  6150. /**
  6151. * Called when the behavior is attached to a target
  6152. * @param target defines the target where the behavior is attached to
  6153. */
  6154. attach(target: T): void;
  6155. /**
  6156. * Called when the behavior is detached from its target
  6157. */
  6158. detach(): void;
  6159. }
  6160. /**
  6161. * Interface implemented by classes supporting behaviors
  6162. */
  6163. export interface IBehaviorAware<T> {
  6164. /**
  6165. * Attach a behavior
  6166. * @param behavior defines the behavior to attach
  6167. * @returns the current host
  6168. */
  6169. addBehavior(behavior: Behavior<T>): T;
  6170. /**
  6171. * Remove a behavior from the current object
  6172. * @param behavior defines the behavior to detach
  6173. * @returns the current host
  6174. */
  6175. removeBehavior(behavior: Behavior<T>): T;
  6176. /**
  6177. * Gets a behavior using its name to search
  6178. * @param name defines the name to search
  6179. * @returns the behavior or null if not found
  6180. */
  6181. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6182. }
  6183. }
  6184. declare module "babylonjs/Misc/smartArray" {
  6185. /**
  6186. * Defines an array and its length.
  6187. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6188. */
  6189. export interface ISmartArrayLike<T> {
  6190. /**
  6191. * The data of the array.
  6192. */
  6193. data: Array<T>;
  6194. /**
  6195. * The active length of the array.
  6196. */
  6197. length: number;
  6198. }
  6199. /**
  6200. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6201. */
  6202. export class SmartArray<T> implements ISmartArrayLike<T> {
  6203. /**
  6204. * The full set of data from the array.
  6205. */
  6206. data: Array<T>;
  6207. /**
  6208. * The active length of the array.
  6209. */
  6210. length: number;
  6211. protected _id: number;
  6212. /**
  6213. * Instantiates a Smart Array.
  6214. * @param capacity defines the default capacity of the array.
  6215. */
  6216. constructor(capacity: number);
  6217. /**
  6218. * Pushes a value at the end of the active data.
  6219. * @param value defines the object to push in the array.
  6220. */
  6221. push(value: T): void;
  6222. /**
  6223. * Iterates over the active data and apply the lambda to them.
  6224. * @param func defines the action to apply on each value.
  6225. */
  6226. forEach(func: (content: T) => void): void;
  6227. /**
  6228. * Sorts the full sets of data.
  6229. * @param compareFn defines the comparison function to apply.
  6230. */
  6231. sort(compareFn: (a: T, b: T) => number): void;
  6232. /**
  6233. * Resets the active data to an empty array.
  6234. */
  6235. reset(): void;
  6236. /**
  6237. * Releases all the data from the array as well as the array.
  6238. */
  6239. dispose(): void;
  6240. /**
  6241. * Concats the active data with a given array.
  6242. * @param array defines the data to concatenate with.
  6243. */
  6244. concat(array: any): void;
  6245. /**
  6246. * Returns the position of a value in the active data.
  6247. * @param value defines the value to find the index for
  6248. * @returns the index if found in the active data otherwise -1
  6249. */
  6250. indexOf(value: T): number;
  6251. /**
  6252. * Returns whether an element is part of the active data.
  6253. * @param value defines the value to look for
  6254. * @returns true if found in the active data otherwise false
  6255. */
  6256. contains(value: T): boolean;
  6257. private static _GlobalId;
  6258. }
  6259. /**
  6260. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6261. * The data in this array can only be present once
  6262. */
  6263. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6264. private _duplicateId;
  6265. /**
  6266. * Pushes a value at the end of the active data.
  6267. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6268. * @param value defines the object to push in the array.
  6269. */
  6270. push(value: T): void;
  6271. /**
  6272. * Pushes a value at the end of the active data.
  6273. * If the data is already present, it won t be added again
  6274. * @param value defines the object to push in the array.
  6275. * @returns true if added false if it was already present
  6276. */
  6277. pushNoDuplicate(value: T): boolean;
  6278. /**
  6279. * Resets the active data to an empty array.
  6280. */
  6281. reset(): void;
  6282. /**
  6283. * Concats the active data with a given array.
  6284. * This ensures no dupplicate will be present in the result.
  6285. * @param array defines the data to concatenate with.
  6286. */
  6287. concatWithNoDuplicate(array: any): void;
  6288. }
  6289. }
  6290. declare module "babylonjs/Cameras/cameraInputsManager" {
  6291. import { Nullable } from "babylonjs/types";
  6292. import { Camera } from "babylonjs/Cameras/camera";
  6293. /**
  6294. * @ignore
  6295. * This is a list of all the different input types that are available in the application.
  6296. * Fo instance: ArcRotateCameraGamepadInput...
  6297. */
  6298. export var CameraInputTypes: {};
  6299. /**
  6300. * This is the contract to implement in order to create a new input class.
  6301. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6302. */
  6303. export interface ICameraInput<TCamera extends Camera> {
  6304. /**
  6305. * Defines the camera the input is attached to.
  6306. */
  6307. camera: Nullable<TCamera>;
  6308. /**
  6309. * Gets the class name of the current intput.
  6310. * @returns the class name
  6311. */
  6312. getClassName(): string;
  6313. /**
  6314. * Get the friendly name associated with the input class.
  6315. * @returns the input friendly name
  6316. */
  6317. getSimpleName(): string;
  6318. /**
  6319. * Attach the input controls to a specific dom element to get the input from.
  6320. * @param element Defines the element the controls should be listened from
  6321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6322. */
  6323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6324. /**
  6325. * Detach the current controls from the specified dom element.
  6326. * @param element Defines the element to stop listening the inputs from
  6327. */
  6328. detachControl(element: Nullable<HTMLElement>): void;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs?: () => void;
  6334. }
  6335. /**
  6336. * Represents a map of input types to input instance or input index to input instance.
  6337. */
  6338. export interface CameraInputsMap<TCamera extends Camera> {
  6339. /**
  6340. * Accessor to the input by input type.
  6341. */
  6342. [name: string]: ICameraInput<TCamera>;
  6343. /**
  6344. * Accessor to the input by input index.
  6345. */
  6346. [idx: number]: ICameraInput<TCamera>;
  6347. }
  6348. /**
  6349. * This represents the input manager used within a camera.
  6350. * It helps dealing with all the different kind of input attached to a camera.
  6351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6352. */
  6353. export class CameraInputsManager<TCamera extends Camera> {
  6354. /**
  6355. * Defines the list of inputs attahed to the camera.
  6356. */
  6357. attached: CameraInputsMap<TCamera>;
  6358. /**
  6359. * Defines the dom element the camera is collecting inputs from.
  6360. * This is null if the controls have not been attached.
  6361. */
  6362. attachedElement: Nullable<HTMLElement>;
  6363. /**
  6364. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6365. */
  6366. noPreventDefault: boolean;
  6367. /**
  6368. * Defined the camera the input manager belongs to.
  6369. */
  6370. camera: TCamera;
  6371. /**
  6372. * Update the current camera state depending on the inputs that have been used this frame.
  6373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6374. */
  6375. checkInputs: () => void;
  6376. /**
  6377. * Instantiate a new Camera Input Manager.
  6378. * @param camera Defines the camera the input manager blongs to
  6379. */
  6380. constructor(camera: TCamera);
  6381. /**
  6382. * Add an input method to a camera
  6383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6384. * @param input camera input method
  6385. */
  6386. add(input: ICameraInput<TCamera>): void;
  6387. /**
  6388. * Remove a specific input method from a camera
  6389. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6390. * @param inputToRemove camera input method
  6391. */
  6392. remove(inputToRemove: ICameraInput<TCamera>): void;
  6393. /**
  6394. * Remove a specific input type from a camera
  6395. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6396. * @param inputType the type of the input to remove
  6397. */
  6398. removeByType(inputType: string): void;
  6399. private _addCheckInputs;
  6400. /**
  6401. * Attach the input controls to the currently attached dom element to listen the events from.
  6402. * @param input Defines the input to attach
  6403. */
  6404. attachInput(input: ICameraInput<TCamera>): void;
  6405. /**
  6406. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6407. * @param element Defines the dom element to collect the events from
  6408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6409. */
  6410. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6411. /**
  6412. * Detach the current manager inputs controls from a specific dom element.
  6413. * @param element Defines the dom element to collect the events from
  6414. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6415. */
  6416. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6417. /**
  6418. * Rebuild the dynamic inputCheck function from the current list of
  6419. * defined inputs in the manager.
  6420. */
  6421. rebuildInputCheck(): void;
  6422. /**
  6423. * Remove all attached input methods from a camera
  6424. */
  6425. clear(): void;
  6426. /**
  6427. * Serialize the current input manager attached to a camera.
  6428. * This ensures than once parsed,
  6429. * the input associated to the camera will be identical to the current ones
  6430. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6431. */
  6432. serialize(serializedCamera: any): void;
  6433. /**
  6434. * Parses an input manager serialized JSON to restore the previous list of inputs
  6435. * and states associated to a camera.
  6436. * @param parsedCamera Defines the JSON to parse
  6437. */
  6438. parse(parsedCamera: any): void;
  6439. }
  6440. }
  6441. declare module "babylonjs/Meshes/buffer" {
  6442. import { Nullable, DataArray } from "babylonjs/types";
  6443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6444. /**
  6445. * Class used to store data that will be store in GPU memory
  6446. */
  6447. export class Buffer {
  6448. private _engine;
  6449. private _buffer;
  6450. /** @hidden */
  6451. _data: Nullable<DataArray>;
  6452. private _updatable;
  6453. private _instanced;
  6454. private _divisor;
  6455. /**
  6456. * Gets the byte stride.
  6457. */
  6458. readonly byteStride: number;
  6459. /**
  6460. * Constructor
  6461. * @param engine the engine
  6462. * @param data the data to use for this buffer
  6463. * @param updatable whether the data is updatable
  6464. * @param stride the stride (optional)
  6465. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6466. * @param instanced whether the buffer is instanced (optional)
  6467. * @param useBytes set to true if the stride in in bytes (optional)
  6468. * @param divisor sets an optional divisor for instances (1 by default)
  6469. */
  6470. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6471. /**
  6472. * Create a new VertexBuffer based on the current buffer
  6473. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6474. * @param offset defines offset in the buffer (0 by default)
  6475. * @param size defines the size in floats of attributes (position is 3 for instance)
  6476. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6477. * @param instanced defines if the vertex buffer contains indexed data
  6478. * @param useBytes defines if the offset and stride are in bytes *
  6479. * @param divisor sets an optional divisor for instances (1 by default)
  6480. * @returns the new vertex buffer
  6481. */
  6482. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6483. /**
  6484. * Gets a boolean indicating if the Buffer is updatable?
  6485. * @returns true if the buffer is updatable
  6486. */
  6487. isUpdatable(): boolean;
  6488. /**
  6489. * Gets current buffer's data
  6490. * @returns a DataArray or null
  6491. */
  6492. getData(): Nullable<DataArray>;
  6493. /**
  6494. * Gets underlying native buffer
  6495. * @returns underlying native buffer
  6496. */
  6497. getBuffer(): Nullable<DataBuffer>;
  6498. /**
  6499. * Gets the stride in float32 units (i.e. byte stride / 4).
  6500. * May not be an integer if the byte stride is not divisible by 4.
  6501. * @returns the stride in float32 units
  6502. * @deprecated Please use byteStride instead.
  6503. */
  6504. getStrideSize(): number;
  6505. /**
  6506. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6507. * @param data defines the data to store
  6508. */
  6509. create(data?: Nullable<DataArray>): void;
  6510. /** @hidden */
  6511. _rebuild(): void;
  6512. /**
  6513. * Update current buffer data
  6514. * @param data defines the data to store
  6515. */
  6516. update(data: DataArray): void;
  6517. /**
  6518. * Updates the data directly.
  6519. * @param data the new data
  6520. * @param offset the new offset
  6521. * @param vertexCount the vertex count (optional)
  6522. * @param useBytes set to true if the offset is in bytes
  6523. */
  6524. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6525. /**
  6526. * Release all resources
  6527. */
  6528. dispose(): void;
  6529. }
  6530. /**
  6531. * Specialized buffer used to store vertex data
  6532. */
  6533. export class VertexBuffer {
  6534. /** @hidden */
  6535. _buffer: Buffer;
  6536. private _kind;
  6537. private _size;
  6538. private _ownsBuffer;
  6539. private _instanced;
  6540. private _instanceDivisor;
  6541. /**
  6542. * The byte type.
  6543. */
  6544. static readonly BYTE: number;
  6545. /**
  6546. * The unsigned byte type.
  6547. */
  6548. static readonly UNSIGNED_BYTE: number;
  6549. /**
  6550. * The short type.
  6551. */
  6552. static readonly SHORT: number;
  6553. /**
  6554. * The unsigned short type.
  6555. */
  6556. static readonly UNSIGNED_SHORT: number;
  6557. /**
  6558. * The integer type.
  6559. */
  6560. static readonly INT: number;
  6561. /**
  6562. * The unsigned integer type.
  6563. */
  6564. static readonly UNSIGNED_INT: number;
  6565. /**
  6566. * The float type.
  6567. */
  6568. static readonly FLOAT: number;
  6569. /**
  6570. * Gets or sets the instance divisor when in instanced mode
  6571. */
  6572. get instanceDivisor(): number;
  6573. set instanceDivisor(value: number);
  6574. /**
  6575. * Gets the byte stride.
  6576. */
  6577. readonly byteStride: number;
  6578. /**
  6579. * Gets the byte offset.
  6580. */
  6581. readonly byteOffset: number;
  6582. /**
  6583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6584. */
  6585. readonly normalized: boolean;
  6586. /**
  6587. * Gets the data type of each component in the array.
  6588. */
  6589. readonly type: number;
  6590. /**
  6591. * Constructor
  6592. * @param engine the engine
  6593. * @param data the data to use for this vertex buffer
  6594. * @param kind the vertex buffer kind
  6595. * @param updatable whether the data is updatable
  6596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6597. * @param stride the stride (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param offset the offset of the data (optional)
  6600. * @param size the number of components (optional)
  6601. * @param type the type of the component (optional)
  6602. * @param normalized whether the data contains normalized data (optional)
  6603. * @param useBytes set to true if stride and offset are in bytes (optional)
  6604. * @param divisor defines the instance divisor to use (1 by default)
  6605. */
  6606. 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, divisor?: number);
  6607. /** @hidden */
  6608. _rebuild(): void;
  6609. /**
  6610. * Returns the kind of the VertexBuffer (string)
  6611. * @returns a string
  6612. */
  6613. getKind(): string;
  6614. /**
  6615. * Gets a boolean indicating if the VertexBuffer is updatable?
  6616. * @returns true if the buffer is updatable
  6617. */
  6618. isUpdatable(): boolean;
  6619. /**
  6620. * Gets current buffer's data
  6621. * @returns a DataArray or null
  6622. */
  6623. getData(): Nullable<DataArray>;
  6624. /**
  6625. * Gets underlying native buffer
  6626. * @returns underlying native buffer
  6627. */
  6628. getBuffer(): Nullable<DataBuffer>;
  6629. /**
  6630. * Gets the stride in float32 units (i.e. byte stride / 4).
  6631. * May not be an integer if the byte stride is not divisible by 4.
  6632. * @returns the stride in float32 units
  6633. * @deprecated Please use byteStride instead.
  6634. */
  6635. getStrideSize(): number;
  6636. /**
  6637. * Returns the offset as a multiple of the type byte length.
  6638. * @returns the offset in bytes
  6639. * @deprecated Please use byteOffset instead.
  6640. */
  6641. getOffset(): number;
  6642. /**
  6643. * Returns the number of components per vertex attribute (integer)
  6644. * @returns the size in float
  6645. */
  6646. getSize(): number;
  6647. /**
  6648. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6649. * @returns true if this buffer is instanced
  6650. */
  6651. getIsInstanced(): boolean;
  6652. /**
  6653. * Returns the instancing divisor, zero for non-instanced (integer).
  6654. * @returns a number
  6655. */
  6656. getInstanceDivisor(): number;
  6657. /**
  6658. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6659. * @param data defines the data to store
  6660. */
  6661. create(data?: DataArray): void;
  6662. /**
  6663. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6664. * This function will create a new buffer if the current one is not updatable
  6665. * @param data defines the data to store
  6666. */
  6667. update(data: DataArray): void;
  6668. /**
  6669. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6670. * Returns the directly updated WebGLBuffer.
  6671. * @param data the new data
  6672. * @param offset the new offset
  6673. * @param useBytes set to true if the offset is in bytes
  6674. */
  6675. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6676. /**
  6677. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6678. */
  6679. dispose(): void;
  6680. /**
  6681. * Enumerates each value of this vertex buffer as numbers.
  6682. * @param count the number of values to enumerate
  6683. * @param callback the callback function called for each value
  6684. */
  6685. forEach(count: number, callback: (value: number, index: number) => void): void;
  6686. /**
  6687. * Positions
  6688. */
  6689. static readonly PositionKind: string;
  6690. /**
  6691. * Normals
  6692. */
  6693. static readonly NormalKind: string;
  6694. /**
  6695. * Tangents
  6696. */
  6697. static readonly TangentKind: string;
  6698. /**
  6699. * Texture coordinates
  6700. */
  6701. static readonly UVKind: string;
  6702. /**
  6703. * Texture coordinates 2
  6704. */
  6705. static readonly UV2Kind: string;
  6706. /**
  6707. * Texture coordinates 3
  6708. */
  6709. static readonly UV3Kind: string;
  6710. /**
  6711. * Texture coordinates 4
  6712. */
  6713. static readonly UV4Kind: string;
  6714. /**
  6715. * Texture coordinates 5
  6716. */
  6717. static readonly UV5Kind: string;
  6718. /**
  6719. * Texture coordinates 6
  6720. */
  6721. static readonly UV6Kind: string;
  6722. /**
  6723. * Colors
  6724. */
  6725. static readonly ColorKind: string;
  6726. /**
  6727. * Matrix indices (for bones)
  6728. */
  6729. static readonly MatricesIndicesKind: string;
  6730. /**
  6731. * Matrix weights (for bones)
  6732. */
  6733. static readonly MatricesWeightsKind: string;
  6734. /**
  6735. * Additional matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesExtraKind: string;
  6738. /**
  6739. * Additional matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsExtraKind: string;
  6742. /**
  6743. * Deduces the stride given a kind.
  6744. * @param kind The kind string to deduce
  6745. * @returns The deduced stride
  6746. */
  6747. static DeduceStride(kind: string): number;
  6748. /**
  6749. * Gets the byte length of the given type.
  6750. * @param type the type
  6751. * @returns the number of bytes
  6752. */
  6753. static GetTypeByteLength(type: number): number;
  6754. /**
  6755. * Enumerates each value of the given parameters as numbers.
  6756. * @param data the data to enumerate
  6757. * @param byteOffset the byte offset of the data
  6758. * @param byteStride the byte stride of the data
  6759. * @param componentCount the number of components per element
  6760. * @param componentType the type of the component
  6761. * @param count the number of values to enumerate
  6762. * @param normalized whether the data is normalized
  6763. * @param callback the callback function called for each value
  6764. */
  6765. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6766. private static _GetFloatValue;
  6767. }
  6768. }
  6769. declare module "babylonjs/Collisions/intersectionInfo" {
  6770. import { Nullable } from "babylonjs/types";
  6771. /**
  6772. * @hidden
  6773. */
  6774. export class IntersectionInfo {
  6775. bu: Nullable<number>;
  6776. bv: Nullable<number>;
  6777. distance: number;
  6778. faceId: number;
  6779. subMeshId: number;
  6780. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6781. }
  6782. }
  6783. declare module "babylonjs/Culling/boundingSphere" {
  6784. import { DeepImmutable } from "babylonjs/types";
  6785. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6786. import { Plane } from "babylonjs/Maths/math.plane";
  6787. /**
  6788. * Class used to store bounding sphere information
  6789. */
  6790. export class BoundingSphere {
  6791. /**
  6792. * Gets the center of the bounding sphere in local space
  6793. */
  6794. readonly center: Vector3;
  6795. /**
  6796. * Radius of the bounding sphere in local space
  6797. */
  6798. radius: number;
  6799. /**
  6800. * Gets the center of the bounding sphere in world space
  6801. */
  6802. readonly centerWorld: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in world space
  6805. */
  6806. radiusWorld: number;
  6807. /**
  6808. * Gets the minimum vector in local space
  6809. */
  6810. readonly minimum: Vector3;
  6811. /**
  6812. * Gets the maximum vector in local space
  6813. */
  6814. readonly maximum: Vector3;
  6815. private _worldMatrix;
  6816. private static readonly TmpVector3;
  6817. /**
  6818. * Creates a new bounding sphere
  6819. * @param min defines the minimum vector (in local space)
  6820. * @param max defines the maximum vector (in local space)
  6821. * @param worldMatrix defines the new world matrix
  6822. */
  6823. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6824. /**
  6825. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6826. * @param min defines the new minimum vector (in local space)
  6827. * @param max defines the new maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6831. /**
  6832. * Scale the current bounding sphere by applying a scale factor
  6833. * @param factor defines the scale factor to apply
  6834. * @returns the current bounding box
  6835. */
  6836. scale(factor: number): BoundingSphere;
  6837. /**
  6838. * Gets the world matrix of the bounding box
  6839. * @returns a matrix
  6840. */
  6841. getWorldMatrix(): DeepImmutable<Matrix>;
  6842. /** @hidden */
  6843. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6844. /**
  6845. * Tests if the bounding sphere is intersecting the frustum planes
  6846. * @param frustumPlanes defines the frustum planes to test
  6847. * @returns true if there is an intersection
  6848. */
  6849. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6850. /**
  6851. * Tests if the bounding sphere center is in between the frustum planes.
  6852. * Used for optimistic fast inclusion.
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if the sphere center is in between the frustum planes
  6855. */
  6856. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if a point is inside the bounding sphere
  6859. * @param point defines the point to test
  6860. * @returns true if the point is inside the bounding sphere
  6861. */
  6862. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6863. /**
  6864. * Checks if two sphere intersct
  6865. * @param sphere0 sphere 0
  6866. * @param sphere1 sphere 1
  6867. * @returns true if the speres intersect
  6868. */
  6869. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingBox" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6876. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6877. import { Plane } from "babylonjs/Maths/math.plane";
  6878. /**
  6879. * Class used to store bounding box information
  6880. */
  6881. export class BoundingBox implements ICullable {
  6882. /**
  6883. * Gets the 8 vectors representing the bounding box in local space
  6884. */
  6885. readonly vectors: Vector3[];
  6886. /**
  6887. * Gets the center of the bounding box in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Gets the center of the bounding box in world space
  6892. */
  6893. readonly centerWorld: Vector3;
  6894. /**
  6895. * Gets the extend size in local space
  6896. */
  6897. readonly extendSize: Vector3;
  6898. /**
  6899. * Gets the extend size in world space
  6900. */
  6901. readonly extendSizeWorld: Vector3;
  6902. /**
  6903. * Gets the OBB (object bounding box) directions
  6904. */
  6905. readonly directions: Vector3[];
  6906. /**
  6907. * Gets the 8 vectors representing the bounding box in world space
  6908. */
  6909. readonly vectorsWorld: Vector3[];
  6910. /**
  6911. * Gets the minimum vector in world space
  6912. */
  6913. readonly minimumWorld: Vector3;
  6914. /**
  6915. * Gets the maximum vector in world space
  6916. */
  6917. readonly maximumWorld: Vector3;
  6918. /**
  6919. * Gets the minimum vector in local space
  6920. */
  6921. readonly minimum: Vector3;
  6922. /**
  6923. * Gets the maximum vector in local space
  6924. */
  6925. readonly maximum: Vector3;
  6926. private _worldMatrix;
  6927. private static readonly TmpVector3;
  6928. /**
  6929. * @hidden
  6930. */
  6931. _tag: number;
  6932. /**
  6933. * Creates a new bounding box
  6934. * @param min defines the minimum vector (in local space)
  6935. * @param max defines the maximum vector (in local space)
  6936. * @param worldMatrix defines the new world matrix
  6937. */
  6938. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6939. /**
  6940. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6941. * @param min defines the new minimum vector (in local space)
  6942. * @param max defines the new maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6946. /**
  6947. * Scale the current bounding box by applying a scale factor
  6948. * @param factor defines the scale factor to apply
  6949. * @returns the current bounding box
  6950. */
  6951. scale(factor: number): BoundingBox;
  6952. /**
  6953. * Gets the world matrix of the bounding box
  6954. * @returns a matrix
  6955. */
  6956. getWorldMatrix(): DeepImmutable<Matrix>;
  6957. /** @hidden */
  6958. _update(world: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Tests if the bounding box is intersecting the frustum planes
  6961. * @param frustumPlanes defines the frustum planes to test
  6962. * @returns true if there is an intersection
  6963. */
  6964. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6965. /**
  6966. * Tests if the bounding box is entirely inside the frustum planes
  6967. * @param frustumPlanes defines the frustum planes to test
  6968. * @returns true if there is an inclusion
  6969. */
  6970. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6971. /**
  6972. * Tests if a point is inside the bounding box
  6973. * @param point defines the point to test
  6974. * @returns true if the point is inside the bounding box
  6975. */
  6976. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6977. /**
  6978. * Tests if the bounding box intersects with a bounding sphere
  6979. * @param sphere defines the sphere to test
  6980. * @returns true if there is an intersection
  6981. */
  6982. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6983. /**
  6984. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6985. * @param min defines the min vector to use
  6986. * @param max defines the max vector to use
  6987. * @returns true if there is an intersection
  6988. */
  6989. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if two bounding boxes are intersections
  6992. * @param box0 defines the first box to test
  6993. * @param box1 defines the second box to test
  6994. * @returns true if there is an intersection
  6995. */
  6996. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6997. /**
  6998. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6999. * @param minPoint defines the minimum vector of the bounding box
  7000. * @param maxPoint defines the maximum vector of the bounding box
  7001. * @param sphereCenter defines the sphere center
  7002. * @param sphereRadius defines the sphere radius
  7003. * @returns true if there is an intersection
  7004. */
  7005. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7006. /**
  7007. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7008. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @return true if there is an inclusion
  7011. */
  7012. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7015. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @return true if there is an intersection
  7018. */
  7019. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. }
  7021. }
  7022. declare module "babylonjs/Collisions/collider" {
  7023. import { Nullable, IndicesArray } from "babylonjs/types";
  7024. import { Vector3 } from "babylonjs/Maths/math.vector";
  7025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7026. import { Plane } from "babylonjs/Maths/math.plane";
  7027. /** @hidden */
  7028. export class Collider {
  7029. /** Define if a collision was found */
  7030. collisionFound: boolean;
  7031. /**
  7032. * Define last intersection point in local space
  7033. */
  7034. intersectionPoint: Vector3;
  7035. /**
  7036. * Define last collided mesh
  7037. */
  7038. collidedMesh: Nullable<AbstractMesh>;
  7039. private _collisionPoint;
  7040. private _planeIntersectionPoint;
  7041. private _tempVector;
  7042. private _tempVector2;
  7043. private _tempVector3;
  7044. private _tempVector4;
  7045. private _edge;
  7046. private _baseToVertex;
  7047. private _destinationPoint;
  7048. private _slidePlaneNormal;
  7049. private _displacementVector;
  7050. /** @hidden */
  7051. _radius: Vector3;
  7052. /** @hidden */
  7053. _retry: number;
  7054. private _velocity;
  7055. private _basePoint;
  7056. private _epsilon;
  7057. /** @hidden */
  7058. _velocityWorldLength: number;
  7059. /** @hidden */
  7060. _basePointWorld: Vector3;
  7061. private _velocityWorld;
  7062. private _normalizedVelocity;
  7063. /** @hidden */
  7064. _initialVelocity: Vector3;
  7065. /** @hidden */
  7066. _initialPosition: Vector3;
  7067. private _nearestDistance;
  7068. private _collisionMask;
  7069. get collisionMask(): number;
  7070. set collisionMask(mask: number);
  7071. /**
  7072. * Gets the plane normal used to compute the sliding response (in local space)
  7073. */
  7074. get slidePlaneNormal(): Vector3;
  7075. /** @hidden */
  7076. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7077. /** @hidden */
  7078. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */
  7080. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7081. /** @hidden */
  7082. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7083. /** @hidden */
  7084. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7085. /** @hidden */
  7086. _getResponse(pos: Vector3, vel: Vector3): void;
  7087. }
  7088. }
  7089. declare module "babylonjs/Culling/boundingInfo" {
  7090. import { DeepImmutable } from "babylonjs/types";
  7091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7092. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7093. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7094. import { Plane } from "babylonjs/Maths/math.plane";
  7095. import { Collider } from "babylonjs/Collisions/collider";
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. get minimum(): Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. get maximum(): Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. get isLocked(): boolean;
  7155. set isLocked(value: boolean);
  7156. /**
  7157. * Updates the bounding sphere and box
  7158. * @param world world matrix to be used to update
  7159. */
  7160. update(world: DeepImmutable<Matrix>): void;
  7161. /**
  7162. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7163. * @param center New center of the bounding info
  7164. * @param extend New extend of the bounding info
  7165. * @returns the current bounding info
  7166. */
  7167. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7168. /**
  7169. * Scale the current bounding info by applying a scale factor
  7170. * @param factor defines the scale factor to apply
  7171. * @returns the current bounding info
  7172. */
  7173. scale(factor: number): BoundingInfo;
  7174. /**
  7175. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7176. * @param frustumPlanes defines the frustum to test
  7177. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7178. * @returns true if the bounding info is in the frustum planes
  7179. */
  7180. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7181. /**
  7182. * Gets the world distance between the min and max points of the bounding box
  7183. */
  7184. get diagonalLength(): number;
  7185. /**
  7186. * Checks if a cullable object (mesh...) is in the camera frustum
  7187. * Unlike isInFrustum this cheks the full bounding box
  7188. * @param frustumPlanes Camera near/planes
  7189. * @returns true if the object is in frustum otherwise false
  7190. */
  7191. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /** @hidden */
  7193. _checkCollision(collider: Collider): boolean;
  7194. /**
  7195. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param point the point to check intersection with
  7198. * @returns if the point intersects
  7199. */
  7200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7201. /**
  7202. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param boundingInfo the bounding info to check intersection with
  7205. * @param precise if the intersection should be done using OBB
  7206. * @returns if the bounding info intersects
  7207. */
  7208. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7209. }
  7210. }
  7211. declare module "babylonjs/Maths/math.functions" {
  7212. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7213. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7214. /**
  7215. * Extracts minimum and maximum values from a list of indexed positions
  7216. * @param positions defines the positions to use
  7217. * @param indices defines the indices to the positions
  7218. * @param indexStart defines the start index
  7219. * @param indexCount defines the end index
  7220. * @param bias defines bias value to add to the result
  7221. * @return minimum and maximum values
  7222. */
  7223. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7224. minimum: Vector3;
  7225. maximum: Vector3;
  7226. };
  7227. /**
  7228. * Extracts minimum and maximum values from a list of positions
  7229. * @param positions defines the positions to use
  7230. * @param start defines the start index in the positions array
  7231. * @param count defines the number of positions to handle
  7232. * @param bias defines bias value to add to the result
  7233. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7234. * @return minimum and maximum values
  7235. */
  7236. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7237. minimum: Vector3;
  7238. maximum: Vector3;
  7239. };
  7240. }
  7241. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7242. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7243. /** @hidden */
  7244. export class WebGLDataBuffer extends DataBuffer {
  7245. private _buffer;
  7246. constructor(resource: WebGLBuffer);
  7247. get underlyingResource(): any;
  7248. }
  7249. }
  7250. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. import { Nullable } from "babylonjs/types";
  7253. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7254. /** @hidden */
  7255. export class WebGLPipelineContext implements IPipelineContext {
  7256. engine: ThinEngine;
  7257. program: Nullable<WebGLProgram>;
  7258. context?: WebGLRenderingContext;
  7259. vertexShader?: WebGLShader;
  7260. fragmentShader?: WebGLShader;
  7261. isParallelCompiled: boolean;
  7262. onCompiled?: () => void;
  7263. transformFeedback?: WebGLTransformFeedback | null;
  7264. vertexCompilationError: Nullable<string>;
  7265. fragmentCompilationError: Nullable<string>;
  7266. programLinkError: Nullable<string>;
  7267. programValidationError: Nullable<string>;
  7268. get isAsync(): boolean;
  7269. get isReady(): boolean;
  7270. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7271. _getVertexShaderCode(): string | null;
  7272. _getFragmentShaderCode(): string | null;
  7273. }
  7274. }
  7275. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7276. import { FloatArray, Nullable } from "babylonjs/types";
  7277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7278. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7279. module "babylonjs/Engines/thinEngine" {
  7280. interface ThinEngine {
  7281. /**
  7282. * Create an uniform buffer
  7283. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7284. * @param elements defines the content of the uniform buffer
  7285. * @returns the webGL uniform buffer
  7286. */
  7287. createUniformBuffer(elements: FloatArray): DataBuffer;
  7288. /**
  7289. * Create a dynamic uniform buffer
  7290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7291. * @param elements defines the content of the uniform buffer
  7292. * @returns the webGL uniform buffer
  7293. */
  7294. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7295. /**
  7296. * Update an existing uniform buffer
  7297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7298. * @param uniformBuffer defines the target uniform buffer
  7299. * @param elements defines the content to update
  7300. * @param offset defines the offset in the uniform buffer where update should start
  7301. * @param count defines the size of the data to update
  7302. */
  7303. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7304. /**
  7305. * Bind an uniform buffer to the current webGL context
  7306. * @param buffer defines the buffer to bind
  7307. */
  7308. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7309. /**
  7310. * Bind a buffer to the current webGL context at a given location
  7311. * @param buffer defines the buffer to bind
  7312. * @param location defines the index where to bind the buffer
  7313. */
  7314. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7315. /**
  7316. * Bind a specific block at a given index in a specific shader program
  7317. * @param pipelineContext defines the pipeline context to use
  7318. * @param blockName defines the block name
  7319. * @param index defines the index where to bind the block
  7320. */
  7321. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7322. }
  7323. }
  7324. }
  7325. declare module "babylonjs/Materials/uniformBuffer" {
  7326. import { Nullable, FloatArray } from "babylonjs/types";
  7327. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7328. import { Engine } from "babylonjs/Engines/engine";
  7329. import { Effect } from "babylonjs/Materials/effect";
  7330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7331. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7332. import { Color3 } from "babylonjs/Maths/math.color";
  7333. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7334. /**
  7335. * Uniform buffer objects.
  7336. *
  7337. * Handles blocks of uniform on the GPU.
  7338. *
  7339. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7340. *
  7341. * For more information, please refer to :
  7342. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7343. */
  7344. export class UniformBuffer {
  7345. private _engine;
  7346. private _buffer;
  7347. private _data;
  7348. private _bufferData;
  7349. private _dynamic?;
  7350. private _uniformLocations;
  7351. private _uniformSizes;
  7352. private _uniformLocationPointer;
  7353. private _needSync;
  7354. private _noUBO;
  7355. private _currentEffect;
  7356. /** @hidden */
  7357. _alreadyBound: boolean;
  7358. private static _MAX_UNIFORM_SIZE;
  7359. private static _tempBuffer;
  7360. /**
  7361. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7362. * This is dynamic to allow compat with webgl 1 and 2.
  7363. * You will need to pass the name of the uniform as well as the value.
  7364. */
  7365. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7366. /**
  7367. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7368. * This is dynamic to allow compat with webgl 1 and 2.
  7369. * You will need to pass the name of the uniform as well as the value.
  7370. */
  7371. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7372. /**
  7373. * Lambda to Update a single float in a uniform buffer.
  7374. * This is dynamic to allow compat with webgl 1 and 2.
  7375. * You will need to pass the name of the uniform as well as the value.
  7376. */
  7377. updateFloat: (name: string, x: number) => void;
  7378. /**
  7379. * Lambda to Update a vec2 of float in a uniform buffer.
  7380. * This is dynamic to allow compat with webgl 1 and 2.
  7381. * You will need to pass the name of the uniform as well as the value.
  7382. */
  7383. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7384. /**
  7385. * Lambda to Update a vec3 of float in a uniform buffer.
  7386. * This is dynamic to allow compat with webgl 1 and 2.
  7387. * You will need to pass the name of the uniform as well as the value.
  7388. */
  7389. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7390. /**
  7391. * Lambda to Update a vec4 of float in a uniform buffer.
  7392. * This is dynamic to allow compat with webgl 1 and 2.
  7393. * You will need to pass the name of the uniform as well as the value.
  7394. */
  7395. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7396. /**
  7397. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7398. * This is dynamic to allow compat with webgl 1 and 2.
  7399. * You will need to pass the name of the uniform as well as the value.
  7400. */
  7401. updateMatrix: (name: string, mat: Matrix) => void;
  7402. /**
  7403. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7404. * This is dynamic to allow compat with webgl 1 and 2.
  7405. * You will need to pass the name of the uniform as well as the value.
  7406. */
  7407. updateVector3: (name: string, vector: Vector3) => void;
  7408. /**
  7409. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7410. * This is dynamic to allow compat with webgl 1 and 2.
  7411. * You will need to pass the name of the uniform as well as the value.
  7412. */
  7413. updateVector4: (name: string, vector: Vector4) => void;
  7414. /**
  7415. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7416. * This is dynamic to allow compat with webgl 1 and 2.
  7417. * You will need to pass the name of the uniform as well as the value.
  7418. */
  7419. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7420. /**
  7421. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7422. * This is dynamic to allow compat with webgl 1 and 2.
  7423. * You will need to pass the name of the uniform as well as the value.
  7424. */
  7425. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7426. /**
  7427. * Instantiates a new Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. * @param engine Define the engine the buffer is associated with
  7436. * @param data Define the data contained in the buffer
  7437. * @param dynamic Define if the buffer is updatable
  7438. */
  7439. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7440. /**
  7441. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7442. * or just falling back on setUniformXXX calls.
  7443. */
  7444. get useUbo(): boolean;
  7445. /**
  7446. * Indicates if the WebGL underlying uniform buffer is in sync
  7447. * with the javascript cache data.
  7448. */
  7449. get isSync(): boolean;
  7450. /**
  7451. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7452. * Also, a dynamic UniformBuffer will disable cache verification and always
  7453. * update the underlying WebGL uniform buffer to the GPU.
  7454. * @returns if Dynamic, otherwise false
  7455. */
  7456. isDynamic(): boolean;
  7457. /**
  7458. * The data cache on JS side.
  7459. * @returns the underlying data as a float array
  7460. */
  7461. getData(): Float32Array;
  7462. /**
  7463. * The underlying WebGL Uniform buffer.
  7464. * @returns the webgl buffer
  7465. */
  7466. getBuffer(): Nullable<DataBuffer>;
  7467. /**
  7468. * std140 layout specifies how to align data within an UBO structure.
  7469. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7470. * for specs.
  7471. */
  7472. private _fillAlignment;
  7473. /**
  7474. * Adds an uniform in the buffer.
  7475. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7476. * for the layout to be correct !
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param size Data size, or data directly.
  7479. */
  7480. addUniform(name: string, size: number | number[]): void;
  7481. /**
  7482. * Adds a Matrix 4x4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param mat A 4x4 matrix.
  7485. */
  7486. addMatrix(name: string, mat: Matrix): void;
  7487. /**
  7488. * Adds a vec2 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. * @param x Define the x component value of the vec2
  7491. * @param y Define the y component value of the vec2
  7492. */
  7493. addFloat2(name: string, x: number, y: number): void;
  7494. /**
  7495. * Adds a vec3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. * @param x Define the x component value of the vec3
  7498. * @param y Define the y component value of the vec3
  7499. * @param z Define the z component value of the vec3
  7500. */
  7501. addFloat3(name: string, x: number, y: number, z: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param color Define the vec3 from a Color
  7506. */
  7507. addColor3(name: string, color: Color3): void;
  7508. /**
  7509. * Adds a vec4 to the uniform buffer.
  7510. * @param name Name of the uniform, as used in the uniform block in the shader.
  7511. * @param color Define the rgb components from a Color
  7512. * @param alpha Define the a component of the vec4
  7513. */
  7514. addColor4(name: string, color: Color3, alpha: number): void;
  7515. /**
  7516. * Adds a vec3 to the uniform buffer.
  7517. * @param name Name of the uniform, as used in the uniform block in the shader.
  7518. * @param vector Define the vec3 components from a Vector
  7519. */
  7520. addVector3(name: string, vector: Vector3): void;
  7521. /**
  7522. * Adds a Matrix 3x3 to the uniform buffer.
  7523. * @param name Name of the uniform, as used in the uniform block in the shader.
  7524. */
  7525. addMatrix3x3(name: string): void;
  7526. /**
  7527. * Adds a Matrix 2x2 to the uniform buffer.
  7528. * @param name Name of the uniform, as used in the uniform block in the shader.
  7529. */
  7530. addMatrix2x2(name: string): void;
  7531. /**
  7532. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7533. */
  7534. create(): void;
  7535. /** @hidden */
  7536. _rebuild(): void;
  7537. /**
  7538. * Updates the WebGL Uniform Buffer on the GPU.
  7539. * If the `dynamic` flag is set to true, no cache comparison is done.
  7540. * Otherwise, the buffer will be updated only if the cache differs.
  7541. */
  7542. update(): void;
  7543. /**
  7544. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7545. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7546. * @param data Define the flattened data
  7547. * @param size Define the size of the data.
  7548. */
  7549. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7550. private _valueCache;
  7551. private _cacheMatrix;
  7552. private _updateMatrix3x3ForUniform;
  7553. private _updateMatrix3x3ForEffect;
  7554. private _updateMatrix2x2ForEffect;
  7555. private _updateMatrix2x2ForUniform;
  7556. private _updateFloatForEffect;
  7557. private _updateFloatForUniform;
  7558. private _updateFloat2ForEffect;
  7559. private _updateFloat2ForUniform;
  7560. private _updateFloat3ForEffect;
  7561. private _updateFloat3ForUniform;
  7562. private _updateFloat4ForEffect;
  7563. private _updateFloat4ForUniform;
  7564. private _updateMatrixForEffect;
  7565. private _updateMatrixForUniform;
  7566. private _updateVector3ForEffect;
  7567. private _updateVector3ForUniform;
  7568. private _updateVector4ForEffect;
  7569. private _updateVector4ForUniform;
  7570. private _updateColor3ForEffect;
  7571. private _updateColor3ForUniform;
  7572. private _updateColor4ForEffect;
  7573. private _updateColor4ForUniform;
  7574. /**
  7575. * Sets a sampler uniform on the effect.
  7576. * @param name Define the name of the sampler.
  7577. * @param texture Define the texture to set in the sampler
  7578. */
  7579. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7580. /**
  7581. * Directly updates the value of the uniform in the cache AND on the GPU.
  7582. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7583. * @param data Define the flattened data
  7584. */
  7585. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7586. /**
  7587. * Binds this uniform buffer to an effect.
  7588. * @param effect Define the effect to bind the buffer to
  7589. * @param name Name of the uniform block in the shader.
  7590. */
  7591. bindToEffect(effect: Effect, name: string): void;
  7592. /**
  7593. * Disposes the uniform buffer.
  7594. */
  7595. dispose(): void;
  7596. }
  7597. }
  7598. declare module "babylonjs/Misc/iInspectable" {
  7599. /**
  7600. * Enum that determines the text-wrapping mode to use.
  7601. */
  7602. export enum InspectableType {
  7603. /**
  7604. * Checkbox for booleans
  7605. */
  7606. Checkbox = 0,
  7607. /**
  7608. * Sliders for numbers
  7609. */
  7610. Slider = 1,
  7611. /**
  7612. * Vector3
  7613. */
  7614. Vector3 = 2,
  7615. /**
  7616. * Quaternions
  7617. */
  7618. Quaternion = 3,
  7619. /**
  7620. * Color3
  7621. */
  7622. Color3 = 4,
  7623. /**
  7624. * String
  7625. */
  7626. String = 5
  7627. }
  7628. /**
  7629. * Interface used to define custom inspectable properties.
  7630. * This interface is used by the inspector to display custom property grids
  7631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7632. */
  7633. export interface IInspectable {
  7634. /**
  7635. * Gets the label to display
  7636. */
  7637. label: string;
  7638. /**
  7639. * Gets the name of the property to edit
  7640. */
  7641. propertyName: string;
  7642. /**
  7643. * Gets the type of the editor to use
  7644. */
  7645. type: InspectableType;
  7646. /**
  7647. * Gets the minimum value of the property when using in "slider" mode
  7648. */
  7649. min?: number;
  7650. /**
  7651. * Gets the maximum value of the property when using in "slider" mode
  7652. */
  7653. max?: number;
  7654. /**
  7655. * Gets the setp to use when using in "slider" mode
  7656. */
  7657. step?: number;
  7658. }
  7659. }
  7660. declare module "babylonjs/Misc/timingTools" {
  7661. /**
  7662. * Class used to provide helper for timing
  7663. */
  7664. export class TimingTools {
  7665. /**
  7666. * Polyfill for setImmediate
  7667. * @param action defines the action to execute after the current execution block
  7668. */
  7669. static SetImmediate(action: () => void): void;
  7670. }
  7671. }
  7672. declare module "babylonjs/Misc/instantiationTools" {
  7673. /**
  7674. * Class used to enable instatition of objects by class name
  7675. */
  7676. export class InstantiationTools {
  7677. /**
  7678. * Use this object to register external classes like custom textures or material
  7679. * to allow the laoders to instantiate them
  7680. */
  7681. static RegisteredExternalClasses: {
  7682. [key: string]: Object;
  7683. };
  7684. /**
  7685. * Tries to instantiate a new object from a given class name
  7686. * @param className defines the class name to instantiate
  7687. * @returns the new object or null if the system was not able to do the instantiation
  7688. */
  7689. static Instantiate(className: string): any;
  7690. }
  7691. }
  7692. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7693. /**
  7694. * Define options used to create a depth texture
  7695. */
  7696. export class DepthTextureCreationOptions {
  7697. /** Specifies whether or not a stencil should be allocated in the texture */
  7698. generateStencil?: boolean;
  7699. /** Specifies whether or not bilinear filtering is enable on the texture */
  7700. bilinearFiltering?: boolean;
  7701. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7702. comparisonFunction?: number;
  7703. /** Specifies if the created texture is a cube texture */
  7704. isCube?: boolean;
  7705. }
  7706. }
  7707. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7709. import { Nullable } from "babylonjs/types";
  7710. import { Scene } from "babylonjs/scene";
  7711. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7712. module "babylonjs/Engines/thinEngine" {
  7713. interface ThinEngine {
  7714. /**
  7715. * Creates a depth stencil cube texture.
  7716. * This is only available in WebGL 2.
  7717. * @param size The size of face edge in the cube texture.
  7718. * @param options The options defining the cube texture.
  7719. * @returns The cube texture
  7720. */
  7721. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7722. /**
  7723. * Creates a cube texture
  7724. * @param rootUrl defines the url where the files to load is located
  7725. * @param scene defines the current scene
  7726. * @param files defines the list of files to load (1 per face)
  7727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7728. * @param onLoad defines an optional callback raised when the texture is loaded
  7729. * @param onError defines an optional callback raised if there is an issue to load the texture
  7730. * @param format defines the format of the data
  7731. * @param forcedExtension defines the extension to use to pick the right loader
  7732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7736. * @returns the cube texture as an InternalTexture
  7737. */
  7738. 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>): InternalTexture;
  7739. /**
  7740. * Creates a cube texture
  7741. * @param rootUrl defines the url where the files to load is located
  7742. * @param scene defines the current scene
  7743. * @param files defines the list of files to load (1 per face)
  7744. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7745. * @param onLoad defines an optional callback raised when the texture is loaded
  7746. * @param onError defines an optional callback raised if there is an issue to load the texture
  7747. * @param format defines the format of the data
  7748. * @param forcedExtension defines the extension to use to pick the right loader
  7749. * @returns the cube texture as an InternalTexture
  7750. */
  7751. 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;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @returns the cube texture as an InternalTexture
  7766. */
  7767. 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;
  7768. /** @hidden */
  7769. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7770. /** @hidden */
  7771. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7772. /** @hidden */
  7773. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7774. /** @hidden */
  7775. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7776. /**
  7777. * @hidden
  7778. */
  7779. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7780. }
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7784. import { Nullable } from "babylonjs/types";
  7785. import { Scene } from "babylonjs/scene";
  7786. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7788. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7789. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7790. import { Observable } from "babylonjs/Misc/observable";
  7791. /**
  7792. * Class for creating a cube texture
  7793. */
  7794. export class CubeTexture extends BaseTexture {
  7795. private _delayedOnLoad;
  7796. /**
  7797. * Observable triggered once the texture has been loaded.
  7798. */
  7799. onLoadObservable: Observable<CubeTexture>;
  7800. /**
  7801. * The url of the texture
  7802. */
  7803. url: string;
  7804. /**
  7805. * Gets or sets the center of the bounding box associated with the cube texture.
  7806. * It must define where the camera used to render the texture was set
  7807. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7808. */
  7809. boundingBoxPosition: Vector3;
  7810. private _boundingBoxSize;
  7811. /**
  7812. * Gets or sets the size of the bounding box associated with the cube texture
  7813. * When defined, the cubemap will switch to local mode
  7814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7815. * @example https://www.babylonjs-playground.com/#RNASML
  7816. */
  7817. set boundingBoxSize(value: Vector3);
  7818. /**
  7819. * Returns the bounding box size
  7820. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7821. */
  7822. get boundingBoxSize(): Vector3;
  7823. protected _rotationY: number;
  7824. /**
  7825. * Sets texture matrix rotation angle around Y axis in radians.
  7826. */
  7827. set rotationY(value: number);
  7828. /**
  7829. * Gets texture matrix rotation angle around Y axis radians.
  7830. */
  7831. get rotationY(): number;
  7832. /**
  7833. * Are mip maps generated for this texture or not.
  7834. */
  7835. get noMipmap(): boolean;
  7836. private _noMipmap;
  7837. private _files;
  7838. protected _forcedExtension: Nullable<string>;
  7839. private _extensions;
  7840. private _textureMatrix;
  7841. private _format;
  7842. private _createPolynomials;
  7843. /** @hidden */
  7844. _prefiltered: boolean;
  7845. /**
  7846. * Creates a cube texture from an array of image urls
  7847. * @param files defines an array of image urls
  7848. * @param scene defines the hosting scene
  7849. * @param noMipmap specifies if mip maps are not used
  7850. * @returns a cube texture
  7851. */
  7852. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7853. /**
  7854. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7855. * @param url defines the url of the prefiltered texture
  7856. * @param scene defines the scene the texture is attached to
  7857. * @param forcedExtension defines the extension of the file if different from the url
  7858. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7859. * @return the prefiltered texture
  7860. */
  7861. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7862. /**
  7863. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7864. * as prefiltered data.
  7865. * @param rootUrl defines the url of the texture or the root name of the six images
  7866. * @param null defines the scene or engine the texture is attached to
  7867. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7868. * @param noMipmap defines if mipmaps should be created or not
  7869. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7870. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7871. * @param onError defines a callback triggered in case of error during load
  7872. * @param format defines the internal format to use for the texture once loaded
  7873. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7874. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7875. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7876. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7877. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7878. * @return the cube texture
  7879. */
  7880. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7881. /**
  7882. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7883. */
  7884. get isPrefiltered(): boolean;
  7885. /**
  7886. * Get the current class name of the texture useful for serialization or dynamic coding.
  7887. * @returns "CubeTexture"
  7888. */
  7889. getClassName(): string;
  7890. /**
  7891. * Update the url (and optional buffer) of this texture if url was null during construction.
  7892. * @param url the url of the texture
  7893. * @param forcedExtension defines the extension to use
  7894. * @param onLoad callback called when the texture is loaded (defaults to null)
  7895. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7896. */
  7897. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7898. /**
  7899. * Delays loading of the cube texture
  7900. * @param forcedExtension defines the extension to use
  7901. */
  7902. delayLoad(forcedExtension?: string): void;
  7903. /**
  7904. * Returns the reflection texture matrix
  7905. * @returns the reflection texture matrix
  7906. */
  7907. getReflectionTextureMatrix(): Matrix;
  7908. /**
  7909. * Sets the reflection texture matrix
  7910. * @param value Reflection texture matrix
  7911. */
  7912. setReflectionTextureMatrix(value: Matrix): void;
  7913. /**
  7914. * Parses text to create a cube texture
  7915. * @param parsedTexture define the serialized text to read from
  7916. * @param scene defines the hosting scene
  7917. * @param rootUrl defines the root url of the cube texture
  7918. * @returns a cube texture
  7919. */
  7920. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7921. /**
  7922. * Makes a clone, or deep copy, of the cube texture
  7923. * @returns a new cube texture
  7924. */
  7925. clone(): CubeTexture;
  7926. }
  7927. }
  7928. declare module "babylonjs/Materials/materialDefines" {
  7929. /**
  7930. * Manages the defines for the Material
  7931. */
  7932. export class MaterialDefines {
  7933. /** @hidden */
  7934. protected _keys: string[];
  7935. private _isDirty;
  7936. /** @hidden */
  7937. _renderId: number;
  7938. /** @hidden */
  7939. _areLightsDirty: boolean;
  7940. /** @hidden */
  7941. _areLightsDisposed: boolean;
  7942. /** @hidden */
  7943. _areAttributesDirty: boolean;
  7944. /** @hidden */
  7945. _areTexturesDirty: boolean;
  7946. /** @hidden */
  7947. _areFresnelDirty: boolean;
  7948. /** @hidden */
  7949. _areMiscDirty: boolean;
  7950. /** @hidden */
  7951. _areImageProcessingDirty: boolean;
  7952. /** @hidden */
  7953. _normals: boolean;
  7954. /** @hidden */
  7955. _uvs: boolean;
  7956. /** @hidden */
  7957. _needNormals: boolean;
  7958. /** @hidden */
  7959. _needUVs: boolean;
  7960. [id: string]: any;
  7961. /**
  7962. * Specifies if the material needs to be re-calculated
  7963. */
  7964. get isDirty(): boolean;
  7965. /**
  7966. * Marks the material to indicate that it has been re-calculated
  7967. */
  7968. markAsProcessed(): void;
  7969. /**
  7970. * Marks the material to indicate that it needs to be re-calculated
  7971. */
  7972. markAsUnprocessed(): void;
  7973. /**
  7974. * Marks the material to indicate all of its defines need to be re-calculated
  7975. */
  7976. markAllAsDirty(): void;
  7977. /**
  7978. * Marks the material to indicate that image processing needs to be re-calculated
  7979. */
  7980. markAsImageProcessingDirty(): void;
  7981. /**
  7982. * Marks the material to indicate the lights need to be re-calculated
  7983. * @param disposed Defines whether the light is dirty due to dispose or not
  7984. */
  7985. markAsLightDirty(disposed?: boolean): void;
  7986. /**
  7987. * Marks the attribute state as changed
  7988. */
  7989. markAsAttributesDirty(): void;
  7990. /**
  7991. * Marks the texture state as changed
  7992. */
  7993. markAsTexturesDirty(): void;
  7994. /**
  7995. * Marks the fresnel state as changed
  7996. */
  7997. markAsFresnelDirty(): void;
  7998. /**
  7999. * Marks the misc state as changed
  8000. */
  8001. markAsMiscDirty(): void;
  8002. /**
  8003. * Rebuilds the material defines
  8004. */
  8005. rebuild(): void;
  8006. /**
  8007. * Specifies if two material defines are equal
  8008. * @param other - A material define instance to compare to
  8009. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8010. */
  8011. isEqual(other: MaterialDefines): boolean;
  8012. /**
  8013. * Clones this instance's defines to another instance
  8014. * @param other - material defines to clone values to
  8015. */
  8016. cloneTo(other: MaterialDefines): void;
  8017. /**
  8018. * Resets the material define values
  8019. */
  8020. reset(): void;
  8021. /**
  8022. * Converts the material define values to a string
  8023. * @returns - String of material define information
  8024. */
  8025. toString(): string;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/colorCurves" {
  8029. import { Effect } from "babylonjs/Materials/effect";
  8030. /**
  8031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8033. * 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;
  8034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8035. */
  8036. export class ColorCurves {
  8037. private _dirty;
  8038. private _tempColor;
  8039. private _globalCurve;
  8040. private _highlightsCurve;
  8041. private _midtonesCurve;
  8042. private _shadowsCurve;
  8043. private _positiveCurve;
  8044. private _negativeCurve;
  8045. private _globalHue;
  8046. private _globalDensity;
  8047. private _globalSaturation;
  8048. private _globalExposure;
  8049. /**
  8050. * Gets the global Hue value.
  8051. * 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).
  8052. */
  8053. get globalHue(): number;
  8054. /**
  8055. * Sets the global Hue value.
  8056. * 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).
  8057. */
  8058. set globalHue(value: number);
  8059. /**
  8060. * Gets the global Density value.
  8061. * 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.
  8062. * Values less than zero provide a filter of opposite hue.
  8063. */
  8064. get globalDensity(): number;
  8065. /**
  8066. * Sets the global Density value.
  8067. * 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.
  8068. * Values less than zero provide a filter of opposite hue.
  8069. */
  8070. set globalDensity(value: number);
  8071. /**
  8072. * Gets the global Saturation value.
  8073. * 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.
  8074. */
  8075. get globalSaturation(): number;
  8076. /**
  8077. * Sets the global Saturation value.
  8078. * 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.
  8079. */
  8080. set globalSaturation(value: number);
  8081. /**
  8082. * Gets the global Exposure value.
  8083. * 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.
  8084. */
  8085. get globalExposure(): number;
  8086. /**
  8087. * Sets the global Exposure value.
  8088. * 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.
  8089. */
  8090. set globalExposure(value: number);
  8091. private _highlightsHue;
  8092. private _highlightsDensity;
  8093. private _highlightsSaturation;
  8094. private _highlightsExposure;
  8095. /**
  8096. * Gets the highlights Hue value.
  8097. * 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).
  8098. */
  8099. get highlightsHue(): number;
  8100. /**
  8101. * Sets the highlights Hue value.
  8102. * 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).
  8103. */
  8104. set highlightsHue(value: number);
  8105. /**
  8106. * Gets the highlights Density value.
  8107. * 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.
  8108. * Values less than zero provide a filter of opposite hue.
  8109. */
  8110. get highlightsDensity(): number;
  8111. /**
  8112. * Sets the highlights Density value.
  8113. * 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.
  8114. * Values less than zero provide a filter of opposite hue.
  8115. */
  8116. set highlightsDensity(value: number);
  8117. /**
  8118. * Gets the highlights Saturation value.
  8119. * 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.
  8120. */
  8121. get highlightsSaturation(): number;
  8122. /**
  8123. * Sets the highlights Saturation value.
  8124. * 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.
  8125. */
  8126. set highlightsSaturation(value: number);
  8127. /**
  8128. * Gets the highlights Exposure value.
  8129. * 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.
  8130. */
  8131. get highlightsExposure(): number;
  8132. /**
  8133. * Sets the highlights Exposure value.
  8134. * 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.
  8135. */
  8136. set highlightsExposure(value: number);
  8137. private _midtonesHue;
  8138. private _midtonesDensity;
  8139. private _midtonesSaturation;
  8140. private _midtonesExposure;
  8141. /**
  8142. * Gets the midtones Hue value.
  8143. * 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).
  8144. */
  8145. get midtonesHue(): number;
  8146. /**
  8147. * Sets the midtones Hue value.
  8148. * 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).
  8149. */
  8150. set midtonesHue(value: number);
  8151. /**
  8152. * Gets the midtones Density value.
  8153. * 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.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. get midtonesDensity(): number;
  8157. /**
  8158. * Sets the midtones Density value.
  8159. * 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.
  8160. * Values less than zero provide a filter of opposite hue.
  8161. */
  8162. set midtonesDensity(value: number);
  8163. /**
  8164. * Gets the midtones Saturation value.
  8165. * 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.
  8166. */
  8167. get midtonesSaturation(): number;
  8168. /**
  8169. * Sets the midtones Saturation value.
  8170. * 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.
  8171. */
  8172. set midtonesSaturation(value: number);
  8173. /**
  8174. * Gets the midtones Exposure value.
  8175. * 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.
  8176. */
  8177. get midtonesExposure(): number;
  8178. /**
  8179. * Sets the midtones Exposure value.
  8180. * 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.
  8181. */
  8182. set midtonesExposure(value: number);
  8183. private _shadowsHue;
  8184. private _shadowsDensity;
  8185. private _shadowsSaturation;
  8186. private _shadowsExposure;
  8187. /**
  8188. * Gets the shadows Hue value.
  8189. * 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).
  8190. */
  8191. get shadowsHue(): number;
  8192. /**
  8193. * Sets the shadows Hue value.
  8194. * 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).
  8195. */
  8196. set shadowsHue(value: number);
  8197. /**
  8198. * Gets the shadows Density value.
  8199. * 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.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. get shadowsDensity(): number;
  8203. /**
  8204. * Sets the shadows Density value.
  8205. * 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.
  8206. * Values less than zero provide a filter of opposite hue.
  8207. */
  8208. set shadowsDensity(value: number);
  8209. /**
  8210. * Gets the shadows Saturation value.
  8211. * 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.
  8212. */
  8213. get shadowsSaturation(): number;
  8214. /**
  8215. * Sets the shadows Saturation value.
  8216. * 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.
  8217. */
  8218. set shadowsSaturation(value: number);
  8219. /**
  8220. * Gets the shadows Exposure value.
  8221. * 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.
  8222. */
  8223. get shadowsExposure(): number;
  8224. /**
  8225. * Sets the shadows Exposure value.
  8226. * 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.
  8227. */
  8228. set shadowsExposure(value: number);
  8229. /**
  8230. * Returns the class name
  8231. * @returns The class name
  8232. */
  8233. getClassName(): string;
  8234. /**
  8235. * Binds the color curves to the shader.
  8236. * @param colorCurves The color curve to bind
  8237. * @param effect The effect to bind to
  8238. * @param positiveUniform The positive uniform shader parameter
  8239. * @param neutralUniform The neutral uniform shader parameter
  8240. * @param negativeUniform The negative uniform shader parameter
  8241. */
  8242. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8243. /**
  8244. * Prepare the list of uniforms associated with the ColorCurves effects.
  8245. * @param uniformsList The list of uniforms used in the effect
  8246. */
  8247. static PrepareUniforms(uniformsList: string[]): void;
  8248. /**
  8249. * Returns color grading data based on a hue, density, saturation and exposure value.
  8250. * @param filterHue The hue of the color filter.
  8251. * @param filterDensity The density of the color filter.
  8252. * @param saturation The saturation.
  8253. * @param exposure The exposure.
  8254. * @param result The result data container.
  8255. */
  8256. private getColorGradingDataToRef;
  8257. /**
  8258. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8259. * @param value The input slider value in range [-100,100].
  8260. * @returns Adjusted value.
  8261. */
  8262. private static applyColorGradingSliderNonlinear;
  8263. /**
  8264. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8265. * @param hue The hue (H) input.
  8266. * @param saturation The saturation (S) input.
  8267. * @param brightness The brightness (B) input.
  8268. * @result An RGBA color represented as Vector4.
  8269. */
  8270. private static fromHSBToRef;
  8271. /**
  8272. * Returns a value clamped between min and max
  8273. * @param value The value to clamp
  8274. * @param min The minimum of value
  8275. * @param max The maximum of value
  8276. * @returns The clamped value.
  8277. */
  8278. private static clamp;
  8279. /**
  8280. * Clones the current color curve instance.
  8281. * @return The cloned curves
  8282. */
  8283. clone(): ColorCurves;
  8284. /**
  8285. * Serializes the current color curve instance to a json representation.
  8286. * @return a JSON representation
  8287. */
  8288. serialize(): any;
  8289. /**
  8290. * Parses the color curve from a json representation.
  8291. * @param source the JSON source to parse
  8292. * @return The parsed curves
  8293. */
  8294. static Parse(source: any): ColorCurves;
  8295. }
  8296. }
  8297. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8298. import { Observable } from "babylonjs/Misc/observable";
  8299. import { Nullable } from "babylonjs/types";
  8300. import { Color4 } from "babylonjs/Maths/math.color";
  8301. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8302. import { Effect } from "babylonjs/Materials/effect";
  8303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8304. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8305. /**
  8306. * Interface to follow in your material defines to integrate easily the
  8307. * Image proccessing functions.
  8308. * @hidden
  8309. */
  8310. export interface IImageProcessingConfigurationDefines {
  8311. IMAGEPROCESSING: boolean;
  8312. VIGNETTE: boolean;
  8313. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8314. VIGNETTEBLENDMODEOPAQUE: boolean;
  8315. TONEMAPPING: boolean;
  8316. TONEMAPPING_ACES: boolean;
  8317. CONTRAST: boolean;
  8318. EXPOSURE: boolean;
  8319. COLORCURVES: boolean;
  8320. COLORGRADING: boolean;
  8321. COLORGRADING3D: boolean;
  8322. SAMPLER3DGREENDEPTH: boolean;
  8323. SAMPLER3DBGRMAP: boolean;
  8324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8325. }
  8326. /**
  8327. * @hidden
  8328. */
  8329. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8330. IMAGEPROCESSING: boolean;
  8331. VIGNETTE: boolean;
  8332. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8333. VIGNETTEBLENDMODEOPAQUE: boolean;
  8334. TONEMAPPING: boolean;
  8335. TONEMAPPING_ACES: boolean;
  8336. CONTRAST: boolean;
  8337. COLORCURVES: boolean;
  8338. COLORGRADING: boolean;
  8339. COLORGRADING3D: boolean;
  8340. SAMPLER3DGREENDEPTH: boolean;
  8341. SAMPLER3DBGRMAP: boolean;
  8342. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8343. EXPOSURE: boolean;
  8344. constructor();
  8345. }
  8346. /**
  8347. * This groups together the common properties used for image processing either in direct forward pass
  8348. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8349. * or not.
  8350. */
  8351. export class ImageProcessingConfiguration {
  8352. /**
  8353. * Default tone mapping applied in BabylonJS.
  8354. */
  8355. static readonly TONEMAPPING_STANDARD: number;
  8356. /**
  8357. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8358. * to other engines rendering to increase portability.
  8359. */
  8360. static readonly TONEMAPPING_ACES: number;
  8361. /**
  8362. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8363. */
  8364. colorCurves: Nullable<ColorCurves>;
  8365. private _colorCurvesEnabled;
  8366. /**
  8367. * Gets wether the color curves effect is enabled.
  8368. */
  8369. get colorCurvesEnabled(): boolean;
  8370. /**
  8371. * Sets wether the color curves effect is enabled.
  8372. */
  8373. set colorCurvesEnabled(value: boolean);
  8374. private _colorGradingTexture;
  8375. /**
  8376. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8377. */
  8378. get colorGradingTexture(): Nullable<BaseTexture>;
  8379. /**
  8380. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8381. */
  8382. set colorGradingTexture(value: Nullable<BaseTexture>);
  8383. private _colorGradingEnabled;
  8384. /**
  8385. * Gets wether the color grading effect is enabled.
  8386. */
  8387. get colorGradingEnabled(): boolean;
  8388. /**
  8389. * Sets wether the color grading effect is enabled.
  8390. */
  8391. set colorGradingEnabled(value: boolean);
  8392. private _colorGradingWithGreenDepth;
  8393. /**
  8394. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8395. */
  8396. get colorGradingWithGreenDepth(): boolean;
  8397. /**
  8398. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8399. */
  8400. set colorGradingWithGreenDepth(value: boolean);
  8401. private _colorGradingBGR;
  8402. /**
  8403. * Gets wether the color grading texture contains BGR values.
  8404. */
  8405. get colorGradingBGR(): boolean;
  8406. /**
  8407. * Sets wether the color grading texture contains BGR values.
  8408. */
  8409. set colorGradingBGR(value: boolean);
  8410. /** @hidden */
  8411. _exposure: number;
  8412. /**
  8413. * Gets the Exposure used in the effect.
  8414. */
  8415. get exposure(): number;
  8416. /**
  8417. * Sets the Exposure used in the effect.
  8418. */
  8419. set exposure(value: number);
  8420. private _toneMappingEnabled;
  8421. /**
  8422. * Gets wether the tone mapping effect is enabled.
  8423. */
  8424. get toneMappingEnabled(): boolean;
  8425. /**
  8426. * Sets wether the tone mapping effect is enabled.
  8427. */
  8428. set toneMappingEnabled(value: boolean);
  8429. private _toneMappingType;
  8430. /**
  8431. * Gets the type of tone mapping effect.
  8432. */
  8433. get toneMappingType(): number;
  8434. /**
  8435. * Sets the type of tone mapping effect used in BabylonJS.
  8436. */
  8437. set toneMappingType(value: number);
  8438. protected _contrast: number;
  8439. /**
  8440. * Gets the contrast used in the effect.
  8441. */
  8442. get contrast(): number;
  8443. /**
  8444. * Sets the contrast used in the effect.
  8445. */
  8446. set contrast(value: number);
  8447. /**
  8448. * Vignette stretch size.
  8449. */
  8450. vignetteStretch: number;
  8451. /**
  8452. * Vignette centre X Offset.
  8453. */
  8454. vignetteCentreX: number;
  8455. /**
  8456. * Vignette centre Y Offset.
  8457. */
  8458. vignetteCentreY: number;
  8459. /**
  8460. * Vignette weight or intensity of the vignette effect.
  8461. */
  8462. vignetteWeight: number;
  8463. /**
  8464. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8465. * if vignetteEnabled is set to true.
  8466. */
  8467. vignetteColor: Color4;
  8468. /**
  8469. * Camera field of view used by the Vignette effect.
  8470. */
  8471. vignetteCameraFov: number;
  8472. private _vignetteBlendMode;
  8473. /**
  8474. * Gets the vignette blend mode allowing different kind of effect.
  8475. */
  8476. get vignetteBlendMode(): number;
  8477. /**
  8478. * Sets the vignette blend mode allowing different kind of effect.
  8479. */
  8480. set vignetteBlendMode(value: number);
  8481. private _vignetteEnabled;
  8482. /**
  8483. * Gets wether the vignette effect is enabled.
  8484. */
  8485. get vignetteEnabled(): boolean;
  8486. /**
  8487. * Sets wether the vignette effect is enabled.
  8488. */
  8489. set vignetteEnabled(value: boolean);
  8490. private _applyByPostProcess;
  8491. /**
  8492. * Gets wether the image processing is applied through a post process or not.
  8493. */
  8494. get applyByPostProcess(): boolean;
  8495. /**
  8496. * Sets wether the image processing is applied through a post process or not.
  8497. */
  8498. set applyByPostProcess(value: boolean);
  8499. private _isEnabled;
  8500. /**
  8501. * Gets wether the image processing is enabled or not.
  8502. */
  8503. get isEnabled(): boolean;
  8504. /**
  8505. * Sets wether the image processing is enabled or not.
  8506. */
  8507. set isEnabled(value: boolean);
  8508. /**
  8509. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8510. */
  8511. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8512. /**
  8513. * Method called each time the image processing information changes requires to recompile the effect.
  8514. */
  8515. protected _updateParameters(): void;
  8516. /**
  8517. * Gets the current class name.
  8518. * @return "ImageProcessingConfiguration"
  8519. */
  8520. getClassName(): string;
  8521. /**
  8522. * Prepare the list of uniforms associated with the Image Processing effects.
  8523. * @param uniforms The list of uniforms used in the effect
  8524. * @param defines the list of defines currently in use
  8525. */
  8526. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8527. /**
  8528. * Prepare the list of samplers associated with the Image Processing effects.
  8529. * @param samplersList The list of uniforms used in the effect
  8530. * @param defines the list of defines currently in use
  8531. */
  8532. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8533. /**
  8534. * Prepare the list of defines associated to the shader.
  8535. * @param defines the list of defines to complete
  8536. * @param forPostProcess Define if we are currently in post process mode or not
  8537. */
  8538. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8539. /**
  8540. * Returns true if all the image processing information are ready.
  8541. * @returns True if ready, otherwise, false
  8542. */
  8543. isReady(): boolean;
  8544. /**
  8545. * Binds the image processing to the shader.
  8546. * @param effect The effect to bind to
  8547. * @param overrideAspectRatio Override the aspect ratio of the effect
  8548. */
  8549. bind(effect: Effect, overrideAspectRatio?: number): void;
  8550. /**
  8551. * Clones the current image processing instance.
  8552. * @return The cloned image processing
  8553. */
  8554. clone(): ImageProcessingConfiguration;
  8555. /**
  8556. * Serializes the current image processing instance to a json representation.
  8557. * @return a JSON representation
  8558. */
  8559. serialize(): any;
  8560. /**
  8561. * Parses the image processing from a json representation.
  8562. * @param source the JSON source to parse
  8563. * @return The parsed image processing
  8564. */
  8565. static Parse(source: any): ImageProcessingConfiguration;
  8566. private static _VIGNETTEMODE_MULTIPLY;
  8567. private static _VIGNETTEMODE_OPAQUE;
  8568. /**
  8569. * Used to apply the vignette as a mix with the pixel color.
  8570. */
  8571. static get VIGNETTEMODE_MULTIPLY(): number;
  8572. /**
  8573. * Used to apply the vignette as a replacement of the pixel color.
  8574. */
  8575. static get VIGNETTEMODE_OPAQUE(): number;
  8576. }
  8577. }
  8578. declare module "babylonjs/Shaders/postprocess.vertex" {
  8579. /** @hidden */
  8580. export var postprocessVertexShader: {
  8581. name: string;
  8582. shader: string;
  8583. };
  8584. }
  8585. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8587. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8588. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8589. module "babylonjs/Engines/thinEngine" {
  8590. interface ThinEngine {
  8591. /**
  8592. * Creates a new render target texture
  8593. * @param size defines the size of the texture
  8594. * @param options defines the options used to create the texture
  8595. * @returns a new render target texture stored in an InternalTexture
  8596. */
  8597. createRenderTargetTexture(size: number | {
  8598. width: number;
  8599. height: number;
  8600. layers?: number;
  8601. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8602. /**
  8603. * Creates a depth stencil texture.
  8604. * This is only available in WebGL 2 or with the depth texture extension available.
  8605. * @param size The size of face edge in the texture.
  8606. * @param options The options defining the texture.
  8607. * @returns The texture
  8608. */
  8609. createDepthStencilTexture(size: number | {
  8610. width: number;
  8611. height: number;
  8612. layers?: number;
  8613. }, options: DepthTextureCreationOptions): InternalTexture;
  8614. /** @hidden */
  8615. _createDepthStencilTexture(size: number | {
  8616. width: number;
  8617. height: number;
  8618. layers?: number;
  8619. }, options: DepthTextureCreationOptions): InternalTexture;
  8620. }
  8621. }
  8622. }
  8623. declare module "babylonjs/Maths/math.axis" {
  8624. import { Vector3 } from "babylonjs/Maths/math.vector";
  8625. /** Defines supported spaces */
  8626. export enum Space {
  8627. /** Local (object) space */
  8628. LOCAL = 0,
  8629. /** World space */
  8630. WORLD = 1,
  8631. /** Bone space */
  8632. BONE = 2
  8633. }
  8634. /** Defines the 3 main axes */
  8635. export class Axis {
  8636. /** X axis */
  8637. static X: Vector3;
  8638. /** Y axis */
  8639. static Y: Vector3;
  8640. /** Z axis */
  8641. static Z: Vector3;
  8642. }
  8643. }
  8644. declare module "babylonjs/Cameras/targetCamera" {
  8645. import { Nullable } from "babylonjs/types";
  8646. import { Camera } from "babylonjs/Cameras/camera";
  8647. import { Scene } from "babylonjs/scene";
  8648. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8649. /**
  8650. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8651. * This is the base of the follow, arc rotate cameras and Free camera
  8652. * @see http://doc.babylonjs.com/features/cameras
  8653. */
  8654. export class TargetCamera extends Camera {
  8655. private static _RigCamTransformMatrix;
  8656. private static _TargetTransformMatrix;
  8657. private static _TargetFocalPoint;
  8658. /**
  8659. * Define the current direction the camera is moving to
  8660. */
  8661. cameraDirection: Vector3;
  8662. /**
  8663. * Define the current rotation the camera is rotating to
  8664. */
  8665. cameraRotation: Vector2;
  8666. /**
  8667. * When set, the up vector of the camera will be updated by the rotation of the camera
  8668. */
  8669. updateUpVectorFromRotation: boolean;
  8670. private _tmpQuaternion;
  8671. /**
  8672. * Define the current rotation of the camera
  8673. */
  8674. rotation: Vector3;
  8675. /**
  8676. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8677. */
  8678. rotationQuaternion: Quaternion;
  8679. /**
  8680. * Define the current speed of the camera
  8681. */
  8682. speed: number;
  8683. /**
  8684. * Add constraint to the camera to prevent it to move freely in all directions and
  8685. * around all axis.
  8686. */
  8687. noRotationConstraint: boolean;
  8688. /**
  8689. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8690. * panning
  8691. */
  8692. invertRotation: boolean;
  8693. /**
  8694. * Speed multiplier for inverse camera panning
  8695. */
  8696. inverseRotationSpeed: number;
  8697. /**
  8698. * Define the current target of the camera as an object or a position.
  8699. */
  8700. lockedTarget: any;
  8701. /** @hidden */
  8702. _currentTarget: Vector3;
  8703. /** @hidden */
  8704. _initialFocalDistance: number;
  8705. /** @hidden */
  8706. _viewMatrix: Matrix;
  8707. /** @hidden */
  8708. _camMatrix: Matrix;
  8709. /** @hidden */
  8710. _cameraTransformMatrix: Matrix;
  8711. /** @hidden */
  8712. _cameraRotationMatrix: Matrix;
  8713. /** @hidden */
  8714. _referencePoint: Vector3;
  8715. /** @hidden */
  8716. _transformedReferencePoint: Vector3;
  8717. protected _globalCurrentTarget: Vector3;
  8718. protected _globalCurrentUpVector: Vector3;
  8719. /** @hidden */
  8720. _reset: () => void;
  8721. private _defaultUp;
  8722. /**
  8723. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8724. * This is the base of the follow, arc rotate cameras and Free camera
  8725. * @see http://doc.babylonjs.com/features/cameras
  8726. * @param name Defines the name of the camera in the scene
  8727. * @param position Defines the start position of the camera in the scene
  8728. * @param scene Defines the scene the camera belongs to
  8729. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8730. */
  8731. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8732. /**
  8733. * Gets the position in front of the camera at a given distance.
  8734. * @param distance The distance from the camera we want the position to be
  8735. * @returns the position
  8736. */
  8737. getFrontPosition(distance: number): Vector3;
  8738. /** @hidden */
  8739. _getLockedTargetPosition(): Nullable<Vector3>;
  8740. private _storedPosition;
  8741. private _storedRotation;
  8742. private _storedRotationQuaternion;
  8743. /**
  8744. * Store current camera state of the camera (fov, position, rotation, etc..)
  8745. * @returns the camera
  8746. */
  8747. storeState(): Camera;
  8748. /**
  8749. * Restored camera state. You must call storeState() first
  8750. * @returns whether it was successful or not
  8751. * @hidden
  8752. */
  8753. _restoreStateValues(): boolean;
  8754. /** @hidden */
  8755. _initCache(): void;
  8756. /** @hidden */
  8757. _updateCache(ignoreParentClass?: boolean): void;
  8758. /** @hidden */
  8759. _isSynchronizedViewMatrix(): boolean;
  8760. /** @hidden */
  8761. _computeLocalCameraSpeed(): number;
  8762. /**
  8763. * Defines the target the camera should look at.
  8764. * @param target Defines the new target as a Vector or a mesh
  8765. */
  8766. setTarget(target: Vector3): void;
  8767. /**
  8768. * Return the current target position of the camera. This value is expressed in local space.
  8769. * @returns the target position
  8770. */
  8771. getTarget(): Vector3;
  8772. /** @hidden */
  8773. _decideIfNeedsToMove(): boolean;
  8774. /** @hidden */
  8775. _updatePosition(): void;
  8776. /** @hidden */
  8777. _checkInputs(): void;
  8778. protected _updateCameraRotationMatrix(): void;
  8779. /**
  8780. * 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)
  8781. * @returns the current camera
  8782. */
  8783. private _rotateUpVectorWithCameraRotationMatrix;
  8784. private _cachedRotationZ;
  8785. private _cachedQuaternionRotationZ;
  8786. /** @hidden */
  8787. _getViewMatrix(): Matrix;
  8788. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8789. /**
  8790. * @hidden
  8791. */
  8792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8793. /**
  8794. * @hidden
  8795. */
  8796. _updateRigCameras(): void;
  8797. private _getRigCamPositionAndTarget;
  8798. /**
  8799. * Gets the current object class name.
  8800. * @return the class name
  8801. */
  8802. getClassName(): string;
  8803. }
  8804. }
  8805. declare module "babylonjs/Events/keyboardEvents" {
  8806. /**
  8807. * Gather the list of keyboard event types as constants.
  8808. */
  8809. export class KeyboardEventTypes {
  8810. /**
  8811. * The keydown event is fired when a key becomes active (pressed).
  8812. */
  8813. static readonly KEYDOWN: number;
  8814. /**
  8815. * The keyup event is fired when a key has been released.
  8816. */
  8817. static readonly KEYUP: number;
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8821. */
  8822. export class KeyboardInfo {
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number;
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent;
  8831. /**
  8832. * Instantiates a new keyboard info.
  8833. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8834. * @param type Defines the type of event (KeyboardEventTypes)
  8835. * @param event Defines the related dom event
  8836. */
  8837. constructor(
  8838. /**
  8839. * Defines the type of event (KeyboardEventTypes)
  8840. */
  8841. type: number,
  8842. /**
  8843. * Defines the related dom event
  8844. */
  8845. event: KeyboardEvent);
  8846. }
  8847. /**
  8848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8849. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8850. */
  8851. export class KeyboardInfoPre extends KeyboardInfo {
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number;
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent;
  8860. /**
  8861. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8862. */
  8863. skipOnPointerObservable: boolean;
  8864. /**
  8865. * Instantiates a new keyboard pre info.
  8866. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8867. * @param type Defines the type of event (KeyboardEventTypes)
  8868. * @param event Defines the related dom event
  8869. */
  8870. constructor(
  8871. /**
  8872. * Defines the type of event (KeyboardEventTypes)
  8873. */
  8874. type: number,
  8875. /**
  8876. * Defines the related dom event
  8877. */
  8878. event: KeyboardEvent);
  8879. }
  8880. }
  8881. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8882. import { Nullable } from "babylonjs/types";
  8883. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8884. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8885. /**
  8886. * Manage the keyboard inputs to control the movement of a free camera.
  8887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8888. */
  8889. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8890. /**
  8891. * Defines the camera the input is attached to.
  8892. */
  8893. camera: FreeCamera;
  8894. /**
  8895. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8896. */
  8897. keysUp: number[];
  8898. /**
  8899. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8900. */
  8901. keysUpward: number[];
  8902. /**
  8903. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8904. */
  8905. keysDown: number[];
  8906. /**
  8907. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8908. */
  8909. keysDownward: number[];
  8910. /**
  8911. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8912. */
  8913. keysLeft: number[];
  8914. /**
  8915. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8916. */
  8917. keysRight: number[];
  8918. private _keys;
  8919. private _onCanvasBlurObserver;
  8920. private _onKeyboardObserver;
  8921. private _engine;
  8922. private _scene;
  8923. /**
  8924. * Attach the input controls to a specific dom element to get the input from.
  8925. * @param element Defines the element the controls should be listened from
  8926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8927. */
  8928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8929. /**
  8930. * Detach the current controls from the specified dom element.
  8931. * @param element Defines the element to stop listening the inputs from
  8932. */
  8933. detachControl(element: Nullable<HTMLElement>): void;
  8934. /**
  8935. * Update the current camera state depending on the inputs that have been used this frame.
  8936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8937. */
  8938. checkInputs(): void;
  8939. /**
  8940. * Gets the class name of the current intput.
  8941. * @returns the class name
  8942. */
  8943. getClassName(): string;
  8944. /** @hidden */
  8945. _onLostFocus(): void;
  8946. /**
  8947. * Get the friendly name associated with the input class.
  8948. * @returns the input friendly name
  8949. */
  8950. getSimpleName(): string;
  8951. }
  8952. }
  8953. declare module "babylonjs/Lights/shadowLight" {
  8954. import { Camera } from "babylonjs/Cameras/camera";
  8955. import { Scene } from "babylonjs/scene";
  8956. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8958. import { Light } from "babylonjs/Lights/light";
  8959. /**
  8960. * Interface describing all the common properties and methods a shadow light needs to implement.
  8961. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8962. * as well as binding the different shadow properties to the effects.
  8963. */
  8964. export interface IShadowLight extends Light {
  8965. /**
  8966. * The light id in the scene (used in scene.findLighById for instance)
  8967. */
  8968. id: string;
  8969. /**
  8970. * The position the shdow will be casted from.
  8971. */
  8972. position: Vector3;
  8973. /**
  8974. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8975. */
  8976. direction: Vector3;
  8977. /**
  8978. * The transformed position. Position of the light in world space taking parenting in account.
  8979. */
  8980. transformedPosition: Vector3;
  8981. /**
  8982. * The transformed direction. Direction of the light in world space taking parenting in account.
  8983. */
  8984. transformedDirection: Vector3;
  8985. /**
  8986. * The friendly name of the light in the scene.
  8987. */
  8988. name: string;
  8989. /**
  8990. * Defines the shadow projection clipping minimum z value.
  8991. */
  8992. shadowMinZ: number;
  8993. /**
  8994. * Defines the shadow projection clipping maximum z value.
  8995. */
  8996. shadowMaxZ: number;
  8997. /**
  8998. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8999. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9000. */
  9001. computeTransformedInformation(): boolean;
  9002. /**
  9003. * Gets the scene the light belongs to.
  9004. * @returns The scene
  9005. */
  9006. getScene(): Scene;
  9007. /**
  9008. * Callback defining a custom Projection Matrix Builder.
  9009. * This can be used to override the default projection matrix computation.
  9010. */
  9011. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9012. /**
  9013. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9014. * @param matrix The materix to updated with the projection information
  9015. * @param viewMatrix The transform matrix of the light
  9016. * @param renderList The list of mesh to render in the map
  9017. * @returns The current light
  9018. */
  9019. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9020. /**
  9021. * Gets the current depth scale used in ESM.
  9022. * @returns The scale
  9023. */
  9024. getDepthScale(): number;
  9025. /**
  9026. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9027. * @returns true if a cube texture needs to be use
  9028. */
  9029. needCube(): boolean;
  9030. /**
  9031. * Detects if the projection matrix requires to be recomputed this frame.
  9032. * @returns true if it requires to be recomputed otherwise, false.
  9033. */
  9034. needProjectionMatrixCompute(): boolean;
  9035. /**
  9036. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9037. */
  9038. forceProjectionMatrixCompute(): void;
  9039. /**
  9040. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9041. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9042. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9043. */
  9044. getShadowDirection(faceIndex?: number): Vector3;
  9045. /**
  9046. * Gets the minZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the min for
  9048. * @returns the depth min z
  9049. */
  9050. getDepthMinZ(activeCamera: Camera): number;
  9051. /**
  9052. * Gets the maxZ used for shadow according to both the scene and the light.
  9053. * @param activeCamera The camera we are returning the max for
  9054. * @returns the depth max z
  9055. */
  9056. getDepthMaxZ(activeCamera: Camera): number;
  9057. }
  9058. /**
  9059. * Base implementation IShadowLight
  9060. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9061. */
  9062. export abstract class ShadowLight extends Light implements IShadowLight {
  9063. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9064. protected _position: Vector3;
  9065. protected _setPosition(value: Vector3): void;
  9066. /**
  9067. * Sets the position the shadow will be casted from. Also use as the light position for both
  9068. * point and spot lights.
  9069. */
  9070. get position(): Vector3;
  9071. /**
  9072. * Sets the position the shadow will be casted from. Also use as the light position for both
  9073. * point and spot lights.
  9074. */
  9075. set position(value: Vector3);
  9076. protected _direction: Vector3;
  9077. protected _setDirection(value: Vector3): void;
  9078. /**
  9079. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9080. * Also use as the light direction on spot and directional lights.
  9081. */
  9082. get direction(): Vector3;
  9083. /**
  9084. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9085. * Also use as the light direction on spot and directional lights.
  9086. */
  9087. set direction(value: Vector3);
  9088. protected _shadowMinZ: number;
  9089. /**
  9090. * Gets the shadow projection clipping minimum z value.
  9091. */
  9092. get shadowMinZ(): number;
  9093. /**
  9094. * Sets the shadow projection clipping minimum z value.
  9095. */
  9096. set shadowMinZ(value: number);
  9097. protected _shadowMaxZ: number;
  9098. /**
  9099. * Sets the shadow projection clipping maximum z value.
  9100. */
  9101. get shadowMaxZ(): number;
  9102. /**
  9103. * Gets the shadow projection clipping maximum z value.
  9104. */
  9105. set shadowMaxZ(value: number);
  9106. /**
  9107. * Callback defining a custom Projection Matrix Builder.
  9108. * This can be used to override the default projection matrix computation.
  9109. */
  9110. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9111. /**
  9112. * The transformed position. Position of the light in world space taking parenting in account.
  9113. */
  9114. transformedPosition: Vector3;
  9115. /**
  9116. * The transformed direction. Direction of the light in world space taking parenting in account.
  9117. */
  9118. transformedDirection: Vector3;
  9119. private _needProjectionMatrixCompute;
  9120. /**
  9121. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9122. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9123. */
  9124. computeTransformedInformation(): boolean;
  9125. /**
  9126. * Return the depth scale used for the shadow map.
  9127. * @returns the depth scale.
  9128. */
  9129. getDepthScale(): number;
  9130. /**
  9131. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9132. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9133. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9134. */
  9135. getShadowDirection(faceIndex?: number): Vector3;
  9136. /**
  9137. * Returns the ShadowLight absolute position in the World.
  9138. * @returns the position vector in world space
  9139. */
  9140. getAbsolutePosition(): Vector3;
  9141. /**
  9142. * Sets the ShadowLight direction toward the passed target.
  9143. * @param target The point to target in local space
  9144. * @returns the updated ShadowLight direction
  9145. */
  9146. setDirectionToTarget(target: Vector3): Vector3;
  9147. /**
  9148. * Returns the light rotation in euler definition.
  9149. * @returns the x y z rotation in local space.
  9150. */
  9151. getRotation(): Vector3;
  9152. /**
  9153. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9154. * @returns true if a cube texture needs to be use
  9155. */
  9156. needCube(): boolean;
  9157. /**
  9158. * Detects if the projection matrix requires to be recomputed this frame.
  9159. * @returns true if it requires to be recomputed otherwise, false.
  9160. */
  9161. needProjectionMatrixCompute(): boolean;
  9162. /**
  9163. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9164. */
  9165. forceProjectionMatrixCompute(): void;
  9166. /** @hidden */
  9167. _initCache(): void;
  9168. /** @hidden */
  9169. _isSynchronized(): boolean;
  9170. /**
  9171. * Computes the world matrix of the node
  9172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9173. * @returns the world matrix
  9174. */
  9175. computeWorldMatrix(force?: boolean): Matrix;
  9176. /**
  9177. * Gets the minZ used for shadow according to both the scene and the light.
  9178. * @param activeCamera The camera we are returning the min for
  9179. * @returns the depth min z
  9180. */
  9181. getDepthMinZ(activeCamera: Camera): number;
  9182. /**
  9183. * Gets the maxZ used for shadow according to both the scene and the light.
  9184. * @param activeCamera The camera we are returning the max for
  9185. * @returns the depth max z
  9186. */
  9187. getDepthMaxZ(activeCamera: Camera): number;
  9188. /**
  9189. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9190. * @param matrix The materix to updated with the projection information
  9191. * @param viewMatrix The transform matrix of the light
  9192. * @param renderList The list of mesh to render in the map
  9193. * @returns The current light
  9194. */
  9195. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9196. }
  9197. }
  9198. declare module "babylonjs/Materials/effectFallbacks" {
  9199. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9200. import { Effect } from "babylonjs/Materials/effect";
  9201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9202. /**
  9203. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9204. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9205. */
  9206. export class EffectFallbacks implements IEffectFallbacks {
  9207. private _defines;
  9208. private _currentRank;
  9209. private _maxRank;
  9210. private _mesh;
  9211. /**
  9212. * Removes the fallback from the bound mesh.
  9213. */
  9214. unBindMesh(): void;
  9215. /**
  9216. * Adds a fallback on the specified property.
  9217. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9218. * @param define The name of the define in the shader
  9219. */
  9220. addFallback(rank: number, define: string): void;
  9221. /**
  9222. * Sets the mesh to use CPU skinning when needing to fallback.
  9223. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9224. * @param mesh The mesh to use the fallbacks.
  9225. */
  9226. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9227. /**
  9228. * Checks to see if more fallbacks are still availible.
  9229. */
  9230. get hasMoreFallbacks(): boolean;
  9231. /**
  9232. * Removes the defines that should be removed when falling back.
  9233. * @param currentDefines defines the current define statements for the shader.
  9234. * @param effect defines the current effect we try to compile
  9235. * @returns The resulting defines with defines of the current rank removed.
  9236. */
  9237. reduce(currentDefines: string, effect: Effect): string;
  9238. }
  9239. }
  9240. declare module "babylonjs/Materials/materialHelper" {
  9241. import { Nullable } from "babylonjs/types";
  9242. import { Scene } from "babylonjs/scene";
  9243. import { Engine } from "babylonjs/Engines/engine";
  9244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9245. import { Light } from "babylonjs/Lights/light";
  9246. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9247. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9249. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9250. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9251. /**
  9252. * "Static Class" containing the most commonly used helper while dealing with material for
  9253. * rendering purpose.
  9254. *
  9255. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9256. *
  9257. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9258. */
  9259. export class MaterialHelper {
  9260. /**
  9261. * Bind the current view position to an effect.
  9262. * @param effect The effect to be bound
  9263. * @param scene The scene the eyes position is used from
  9264. * @param variableName name of the shader variable that will hold the eye position
  9265. */
  9266. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9267. /**
  9268. * Helps preparing the defines values about the UVs in used in the effect.
  9269. * UVs are shared as much as we can accross channels in the shaders.
  9270. * @param texture The texture we are preparing the UVs for
  9271. * @param defines The defines to update
  9272. * @param key The channel key "diffuse", "specular"... used in the shader
  9273. */
  9274. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9275. /**
  9276. * Binds a texture matrix value to its corrsponding uniform
  9277. * @param texture The texture to bind the matrix for
  9278. * @param uniformBuffer The uniform buffer receivin the data
  9279. * @param key The channel key "diffuse", "specular"... used in the shader
  9280. */
  9281. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9282. /**
  9283. * Gets the current status of the fog (should it be enabled?)
  9284. * @param mesh defines the mesh to evaluate for fog support
  9285. * @param scene defines the hosting scene
  9286. * @returns true if fog must be enabled
  9287. */
  9288. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9289. /**
  9290. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9291. * @param mesh defines the current mesh
  9292. * @param scene defines the current scene
  9293. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9294. * @param pointsCloud defines if point cloud rendering has to be turned on
  9295. * @param fogEnabled defines if fog has to be turned on
  9296. * @param alphaTest defines if alpha testing has to be turned on
  9297. * @param defines defines the current list of defines
  9298. */
  9299. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9300. /**
  9301. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9302. * @param scene defines the current scene
  9303. * @param engine defines the current engine
  9304. * @param defines specifies the list of active defines
  9305. * @param useInstances defines if instances have to be turned on
  9306. * @param useClipPlane defines if clip plane have to be turned on
  9307. */
  9308. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9309. /**
  9310. * Prepares the defines for bones
  9311. * @param mesh The mesh containing the geometry data we will draw
  9312. * @param defines The defines to update
  9313. */
  9314. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9315. /**
  9316. * Prepares the defines for morph targets
  9317. * @param mesh The mesh containing the geometry data we will draw
  9318. * @param defines The defines to update
  9319. */
  9320. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9321. /**
  9322. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9323. * @param mesh The mesh containing the geometry data we will draw
  9324. * @param defines The defines to update
  9325. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9326. * @param useBones Precise whether bones should be used or not (override mesh info)
  9327. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9328. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9329. * @returns false if defines are considered not dirty and have not been checked
  9330. */
  9331. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9332. /**
  9333. * Prepares the defines related to multiview
  9334. * @param scene The scene we are intending to draw
  9335. * @param defines The defines to update
  9336. */
  9337. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9338. /**
  9339. * Prepares the defines related to the light information passed in parameter
  9340. * @param scene The scene we are intending to draw
  9341. * @param mesh The mesh the effect is compiling for
  9342. * @param light The light the effect is compiling for
  9343. * @param lightIndex The index of the light
  9344. * @param defines The defines to update
  9345. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9346. * @param state Defines the current state regarding what is needed (normals, etc...)
  9347. */
  9348. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9349. needNormals: boolean;
  9350. needRebuild: boolean;
  9351. shadowEnabled: boolean;
  9352. specularEnabled: boolean;
  9353. lightmapMode: boolean;
  9354. }): void;
  9355. /**
  9356. * Prepares the defines related to the light information passed in parameter
  9357. * @param scene The scene we are intending to draw
  9358. * @param mesh The mesh the effect is compiling for
  9359. * @param defines The defines to update
  9360. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9361. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9362. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9363. * @returns true if normals will be required for the rest of the effect
  9364. */
  9365. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9366. /**
  9367. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9368. * @param lightIndex defines the light index
  9369. * @param uniformsList The uniform list
  9370. * @param samplersList The sampler list
  9371. * @param projectedLightTexture defines if projected texture must be used
  9372. * @param uniformBuffersList defines an optional list of uniform buffers
  9373. */
  9374. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9375. /**
  9376. * Prepares the uniforms and samplers list to be used in the effect
  9377. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9378. * @param samplersList The sampler list
  9379. * @param defines The defines helping in the list generation
  9380. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9381. */
  9382. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9383. /**
  9384. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9385. * @param defines The defines to update while falling back
  9386. * @param fallbacks The authorized effect fallbacks
  9387. * @param maxSimultaneousLights The maximum number of lights allowed
  9388. * @param rank the current rank of the Effect
  9389. * @returns The newly affected rank
  9390. */
  9391. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9392. private static _TmpMorphInfluencers;
  9393. /**
  9394. * Prepares the list of attributes required for morph targets according to the effect defines.
  9395. * @param attribs The current list of supported attribs
  9396. * @param mesh The mesh to prepare the morph targets attributes for
  9397. * @param influencers The number of influencers
  9398. */
  9399. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9400. /**
  9401. * Prepares the list of attributes required for morph targets according to the effect defines.
  9402. * @param attribs The current list of supported attribs
  9403. * @param mesh The mesh to prepare the morph targets attributes for
  9404. * @param defines The current Defines of the effect
  9405. */
  9406. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9407. /**
  9408. * Prepares the list of attributes required for bones according to the effect defines.
  9409. * @param attribs The current list of supported attribs
  9410. * @param mesh The mesh to prepare the bones attributes for
  9411. * @param defines The current Defines of the effect
  9412. * @param fallbacks The current efffect fallback strategy
  9413. */
  9414. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9415. /**
  9416. * Check and prepare the list of attributes required for instances according to the effect defines.
  9417. * @param attribs The current list of supported attribs
  9418. * @param defines The current MaterialDefines of the effect
  9419. */
  9420. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9421. /**
  9422. * Add the list of attributes required for instances to the attribs array.
  9423. * @param attribs The current list of supported attribs
  9424. */
  9425. static PushAttributesForInstances(attribs: string[]): void;
  9426. /**
  9427. * Binds the light information to the effect.
  9428. * @param light The light containing the generator
  9429. * @param effect The effect we are binding the data to
  9430. * @param lightIndex The light index in the effect used to render
  9431. */
  9432. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9433. /**
  9434. * Binds the lights information from the scene to the effect for the given mesh.
  9435. * @param light Light to bind
  9436. * @param lightIndex Light index
  9437. * @param scene The scene where the light belongs to
  9438. * @param effect The effect we are binding the data to
  9439. * @param useSpecular Defines if specular is supported
  9440. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9441. */
  9442. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9443. /**
  9444. * Binds the lights information from the scene to the effect for the given mesh.
  9445. * @param scene The scene the lights belongs to
  9446. * @param mesh The mesh we are binding the information to render
  9447. * @param effect The effect we are binding the data to
  9448. * @param defines The generated defines for the effect
  9449. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9450. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9451. */
  9452. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9453. private static _tempFogColor;
  9454. /**
  9455. * Binds the fog information from the scene to the effect for the given mesh.
  9456. * @param scene The scene the lights belongs to
  9457. * @param mesh The mesh we are binding the information to render
  9458. * @param effect The effect we are binding the data to
  9459. * @param linearSpace Defines if the fog effect is applied in linear space
  9460. */
  9461. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9462. /**
  9463. * Binds the bones information from the mesh to the effect.
  9464. * @param mesh The mesh we are binding the information to render
  9465. * @param effect The effect we are binding the data to
  9466. */
  9467. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9468. /**
  9469. * Binds the morph targets information from the mesh to the effect.
  9470. * @param abstractMesh The mesh we are binding the information to render
  9471. * @param effect The effect we are binding the data to
  9472. */
  9473. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9474. /**
  9475. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9476. * @param defines The generated defines used in the effect
  9477. * @param effect The effect we are binding the data to
  9478. * @param scene The scene we are willing to render with logarithmic scale for
  9479. */
  9480. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9481. /**
  9482. * Binds the clip plane information from the scene to the effect.
  9483. * @param scene The scene the clip plane information are extracted from
  9484. * @param effect The effect we are binding the data to
  9485. */
  9486. static BindClipPlane(effect: Effect, scene: Scene): void;
  9487. }
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9490. /** @hidden */
  9491. export var packingFunctions: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9497. /** @hidden */
  9498. export var bayerDitherFunctions: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9504. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9505. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9506. /** @hidden */
  9507. export var shadowMapFragmentDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9513. /** @hidden */
  9514. export var clipPlaneFragmentDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9520. /** @hidden */
  9521. export var clipPlaneFragment: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9527. /** @hidden */
  9528. export var shadowMapFragment: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9534. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9535. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9537. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9538. /** @hidden */
  9539. export var shadowMapPixelShader: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9545. /** @hidden */
  9546. export var bonesDeclaration: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9552. /** @hidden */
  9553. export var morphTargetsVertexGlobalDeclaration: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9559. /** @hidden */
  9560. export var morphTargetsVertexDeclaration: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9566. /** @hidden */
  9567. export var instancesDeclaration: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9573. /** @hidden */
  9574. export var helperFunctions: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9580. /** @hidden */
  9581. export var shadowMapVertexDeclaration: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9587. /** @hidden */
  9588. export var clipPlaneVertexDeclaration: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9594. /** @hidden */
  9595. export var morphTargetsVertex: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9601. /** @hidden */
  9602. export var instancesVertex: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9608. /** @hidden */
  9609. export var bonesVertex: {
  9610. name: string;
  9611. shader: string;
  9612. };
  9613. }
  9614. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9615. /** @hidden */
  9616. export var shadowMapVertexNormalBias: {
  9617. name: string;
  9618. shader: string;
  9619. };
  9620. }
  9621. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9622. /** @hidden */
  9623. export var shadowMapVertexMetric: {
  9624. name: string;
  9625. shader: string;
  9626. };
  9627. }
  9628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9629. /** @hidden */
  9630. export var clipPlaneVertex: {
  9631. name: string;
  9632. shader: string;
  9633. };
  9634. }
  9635. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9636. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9637. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9639. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9640. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9641. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9642. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9643. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9644. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9645. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9646. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9647. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9649. /** @hidden */
  9650. export var shadowMapVertexShader: {
  9651. name: string;
  9652. shader: string;
  9653. };
  9654. }
  9655. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9656. /** @hidden */
  9657. export var depthBoxBlurPixelShader: {
  9658. name: string;
  9659. shader: string;
  9660. };
  9661. }
  9662. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9663. /** @hidden */
  9664. export var shadowMapFragmentSoftTransparentShadow: {
  9665. name: string;
  9666. shader: string;
  9667. };
  9668. }
  9669. declare module "babylonjs/Culling/ray" {
  9670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9677. import { Plane } from "babylonjs/Maths/math.plane";
  9678. /**
  9679. * Class representing a ray with position and direction
  9680. */
  9681. export class Ray {
  9682. /** origin point */
  9683. origin: Vector3;
  9684. /** direction */
  9685. direction: Vector3;
  9686. /** length of the ray */
  9687. length: number;
  9688. private static readonly TmpVector3;
  9689. private _tmpRay;
  9690. /**
  9691. * Creates a new ray
  9692. * @param origin origin point
  9693. * @param direction direction
  9694. * @param length length of the ray
  9695. */
  9696. constructor(
  9697. /** origin point */
  9698. origin: Vector3,
  9699. /** direction */
  9700. direction: Vector3,
  9701. /** length of the ray */
  9702. length?: number);
  9703. /**
  9704. * Checks if the ray intersects a box
  9705. * This does not account for the ray lenght by design to improve perfs.
  9706. * @param minimum bound of the box
  9707. * @param maximum bound of the box
  9708. * @param intersectionTreshold extra extend to be added to the box in all direction
  9709. * @returns if the box was hit
  9710. */
  9711. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9712. /**
  9713. * Checks if the ray intersects a box
  9714. * This does not account for the ray lenght by design to improve perfs.
  9715. * @param box the bounding box to check
  9716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9717. * @returns if the box was hit
  9718. */
  9719. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9720. /**
  9721. * If the ray hits a sphere
  9722. * @param sphere the bounding sphere to check
  9723. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9724. * @returns true if it hits the sphere
  9725. */
  9726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9727. /**
  9728. * If the ray hits a triange
  9729. * @param vertex0 triangle vertex
  9730. * @param vertex1 triangle vertex
  9731. * @param vertex2 triangle vertex
  9732. * @returns intersection information if hit
  9733. */
  9734. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9735. /**
  9736. * Checks if ray intersects a plane
  9737. * @param plane the plane to check
  9738. * @returns the distance away it was hit
  9739. */
  9740. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9741. /**
  9742. * Calculate the intercept of a ray on a given axis
  9743. * @param axis to check 'x' | 'y' | 'z'
  9744. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9745. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9746. */
  9747. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9748. /**
  9749. * Checks if ray intersects a mesh
  9750. * @param mesh the mesh to check
  9751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9752. * @returns picking info of the intersecton
  9753. */
  9754. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9755. /**
  9756. * Checks if ray intersects a mesh
  9757. * @param meshes the meshes to check
  9758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9759. * @param results array to store result in
  9760. * @returns Array of picking infos
  9761. */
  9762. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9763. private _comparePickingInfo;
  9764. private static smallnum;
  9765. private static rayl;
  9766. /**
  9767. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9768. * @param sega the first point of the segment to test the intersection against
  9769. * @param segb the second point of the segment to test the intersection against
  9770. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9771. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9772. */
  9773. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9774. /**
  9775. * Update the ray from viewport position
  9776. * @param x position
  9777. * @param y y position
  9778. * @param viewportWidth viewport width
  9779. * @param viewportHeight viewport height
  9780. * @param world world matrix
  9781. * @param view view matrix
  9782. * @param projection projection matrix
  9783. * @returns this ray updated
  9784. */
  9785. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9786. /**
  9787. * Creates a ray with origin and direction of 0,0,0
  9788. * @returns the new ray
  9789. */
  9790. static Zero(): Ray;
  9791. /**
  9792. * Creates a new ray from screen space and viewport
  9793. * @param x position
  9794. * @param y y position
  9795. * @param viewportWidth viewport width
  9796. * @param viewportHeight viewport height
  9797. * @param world world matrix
  9798. * @param view view matrix
  9799. * @param projection projection matrix
  9800. * @returns new ray
  9801. */
  9802. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9803. /**
  9804. * 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
  9805. * transformed to the given world matrix.
  9806. * @param origin The origin point
  9807. * @param end The end point
  9808. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9809. * @returns the new ray
  9810. */
  9811. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9812. /**
  9813. * Transforms a ray by a matrix
  9814. * @param ray ray to transform
  9815. * @param matrix matrix to apply
  9816. * @returns the resulting new ray
  9817. */
  9818. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9819. /**
  9820. * Transforms a ray by a matrix
  9821. * @param ray ray to transform
  9822. * @param matrix matrix to apply
  9823. * @param result ray to store result in
  9824. */
  9825. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9826. /**
  9827. * Unproject a ray from screen space to object space
  9828. * @param sourceX defines the screen space x coordinate to use
  9829. * @param sourceY defines the screen space y coordinate to use
  9830. * @param viewportWidth defines the current width of the viewport
  9831. * @param viewportHeight defines the current height of the viewport
  9832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9833. * @param view defines the view matrix to use
  9834. * @param projection defines the projection matrix to use
  9835. */
  9836. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9837. }
  9838. /**
  9839. * Type used to define predicate used to select faces when a mesh intersection is detected
  9840. */
  9841. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9842. module "babylonjs/scene" {
  9843. interface Scene {
  9844. /** @hidden */
  9845. _tempPickingRay: Nullable<Ray>;
  9846. /** @hidden */
  9847. _cachedRayForTransform: Ray;
  9848. /** @hidden */
  9849. _pickWithRayInverseMatrix: Matrix;
  9850. /** @hidden */
  9851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9852. /** @hidden */
  9853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9854. }
  9855. }
  9856. }
  9857. declare module "babylonjs/sceneComponent" {
  9858. import { Scene } from "babylonjs/scene";
  9859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9861. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9862. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9863. import { Nullable } from "babylonjs/types";
  9864. import { Camera } from "babylonjs/Cameras/camera";
  9865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9866. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9867. import { AbstractScene } from "babylonjs/abstractScene";
  9868. import { Mesh } from "babylonjs/Meshes/mesh";
  9869. /**
  9870. * Groups all the scene component constants in one place to ease maintenance.
  9871. * @hidden
  9872. */
  9873. export class SceneComponentConstants {
  9874. static readonly NAME_EFFECTLAYER: string;
  9875. static readonly NAME_LAYER: string;
  9876. static readonly NAME_LENSFLARESYSTEM: string;
  9877. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9878. static readonly NAME_PARTICLESYSTEM: string;
  9879. static readonly NAME_GAMEPAD: string;
  9880. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9881. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9882. static readonly NAME_DEPTHRENDERER: string;
  9883. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9884. static readonly NAME_SPRITE: string;
  9885. static readonly NAME_OUTLINERENDERER: string;
  9886. static readonly NAME_PROCEDURALTEXTURE: string;
  9887. static readonly NAME_SHADOWGENERATOR: string;
  9888. static readonly NAME_OCTREE: string;
  9889. static readonly NAME_PHYSICSENGINE: string;
  9890. static readonly NAME_AUDIO: string;
  9891. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9892. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9893. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9894. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9895. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9896. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9897. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9898. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9899. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9900. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9901. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9902. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9903. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9904. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9905. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9906. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9907. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9908. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9909. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9910. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9911. static readonly STEP_AFTERRENDER_AUDIO: number;
  9912. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9913. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9914. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9915. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9916. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9917. static readonly STEP_POINTERMOVE_SPRITE: number;
  9918. static readonly STEP_POINTERDOWN_SPRITE: number;
  9919. static readonly STEP_POINTERUP_SPRITE: number;
  9920. }
  9921. /**
  9922. * This represents a scene component.
  9923. *
  9924. * This is used to decouple the dependency the scene is having on the different workloads like
  9925. * layers, post processes...
  9926. */
  9927. export interface ISceneComponent {
  9928. /**
  9929. * The name of the component. Each component must have a unique name.
  9930. */
  9931. name: string;
  9932. /**
  9933. * The scene the component belongs to.
  9934. */
  9935. scene: Scene;
  9936. /**
  9937. * Register the component to one instance of a scene.
  9938. */
  9939. register(): void;
  9940. /**
  9941. * Rebuilds the elements related to this component in case of
  9942. * context lost for instance.
  9943. */
  9944. rebuild(): void;
  9945. /**
  9946. * Disposes the component and the associated ressources.
  9947. */
  9948. dispose(): void;
  9949. }
  9950. /**
  9951. * This represents a SERIALIZABLE scene component.
  9952. *
  9953. * This extends Scene Component to add Serialization methods on top.
  9954. */
  9955. export interface ISceneSerializableComponent extends ISceneComponent {
  9956. /**
  9957. * Adds all the elements from the container to the scene
  9958. * @param container the container holding the elements
  9959. */
  9960. addFromContainer(container: AbstractScene): void;
  9961. /**
  9962. * Removes all the elements in the container from the scene
  9963. * @param container contains the elements to remove
  9964. * @param dispose if the removed element should be disposed (default: false)
  9965. */
  9966. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9967. /**
  9968. * Serializes the component data to the specified json object
  9969. * @param serializationObject The object to serialize to
  9970. */
  9971. serialize(serializationObject: any): void;
  9972. }
  9973. /**
  9974. * Strong typing of a Mesh related stage step action
  9975. */
  9976. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9977. /**
  9978. * Strong typing of a Evaluate Sub Mesh related stage step action
  9979. */
  9980. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9981. /**
  9982. * Strong typing of a Active Mesh related stage step action
  9983. */
  9984. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9985. /**
  9986. * Strong typing of a Camera related stage step action
  9987. */
  9988. export type CameraStageAction = (camera: Camera) => void;
  9989. /**
  9990. * Strong typing of a Camera Frame buffer related stage step action
  9991. */
  9992. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9993. /**
  9994. * Strong typing of a Render Target related stage step action
  9995. */
  9996. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9997. /**
  9998. * Strong typing of a RenderingGroup related stage step action
  9999. */
  10000. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10001. /**
  10002. * Strong typing of a Mesh Render related stage step action
  10003. */
  10004. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10005. /**
  10006. * Strong typing of a simple stage step action
  10007. */
  10008. export type SimpleStageAction = () => void;
  10009. /**
  10010. * Strong typing of a render target action.
  10011. */
  10012. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10013. /**
  10014. * Strong typing of a pointer move action.
  10015. */
  10016. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10017. /**
  10018. * Strong typing of a pointer up/down action.
  10019. */
  10020. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10021. /**
  10022. * Representation of a stage in the scene (Basically a list of ordered steps)
  10023. * @hidden
  10024. */
  10025. export class Stage<T extends Function> extends Array<{
  10026. index: number;
  10027. component: ISceneComponent;
  10028. action: T;
  10029. }> {
  10030. /**
  10031. * Hide ctor from the rest of the world.
  10032. * @param items The items to add.
  10033. */
  10034. private constructor();
  10035. /**
  10036. * Creates a new Stage.
  10037. * @returns A new instance of a Stage
  10038. */
  10039. static Create<T extends Function>(): Stage<T>;
  10040. /**
  10041. * Registers a step in an ordered way in the targeted stage.
  10042. * @param index Defines the position to register the step in
  10043. * @param component Defines the component attached to the step
  10044. * @param action Defines the action to launch during the step
  10045. */
  10046. registerStep(index: number, component: ISceneComponent, action: T): void;
  10047. /**
  10048. * Clears all the steps from the stage.
  10049. */
  10050. clear(): void;
  10051. }
  10052. }
  10053. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10054. import { Nullable } from "babylonjs/types";
  10055. import { Observable } from "babylonjs/Misc/observable";
  10056. import { Scene } from "babylonjs/scene";
  10057. import { Sprite } from "babylonjs/Sprites/sprite";
  10058. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10059. import { Ray } from "babylonjs/Culling/ray";
  10060. import { Camera } from "babylonjs/Cameras/camera";
  10061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10062. import { ISceneComponent } from "babylonjs/sceneComponent";
  10063. module "babylonjs/scene" {
  10064. interface Scene {
  10065. /** @hidden */
  10066. _pointerOverSprite: Nullable<Sprite>;
  10067. /** @hidden */
  10068. _pickedDownSprite: Nullable<Sprite>;
  10069. /** @hidden */
  10070. _tempSpritePickingRay: Nullable<Ray>;
  10071. /**
  10072. * All of the sprite managers added to this scene
  10073. * @see http://doc.babylonjs.com/babylon101/sprites
  10074. */
  10075. spriteManagers: Array<ISpriteManager>;
  10076. /**
  10077. * An event triggered when sprites rendering is about to start
  10078. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10079. */
  10080. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10081. /**
  10082. * An event triggered when sprites rendering is done
  10083. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10084. */
  10085. onAfterSpritesRenderingObservable: Observable<Scene>;
  10086. /** @hidden */
  10087. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10088. /** Launch a ray to try to pick a sprite in the scene
  10089. * @param x position on screen
  10090. * @param y position on screen
  10091. * @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
  10092. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10094. * @returns a PickingInfo
  10095. */
  10096. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10097. /** Use the given ray to pick a sprite in the scene
  10098. * @param ray The ray (in world space) to use to pick meshes
  10099. * @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
  10100. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10101. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10102. * @returns a PickingInfo
  10103. */
  10104. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10105. /** @hidden */
  10106. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10107. /** Launch a ray to try to pick sprites in the scene
  10108. * @param x position on screen
  10109. * @param y position on screen
  10110. * @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
  10111. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10112. * @returns a PickingInfo array
  10113. */
  10114. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10115. /** Use the given ray to pick sprites in the scene
  10116. * @param ray The ray (in world space) to use to pick meshes
  10117. * @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
  10118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10119. * @returns a PickingInfo array
  10120. */
  10121. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10122. /**
  10123. * Force the sprite under the pointer
  10124. * @param sprite defines the sprite to use
  10125. */
  10126. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10127. /**
  10128. * Gets the sprite under the pointer
  10129. * @returns a Sprite or null if no sprite is under the pointer
  10130. */
  10131. getPointerOverSprite(): Nullable<Sprite>;
  10132. }
  10133. }
  10134. /**
  10135. * Defines the sprite scene component responsible to manage sprites
  10136. * in a given scene.
  10137. */
  10138. export class SpriteSceneComponent implements ISceneComponent {
  10139. /**
  10140. * The component name helpfull to identify the component in the list of scene components.
  10141. */
  10142. readonly name: string;
  10143. /**
  10144. * The scene the component belongs to.
  10145. */
  10146. scene: Scene;
  10147. /** @hidden */
  10148. private _spritePredicate;
  10149. /**
  10150. * Creates a new instance of the component for the given scene
  10151. * @param scene Defines the scene to register the component in
  10152. */
  10153. constructor(scene: Scene);
  10154. /**
  10155. * Registers the component in a given scene
  10156. */
  10157. register(): void;
  10158. /**
  10159. * Rebuilds the elements related to this component in case of
  10160. * context lost for instance.
  10161. */
  10162. rebuild(): void;
  10163. /**
  10164. * Disposes the component and the associated ressources.
  10165. */
  10166. dispose(): void;
  10167. private _pickSpriteButKeepRay;
  10168. private _pointerMove;
  10169. private _pointerDown;
  10170. private _pointerUp;
  10171. }
  10172. }
  10173. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10174. /** @hidden */
  10175. export var fogFragmentDeclaration: {
  10176. name: string;
  10177. shader: string;
  10178. };
  10179. }
  10180. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10181. /** @hidden */
  10182. export var fogFragment: {
  10183. name: string;
  10184. shader: string;
  10185. };
  10186. }
  10187. declare module "babylonjs/Shaders/sprites.fragment" {
  10188. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10189. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10190. /** @hidden */
  10191. export var spritesPixelShader: {
  10192. name: string;
  10193. shader: string;
  10194. };
  10195. }
  10196. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10197. /** @hidden */
  10198. export var fogVertexDeclaration: {
  10199. name: string;
  10200. shader: string;
  10201. };
  10202. }
  10203. declare module "babylonjs/Shaders/sprites.vertex" {
  10204. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10205. /** @hidden */
  10206. export var spritesVertexShader: {
  10207. name: string;
  10208. shader: string;
  10209. };
  10210. }
  10211. declare module "babylonjs/Sprites/spriteManager" {
  10212. import { IDisposable, Scene } from "babylonjs/scene";
  10213. import { Nullable } from "babylonjs/types";
  10214. import { Observable } from "babylonjs/Misc/observable";
  10215. import { Sprite } from "babylonjs/Sprites/sprite";
  10216. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10217. import { Camera } from "babylonjs/Cameras/camera";
  10218. import { Texture } from "babylonjs/Materials/Textures/texture";
  10219. import "babylonjs/Shaders/sprites.fragment";
  10220. import "babylonjs/Shaders/sprites.vertex";
  10221. import { Ray } from "babylonjs/Culling/ray";
  10222. /**
  10223. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10224. */
  10225. export interface ISpriteManager extends IDisposable {
  10226. /**
  10227. * Gets manager's name
  10228. */
  10229. name: string;
  10230. /**
  10231. * Restricts the camera to viewing objects with the same layerMask.
  10232. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10233. */
  10234. layerMask: number;
  10235. /**
  10236. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10237. */
  10238. isPickable: boolean;
  10239. /**
  10240. * Gets the hosting scene
  10241. */
  10242. scene: Scene;
  10243. /**
  10244. * Specifies the rendering group id for this mesh (0 by default)
  10245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10246. */
  10247. renderingGroupId: number;
  10248. /**
  10249. * Defines the list of sprites managed by the manager.
  10250. */
  10251. sprites: Array<Sprite>;
  10252. /**
  10253. * Gets or sets the spritesheet texture
  10254. */
  10255. texture: Texture;
  10256. /** Defines the default width of a cell in the spritesheet */
  10257. cellWidth: number;
  10258. /** Defines the default height of a cell in the spritesheet */
  10259. cellHeight: number;
  10260. /**
  10261. * Tests the intersection of a sprite with a specific ray.
  10262. * @param ray The ray we are sending to test the collision
  10263. * @param camera The camera space we are sending rays in
  10264. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10265. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10266. * @returns picking info or null.
  10267. */
  10268. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10269. /**
  10270. * Intersects the sprites with a ray
  10271. * @param ray defines the ray to intersect with
  10272. * @param camera defines the current active camera
  10273. * @param predicate defines a predicate used to select candidate sprites
  10274. * @returns null if no hit or a PickingInfo array
  10275. */
  10276. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10277. /**
  10278. * Renders the list of sprites on screen.
  10279. */
  10280. render(): void;
  10281. }
  10282. /**
  10283. * Class used to manage multiple sprites on the same spritesheet
  10284. * @see http://doc.babylonjs.com/babylon101/sprites
  10285. */
  10286. export class SpriteManager implements ISpriteManager {
  10287. /** defines the manager's name */
  10288. name: string;
  10289. /** Gets the list of sprites */
  10290. sprites: Sprite[];
  10291. /** Gets or sets the rendering group id (0 by default) */
  10292. renderingGroupId: number;
  10293. /** Gets or sets camera layer mask */
  10294. layerMask: number;
  10295. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10296. fogEnabled: boolean;
  10297. /** Gets or sets a boolean indicating if the sprites are pickable */
  10298. isPickable: boolean;
  10299. /** Defines the default width of a cell in the spritesheet */
  10300. cellWidth: number;
  10301. /** Defines the default height of a cell in the spritesheet */
  10302. cellHeight: number;
  10303. /** Associative array from JSON sprite data file */
  10304. private _cellData;
  10305. /** Array of sprite names from JSON sprite data file */
  10306. private _spriteMap;
  10307. /** True when packed cell data from JSON file is ready*/
  10308. private _packedAndReady;
  10309. private _textureContent;
  10310. /**
  10311. * An event triggered when the manager is disposed.
  10312. */
  10313. onDisposeObservable: Observable<SpriteManager>;
  10314. private _onDisposeObserver;
  10315. /**
  10316. * Callback called when the manager is disposed
  10317. */
  10318. set onDispose(callback: () => void);
  10319. private _capacity;
  10320. private _fromPacked;
  10321. private _spriteTexture;
  10322. private _epsilon;
  10323. private _scene;
  10324. private _vertexData;
  10325. private _buffer;
  10326. private _vertexBuffers;
  10327. private _indexBuffer;
  10328. private _effectBase;
  10329. private _effectFog;
  10330. /**
  10331. * Gets or sets the unique id of the sprite
  10332. */
  10333. uniqueId: number;
  10334. /**
  10335. * Gets the array of sprites
  10336. */
  10337. get children(): Sprite[];
  10338. /**
  10339. * Gets the hosting scene
  10340. */
  10341. get scene(): Scene;
  10342. /**
  10343. * Gets or sets the capacity of the manager
  10344. */
  10345. get capacity(): number;
  10346. set capacity(value: number);
  10347. /**
  10348. * Gets or sets the spritesheet texture
  10349. */
  10350. get texture(): Texture;
  10351. set texture(value: Texture);
  10352. private _blendMode;
  10353. /**
  10354. * Blend mode use to render the particle, it can be any of
  10355. * the static Constants.ALPHA_x properties provided in this class.
  10356. * Default value is Constants.ALPHA_COMBINE
  10357. */
  10358. get blendMode(): number;
  10359. set blendMode(blendMode: number);
  10360. /** Disables writing to the depth buffer when rendering the sprites.
  10361. * It can be handy to disable depth writing when using textures without alpha channel
  10362. * and setting some specific blend modes.
  10363. */
  10364. disableDepthWrite: boolean;
  10365. /**
  10366. * Creates a new sprite manager
  10367. * @param name defines the manager's name
  10368. * @param imgUrl defines the sprite sheet url
  10369. * @param capacity defines the maximum allowed number of sprites
  10370. * @param cellSize defines the size of a sprite cell
  10371. * @param scene defines the hosting scene
  10372. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10373. * @param samplingMode defines the smapling mode to use with spritesheet
  10374. * @param fromPacked set to false; do not alter
  10375. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10376. */
  10377. constructor(
  10378. /** defines the manager's name */
  10379. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10380. /**
  10381. * Returns the string "SpriteManager"
  10382. * @returns "SpriteManager"
  10383. */
  10384. getClassName(): string;
  10385. private _makePacked;
  10386. private _appendSpriteVertex;
  10387. private _checkTextureAlpha;
  10388. /**
  10389. * Intersects the sprites with a ray
  10390. * @param ray defines the ray to intersect with
  10391. * @param camera defines the current active camera
  10392. * @param predicate defines a predicate used to select candidate sprites
  10393. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10394. * @returns null if no hit or a PickingInfo
  10395. */
  10396. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10397. /**
  10398. * Intersects the sprites with a ray
  10399. * @param ray defines the ray to intersect with
  10400. * @param camera defines the current active camera
  10401. * @param predicate defines a predicate used to select candidate sprites
  10402. * @returns null if no hit or a PickingInfo array
  10403. */
  10404. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10405. /**
  10406. * Render all child sprites
  10407. */
  10408. render(): void;
  10409. /**
  10410. * Release associated resources
  10411. */
  10412. dispose(): void;
  10413. }
  10414. }
  10415. declare module "babylonjs/Misc/gradients" {
  10416. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10417. /** Interface used by value gradients (color, factor, ...) */
  10418. export interface IValueGradient {
  10419. /**
  10420. * Gets or sets the gradient value (between 0 and 1)
  10421. */
  10422. gradient: number;
  10423. }
  10424. /** Class used to store color4 gradient */
  10425. export class ColorGradient implements IValueGradient {
  10426. /**
  10427. * Gets or sets the gradient value (between 0 and 1)
  10428. */
  10429. gradient: number;
  10430. /**
  10431. * Gets or sets first associated color
  10432. */
  10433. color1: Color4;
  10434. /**
  10435. * Gets or sets second associated color
  10436. */
  10437. color2?: Color4 | undefined;
  10438. /**
  10439. * Creates a new color4 gradient
  10440. * @param gradient gets or sets the gradient value (between 0 and 1)
  10441. * @param color1 gets or sets first associated color
  10442. * @param color2 gets or sets first second color
  10443. */
  10444. constructor(
  10445. /**
  10446. * Gets or sets the gradient value (between 0 and 1)
  10447. */
  10448. gradient: number,
  10449. /**
  10450. * Gets or sets first associated color
  10451. */
  10452. color1: Color4,
  10453. /**
  10454. * Gets or sets second associated color
  10455. */
  10456. color2?: Color4 | undefined);
  10457. /**
  10458. * Will get a color picked randomly between color1 and color2.
  10459. * If color2 is undefined then color1 will be used
  10460. * @param result defines the target Color4 to store the result in
  10461. */
  10462. getColorToRef(result: Color4): void;
  10463. }
  10464. /** Class used to store color 3 gradient */
  10465. export class Color3Gradient implements IValueGradient {
  10466. /**
  10467. * Gets or sets the gradient value (between 0 and 1)
  10468. */
  10469. gradient: number;
  10470. /**
  10471. * Gets or sets the associated color
  10472. */
  10473. color: Color3;
  10474. /**
  10475. * Creates a new color3 gradient
  10476. * @param gradient gets or sets the gradient value (between 0 and 1)
  10477. * @param color gets or sets associated color
  10478. */
  10479. constructor(
  10480. /**
  10481. * Gets or sets the gradient value (between 0 and 1)
  10482. */
  10483. gradient: number,
  10484. /**
  10485. * Gets or sets the associated color
  10486. */
  10487. color: Color3);
  10488. }
  10489. /** Class used to store factor gradient */
  10490. export class FactorGradient implements IValueGradient {
  10491. /**
  10492. * Gets or sets the gradient value (between 0 and 1)
  10493. */
  10494. gradient: number;
  10495. /**
  10496. * Gets or sets first associated factor
  10497. */
  10498. factor1: number;
  10499. /**
  10500. * Gets or sets second associated factor
  10501. */
  10502. factor2?: number | undefined;
  10503. /**
  10504. * Creates a new factor gradient
  10505. * @param gradient gets or sets the gradient value (between 0 and 1)
  10506. * @param factor1 gets or sets first associated factor
  10507. * @param factor2 gets or sets second associated factor
  10508. */
  10509. constructor(
  10510. /**
  10511. * Gets or sets the gradient value (between 0 and 1)
  10512. */
  10513. gradient: number,
  10514. /**
  10515. * Gets or sets first associated factor
  10516. */
  10517. factor1: number,
  10518. /**
  10519. * Gets or sets second associated factor
  10520. */
  10521. factor2?: number | undefined);
  10522. /**
  10523. * Will get a number picked randomly between factor1 and factor2.
  10524. * If factor2 is undefined then factor1 will be used
  10525. * @returns the picked number
  10526. */
  10527. getFactor(): number;
  10528. }
  10529. /**
  10530. * Helper used to simplify some generic gradient tasks
  10531. */
  10532. export class GradientHelper {
  10533. /**
  10534. * Gets the current gradient from an array of IValueGradient
  10535. * @param ratio defines the current ratio to get
  10536. * @param gradients defines the array of IValueGradient
  10537. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10538. */
  10539. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10540. }
  10541. }
  10542. declare module "babylonjs/Maths/math.size" {
  10543. /**
  10544. * Interface for the size containing width and height
  10545. */
  10546. export interface ISize {
  10547. /**
  10548. * Width
  10549. */
  10550. width: number;
  10551. /**
  10552. * Heighht
  10553. */
  10554. height: number;
  10555. }
  10556. /**
  10557. * Size containing widht and height
  10558. */
  10559. export class Size implements ISize {
  10560. /**
  10561. * Width
  10562. */
  10563. width: number;
  10564. /**
  10565. * Height
  10566. */
  10567. height: number;
  10568. /**
  10569. * Creates a Size object from the given width and height (floats).
  10570. * @param width width of the new size
  10571. * @param height height of the new size
  10572. */
  10573. constructor(width: number, height: number);
  10574. /**
  10575. * Returns a string with the Size width and height
  10576. * @returns a string with the Size width and height
  10577. */
  10578. toString(): string;
  10579. /**
  10580. * "Size"
  10581. * @returns the string "Size"
  10582. */
  10583. getClassName(): string;
  10584. /**
  10585. * Returns the Size hash code.
  10586. * @returns a hash code for a unique width and height
  10587. */
  10588. getHashCode(): number;
  10589. /**
  10590. * Updates the current size from the given one.
  10591. * @param src the given size
  10592. */
  10593. copyFrom(src: Size): void;
  10594. /**
  10595. * Updates in place the current Size from the given floats.
  10596. * @param width width of the new size
  10597. * @param height height of the new size
  10598. * @returns the updated Size.
  10599. */
  10600. copyFromFloats(width: number, height: number): Size;
  10601. /**
  10602. * Updates in place the current Size from the given floats.
  10603. * @param width width to set
  10604. * @param height height to set
  10605. * @returns the updated Size.
  10606. */
  10607. set(width: number, height: number): Size;
  10608. /**
  10609. * Multiplies the width and height by numbers
  10610. * @param w factor to multiple the width by
  10611. * @param h factor to multiple the height by
  10612. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10613. */
  10614. multiplyByFloats(w: number, h: number): Size;
  10615. /**
  10616. * Clones the size
  10617. * @returns a new Size copied from the given one.
  10618. */
  10619. clone(): Size;
  10620. /**
  10621. * True if the current Size and the given one width and height are strictly equal.
  10622. * @param other the other size to compare against
  10623. * @returns True if the current Size and the given one width and height are strictly equal.
  10624. */
  10625. equals(other: Size): boolean;
  10626. /**
  10627. * The surface of the Size : width * height (float).
  10628. */
  10629. get surface(): number;
  10630. /**
  10631. * Create a new size of zero
  10632. * @returns a new Size set to (0.0, 0.0)
  10633. */
  10634. static Zero(): Size;
  10635. /**
  10636. * Sums the width and height of two sizes
  10637. * @param otherSize size to add to this size
  10638. * @returns a new Size set as the addition result of the current Size and the given one.
  10639. */
  10640. add(otherSize: Size): Size;
  10641. /**
  10642. * Subtracts the width and height of two
  10643. * @param otherSize size to subtract to this size
  10644. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10645. */
  10646. subtract(otherSize: Size): Size;
  10647. /**
  10648. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10649. * @param start starting size to lerp between
  10650. * @param end end size to lerp between
  10651. * @param amount amount to lerp between the start and end values
  10652. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10653. */
  10654. static Lerp(start: Size, end: Size, amount: number): Size;
  10655. }
  10656. }
  10657. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10658. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10659. import { Nullable } from "babylonjs/types";
  10660. module "babylonjs/Engines/thinEngine" {
  10661. interface ThinEngine {
  10662. /**
  10663. * Creates a dynamic texture
  10664. * @param width defines the width of the texture
  10665. * @param height defines the height of the texture
  10666. * @param generateMipMaps defines if the engine should generate the mip levels
  10667. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10668. * @returns the dynamic texture inside an InternalTexture
  10669. */
  10670. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10671. /**
  10672. * Update the content of a dynamic texture
  10673. * @param texture defines the texture to update
  10674. * @param canvas defines the canvas containing the source
  10675. * @param invertY defines if data must be stored with Y axis inverted
  10676. * @param premulAlpha defines if alpha is stored as premultiplied
  10677. * @param format defines the format of the data
  10678. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10679. */
  10680. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10681. }
  10682. }
  10683. }
  10684. declare module "babylonjs/Misc/canvasGenerator" {
  10685. /**
  10686. * Helper class used to generate a canvas to manipulate images
  10687. */
  10688. export class CanvasGenerator {
  10689. /**
  10690. * Create a new canvas (or offscreen canvas depending on the context)
  10691. * @param width defines the expected width
  10692. * @param height defines the expected height
  10693. * @return a new canvas or offscreen canvas
  10694. */
  10695. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10696. }
  10697. }
  10698. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10699. import { Scene } from "babylonjs/scene";
  10700. import { Texture } from "babylonjs/Materials/Textures/texture";
  10701. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10702. /**
  10703. * A class extending Texture allowing drawing on a texture
  10704. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10705. */
  10706. export class DynamicTexture extends Texture {
  10707. private _generateMipMaps;
  10708. private _canvas;
  10709. private _context;
  10710. /**
  10711. * Creates a DynamicTexture
  10712. * @param name defines the name of the texture
  10713. * @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
  10714. * @param scene defines the scene where you want the texture
  10715. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10716. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10717. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10718. */
  10719. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10720. /**
  10721. * Get the current class name of the texture useful for serialization or dynamic coding.
  10722. * @returns "DynamicTexture"
  10723. */
  10724. getClassName(): string;
  10725. /**
  10726. * Gets the current state of canRescale
  10727. */
  10728. get canRescale(): boolean;
  10729. private _recreate;
  10730. /**
  10731. * Scales the texture
  10732. * @param ratio the scale factor to apply to both width and height
  10733. */
  10734. scale(ratio: number): void;
  10735. /**
  10736. * Resizes the texture
  10737. * @param width the new width
  10738. * @param height the new height
  10739. */
  10740. scaleTo(width: number, height: number): void;
  10741. /**
  10742. * Gets the context of the canvas used by the texture
  10743. * @returns the canvas context of the dynamic texture
  10744. */
  10745. getContext(): CanvasRenderingContext2D;
  10746. /**
  10747. * Clears the texture
  10748. */
  10749. clear(): void;
  10750. /**
  10751. * Updates the texture
  10752. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10753. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10754. */
  10755. update(invertY?: boolean, premulAlpha?: boolean): void;
  10756. /**
  10757. * Draws text onto the texture
  10758. * @param text defines the text to be drawn
  10759. * @param x defines the placement of the text from the left
  10760. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10761. * @param font defines the font to be used with font-style, font-size, font-name
  10762. * @param color defines the color used for the text
  10763. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10764. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10765. * @param update defines whether texture is immediately update (default is true)
  10766. */
  10767. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10768. /**
  10769. * Clones the texture
  10770. * @returns the clone of the texture.
  10771. */
  10772. clone(): DynamicTexture;
  10773. /**
  10774. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10775. * @returns a serialized dynamic texture object
  10776. */
  10777. serialize(): any;
  10778. /** @hidden */
  10779. _rebuild(): void;
  10780. }
  10781. }
  10782. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10785. import { Scene } from "babylonjs/scene";
  10786. module "babylonjs/Engines/thinEngine" {
  10787. interface ThinEngine {
  10788. /**
  10789. * Creates a raw texture
  10790. * @param data defines the data to store in the texture
  10791. * @param width defines the width of the texture
  10792. * @param height defines the height of the texture
  10793. * @param format defines the format of the data
  10794. * @param generateMipMaps defines if the engine should generate the mip levels
  10795. * @param invertY defines if data must be stored with Y axis inverted
  10796. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10797. * @param compression defines the compression used (null by default)
  10798. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10799. * @returns the raw texture inside an InternalTexture
  10800. */
  10801. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10802. /**
  10803. * Update a raw texture
  10804. * @param texture defines the texture to update
  10805. * @param data defines the data to store in the texture
  10806. * @param format defines the format of the data
  10807. * @param invertY defines if data must be stored with Y axis inverted
  10808. */
  10809. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10810. /**
  10811. * Update a raw texture
  10812. * @param texture defines the texture to update
  10813. * @param data defines the data to store in the texture
  10814. * @param format defines the format of the data
  10815. * @param invertY defines if data must be stored with Y axis inverted
  10816. * @param compression defines the compression used (null by default)
  10817. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10818. */
  10819. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10820. /**
  10821. * Creates a new raw cube texture
  10822. * @param data defines the array of data to use to create each face
  10823. * @param size defines the size of the textures
  10824. * @param format defines the format of the data
  10825. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10826. * @param generateMipMaps defines if the engine should generate the mip levels
  10827. * @param invertY defines if data must be stored with Y axis inverted
  10828. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10829. * @param compression defines the compression used (null by default)
  10830. * @returns the cube texture as an InternalTexture
  10831. */
  10832. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10833. /**
  10834. * Update a raw cube texture
  10835. * @param texture defines the texture to udpdate
  10836. * @param data defines the data to store
  10837. * @param format defines the data format
  10838. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10839. * @param invertY defines if data must be stored with Y axis inverted
  10840. */
  10841. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10842. /**
  10843. * Update a raw cube texture
  10844. * @param texture defines the texture to udpdate
  10845. * @param data defines the data to store
  10846. * @param format defines the data format
  10847. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10848. * @param invertY defines if data must be stored with Y axis inverted
  10849. * @param compression defines the compression used (null by default)
  10850. */
  10851. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10852. /**
  10853. * Update a raw cube texture
  10854. * @param texture defines the texture to udpdate
  10855. * @param data defines the data to store
  10856. * @param format defines the data format
  10857. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10858. * @param invertY defines if data must be stored with Y axis inverted
  10859. * @param compression defines the compression used (null by default)
  10860. * @param level defines which level of the texture to update
  10861. */
  10862. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10863. /**
  10864. * Creates a new raw cube texture from a specified url
  10865. * @param url defines the url where the data is located
  10866. * @param scene defines the current scene
  10867. * @param size defines the size of the textures
  10868. * @param format defines the format of the data
  10869. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10870. * @param noMipmap defines if the engine should avoid generating the mip levels
  10871. * @param callback defines a callback used to extract texture data from loaded data
  10872. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10873. * @param onLoad defines a callback called when texture is loaded
  10874. * @param onError defines a callback called if there is an error
  10875. * @returns the cube texture as an InternalTexture
  10876. */
  10877. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10878. /**
  10879. * Creates a new raw cube texture from a specified url
  10880. * @param url defines the url where the data is located
  10881. * @param scene defines the current scene
  10882. * @param size defines the size of the textures
  10883. * @param format defines the format of the data
  10884. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10885. * @param noMipmap defines if the engine should avoid generating the mip levels
  10886. * @param callback defines a callback used to extract texture data from loaded data
  10887. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10888. * @param onLoad defines a callback called when texture is loaded
  10889. * @param onError defines a callback called if there is an error
  10890. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10891. * @param invertY defines if data must be stored with Y axis inverted
  10892. * @returns the cube texture as an InternalTexture
  10893. */
  10894. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10895. /**
  10896. * Creates a new raw 3D texture
  10897. * @param data defines the data used to create the texture
  10898. * @param width defines the width of the texture
  10899. * @param height defines the height of the texture
  10900. * @param depth defines the depth of the texture
  10901. * @param format defines the format of the texture
  10902. * @param generateMipMaps defines if the engine must generate mip levels
  10903. * @param invertY defines if data must be stored with Y axis inverted
  10904. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10905. * @param compression defines the compressed used (can be null)
  10906. * @param textureType defines the compressed used (can be null)
  10907. * @returns a new raw 3D texture (stored in an InternalTexture)
  10908. */
  10909. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10910. /**
  10911. * Update a raw 3D texture
  10912. * @param texture defines the texture to update
  10913. * @param data defines the data to store
  10914. * @param format defines the data format
  10915. * @param invertY defines if data must be stored with Y axis inverted
  10916. */
  10917. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10918. /**
  10919. * Update a raw 3D texture
  10920. * @param texture defines the texture to update
  10921. * @param data defines the data to store
  10922. * @param format defines the data format
  10923. * @param invertY defines if data must be stored with Y axis inverted
  10924. * @param compression defines the used compression (can be null)
  10925. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10926. */
  10927. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10928. /**
  10929. * Creates a new raw 2D array texture
  10930. * @param data defines the data used to create the texture
  10931. * @param width defines the width of the texture
  10932. * @param height defines the height of the texture
  10933. * @param depth defines the number of layers of the texture
  10934. * @param format defines the format of the texture
  10935. * @param generateMipMaps defines if the engine must generate mip levels
  10936. * @param invertY defines if data must be stored with Y axis inverted
  10937. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10938. * @param compression defines the compressed used (can be null)
  10939. * @param textureType defines the compressed used (can be null)
  10940. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10941. */
  10942. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10943. /**
  10944. * Update a raw 2D array texture
  10945. * @param texture defines the texture to update
  10946. * @param data defines the data to store
  10947. * @param format defines the data format
  10948. * @param invertY defines if data must be stored with Y axis inverted
  10949. */
  10950. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10951. /**
  10952. * Update a raw 2D array texture
  10953. * @param texture defines the texture to update
  10954. * @param data defines the data to store
  10955. * @param format defines the data format
  10956. * @param invertY defines if data must be stored with Y axis inverted
  10957. * @param compression defines the used compression (can be null)
  10958. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10959. */
  10960. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10961. }
  10962. }
  10963. }
  10964. declare module "babylonjs/Materials/Textures/rawTexture" {
  10965. import { Scene } from "babylonjs/scene";
  10966. import { Texture } from "babylonjs/Materials/Textures/texture";
  10967. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10968. /**
  10969. * Raw texture can help creating a texture directly from an array of data.
  10970. * This can be super useful if you either get the data from an uncompressed source or
  10971. * if you wish to create your texture pixel by pixel.
  10972. */
  10973. export class RawTexture extends Texture {
  10974. /**
  10975. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10976. */
  10977. format: number;
  10978. /**
  10979. * Instantiates a new RawTexture.
  10980. * Raw texture can help creating a texture directly from an array of data.
  10981. * This can be super useful if you either get the data from an uncompressed source or
  10982. * if you wish to create your texture pixel by pixel.
  10983. * @param data define the array of data to use to create the texture
  10984. * @param width define the width of the texture
  10985. * @param height define the height of the texture
  10986. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10987. * @param scene define the scene the texture belongs to
  10988. * @param generateMipMaps define whether mip maps should be generated or not
  10989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10992. */
  10993. constructor(data: ArrayBufferView, width: number, height: number,
  10994. /**
  10995. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10996. */
  10997. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10998. /**
  10999. * Updates the texture underlying data.
  11000. * @param data Define the new data of the texture
  11001. */
  11002. update(data: ArrayBufferView): void;
  11003. /**
  11004. * Creates a luminance texture from some data.
  11005. * @param data Define the texture data
  11006. * @param width Define the width of the texture
  11007. * @param height Define the height of the texture
  11008. * @param scene Define the scene the texture belongs to
  11009. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11010. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11011. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11012. * @returns the luminance texture
  11013. */
  11014. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11015. /**
  11016. * Creates a luminance alpha texture from some data.
  11017. * @param data Define the texture data
  11018. * @param width Define the width of the texture
  11019. * @param height Define the height of the texture
  11020. * @param scene Define the scene the texture belongs to
  11021. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11022. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11023. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11024. * @returns the luminance alpha texture
  11025. */
  11026. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11027. /**
  11028. * Creates an alpha texture from some data.
  11029. * @param data Define the texture data
  11030. * @param width Define the width of the texture
  11031. * @param height Define the height of the texture
  11032. * @param scene Define the scene the texture belongs to
  11033. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11034. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11035. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11036. * @returns the alpha texture
  11037. */
  11038. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11039. /**
  11040. * Creates a RGB texture from some data.
  11041. * @param data Define the texture data
  11042. * @param width Define the width of the texture
  11043. * @param height Define the height of the texture
  11044. * @param scene Define the scene the texture belongs to
  11045. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11046. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11047. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11048. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11049. * @returns the RGB alpha texture
  11050. */
  11051. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11052. /**
  11053. * Creates a RGBA texture from some data.
  11054. * @param data Define the texture data
  11055. * @param width Define the width of the texture
  11056. * @param height Define the height of the texture
  11057. * @param scene Define the scene the texture belongs to
  11058. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11059. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11060. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11061. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11062. * @returns the RGBA texture
  11063. */
  11064. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11065. /**
  11066. * Creates a R texture from some data.
  11067. * @param data Define the texture data
  11068. * @param width Define the width of the texture
  11069. * @param height Define the height of the texture
  11070. * @param scene Define the scene the texture belongs to
  11071. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11072. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11073. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11074. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11075. * @returns the R texture
  11076. */
  11077. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11078. }
  11079. }
  11080. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11081. import { Scene } from "babylonjs/scene";
  11082. import { ISceneComponent } from "babylonjs/sceneComponent";
  11083. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11084. module "babylonjs/abstractScene" {
  11085. interface AbstractScene {
  11086. /**
  11087. * The list of procedural textures added to the scene
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11089. */
  11090. proceduralTextures: Array<ProceduralTexture>;
  11091. }
  11092. }
  11093. /**
  11094. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11095. * in a given scene.
  11096. */
  11097. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11098. /**
  11099. * The component name helpfull to identify the component in the list of scene components.
  11100. */
  11101. readonly name: string;
  11102. /**
  11103. * The scene the component belongs to.
  11104. */
  11105. scene: Scene;
  11106. /**
  11107. * Creates a new instance of the component for the given scene
  11108. * @param scene Defines the scene to register the component in
  11109. */
  11110. constructor(scene: Scene);
  11111. /**
  11112. * Registers the component in a given scene
  11113. */
  11114. register(): void;
  11115. /**
  11116. * Rebuilds the elements related to this component in case of
  11117. * context lost for instance.
  11118. */
  11119. rebuild(): void;
  11120. /**
  11121. * Disposes the component and the associated ressources.
  11122. */
  11123. dispose(): void;
  11124. private _beforeClear;
  11125. }
  11126. }
  11127. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11128. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11129. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11130. module "babylonjs/Engines/thinEngine" {
  11131. interface ThinEngine {
  11132. /**
  11133. * Creates a new render target cube texture
  11134. * @param size defines the size of the texture
  11135. * @param options defines the options used to create the texture
  11136. * @returns a new render target cube texture stored in an InternalTexture
  11137. */
  11138. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11139. }
  11140. }
  11141. }
  11142. declare module "babylonjs/Shaders/procedural.vertex" {
  11143. /** @hidden */
  11144. export var proceduralVertexShader: {
  11145. name: string;
  11146. shader: string;
  11147. };
  11148. }
  11149. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11150. import { Observable } from "babylonjs/Misc/observable";
  11151. import { Nullable } from "babylonjs/types";
  11152. import { Scene } from "babylonjs/scene";
  11153. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11154. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11155. import { Effect } from "babylonjs/Materials/effect";
  11156. import { Texture } from "babylonjs/Materials/Textures/texture";
  11157. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11158. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11159. import "babylonjs/Shaders/procedural.vertex";
  11160. /**
  11161. * 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.
  11162. * This is the base class of any Procedural texture and contains most of the shareable code.
  11163. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11164. */
  11165. export class ProceduralTexture extends Texture {
  11166. isCube: boolean;
  11167. /**
  11168. * Define if the texture is enabled or not (disabled texture will not render)
  11169. */
  11170. isEnabled: boolean;
  11171. /**
  11172. * Define if the texture must be cleared before rendering (default is true)
  11173. */
  11174. autoClear: boolean;
  11175. /**
  11176. * Callback called when the texture is generated
  11177. */
  11178. onGenerated: () => void;
  11179. /**
  11180. * Event raised when the texture is generated
  11181. */
  11182. onGeneratedObservable: Observable<ProceduralTexture>;
  11183. /** @hidden */
  11184. _generateMipMaps: boolean;
  11185. /** @hidden **/
  11186. _effect: Effect;
  11187. /** @hidden */
  11188. _textures: {
  11189. [key: string]: Texture;
  11190. };
  11191. /** @hidden */
  11192. protected _fallbackTexture: Nullable<Texture>;
  11193. private _size;
  11194. private _currentRefreshId;
  11195. private _frameId;
  11196. private _refreshRate;
  11197. private _vertexBuffers;
  11198. private _indexBuffer;
  11199. private _uniforms;
  11200. private _samplers;
  11201. private _fragment;
  11202. private _floats;
  11203. private _ints;
  11204. private _floatsArrays;
  11205. private _colors3;
  11206. private _colors4;
  11207. private _vectors2;
  11208. private _vectors3;
  11209. private _matrices;
  11210. private _fallbackTextureUsed;
  11211. private _fullEngine;
  11212. private _cachedDefines;
  11213. private _contentUpdateId;
  11214. private _contentData;
  11215. /**
  11216. * Instantiates a new procedural texture.
  11217. * 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.
  11218. * This is the base class of any Procedural texture and contains most of the shareable code.
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11220. * @param name Define the name of the texture
  11221. * @param size Define the size of the texture to create
  11222. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11223. * @param scene Define the scene the texture belongs to
  11224. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11225. * @param generateMipMaps Define if the texture should creates mip maps or not
  11226. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11227. */
  11228. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11229. /**
  11230. * The effect that is created when initializing the post process.
  11231. * @returns The created effect corresponding the the postprocess.
  11232. */
  11233. getEffect(): Effect;
  11234. /**
  11235. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11236. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11237. */
  11238. getContent(): Nullable<ArrayBufferView>;
  11239. private _createIndexBuffer;
  11240. /** @hidden */
  11241. _rebuild(): void;
  11242. /**
  11243. * Resets the texture in order to recreate its associated resources.
  11244. * This can be called in case of context loss
  11245. */
  11246. reset(): void;
  11247. protected _getDefines(): string;
  11248. /**
  11249. * Is the texture ready to be used ? (rendered at least once)
  11250. * @returns true if ready, otherwise, false.
  11251. */
  11252. isReady(): boolean;
  11253. /**
  11254. * Resets the refresh counter of the texture and start bak from scratch.
  11255. * Could be useful to regenerate the texture if it is setup to render only once.
  11256. */
  11257. resetRefreshCounter(): void;
  11258. /**
  11259. * Set the fragment shader to use in order to render the texture.
  11260. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11261. */
  11262. setFragment(fragment: any): void;
  11263. /**
  11264. * Define the refresh rate of the texture or the rendering frequency.
  11265. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11266. */
  11267. get refreshRate(): number;
  11268. set refreshRate(value: number);
  11269. /** @hidden */
  11270. _shouldRender(): boolean;
  11271. /**
  11272. * Get the size the texture is rendering at.
  11273. * @returns the size (texture is always squared)
  11274. */
  11275. getRenderSize(): number;
  11276. /**
  11277. * Resize the texture to new value.
  11278. * @param size Define the new size the texture should have
  11279. * @param generateMipMaps Define whether the new texture should create mip maps
  11280. */
  11281. resize(size: number, generateMipMaps: boolean): void;
  11282. private _checkUniform;
  11283. /**
  11284. * Set a texture in the shader program used to render.
  11285. * @param name Define the name of the uniform samplers as defined in the shader
  11286. * @param texture Define the texture to bind to this sampler
  11287. * @return the texture itself allowing "fluent" like uniform updates
  11288. */
  11289. setTexture(name: string, texture: Texture): ProceduralTexture;
  11290. /**
  11291. * Set a float in the shader.
  11292. * @param name Define the name of the uniform as defined in the shader
  11293. * @param value Define the value to give to the uniform
  11294. * @return the texture itself allowing "fluent" like uniform updates
  11295. */
  11296. setFloat(name: string, value: number): ProceduralTexture;
  11297. /**
  11298. * Set a int in the shader.
  11299. * @param name Define the name of the uniform as defined in the shader
  11300. * @param value Define the value to give to the uniform
  11301. * @return the texture itself allowing "fluent" like uniform updates
  11302. */
  11303. setInt(name: string, value: number): ProceduralTexture;
  11304. /**
  11305. * Set an array of floats in the shader.
  11306. * @param name Define the name of the uniform as defined in the shader
  11307. * @param value Define the value to give to the uniform
  11308. * @return the texture itself allowing "fluent" like uniform updates
  11309. */
  11310. setFloats(name: string, value: number[]): ProceduralTexture;
  11311. /**
  11312. * Set a vec3 in the shader from a Color3.
  11313. * @param name Define the name of the uniform as defined in the shader
  11314. * @param value Define the value to give to the uniform
  11315. * @return the texture itself allowing "fluent" like uniform updates
  11316. */
  11317. setColor3(name: string, value: Color3): ProceduralTexture;
  11318. /**
  11319. * Set a vec4 in the shader from a Color4.
  11320. * @param name Define the name of the uniform as defined in the shader
  11321. * @param value Define the value to give to the uniform
  11322. * @return the texture itself allowing "fluent" like uniform updates
  11323. */
  11324. setColor4(name: string, value: Color4): ProceduralTexture;
  11325. /**
  11326. * Set a vec2 in the shader from a Vector2.
  11327. * @param name Define the name of the uniform as defined in the shader
  11328. * @param value Define the value to give to the uniform
  11329. * @return the texture itself allowing "fluent" like uniform updates
  11330. */
  11331. setVector2(name: string, value: Vector2): ProceduralTexture;
  11332. /**
  11333. * Set a vec3 in the shader from a Vector3.
  11334. * @param name Define the name of the uniform as defined in the shader
  11335. * @param value Define the value to give to the uniform
  11336. * @return the texture itself allowing "fluent" like uniform updates
  11337. */
  11338. setVector3(name: string, value: Vector3): ProceduralTexture;
  11339. /**
  11340. * Set a mat4 in the shader from a MAtrix.
  11341. * @param name Define the name of the uniform as defined in the shader
  11342. * @param value Define the value to give to the uniform
  11343. * @return the texture itself allowing "fluent" like uniform updates
  11344. */
  11345. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11346. /**
  11347. * Render the texture to its associated render target.
  11348. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11349. */
  11350. render(useCameraPostProcess?: boolean): void;
  11351. /**
  11352. * Clone the texture.
  11353. * @returns the cloned texture
  11354. */
  11355. clone(): ProceduralTexture;
  11356. /**
  11357. * Dispose the texture and release its asoociated resources.
  11358. */
  11359. dispose(): void;
  11360. }
  11361. }
  11362. declare module "babylonjs/Particles/baseParticleSystem" {
  11363. import { Nullable } from "babylonjs/types";
  11364. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11366. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11367. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11368. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11369. import { Scene } from "babylonjs/scene";
  11370. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11371. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11372. import { Texture } from "babylonjs/Materials/Textures/texture";
  11373. import { Color4 } from "babylonjs/Maths/math.color";
  11374. import { Animation } from "babylonjs/Animations/animation";
  11375. /**
  11376. * This represents the base class for particle system in Babylon.
  11377. * 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.
  11378. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11379. * @example https://doc.babylonjs.com/babylon101/particles
  11380. */
  11381. export class BaseParticleSystem {
  11382. /**
  11383. * Source color is added to the destination color without alpha affecting the result
  11384. */
  11385. static BLENDMODE_ONEONE: number;
  11386. /**
  11387. * Blend current color and particle color using particle’s alpha
  11388. */
  11389. static BLENDMODE_STANDARD: number;
  11390. /**
  11391. * Add current color and particle color multiplied by particle’s alpha
  11392. */
  11393. static BLENDMODE_ADD: number;
  11394. /**
  11395. * Multiply current color with particle color
  11396. */
  11397. static BLENDMODE_MULTIPLY: number;
  11398. /**
  11399. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11400. */
  11401. static BLENDMODE_MULTIPLYADD: number;
  11402. /**
  11403. * List of animations used by the particle system.
  11404. */
  11405. animations: Animation[];
  11406. /**
  11407. * Gets or sets the unique id of the particle system
  11408. */
  11409. uniqueId: number;
  11410. /**
  11411. * The id of the Particle system.
  11412. */
  11413. id: string;
  11414. /**
  11415. * The friendly name of the Particle system.
  11416. */
  11417. name: string;
  11418. /**
  11419. * Snippet ID if the particle system was created from the snippet server
  11420. */
  11421. snippetId: string;
  11422. /**
  11423. * The rendering group used by the Particle system to chose when to render.
  11424. */
  11425. renderingGroupId: number;
  11426. /**
  11427. * The emitter represents the Mesh or position we are attaching the particle system to.
  11428. */
  11429. emitter: Nullable<AbstractMesh | Vector3>;
  11430. /**
  11431. * The maximum number of particles to emit per frame
  11432. */
  11433. emitRate: number;
  11434. /**
  11435. * If you want to launch only a few particles at once, that can be done, as well.
  11436. */
  11437. manualEmitCount: number;
  11438. /**
  11439. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11440. */
  11441. updateSpeed: number;
  11442. /**
  11443. * The amount of time the particle system is running (depends of the overall update speed).
  11444. */
  11445. targetStopDuration: number;
  11446. /**
  11447. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11448. */
  11449. disposeOnStop: boolean;
  11450. /**
  11451. * Minimum power of emitting particles.
  11452. */
  11453. minEmitPower: number;
  11454. /**
  11455. * Maximum power of emitting particles.
  11456. */
  11457. maxEmitPower: number;
  11458. /**
  11459. * Minimum life time of emitting particles.
  11460. */
  11461. minLifeTime: number;
  11462. /**
  11463. * Maximum life time of emitting particles.
  11464. */
  11465. maxLifeTime: number;
  11466. /**
  11467. * Minimum Size of emitting particles.
  11468. */
  11469. minSize: number;
  11470. /**
  11471. * Maximum Size of emitting particles.
  11472. */
  11473. maxSize: number;
  11474. /**
  11475. * Minimum scale of emitting particles on X axis.
  11476. */
  11477. minScaleX: number;
  11478. /**
  11479. * Maximum scale of emitting particles on X axis.
  11480. */
  11481. maxScaleX: number;
  11482. /**
  11483. * Minimum scale of emitting particles on Y axis.
  11484. */
  11485. minScaleY: number;
  11486. /**
  11487. * Maximum scale of emitting particles on Y axis.
  11488. */
  11489. maxScaleY: number;
  11490. /**
  11491. * Gets or sets the minimal initial rotation in radians.
  11492. */
  11493. minInitialRotation: number;
  11494. /**
  11495. * Gets or sets the maximal initial rotation in radians.
  11496. */
  11497. maxInitialRotation: number;
  11498. /**
  11499. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11500. */
  11501. minAngularSpeed: number;
  11502. /**
  11503. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11504. */
  11505. maxAngularSpeed: number;
  11506. /**
  11507. * The texture used to render each particle. (this can be a spritesheet)
  11508. */
  11509. particleTexture: Nullable<Texture>;
  11510. /**
  11511. * The layer mask we are rendering the particles through.
  11512. */
  11513. layerMask: number;
  11514. /**
  11515. * This can help using your own shader to render the particle system.
  11516. * The according effect will be created
  11517. */
  11518. customShader: any;
  11519. /**
  11520. * By default particle system starts as soon as they are created. This prevents the
  11521. * automatic start to happen and let you decide when to start emitting particles.
  11522. */
  11523. preventAutoStart: boolean;
  11524. private _noiseTexture;
  11525. /**
  11526. * Gets or sets a texture used to add random noise to particle positions
  11527. */
  11528. get noiseTexture(): Nullable<ProceduralTexture>;
  11529. set noiseTexture(value: Nullable<ProceduralTexture>);
  11530. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11531. noiseStrength: Vector3;
  11532. /**
  11533. * Callback triggered when the particle animation is ending.
  11534. */
  11535. onAnimationEnd: Nullable<() => void>;
  11536. /**
  11537. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11538. */
  11539. blendMode: number;
  11540. /**
  11541. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11542. * to override the particles.
  11543. */
  11544. forceDepthWrite: boolean;
  11545. /** 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 */
  11546. preWarmCycles: number;
  11547. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11548. preWarmStepOffset: number;
  11549. /**
  11550. * 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)
  11551. */
  11552. spriteCellChangeSpeed: number;
  11553. /**
  11554. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11555. */
  11556. startSpriteCellID: number;
  11557. /**
  11558. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11559. */
  11560. endSpriteCellID: number;
  11561. /**
  11562. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11563. */
  11564. spriteCellWidth: number;
  11565. /**
  11566. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11567. */
  11568. spriteCellHeight: number;
  11569. /**
  11570. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11571. */
  11572. spriteRandomStartCell: boolean;
  11573. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11574. translationPivot: Vector2;
  11575. /** @hidden */
  11576. protected _isAnimationSheetEnabled: boolean;
  11577. /**
  11578. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11579. */
  11580. beginAnimationOnStart: boolean;
  11581. /**
  11582. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11583. */
  11584. beginAnimationFrom: number;
  11585. /**
  11586. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11587. */
  11588. beginAnimationTo: number;
  11589. /**
  11590. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11591. */
  11592. beginAnimationLoop: boolean;
  11593. /**
  11594. * Gets or sets a world offset applied to all particles
  11595. */
  11596. worldOffset: Vector3;
  11597. /**
  11598. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11599. */
  11600. get isAnimationSheetEnabled(): boolean;
  11601. set isAnimationSheetEnabled(value: boolean);
  11602. /**
  11603. * Get hosting scene
  11604. * @returns the scene
  11605. */
  11606. getScene(): Scene;
  11607. /**
  11608. * You can use gravity if you want to give an orientation to your particles.
  11609. */
  11610. gravity: Vector3;
  11611. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11612. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11613. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11614. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11615. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11616. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11617. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11618. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11619. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11620. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11621. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11622. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11623. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11624. /**
  11625. * Defines the delay in milliseconds before starting the system (0 by default)
  11626. */
  11627. startDelay: number;
  11628. /**
  11629. * Gets the current list of drag gradients.
  11630. * You must use addDragGradient and removeDragGradient to udpate this list
  11631. * @returns the list of drag gradients
  11632. */
  11633. getDragGradients(): Nullable<Array<FactorGradient>>;
  11634. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11635. limitVelocityDamping: number;
  11636. /**
  11637. * Gets the current list of limit velocity gradients.
  11638. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11639. * @returns the list of limit velocity gradients
  11640. */
  11641. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11642. /**
  11643. * Gets the current list of color gradients.
  11644. * You must use addColorGradient and removeColorGradient to udpate this list
  11645. * @returns the list of color gradients
  11646. */
  11647. getColorGradients(): Nullable<Array<ColorGradient>>;
  11648. /**
  11649. * Gets the current list of size gradients.
  11650. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11651. * @returns the list of size gradients
  11652. */
  11653. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11654. /**
  11655. * Gets the current list of color remap gradients.
  11656. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11657. * @returns the list of color remap gradients
  11658. */
  11659. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11660. /**
  11661. * Gets the current list of alpha remap gradients.
  11662. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11663. * @returns the list of alpha remap gradients
  11664. */
  11665. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11666. /**
  11667. * Gets the current list of life time gradients.
  11668. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11669. * @returns the list of life time gradients
  11670. */
  11671. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11672. /**
  11673. * Gets the current list of angular speed gradients.
  11674. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11675. * @returns the list of angular speed gradients
  11676. */
  11677. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11678. /**
  11679. * Gets the current list of velocity gradients.
  11680. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11681. * @returns the list of velocity gradients
  11682. */
  11683. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11684. /**
  11685. * Gets the current list of start size gradients.
  11686. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11687. * @returns the list of start size gradients
  11688. */
  11689. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11690. /**
  11691. * Gets the current list of emit rate gradients.
  11692. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11693. * @returns the list of emit rate gradients
  11694. */
  11695. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11696. /**
  11697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11698. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11699. */
  11700. get direction1(): Vector3;
  11701. set direction1(value: Vector3);
  11702. /**
  11703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11704. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11705. */
  11706. get direction2(): Vector3;
  11707. set direction2(value: Vector3);
  11708. /**
  11709. * 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.
  11710. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11711. */
  11712. get minEmitBox(): Vector3;
  11713. set minEmitBox(value: Vector3);
  11714. /**
  11715. * 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.
  11716. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11717. */
  11718. get maxEmitBox(): Vector3;
  11719. set maxEmitBox(value: Vector3);
  11720. /**
  11721. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11722. */
  11723. color1: Color4;
  11724. /**
  11725. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11726. */
  11727. color2: Color4;
  11728. /**
  11729. * Color the particle will have at the end of its lifetime
  11730. */
  11731. colorDead: Color4;
  11732. /**
  11733. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11734. */
  11735. textureMask: Color4;
  11736. /**
  11737. * The particle emitter type defines the emitter used by the particle system.
  11738. * It can be for example box, sphere, or cone...
  11739. */
  11740. particleEmitterType: IParticleEmitterType;
  11741. /** @hidden */
  11742. _isSubEmitter: boolean;
  11743. /**
  11744. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11745. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11746. */
  11747. billboardMode: number;
  11748. protected _isBillboardBased: boolean;
  11749. /**
  11750. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11751. */
  11752. get isBillboardBased(): boolean;
  11753. set isBillboardBased(value: boolean);
  11754. /**
  11755. * The scene the particle system belongs to.
  11756. */
  11757. protected _scene: Scene;
  11758. /**
  11759. * Local cache of defines for image processing.
  11760. */
  11761. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11762. /**
  11763. * Default configuration related to image processing available in the standard Material.
  11764. */
  11765. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11766. /**
  11767. * Gets the image processing configuration used either in this material.
  11768. */
  11769. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11770. /**
  11771. * Sets the Default image processing configuration used either in the this material.
  11772. *
  11773. * If sets to null, the scene one is in use.
  11774. */
  11775. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11776. /**
  11777. * Attaches a new image processing configuration to the Standard Material.
  11778. * @param configuration
  11779. */
  11780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11781. /** @hidden */
  11782. protected _reset(): void;
  11783. /** @hidden */
  11784. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11785. /**
  11786. * Instantiates a particle system.
  11787. * 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.
  11788. * @param name The name of the particle system
  11789. */
  11790. constructor(name: string);
  11791. /**
  11792. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11793. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11794. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11795. * @returns the emitter
  11796. */
  11797. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11798. /**
  11799. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11800. * @param radius The radius of the hemisphere to emit from
  11801. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11802. * @returns the emitter
  11803. */
  11804. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11805. /**
  11806. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11807. * @param radius The radius of the sphere to emit from
  11808. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11809. * @returns the emitter
  11810. */
  11811. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11812. /**
  11813. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11814. * @param radius The radius of the sphere to emit from
  11815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11817. * @returns the emitter
  11818. */
  11819. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11820. /**
  11821. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11822. * @param radius The radius of the emission cylinder
  11823. * @param height The height of the emission cylinder
  11824. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11825. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11826. * @returns the emitter
  11827. */
  11828. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11829. /**
  11830. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11831. * @param radius The radius of the cylinder to emit from
  11832. * @param height The height of the emission cylinder
  11833. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11836. * @returns the emitter
  11837. */
  11838. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11839. /**
  11840. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11841. * @param radius The radius of the cone to emit from
  11842. * @param angle The base angle of the cone
  11843. * @returns the emitter
  11844. */
  11845. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11846. /**
  11847. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11850. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11851. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11852. * @returns the emitter
  11853. */
  11854. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11855. }
  11856. }
  11857. declare module "babylonjs/Particles/subEmitter" {
  11858. import { Scene } from "babylonjs/scene";
  11859. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11860. /**
  11861. * Type of sub emitter
  11862. */
  11863. export enum SubEmitterType {
  11864. /**
  11865. * Attached to the particle over it's lifetime
  11866. */
  11867. ATTACHED = 0,
  11868. /**
  11869. * Created when the particle dies
  11870. */
  11871. END = 1
  11872. }
  11873. /**
  11874. * Sub emitter class used to emit particles from an existing particle
  11875. */
  11876. export class SubEmitter {
  11877. /**
  11878. * the particle system to be used by the sub emitter
  11879. */
  11880. particleSystem: ParticleSystem;
  11881. /**
  11882. * Type of the submitter (Default: END)
  11883. */
  11884. type: SubEmitterType;
  11885. /**
  11886. * 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)
  11887. * Note: This only is supported when using an emitter of type Mesh
  11888. */
  11889. inheritDirection: boolean;
  11890. /**
  11891. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11892. */
  11893. inheritedVelocityAmount: number;
  11894. /**
  11895. * Creates a sub emitter
  11896. * @param particleSystem the particle system to be used by the sub emitter
  11897. */
  11898. constructor(
  11899. /**
  11900. * the particle system to be used by the sub emitter
  11901. */
  11902. particleSystem: ParticleSystem);
  11903. /**
  11904. * Clones the sub emitter
  11905. * @returns the cloned sub emitter
  11906. */
  11907. clone(): SubEmitter;
  11908. /**
  11909. * Serialize current object to a JSON object
  11910. * @returns the serialized object
  11911. */
  11912. serialize(): any;
  11913. /** @hidden */
  11914. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11915. /**
  11916. * Creates a new SubEmitter from a serialized JSON version
  11917. * @param serializationObject defines the JSON object to read from
  11918. * @param scene defines the hosting scene
  11919. * @param rootUrl defines the rootUrl for data loading
  11920. * @returns a new SubEmitter
  11921. */
  11922. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11923. /** Release associated resources */
  11924. dispose(): void;
  11925. }
  11926. }
  11927. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11928. /** @hidden */
  11929. export var imageProcessingDeclaration: {
  11930. name: string;
  11931. shader: string;
  11932. };
  11933. }
  11934. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11935. /** @hidden */
  11936. export var imageProcessingFunctions: {
  11937. name: string;
  11938. shader: string;
  11939. };
  11940. }
  11941. declare module "babylonjs/Shaders/particles.fragment" {
  11942. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11943. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11944. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11945. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11946. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11947. /** @hidden */
  11948. export var particlesPixelShader: {
  11949. name: string;
  11950. shader: string;
  11951. };
  11952. }
  11953. declare module "babylonjs/Shaders/particles.vertex" {
  11954. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11955. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11956. /** @hidden */
  11957. export var particlesVertexShader: {
  11958. name: string;
  11959. shader: string;
  11960. };
  11961. }
  11962. declare module "babylonjs/Particles/particleSystem" {
  11963. import { Nullable } from "babylonjs/types";
  11964. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11965. import { Observable } from "babylonjs/Misc/observable";
  11966. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11967. import { Effect } from "babylonjs/Materials/effect";
  11968. import { Scene, IDisposable } from "babylonjs/scene";
  11969. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11970. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11971. import { Particle } from "babylonjs/Particles/particle";
  11972. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11973. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11974. import "babylonjs/Shaders/particles.fragment";
  11975. import "babylonjs/Shaders/particles.vertex";
  11976. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11977. /**
  11978. * This represents a particle system in Babylon.
  11979. * 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.
  11980. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11981. * @example https://doc.babylonjs.com/babylon101/particles
  11982. */
  11983. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11984. /**
  11985. * Billboard mode will only apply to Y axis
  11986. */
  11987. static readonly BILLBOARDMODE_Y: number;
  11988. /**
  11989. * Billboard mode will apply to all axes
  11990. */
  11991. static readonly BILLBOARDMODE_ALL: number;
  11992. /**
  11993. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11994. */
  11995. static readonly BILLBOARDMODE_STRETCHED: number;
  11996. /**
  11997. * This function can be defined to provide custom update for active particles.
  11998. * This function will be called instead of regular update (age, position, color, etc.).
  11999. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12000. */
  12001. updateFunction: (particles: Particle[]) => void;
  12002. private _emitterWorldMatrix;
  12003. /**
  12004. * This function can be defined to specify initial direction for every new particle.
  12005. * It by default use the emitterType defined function
  12006. */
  12007. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12008. /**
  12009. * This function can be defined to specify initial position for every new particle.
  12010. * It by default use the emitterType defined function
  12011. */
  12012. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12013. /**
  12014. * @hidden
  12015. */
  12016. _inheritedVelocityOffset: Vector3;
  12017. /**
  12018. * An event triggered when the system is disposed
  12019. */
  12020. onDisposeObservable: Observable<ParticleSystem>;
  12021. private _onDisposeObserver;
  12022. /**
  12023. * Sets a callback that will be triggered when the system is disposed
  12024. */
  12025. set onDispose(callback: () => void);
  12026. private _particles;
  12027. private _epsilon;
  12028. private _capacity;
  12029. private _stockParticles;
  12030. private _newPartsExcess;
  12031. private _vertexData;
  12032. private _vertexBuffer;
  12033. private _vertexBuffers;
  12034. private _spriteBuffer;
  12035. private _indexBuffer;
  12036. private _effect;
  12037. private _customEffect;
  12038. private _cachedDefines;
  12039. private _scaledColorStep;
  12040. private _colorDiff;
  12041. private _scaledDirection;
  12042. private _scaledGravity;
  12043. private _currentRenderId;
  12044. private _alive;
  12045. private _useInstancing;
  12046. private _started;
  12047. private _stopped;
  12048. private _actualFrame;
  12049. private _scaledUpdateSpeed;
  12050. private _vertexBufferSize;
  12051. /** @hidden */
  12052. _currentEmitRateGradient: Nullable<FactorGradient>;
  12053. /** @hidden */
  12054. _currentEmitRate1: number;
  12055. /** @hidden */
  12056. _currentEmitRate2: number;
  12057. /** @hidden */
  12058. _currentStartSizeGradient: Nullable<FactorGradient>;
  12059. /** @hidden */
  12060. _currentStartSize1: number;
  12061. /** @hidden */
  12062. _currentStartSize2: number;
  12063. private readonly _rawTextureWidth;
  12064. private _rampGradientsTexture;
  12065. private _useRampGradients;
  12066. /** Gets or sets a boolean indicating that ramp gradients must be used
  12067. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12068. */
  12069. get useRampGradients(): boolean;
  12070. set useRampGradients(value: boolean);
  12071. /**
  12072. * 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.
  12073. * 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: [])
  12074. */
  12075. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12076. private _subEmitters;
  12077. /**
  12078. * @hidden
  12079. * If the particle systems emitter should be disposed when the particle system is disposed
  12080. */
  12081. _disposeEmitterOnDispose: boolean;
  12082. /**
  12083. * The current active Sub-systems, this property is used by the root particle system only.
  12084. */
  12085. activeSubSystems: Array<ParticleSystem>;
  12086. /**
  12087. * Specifies if the particles are updated in emitter local space or world space
  12088. */
  12089. isLocal: boolean;
  12090. private _rootParticleSystem;
  12091. /**
  12092. * Gets the current list of active particles
  12093. */
  12094. get particles(): Particle[];
  12095. /**
  12096. * Gets the number of particles active at the same time.
  12097. * @returns The number of active particles.
  12098. */
  12099. getActiveCount(): number;
  12100. /**
  12101. * Returns the string "ParticleSystem"
  12102. * @returns a string containing the class name
  12103. */
  12104. getClassName(): string;
  12105. /**
  12106. * Gets a boolean indicating that the system is stopping
  12107. * @returns true if the system is currently stopping
  12108. */
  12109. isStopping(): boolean;
  12110. /**
  12111. * Instantiates a particle system.
  12112. * 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.
  12113. * @param name The name of the particle system
  12114. * @param capacity The max number of particles alive at the same time
  12115. * @param scene The scene the particle system belongs to
  12116. * @param customEffect a custom effect used to change the way particles are rendered by default
  12117. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12118. * @param epsilon Offset used to render the particles
  12119. */
  12120. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12121. private _addFactorGradient;
  12122. private _removeFactorGradient;
  12123. /**
  12124. * Adds a new life time gradient
  12125. * @param gradient defines the gradient to use (between 0 and 1)
  12126. * @param factor defines the life time factor to affect to the specified gradient
  12127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12128. * @returns the current particle system
  12129. */
  12130. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12131. /**
  12132. * Remove a specific life time gradient
  12133. * @param gradient defines the gradient to remove
  12134. * @returns the current particle system
  12135. */
  12136. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12137. /**
  12138. * Adds a new size gradient
  12139. * @param gradient defines the gradient to use (between 0 and 1)
  12140. * @param factor defines the size factor to affect to the specified gradient
  12141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12142. * @returns the current particle system
  12143. */
  12144. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12145. /**
  12146. * Remove a specific size gradient
  12147. * @param gradient defines the gradient to remove
  12148. * @returns the current particle system
  12149. */
  12150. removeSizeGradient(gradient: number): IParticleSystem;
  12151. /**
  12152. * Adds a new color remap gradient
  12153. * @param gradient defines the gradient to use (between 0 and 1)
  12154. * @param min defines the color remap minimal range
  12155. * @param max defines the color remap maximal range
  12156. * @returns the current particle system
  12157. */
  12158. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12159. /**
  12160. * Remove a specific color remap gradient
  12161. * @param gradient defines the gradient to remove
  12162. * @returns the current particle system
  12163. */
  12164. removeColorRemapGradient(gradient: number): IParticleSystem;
  12165. /**
  12166. * Adds a new alpha remap gradient
  12167. * @param gradient defines the gradient to use (between 0 and 1)
  12168. * @param min defines the alpha remap minimal range
  12169. * @param max defines the alpha remap maximal range
  12170. * @returns the current particle system
  12171. */
  12172. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12173. /**
  12174. * Remove a specific alpha remap gradient
  12175. * @param gradient defines the gradient to remove
  12176. * @returns the current particle system
  12177. */
  12178. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12179. /**
  12180. * Adds a new angular speed gradient
  12181. * @param gradient defines the gradient to use (between 0 and 1)
  12182. * @param factor defines the angular speed to affect to the specified gradient
  12183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12184. * @returns the current particle system
  12185. */
  12186. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12187. /**
  12188. * Remove a specific angular speed gradient
  12189. * @param gradient defines the gradient to remove
  12190. * @returns the current particle system
  12191. */
  12192. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12193. /**
  12194. * Adds a new velocity gradient
  12195. * @param gradient defines the gradient to use (between 0 and 1)
  12196. * @param factor defines the velocity to affect to the specified gradient
  12197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12198. * @returns the current particle system
  12199. */
  12200. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12201. /**
  12202. * Remove a specific velocity gradient
  12203. * @param gradient defines the gradient to remove
  12204. * @returns the current particle system
  12205. */
  12206. removeVelocityGradient(gradient: number): IParticleSystem;
  12207. /**
  12208. * Adds a new limit velocity gradient
  12209. * @param gradient defines the gradient to use (between 0 and 1)
  12210. * @param factor defines the limit velocity value to affect to the specified gradient
  12211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12212. * @returns the current particle system
  12213. */
  12214. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12215. /**
  12216. * Remove a specific limit velocity gradient
  12217. * @param gradient defines the gradient to remove
  12218. * @returns the current particle system
  12219. */
  12220. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12221. /**
  12222. * Adds a new drag gradient
  12223. * @param gradient defines the gradient to use (between 0 and 1)
  12224. * @param factor defines the drag value to affect to the specified gradient
  12225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12226. * @returns the current particle system
  12227. */
  12228. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12229. /**
  12230. * Remove a specific drag gradient
  12231. * @param gradient defines the gradient to remove
  12232. * @returns the current particle system
  12233. */
  12234. removeDragGradient(gradient: number): IParticleSystem;
  12235. /**
  12236. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12237. * @param gradient defines the gradient to use (between 0 and 1)
  12238. * @param factor defines the emit rate value to affect to the specified gradient
  12239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12240. * @returns the current particle system
  12241. */
  12242. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12243. /**
  12244. * Remove a specific emit rate gradient
  12245. * @param gradient defines the gradient to remove
  12246. * @returns the current particle system
  12247. */
  12248. removeEmitRateGradient(gradient: number): IParticleSystem;
  12249. /**
  12250. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12251. * @param gradient defines the gradient to use (between 0 and 1)
  12252. * @param factor defines the start size value to affect to the specified gradient
  12253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12254. * @returns the current particle system
  12255. */
  12256. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12257. /**
  12258. * Remove a specific start size gradient
  12259. * @param gradient defines the gradient to remove
  12260. * @returns the current particle system
  12261. */
  12262. removeStartSizeGradient(gradient: number): IParticleSystem;
  12263. private _createRampGradientTexture;
  12264. /**
  12265. * Gets the current list of ramp gradients.
  12266. * You must use addRampGradient and removeRampGradient to udpate this list
  12267. * @returns the list of ramp gradients
  12268. */
  12269. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12270. /** Force the system to rebuild all gradients that need to be resync */
  12271. forceRefreshGradients(): void;
  12272. private _syncRampGradientTexture;
  12273. /**
  12274. * Adds a new ramp gradient used to remap particle colors
  12275. * @param gradient defines the gradient to use (between 0 and 1)
  12276. * @param color defines the color to affect to the specified gradient
  12277. * @returns the current particle system
  12278. */
  12279. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12280. /**
  12281. * Remove a specific ramp gradient
  12282. * @param gradient defines the gradient to remove
  12283. * @returns the current particle system
  12284. */
  12285. removeRampGradient(gradient: number): ParticleSystem;
  12286. /**
  12287. * Adds a new color gradient
  12288. * @param gradient defines the gradient to use (between 0 and 1)
  12289. * @param color1 defines the color to affect to the specified gradient
  12290. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12291. * @returns this particle system
  12292. */
  12293. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12294. /**
  12295. * Remove a specific color gradient
  12296. * @param gradient defines the gradient to remove
  12297. * @returns this particle system
  12298. */
  12299. removeColorGradient(gradient: number): IParticleSystem;
  12300. private _fetchR;
  12301. protected _reset(): void;
  12302. private _resetEffect;
  12303. private _createVertexBuffers;
  12304. private _createIndexBuffer;
  12305. /**
  12306. * Gets the maximum number of particles active at the same time.
  12307. * @returns The max number of active particles.
  12308. */
  12309. getCapacity(): number;
  12310. /**
  12311. * Gets whether there are still active particles in the system.
  12312. * @returns True if it is alive, otherwise false.
  12313. */
  12314. isAlive(): boolean;
  12315. /**
  12316. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12317. * @returns True if it has been started, otherwise false.
  12318. */
  12319. isStarted(): boolean;
  12320. private _prepareSubEmitterInternalArray;
  12321. /**
  12322. * Starts the particle system and begins to emit
  12323. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12324. */
  12325. start(delay?: number): void;
  12326. /**
  12327. * Stops the particle system.
  12328. * @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.
  12329. */
  12330. stop(stopSubEmitters?: boolean): void;
  12331. /**
  12332. * Remove all active particles
  12333. */
  12334. reset(): void;
  12335. /**
  12336. * @hidden (for internal use only)
  12337. */
  12338. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12339. /**
  12340. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12341. * Its lifetime will start back at 0.
  12342. */
  12343. recycleParticle: (particle: Particle) => void;
  12344. private _stopSubEmitters;
  12345. private _createParticle;
  12346. private _removeFromRoot;
  12347. private _emitFromParticle;
  12348. private _update;
  12349. /** @hidden */
  12350. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12351. /** @hidden */
  12352. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12353. /** @hidden */
  12354. private _getEffect;
  12355. /**
  12356. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12357. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12358. */
  12359. animate(preWarmOnly?: boolean): void;
  12360. private _appendParticleVertices;
  12361. /**
  12362. * Rebuilds the particle system.
  12363. */
  12364. rebuild(): void;
  12365. /**
  12366. * Is this system ready to be used/rendered
  12367. * @return true if the system is ready
  12368. */
  12369. isReady(): boolean;
  12370. private _render;
  12371. /**
  12372. * Renders the particle system in its current state.
  12373. * @returns the current number of particles
  12374. */
  12375. render(): number;
  12376. /**
  12377. * Disposes the particle system and free the associated resources
  12378. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12379. */
  12380. dispose(disposeTexture?: boolean): void;
  12381. /**
  12382. * Clones the particle system.
  12383. * @param name The name of the cloned object
  12384. * @param newEmitter The new emitter to use
  12385. * @returns the cloned particle system
  12386. */
  12387. clone(name: string, newEmitter: any): ParticleSystem;
  12388. /**
  12389. * Serializes the particle system to a JSON object
  12390. * @param serializeTexture defines if the texture must be serialized as well
  12391. * @returns the JSON object
  12392. */
  12393. serialize(serializeTexture?: boolean): any;
  12394. /** @hidden */
  12395. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12396. /** @hidden */
  12397. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12398. /**
  12399. * Parses a JSON object to create a particle system.
  12400. * @param parsedParticleSystem The JSON object to parse
  12401. * @param scene The scene to create the particle system in
  12402. * @param rootUrl The root url to use to load external dependencies like texture
  12403. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12404. * @returns the Parsed particle system
  12405. */
  12406. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12407. }
  12408. }
  12409. declare module "babylonjs/Particles/particle" {
  12410. import { Nullable } from "babylonjs/types";
  12411. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12412. import { Color4 } from "babylonjs/Maths/math.color";
  12413. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12414. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12415. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12416. /**
  12417. * A particle represents one of the element emitted by a particle system.
  12418. * This is mainly define by its coordinates, direction, velocity and age.
  12419. */
  12420. export class Particle {
  12421. /**
  12422. * The particle system the particle belongs to.
  12423. */
  12424. particleSystem: ParticleSystem;
  12425. private static _Count;
  12426. /**
  12427. * Unique ID of the particle
  12428. */
  12429. id: number;
  12430. /**
  12431. * The world position of the particle in the scene.
  12432. */
  12433. position: Vector3;
  12434. /**
  12435. * The world direction of the particle in the scene.
  12436. */
  12437. direction: Vector3;
  12438. /**
  12439. * The color of the particle.
  12440. */
  12441. color: Color4;
  12442. /**
  12443. * The color change of the particle per step.
  12444. */
  12445. colorStep: Color4;
  12446. /**
  12447. * Defines how long will the life of the particle be.
  12448. */
  12449. lifeTime: number;
  12450. /**
  12451. * The current age of the particle.
  12452. */
  12453. age: number;
  12454. /**
  12455. * The current size of the particle.
  12456. */
  12457. size: number;
  12458. /**
  12459. * The current scale of the particle.
  12460. */
  12461. scale: Vector2;
  12462. /**
  12463. * The current angle of the particle.
  12464. */
  12465. angle: number;
  12466. /**
  12467. * Defines how fast is the angle changing.
  12468. */
  12469. angularSpeed: number;
  12470. /**
  12471. * Defines the cell index used by the particle to be rendered from a sprite.
  12472. */
  12473. cellIndex: number;
  12474. /**
  12475. * The information required to support color remapping
  12476. */
  12477. remapData: Vector4;
  12478. /** @hidden */
  12479. _randomCellOffset?: number;
  12480. /** @hidden */
  12481. _initialDirection: Nullable<Vector3>;
  12482. /** @hidden */
  12483. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12484. /** @hidden */
  12485. _initialStartSpriteCellID: number;
  12486. /** @hidden */
  12487. _initialEndSpriteCellID: number;
  12488. /** @hidden */
  12489. _currentColorGradient: Nullable<ColorGradient>;
  12490. /** @hidden */
  12491. _currentColor1: Color4;
  12492. /** @hidden */
  12493. _currentColor2: Color4;
  12494. /** @hidden */
  12495. _currentSizeGradient: Nullable<FactorGradient>;
  12496. /** @hidden */
  12497. _currentSize1: number;
  12498. /** @hidden */
  12499. _currentSize2: number;
  12500. /** @hidden */
  12501. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12502. /** @hidden */
  12503. _currentAngularSpeed1: number;
  12504. /** @hidden */
  12505. _currentAngularSpeed2: number;
  12506. /** @hidden */
  12507. _currentVelocityGradient: Nullable<FactorGradient>;
  12508. /** @hidden */
  12509. _currentVelocity1: number;
  12510. /** @hidden */
  12511. _currentVelocity2: number;
  12512. /** @hidden */
  12513. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12514. /** @hidden */
  12515. _currentLimitVelocity1: number;
  12516. /** @hidden */
  12517. _currentLimitVelocity2: number;
  12518. /** @hidden */
  12519. _currentDragGradient: Nullable<FactorGradient>;
  12520. /** @hidden */
  12521. _currentDrag1: number;
  12522. /** @hidden */
  12523. _currentDrag2: number;
  12524. /** @hidden */
  12525. _randomNoiseCoordinates1: Vector3;
  12526. /** @hidden */
  12527. _randomNoiseCoordinates2: Vector3;
  12528. /** @hidden */
  12529. _localPosition?: Vector3;
  12530. /**
  12531. * Creates a new instance Particle
  12532. * @param particleSystem the particle system the particle belongs to
  12533. */
  12534. constructor(
  12535. /**
  12536. * The particle system the particle belongs to.
  12537. */
  12538. particleSystem: ParticleSystem);
  12539. private updateCellInfoFromSystem;
  12540. /**
  12541. * Defines how the sprite cell index is updated for the particle
  12542. */
  12543. updateCellIndex(): void;
  12544. /** @hidden */
  12545. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12546. /** @hidden */
  12547. _inheritParticleInfoToSubEmitters(): void;
  12548. /** @hidden */
  12549. _reset(): void;
  12550. /**
  12551. * Copy the properties of particle to another one.
  12552. * @param other the particle to copy the information to.
  12553. */
  12554. copyTo(other: Particle): void;
  12555. }
  12556. }
  12557. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12558. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12559. import { Effect } from "babylonjs/Materials/effect";
  12560. import { Particle } from "babylonjs/Particles/particle";
  12561. import { Scene } from "babylonjs/scene";
  12562. /**
  12563. * Particle emitter represents a volume emitting particles.
  12564. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12565. */
  12566. export interface IParticleEmitterType {
  12567. /**
  12568. * Called by the particle System when the direction is computed for the created particle.
  12569. * @param worldMatrix is the world matrix of the particle system
  12570. * @param directionToUpdate is the direction vector to update with the result
  12571. * @param particle is the particle we are computed the direction for
  12572. * @param isLocal defines if the direction should be set in local space
  12573. */
  12574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12575. /**
  12576. * Called by the particle System when the position is computed for the created particle.
  12577. * @param worldMatrix is the world matrix of the particle system
  12578. * @param positionToUpdate is the position vector to update with the result
  12579. * @param particle is the particle we are computed the position for
  12580. * @param isLocal defines if the position should be set in local space
  12581. */
  12582. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12583. /**
  12584. * Clones the current emitter and returns a copy of it
  12585. * @returns the new emitter
  12586. */
  12587. clone(): IParticleEmitterType;
  12588. /**
  12589. * Called by the GPUParticleSystem to setup the update shader
  12590. * @param effect defines the update shader
  12591. */
  12592. applyToShader(effect: Effect): void;
  12593. /**
  12594. * Returns a string to use to update the GPU particles update shader
  12595. * @returns the effect defines string
  12596. */
  12597. getEffectDefines(): string;
  12598. /**
  12599. * Returns a string representing the class name
  12600. * @returns a string containing the class name
  12601. */
  12602. getClassName(): string;
  12603. /**
  12604. * Serializes the particle system to a JSON object.
  12605. * @returns the JSON object
  12606. */
  12607. serialize(): any;
  12608. /**
  12609. * Parse properties from a JSON object
  12610. * @param serializationObject defines the JSON object
  12611. * @param scene defines the hosting scene
  12612. */
  12613. parse(serializationObject: any, scene: Scene): void;
  12614. }
  12615. }
  12616. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12617. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12618. import { Effect } from "babylonjs/Materials/effect";
  12619. import { Particle } from "babylonjs/Particles/particle";
  12620. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12621. /**
  12622. * Particle emitter emitting particles from the inside of a box.
  12623. * It emits the particles randomly between 2 given directions.
  12624. */
  12625. export class BoxParticleEmitter implements IParticleEmitterType {
  12626. /**
  12627. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12628. */
  12629. direction1: Vector3;
  12630. /**
  12631. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12632. */
  12633. direction2: Vector3;
  12634. /**
  12635. * 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.
  12636. */
  12637. minEmitBox: Vector3;
  12638. /**
  12639. * 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.
  12640. */
  12641. maxEmitBox: Vector3;
  12642. /**
  12643. * Creates a new instance BoxParticleEmitter
  12644. */
  12645. constructor();
  12646. /**
  12647. * Called by the particle System when the direction is computed for the created particle.
  12648. * @param worldMatrix is the world matrix of the particle system
  12649. * @param directionToUpdate is the direction vector to update with the result
  12650. * @param particle is the particle we are computed the direction for
  12651. * @param isLocal defines if the direction should be set in local space
  12652. */
  12653. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12654. /**
  12655. * Called by the particle System when the position is computed for the created particle.
  12656. * @param worldMatrix is the world matrix of the particle system
  12657. * @param positionToUpdate is the position vector to update with the result
  12658. * @param particle is the particle we are computed the position for
  12659. * @param isLocal defines if the position should be set in local space
  12660. */
  12661. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12662. /**
  12663. * Clones the current emitter and returns a copy of it
  12664. * @returns the new emitter
  12665. */
  12666. clone(): BoxParticleEmitter;
  12667. /**
  12668. * Called by the GPUParticleSystem to setup the update shader
  12669. * @param effect defines the update shader
  12670. */
  12671. applyToShader(effect: Effect): void;
  12672. /**
  12673. * Returns a string to use to update the GPU particles update shader
  12674. * @returns a string containng the defines string
  12675. */
  12676. getEffectDefines(): string;
  12677. /**
  12678. * Returns the string "BoxParticleEmitter"
  12679. * @returns a string containing the class name
  12680. */
  12681. getClassName(): string;
  12682. /**
  12683. * Serializes the particle system to a JSON object.
  12684. * @returns the JSON object
  12685. */
  12686. serialize(): any;
  12687. /**
  12688. * Parse properties from a JSON object
  12689. * @param serializationObject defines the JSON object
  12690. */
  12691. parse(serializationObject: any): void;
  12692. }
  12693. }
  12694. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12695. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12696. import { Effect } from "babylonjs/Materials/effect";
  12697. import { Particle } from "babylonjs/Particles/particle";
  12698. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12699. /**
  12700. * Particle emitter emitting particles from the inside of a cone.
  12701. * It emits the particles alongside the cone volume from the base to the particle.
  12702. * The emission direction might be randomized.
  12703. */
  12704. export class ConeParticleEmitter implements IParticleEmitterType {
  12705. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12706. directionRandomizer: number;
  12707. private _radius;
  12708. private _angle;
  12709. private _height;
  12710. /**
  12711. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12712. */
  12713. radiusRange: number;
  12714. /**
  12715. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12716. */
  12717. heightRange: number;
  12718. /**
  12719. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12720. */
  12721. emitFromSpawnPointOnly: boolean;
  12722. /**
  12723. * Gets or sets the radius of the emission cone
  12724. */
  12725. get radius(): number;
  12726. set radius(value: number);
  12727. /**
  12728. * Gets or sets the angle of the emission cone
  12729. */
  12730. get angle(): number;
  12731. set angle(value: number);
  12732. private _buildHeight;
  12733. /**
  12734. * Creates a new instance ConeParticleEmitter
  12735. * @param radius the radius of the emission cone (1 by default)
  12736. * @param angle the cone base angle (PI by default)
  12737. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12738. */
  12739. constructor(radius?: number, angle?: number,
  12740. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12741. directionRandomizer?: number);
  12742. /**
  12743. * Called by the particle System when the direction is computed for the created particle.
  12744. * @param worldMatrix is the world matrix of the particle system
  12745. * @param directionToUpdate is the direction vector to update with the result
  12746. * @param particle is the particle we are computed the direction for
  12747. * @param isLocal defines if the direction should be set in local space
  12748. */
  12749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12750. /**
  12751. * Called by the particle System when the position is computed for the created particle.
  12752. * @param worldMatrix is the world matrix of the particle system
  12753. * @param positionToUpdate is the position vector to update with the result
  12754. * @param particle is the particle we are computed the position for
  12755. * @param isLocal defines if the position should be set in local space
  12756. */
  12757. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12758. /**
  12759. * Clones the current emitter and returns a copy of it
  12760. * @returns the new emitter
  12761. */
  12762. clone(): ConeParticleEmitter;
  12763. /**
  12764. * Called by the GPUParticleSystem to setup the update shader
  12765. * @param effect defines the update shader
  12766. */
  12767. applyToShader(effect: Effect): void;
  12768. /**
  12769. * Returns a string to use to update the GPU particles update shader
  12770. * @returns a string containng the defines string
  12771. */
  12772. getEffectDefines(): string;
  12773. /**
  12774. * Returns the string "ConeParticleEmitter"
  12775. * @returns a string containing the class name
  12776. */
  12777. getClassName(): string;
  12778. /**
  12779. * Serializes the particle system to a JSON object.
  12780. * @returns the JSON object
  12781. */
  12782. serialize(): any;
  12783. /**
  12784. * Parse properties from a JSON object
  12785. * @param serializationObject defines the JSON object
  12786. */
  12787. parse(serializationObject: any): void;
  12788. }
  12789. }
  12790. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12791. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12792. import { Effect } from "babylonjs/Materials/effect";
  12793. import { Particle } from "babylonjs/Particles/particle";
  12794. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12795. /**
  12796. * Particle emitter emitting particles from the inside of a cylinder.
  12797. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12798. */
  12799. export class CylinderParticleEmitter implements IParticleEmitterType {
  12800. /**
  12801. * The radius of the emission cylinder.
  12802. */
  12803. radius: number;
  12804. /**
  12805. * The height of the emission cylinder.
  12806. */
  12807. height: number;
  12808. /**
  12809. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12810. */
  12811. radiusRange: number;
  12812. /**
  12813. * How much to randomize the particle direction [0-1].
  12814. */
  12815. directionRandomizer: number;
  12816. /**
  12817. * Creates a new instance CylinderParticleEmitter
  12818. * @param radius the radius of the emission cylinder (1 by default)
  12819. * @param height the height of the emission cylinder (1 by default)
  12820. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12822. */
  12823. constructor(
  12824. /**
  12825. * The radius of the emission cylinder.
  12826. */
  12827. radius?: number,
  12828. /**
  12829. * The height of the emission cylinder.
  12830. */
  12831. height?: number,
  12832. /**
  12833. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12834. */
  12835. radiusRange?: number,
  12836. /**
  12837. * How much to randomize the particle direction [0-1].
  12838. */
  12839. directionRandomizer?: number);
  12840. /**
  12841. * Called by the particle System when the direction is computed for the created particle.
  12842. * @param worldMatrix is the world matrix of the particle system
  12843. * @param directionToUpdate is the direction vector to update with the result
  12844. * @param particle is the particle we are computed the direction for
  12845. * @param isLocal defines if the direction should be set in local space
  12846. */
  12847. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12848. /**
  12849. * Called by the particle System when the position is computed for the created particle.
  12850. * @param worldMatrix is the world matrix of the particle system
  12851. * @param positionToUpdate is the position vector to update with the result
  12852. * @param particle is the particle we are computed the position for
  12853. * @param isLocal defines if the position should be set in local space
  12854. */
  12855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12856. /**
  12857. * Clones the current emitter and returns a copy of it
  12858. * @returns the new emitter
  12859. */
  12860. clone(): CylinderParticleEmitter;
  12861. /**
  12862. * Called by the GPUParticleSystem to setup the update shader
  12863. * @param effect defines the update shader
  12864. */
  12865. applyToShader(effect: Effect): void;
  12866. /**
  12867. * Returns a string to use to update the GPU particles update shader
  12868. * @returns a string containng the defines string
  12869. */
  12870. getEffectDefines(): string;
  12871. /**
  12872. * Returns the string "CylinderParticleEmitter"
  12873. * @returns a string containing the class name
  12874. */
  12875. getClassName(): string;
  12876. /**
  12877. * Serializes the particle system to a JSON object.
  12878. * @returns the JSON object
  12879. */
  12880. serialize(): any;
  12881. /**
  12882. * Parse properties from a JSON object
  12883. * @param serializationObject defines the JSON object
  12884. */
  12885. parse(serializationObject: any): void;
  12886. }
  12887. /**
  12888. * Particle emitter emitting particles from the inside of a cylinder.
  12889. * It emits the particles randomly between two vectors.
  12890. */
  12891. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12892. /**
  12893. * The min limit of the emission direction.
  12894. */
  12895. direction1: Vector3;
  12896. /**
  12897. * The max limit of the emission direction.
  12898. */
  12899. direction2: Vector3;
  12900. /**
  12901. * Creates a new instance CylinderDirectedParticleEmitter
  12902. * @param radius the radius of the emission cylinder (1 by default)
  12903. * @param height the height of the emission cylinder (1 by default)
  12904. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12905. * @param direction1 the min limit of the emission direction (up vector by default)
  12906. * @param direction2 the max limit of the emission direction (up vector by default)
  12907. */
  12908. constructor(radius?: number, height?: number, radiusRange?: number,
  12909. /**
  12910. * The min limit of the emission direction.
  12911. */
  12912. direction1?: Vector3,
  12913. /**
  12914. * The max limit of the emission direction.
  12915. */
  12916. direction2?: Vector3);
  12917. /**
  12918. * Called by the particle System when the direction is computed for the created particle.
  12919. * @param worldMatrix is the world matrix of the particle system
  12920. * @param directionToUpdate is the direction vector to update with the result
  12921. * @param particle is the particle we are computed the direction for
  12922. */
  12923. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12924. /**
  12925. * Clones the current emitter and returns a copy of it
  12926. * @returns the new emitter
  12927. */
  12928. clone(): CylinderDirectedParticleEmitter;
  12929. /**
  12930. * Called by the GPUParticleSystem to setup the update shader
  12931. * @param effect defines the update shader
  12932. */
  12933. applyToShader(effect: Effect): void;
  12934. /**
  12935. * Returns a string to use to update the GPU particles update shader
  12936. * @returns a string containng the defines string
  12937. */
  12938. getEffectDefines(): string;
  12939. /**
  12940. * Returns the string "CylinderDirectedParticleEmitter"
  12941. * @returns a string containing the class name
  12942. */
  12943. getClassName(): string;
  12944. /**
  12945. * Serializes the particle system to a JSON object.
  12946. * @returns the JSON object
  12947. */
  12948. serialize(): any;
  12949. /**
  12950. * Parse properties from a JSON object
  12951. * @param serializationObject defines the JSON object
  12952. */
  12953. parse(serializationObject: any): void;
  12954. }
  12955. }
  12956. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12957. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12958. import { Effect } from "babylonjs/Materials/effect";
  12959. import { Particle } from "babylonjs/Particles/particle";
  12960. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12961. /**
  12962. * Particle emitter emitting particles from the inside of a hemisphere.
  12963. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12964. */
  12965. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12966. /**
  12967. * The radius of the emission hemisphere.
  12968. */
  12969. radius: number;
  12970. /**
  12971. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12972. */
  12973. radiusRange: number;
  12974. /**
  12975. * How much to randomize the particle direction [0-1].
  12976. */
  12977. directionRandomizer: number;
  12978. /**
  12979. * Creates a new instance HemisphericParticleEmitter
  12980. * @param radius the radius of the emission hemisphere (1 by default)
  12981. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12982. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12983. */
  12984. constructor(
  12985. /**
  12986. * The radius of the emission hemisphere.
  12987. */
  12988. radius?: number,
  12989. /**
  12990. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12991. */
  12992. radiusRange?: number,
  12993. /**
  12994. * How much to randomize the particle direction [0-1].
  12995. */
  12996. directionRandomizer?: number);
  12997. /**
  12998. * Called by the particle System when the direction is computed for the created particle.
  12999. * @param worldMatrix is the world matrix of the particle system
  13000. * @param directionToUpdate is the direction vector to update with the result
  13001. * @param particle is the particle we are computed the direction for
  13002. * @param isLocal defines if the direction should be set in local space
  13003. */
  13004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13005. /**
  13006. * Called by the particle System when the position is computed for the created particle.
  13007. * @param worldMatrix is the world matrix of the particle system
  13008. * @param positionToUpdate is the position vector to update with the result
  13009. * @param particle is the particle we are computed the position for
  13010. * @param isLocal defines if the position should be set in local space
  13011. */
  13012. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13013. /**
  13014. * Clones the current emitter and returns a copy of it
  13015. * @returns the new emitter
  13016. */
  13017. clone(): HemisphericParticleEmitter;
  13018. /**
  13019. * Called by the GPUParticleSystem to setup the update shader
  13020. * @param effect defines the update shader
  13021. */
  13022. applyToShader(effect: Effect): void;
  13023. /**
  13024. * Returns a string to use to update the GPU particles update shader
  13025. * @returns a string containng the defines string
  13026. */
  13027. getEffectDefines(): string;
  13028. /**
  13029. * Returns the string "HemisphericParticleEmitter"
  13030. * @returns a string containing the class name
  13031. */
  13032. getClassName(): string;
  13033. /**
  13034. * Serializes the particle system to a JSON object.
  13035. * @returns the JSON object
  13036. */
  13037. serialize(): any;
  13038. /**
  13039. * Parse properties from a JSON object
  13040. * @param serializationObject defines the JSON object
  13041. */
  13042. parse(serializationObject: any): void;
  13043. }
  13044. }
  13045. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13046. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13047. import { Effect } from "babylonjs/Materials/effect";
  13048. import { Particle } from "babylonjs/Particles/particle";
  13049. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13050. /**
  13051. * Particle emitter emitting particles from a point.
  13052. * It emits the particles randomly between 2 given directions.
  13053. */
  13054. export class PointParticleEmitter implements IParticleEmitterType {
  13055. /**
  13056. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13057. */
  13058. direction1: Vector3;
  13059. /**
  13060. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13061. */
  13062. direction2: Vector3;
  13063. /**
  13064. * Creates a new instance PointParticleEmitter
  13065. */
  13066. constructor();
  13067. /**
  13068. * Called by the particle System when the direction is computed for the created particle.
  13069. * @param worldMatrix is the world matrix of the particle system
  13070. * @param directionToUpdate is the direction vector to update with the result
  13071. * @param particle is the particle we are computed the direction for
  13072. * @param isLocal defines if the direction should be set in local space
  13073. */
  13074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13075. /**
  13076. * Called by the particle System when the position is computed for the created particle.
  13077. * @param worldMatrix is the world matrix of the particle system
  13078. * @param positionToUpdate is the position vector to update with the result
  13079. * @param particle is the particle we are computed the position for
  13080. * @param isLocal defines if the position should be set in local space
  13081. */
  13082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13083. /**
  13084. * Clones the current emitter and returns a copy of it
  13085. * @returns the new emitter
  13086. */
  13087. clone(): PointParticleEmitter;
  13088. /**
  13089. * Called by the GPUParticleSystem to setup the update shader
  13090. * @param effect defines the update shader
  13091. */
  13092. applyToShader(effect: Effect): void;
  13093. /**
  13094. * Returns a string to use to update the GPU particles update shader
  13095. * @returns a string containng the defines string
  13096. */
  13097. getEffectDefines(): string;
  13098. /**
  13099. * Returns the string "PointParticleEmitter"
  13100. * @returns a string containing the class name
  13101. */
  13102. getClassName(): string;
  13103. /**
  13104. * Serializes the particle system to a JSON object.
  13105. * @returns the JSON object
  13106. */
  13107. serialize(): any;
  13108. /**
  13109. * Parse properties from a JSON object
  13110. * @param serializationObject defines the JSON object
  13111. */
  13112. parse(serializationObject: any): void;
  13113. }
  13114. }
  13115. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13116. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13117. import { Effect } from "babylonjs/Materials/effect";
  13118. import { Particle } from "babylonjs/Particles/particle";
  13119. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13120. /**
  13121. * Particle emitter emitting particles from the inside of a sphere.
  13122. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13123. */
  13124. export class SphereParticleEmitter implements IParticleEmitterType {
  13125. /**
  13126. * The radius of the emission sphere.
  13127. */
  13128. radius: number;
  13129. /**
  13130. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13131. */
  13132. radiusRange: number;
  13133. /**
  13134. * How much to randomize the particle direction [0-1].
  13135. */
  13136. directionRandomizer: number;
  13137. /**
  13138. * Creates a new instance SphereParticleEmitter
  13139. * @param radius the radius of the emission sphere (1 by default)
  13140. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13141. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13142. */
  13143. constructor(
  13144. /**
  13145. * The radius of the emission sphere.
  13146. */
  13147. radius?: number,
  13148. /**
  13149. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13150. */
  13151. radiusRange?: number,
  13152. /**
  13153. * How much to randomize the particle direction [0-1].
  13154. */
  13155. directionRandomizer?: number);
  13156. /**
  13157. * Called by the particle System when the direction is computed for the created particle.
  13158. * @param worldMatrix is the world matrix of the particle system
  13159. * @param directionToUpdate is the direction vector to update with the result
  13160. * @param particle is the particle we are computed the direction for
  13161. * @param isLocal defines if the direction should be set in local space
  13162. */
  13163. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13164. /**
  13165. * Called by the particle System when the position is computed for the created particle.
  13166. * @param worldMatrix is the world matrix of the particle system
  13167. * @param positionToUpdate is the position vector to update with the result
  13168. * @param particle is the particle we are computed the position for
  13169. * @param isLocal defines if the position should be set in local space
  13170. */
  13171. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13172. /**
  13173. * Clones the current emitter and returns a copy of it
  13174. * @returns the new emitter
  13175. */
  13176. clone(): SphereParticleEmitter;
  13177. /**
  13178. * Called by the GPUParticleSystem to setup the update shader
  13179. * @param effect defines the update shader
  13180. */
  13181. applyToShader(effect: Effect): void;
  13182. /**
  13183. * Returns a string to use to update the GPU particles update shader
  13184. * @returns a string containng the defines string
  13185. */
  13186. getEffectDefines(): string;
  13187. /**
  13188. * Returns the string "SphereParticleEmitter"
  13189. * @returns a string containing the class name
  13190. */
  13191. getClassName(): string;
  13192. /**
  13193. * Serializes the particle system to a JSON object.
  13194. * @returns the JSON object
  13195. */
  13196. serialize(): any;
  13197. /**
  13198. * Parse properties from a JSON object
  13199. * @param serializationObject defines the JSON object
  13200. */
  13201. parse(serializationObject: any): void;
  13202. }
  13203. /**
  13204. * Particle emitter emitting particles from the inside of a sphere.
  13205. * It emits the particles randomly between two vectors.
  13206. */
  13207. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13208. /**
  13209. * The min limit of the emission direction.
  13210. */
  13211. direction1: Vector3;
  13212. /**
  13213. * The max limit of the emission direction.
  13214. */
  13215. direction2: Vector3;
  13216. /**
  13217. * Creates a new instance SphereDirectedParticleEmitter
  13218. * @param radius the radius of the emission sphere (1 by default)
  13219. * @param direction1 the min limit of the emission direction (up vector by default)
  13220. * @param direction2 the max limit of the emission direction (up vector by default)
  13221. */
  13222. constructor(radius?: number,
  13223. /**
  13224. * The min limit of the emission direction.
  13225. */
  13226. direction1?: Vector3,
  13227. /**
  13228. * The max limit of the emission direction.
  13229. */
  13230. direction2?: Vector3);
  13231. /**
  13232. * Called by the particle System when the direction is computed for the created particle.
  13233. * @param worldMatrix is the world matrix of the particle system
  13234. * @param directionToUpdate is the direction vector to update with the result
  13235. * @param particle is the particle we are computed the direction for
  13236. */
  13237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13238. /**
  13239. * Clones the current emitter and returns a copy of it
  13240. * @returns the new emitter
  13241. */
  13242. clone(): SphereDirectedParticleEmitter;
  13243. /**
  13244. * Called by the GPUParticleSystem to setup the update shader
  13245. * @param effect defines the update shader
  13246. */
  13247. applyToShader(effect: Effect): void;
  13248. /**
  13249. * Returns a string to use to update the GPU particles update shader
  13250. * @returns a string containng the defines string
  13251. */
  13252. getEffectDefines(): string;
  13253. /**
  13254. * Returns the string "SphereDirectedParticleEmitter"
  13255. * @returns a string containing the class name
  13256. */
  13257. getClassName(): string;
  13258. /**
  13259. * Serializes the particle system to a JSON object.
  13260. * @returns the JSON object
  13261. */
  13262. serialize(): any;
  13263. /**
  13264. * Parse properties from a JSON object
  13265. * @param serializationObject defines the JSON object
  13266. */
  13267. parse(serializationObject: any): void;
  13268. }
  13269. }
  13270. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13271. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13272. import { Effect } from "babylonjs/Materials/effect";
  13273. import { Particle } from "babylonjs/Particles/particle";
  13274. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13275. import { Nullable } from "babylonjs/types";
  13276. /**
  13277. * Particle emitter emitting particles from a custom list of positions.
  13278. */
  13279. export class CustomParticleEmitter implements IParticleEmitterType {
  13280. /**
  13281. * Gets or sets the position generator that will create the inital position of each particle.
  13282. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13283. */
  13284. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13285. /**
  13286. * Gets or sets the destination generator that will create the final destination of each particle.
  13287. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13288. */
  13289. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13290. /**
  13291. * Creates a new instance CustomParticleEmitter
  13292. */
  13293. constructor();
  13294. /**
  13295. * Called by the particle System when the direction is computed for the created particle.
  13296. * @param worldMatrix is the world matrix of the particle system
  13297. * @param directionToUpdate is the direction vector to update with the result
  13298. * @param particle is the particle we are computed the direction for
  13299. * @param isLocal defines if the direction should be set in local space
  13300. */
  13301. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13302. /**
  13303. * Called by the particle System when the position is computed for the created particle.
  13304. * @param worldMatrix is the world matrix of the particle system
  13305. * @param positionToUpdate is the position vector to update with the result
  13306. * @param particle is the particle we are computed the position for
  13307. * @param isLocal defines if the position should be set in local space
  13308. */
  13309. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13310. /**
  13311. * Clones the current emitter and returns a copy of it
  13312. * @returns the new emitter
  13313. */
  13314. clone(): CustomParticleEmitter;
  13315. /**
  13316. * Called by the GPUParticleSystem to setup the update shader
  13317. * @param effect defines the update shader
  13318. */
  13319. applyToShader(effect: Effect): void;
  13320. /**
  13321. * Returns a string to use to update the GPU particles update shader
  13322. * @returns a string containng the defines string
  13323. */
  13324. getEffectDefines(): string;
  13325. /**
  13326. * Returns the string "PointParticleEmitter"
  13327. * @returns a string containing the class name
  13328. */
  13329. getClassName(): string;
  13330. /**
  13331. * Serializes the particle system to a JSON object.
  13332. * @returns the JSON object
  13333. */
  13334. serialize(): any;
  13335. /**
  13336. * Parse properties from a JSON object
  13337. * @param serializationObject defines the JSON object
  13338. */
  13339. parse(serializationObject: any): void;
  13340. }
  13341. }
  13342. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13343. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13344. import { Effect } from "babylonjs/Materials/effect";
  13345. import { Particle } from "babylonjs/Particles/particle";
  13346. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13347. import { Nullable } from "babylonjs/types";
  13348. import { Scene } from "babylonjs/scene";
  13349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13350. /**
  13351. * Particle emitter emitting particles from the inside of a box.
  13352. * It emits the particles randomly between 2 given directions.
  13353. */
  13354. export class MeshParticleEmitter implements IParticleEmitterType {
  13355. private _indices;
  13356. private _positions;
  13357. private _normals;
  13358. private _storedNormal;
  13359. private _mesh;
  13360. /**
  13361. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13362. */
  13363. direction1: Vector3;
  13364. /**
  13365. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13366. */
  13367. direction2: Vector3;
  13368. /**
  13369. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13370. */
  13371. useMeshNormalsForDirection: boolean;
  13372. /** Defines the mesh to use as source */
  13373. get mesh(): Nullable<AbstractMesh>;
  13374. set mesh(value: Nullable<AbstractMesh>);
  13375. /**
  13376. * Creates a new instance MeshParticleEmitter
  13377. * @param mesh defines the mesh to use as source
  13378. */
  13379. constructor(mesh?: Nullable<AbstractMesh>);
  13380. /**
  13381. * Called by the particle System when the direction is computed for the created particle.
  13382. * @param worldMatrix is the world matrix of the particle system
  13383. * @param directionToUpdate is the direction vector to update with the result
  13384. * @param particle is the particle we are computed the direction for
  13385. * @param isLocal defines if the direction should be set in local space
  13386. */
  13387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13388. /**
  13389. * Called by the particle System when the position is computed for the created particle.
  13390. * @param worldMatrix is the world matrix of the particle system
  13391. * @param positionToUpdate is the position vector to update with the result
  13392. * @param particle is the particle we are computed the position for
  13393. * @param isLocal defines if the position should be set in local space
  13394. */
  13395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13396. /**
  13397. * Clones the current emitter and returns a copy of it
  13398. * @returns the new emitter
  13399. */
  13400. clone(): MeshParticleEmitter;
  13401. /**
  13402. * Called by the GPUParticleSystem to setup the update shader
  13403. * @param effect defines the update shader
  13404. */
  13405. applyToShader(effect: Effect): void;
  13406. /**
  13407. * Returns a string to use to update the GPU particles update shader
  13408. * @returns a string containng the defines string
  13409. */
  13410. getEffectDefines(): string;
  13411. /**
  13412. * Returns the string "BoxParticleEmitter"
  13413. * @returns a string containing the class name
  13414. */
  13415. getClassName(): string;
  13416. /**
  13417. * Serializes the particle system to a JSON object.
  13418. * @returns the JSON object
  13419. */
  13420. serialize(): any;
  13421. /**
  13422. * Parse properties from a JSON object
  13423. * @param serializationObject defines the JSON object
  13424. * @param scene defines the hosting scene
  13425. */
  13426. parse(serializationObject: any, scene: Scene): void;
  13427. }
  13428. }
  13429. declare module "babylonjs/Particles/EmitterTypes/index" {
  13430. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13431. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13432. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13433. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13434. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13435. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13436. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13437. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13438. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13439. }
  13440. declare module "babylonjs/Particles/IParticleSystem" {
  13441. import { Nullable } from "babylonjs/types";
  13442. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13443. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13446. import { Texture } from "babylonjs/Materials/Textures/texture";
  13447. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13448. import { Scene } from "babylonjs/scene";
  13449. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13450. import { Animation } from "babylonjs/Animations/animation";
  13451. /**
  13452. * Interface representing a particle system in Babylon.js.
  13453. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13454. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13455. */
  13456. export interface IParticleSystem {
  13457. /**
  13458. * List of animations used by the particle system.
  13459. */
  13460. animations: Animation[];
  13461. /**
  13462. * The id of the Particle system.
  13463. */
  13464. id: string;
  13465. /**
  13466. * The name of the Particle system.
  13467. */
  13468. name: string;
  13469. /**
  13470. * The emitter represents the Mesh or position we are attaching the particle system to.
  13471. */
  13472. emitter: Nullable<AbstractMesh | Vector3>;
  13473. /**
  13474. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13475. */
  13476. isBillboardBased: boolean;
  13477. /**
  13478. * The rendering group used by the Particle system to chose when to render.
  13479. */
  13480. renderingGroupId: number;
  13481. /**
  13482. * The layer mask we are rendering the particles through.
  13483. */
  13484. layerMask: number;
  13485. /**
  13486. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13487. */
  13488. updateSpeed: number;
  13489. /**
  13490. * The amount of time the particle system is running (depends of the overall update speed).
  13491. */
  13492. targetStopDuration: number;
  13493. /**
  13494. * The texture used to render each particle. (this can be a spritesheet)
  13495. */
  13496. particleTexture: Nullable<Texture>;
  13497. /**
  13498. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13499. */
  13500. blendMode: number;
  13501. /**
  13502. * Minimum life time of emitting particles.
  13503. */
  13504. minLifeTime: number;
  13505. /**
  13506. * Maximum life time of emitting particles.
  13507. */
  13508. maxLifeTime: number;
  13509. /**
  13510. * Minimum Size of emitting particles.
  13511. */
  13512. minSize: number;
  13513. /**
  13514. * Maximum Size of emitting particles.
  13515. */
  13516. maxSize: number;
  13517. /**
  13518. * Minimum scale of emitting particles on X axis.
  13519. */
  13520. minScaleX: number;
  13521. /**
  13522. * Maximum scale of emitting particles on X axis.
  13523. */
  13524. maxScaleX: number;
  13525. /**
  13526. * Minimum scale of emitting particles on Y axis.
  13527. */
  13528. minScaleY: number;
  13529. /**
  13530. * Maximum scale of emitting particles on Y axis.
  13531. */
  13532. maxScaleY: number;
  13533. /**
  13534. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13535. */
  13536. color1: Color4;
  13537. /**
  13538. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13539. */
  13540. color2: Color4;
  13541. /**
  13542. * Color the particle will have at the end of its lifetime.
  13543. */
  13544. colorDead: Color4;
  13545. /**
  13546. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13547. */
  13548. emitRate: number;
  13549. /**
  13550. * You can use gravity if you want to give an orientation to your particles.
  13551. */
  13552. gravity: Vector3;
  13553. /**
  13554. * Minimum power of emitting particles.
  13555. */
  13556. minEmitPower: number;
  13557. /**
  13558. * Maximum power of emitting particles.
  13559. */
  13560. maxEmitPower: number;
  13561. /**
  13562. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13563. */
  13564. minAngularSpeed: number;
  13565. /**
  13566. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13567. */
  13568. maxAngularSpeed: number;
  13569. /**
  13570. * Gets or sets the minimal initial rotation in radians.
  13571. */
  13572. minInitialRotation: number;
  13573. /**
  13574. * Gets or sets the maximal initial rotation in radians.
  13575. */
  13576. maxInitialRotation: number;
  13577. /**
  13578. * The particle emitter type defines the emitter used by the particle system.
  13579. * It can be for example box, sphere, or cone...
  13580. */
  13581. particleEmitterType: Nullable<IParticleEmitterType>;
  13582. /**
  13583. * Defines the delay in milliseconds before starting the system (0 by default)
  13584. */
  13585. startDelay: number;
  13586. /**
  13587. * 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
  13588. */
  13589. preWarmCycles: number;
  13590. /**
  13591. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13592. */
  13593. preWarmStepOffset: number;
  13594. /**
  13595. * 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)
  13596. */
  13597. spriteCellChangeSpeed: number;
  13598. /**
  13599. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13600. */
  13601. startSpriteCellID: number;
  13602. /**
  13603. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13604. */
  13605. endSpriteCellID: number;
  13606. /**
  13607. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13608. */
  13609. spriteCellWidth: number;
  13610. /**
  13611. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13612. */
  13613. spriteCellHeight: number;
  13614. /**
  13615. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13616. */
  13617. spriteRandomStartCell: boolean;
  13618. /**
  13619. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13620. */
  13621. isAnimationSheetEnabled: boolean;
  13622. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13623. translationPivot: Vector2;
  13624. /**
  13625. * Gets or sets a texture used to add random noise to particle positions
  13626. */
  13627. noiseTexture: Nullable<BaseTexture>;
  13628. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13629. noiseStrength: Vector3;
  13630. /**
  13631. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13632. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13633. */
  13634. billboardMode: number;
  13635. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13636. limitVelocityDamping: number;
  13637. /**
  13638. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13639. */
  13640. beginAnimationOnStart: boolean;
  13641. /**
  13642. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13643. */
  13644. beginAnimationFrom: number;
  13645. /**
  13646. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13647. */
  13648. beginAnimationTo: number;
  13649. /**
  13650. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13651. */
  13652. beginAnimationLoop: boolean;
  13653. /**
  13654. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13655. */
  13656. disposeOnStop: boolean;
  13657. /**
  13658. * Specifies if the particles are updated in emitter local space or world space
  13659. */
  13660. isLocal: boolean;
  13661. /** Snippet ID if the particle system was created from the snippet server */
  13662. snippetId: string;
  13663. /**
  13664. * Gets the maximum number of particles active at the same time.
  13665. * @returns The max number of active particles.
  13666. */
  13667. getCapacity(): number;
  13668. /**
  13669. * Gets the number of particles active at the same time.
  13670. * @returns The number of active particles.
  13671. */
  13672. getActiveCount(): number;
  13673. /**
  13674. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13675. * @returns True if it has been started, otherwise false.
  13676. */
  13677. isStarted(): boolean;
  13678. /**
  13679. * Animates the particle system for this frame.
  13680. */
  13681. animate(): void;
  13682. /**
  13683. * Renders the particle system in its current state.
  13684. * @returns the current number of particles
  13685. */
  13686. render(): number;
  13687. /**
  13688. * Dispose the particle system and frees its associated resources.
  13689. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13690. */
  13691. dispose(disposeTexture?: boolean): void;
  13692. /**
  13693. * Clones the particle system.
  13694. * @param name The name of the cloned object
  13695. * @param newEmitter The new emitter to use
  13696. * @returns the cloned particle system
  13697. */
  13698. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13699. /**
  13700. * Serializes the particle system to a JSON object
  13701. * @param serializeTexture defines if the texture must be serialized as well
  13702. * @returns the JSON object
  13703. */
  13704. serialize(serializeTexture: boolean): any;
  13705. /**
  13706. * Rebuild the particle system
  13707. */
  13708. rebuild(): void;
  13709. /** Force the system to rebuild all gradients that need to be resync */
  13710. forceRefreshGradients(): void;
  13711. /**
  13712. * Starts the particle system and begins to emit
  13713. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13714. */
  13715. start(delay?: number): void;
  13716. /**
  13717. * Stops the particle system.
  13718. */
  13719. stop(): void;
  13720. /**
  13721. * Remove all active particles
  13722. */
  13723. reset(): void;
  13724. /**
  13725. * Gets a boolean indicating that the system is stopping
  13726. * @returns true if the system is currently stopping
  13727. */
  13728. isStopping(): boolean;
  13729. /**
  13730. * Is this system ready to be used/rendered
  13731. * @return true if the system is ready
  13732. */
  13733. isReady(): boolean;
  13734. /**
  13735. * Returns the string "ParticleSystem"
  13736. * @returns a string containing the class name
  13737. */
  13738. getClassName(): string;
  13739. /**
  13740. * Adds a new color gradient
  13741. * @param gradient defines the gradient to use (between 0 and 1)
  13742. * @param color1 defines the color to affect to the specified gradient
  13743. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13744. * @returns the current particle system
  13745. */
  13746. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13747. /**
  13748. * Remove a specific color gradient
  13749. * @param gradient defines the gradient to remove
  13750. * @returns the current particle system
  13751. */
  13752. removeColorGradient(gradient: number): IParticleSystem;
  13753. /**
  13754. * Adds a new size gradient
  13755. * @param gradient defines the gradient to use (between 0 and 1)
  13756. * @param factor defines the size factor to affect to the specified gradient
  13757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13758. * @returns the current particle system
  13759. */
  13760. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13761. /**
  13762. * Remove a specific size gradient
  13763. * @param gradient defines the gradient to remove
  13764. * @returns the current particle system
  13765. */
  13766. removeSizeGradient(gradient: number): IParticleSystem;
  13767. /**
  13768. * Gets the current list of color gradients.
  13769. * You must use addColorGradient and removeColorGradient to udpate this list
  13770. * @returns the list of color gradients
  13771. */
  13772. getColorGradients(): Nullable<Array<ColorGradient>>;
  13773. /**
  13774. * Gets the current list of size gradients.
  13775. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13776. * @returns the list of size gradients
  13777. */
  13778. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13779. /**
  13780. * Gets the current list of angular speed gradients.
  13781. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13782. * @returns the list of angular speed gradients
  13783. */
  13784. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13785. /**
  13786. * Adds a new angular speed gradient
  13787. * @param gradient defines the gradient to use (between 0 and 1)
  13788. * @param factor defines the angular speed to affect to the specified gradient
  13789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13790. * @returns the current particle system
  13791. */
  13792. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13793. /**
  13794. * Remove a specific angular speed gradient
  13795. * @param gradient defines the gradient to remove
  13796. * @returns the current particle system
  13797. */
  13798. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13799. /**
  13800. * Gets the current list of velocity gradients.
  13801. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13802. * @returns the list of velocity gradients
  13803. */
  13804. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13805. /**
  13806. * Adds a new velocity gradient
  13807. * @param gradient defines the gradient to use (between 0 and 1)
  13808. * @param factor defines the velocity to affect to the specified gradient
  13809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13810. * @returns the current particle system
  13811. */
  13812. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13813. /**
  13814. * Remove a specific velocity gradient
  13815. * @param gradient defines the gradient to remove
  13816. * @returns the current particle system
  13817. */
  13818. removeVelocityGradient(gradient: number): IParticleSystem;
  13819. /**
  13820. * Gets the current list of limit velocity gradients.
  13821. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13822. * @returns the list of limit velocity gradients
  13823. */
  13824. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13825. /**
  13826. * Adds a new limit velocity gradient
  13827. * @param gradient defines the gradient to use (between 0 and 1)
  13828. * @param factor defines the limit velocity to affect to the specified gradient
  13829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13830. * @returns the current particle system
  13831. */
  13832. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13833. /**
  13834. * Remove a specific limit velocity gradient
  13835. * @param gradient defines the gradient to remove
  13836. * @returns the current particle system
  13837. */
  13838. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13839. /**
  13840. * Adds a new drag gradient
  13841. * @param gradient defines the gradient to use (between 0 and 1)
  13842. * @param factor defines the drag to affect to the specified gradient
  13843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13844. * @returns the current particle system
  13845. */
  13846. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13847. /**
  13848. * Remove a specific drag gradient
  13849. * @param gradient defines the gradient to remove
  13850. * @returns the current particle system
  13851. */
  13852. removeDragGradient(gradient: number): IParticleSystem;
  13853. /**
  13854. * Gets the current list of drag gradients.
  13855. * You must use addDragGradient and removeDragGradient to udpate this list
  13856. * @returns the list of drag gradients
  13857. */
  13858. getDragGradients(): Nullable<Array<FactorGradient>>;
  13859. /**
  13860. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13861. * @param gradient defines the gradient to use (between 0 and 1)
  13862. * @param factor defines the emit rate to affect to the specified gradient
  13863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13864. * @returns the current particle system
  13865. */
  13866. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13867. /**
  13868. * Remove a specific emit rate gradient
  13869. * @param gradient defines the gradient to remove
  13870. * @returns the current particle system
  13871. */
  13872. removeEmitRateGradient(gradient: number): IParticleSystem;
  13873. /**
  13874. * Gets the current list of emit rate gradients.
  13875. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13876. * @returns the list of emit rate gradients
  13877. */
  13878. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13879. /**
  13880. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13881. * @param gradient defines the gradient to use (between 0 and 1)
  13882. * @param factor defines the start size to affect to the specified gradient
  13883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13884. * @returns the current particle system
  13885. */
  13886. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13887. /**
  13888. * Remove a specific start size gradient
  13889. * @param gradient defines the gradient to remove
  13890. * @returns the current particle system
  13891. */
  13892. removeStartSizeGradient(gradient: number): IParticleSystem;
  13893. /**
  13894. * Gets the current list of start size gradients.
  13895. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13896. * @returns the list of start size gradients
  13897. */
  13898. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13899. /**
  13900. * Adds a new life time gradient
  13901. * @param gradient defines the gradient to use (between 0 and 1)
  13902. * @param factor defines the life time factor to affect to the specified gradient
  13903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13904. * @returns the current particle system
  13905. */
  13906. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13907. /**
  13908. * Remove a specific life time gradient
  13909. * @param gradient defines the gradient to remove
  13910. * @returns the current particle system
  13911. */
  13912. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13913. /**
  13914. * Gets the current list of life time gradients.
  13915. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13916. * @returns the list of life time gradients
  13917. */
  13918. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13919. /**
  13920. * Gets the current list of color gradients.
  13921. * You must use addColorGradient and removeColorGradient to udpate this list
  13922. * @returns the list of color gradients
  13923. */
  13924. getColorGradients(): Nullable<Array<ColorGradient>>;
  13925. /**
  13926. * Adds a new ramp gradient used to remap particle colors
  13927. * @param gradient defines the gradient to use (between 0 and 1)
  13928. * @param color defines the color to affect to the specified gradient
  13929. * @returns the current particle system
  13930. */
  13931. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13932. /**
  13933. * Gets the current list of ramp gradients.
  13934. * You must use addRampGradient and removeRampGradient to udpate this list
  13935. * @returns the list of ramp gradients
  13936. */
  13937. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13938. /** Gets or sets a boolean indicating that ramp gradients must be used
  13939. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13940. */
  13941. useRampGradients: boolean;
  13942. /**
  13943. * Adds a new color remap gradient
  13944. * @param gradient defines the gradient to use (between 0 and 1)
  13945. * @param min defines the color remap minimal range
  13946. * @param max defines the color remap maximal range
  13947. * @returns the current particle system
  13948. */
  13949. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13950. /**
  13951. * Gets the current list of color remap gradients.
  13952. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13953. * @returns the list of color remap gradients
  13954. */
  13955. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13956. /**
  13957. * Adds a new alpha remap gradient
  13958. * @param gradient defines the gradient to use (between 0 and 1)
  13959. * @param min defines the alpha remap minimal range
  13960. * @param max defines the alpha remap maximal range
  13961. * @returns the current particle system
  13962. */
  13963. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13964. /**
  13965. * Gets the current list of alpha remap gradients.
  13966. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13967. * @returns the list of alpha remap gradients
  13968. */
  13969. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13970. /**
  13971. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13972. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13973. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13974. * @returns the emitter
  13975. */
  13976. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13977. /**
  13978. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13979. * @param radius The radius of the hemisphere to emit from
  13980. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13981. * @returns the emitter
  13982. */
  13983. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13984. /**
  13985. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13986. * @param radius The radius of the sphere to emit from
  13987. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13988. * @returns the emitter
  13989. */
  13990. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13991. /**
  13992. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13993. * @param radius The radius of the sphere to emit from
  13994. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13995. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13996. * @returns the emitter
  13997. */
  13998. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13999. /**
  14000. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14001. * @param radius The radius of the emission cylinder
  14002. * @param height The height of the emission cylinder
  14003. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14004. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14005. * @returns the emitter
  14006. */
  14007. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14008. /**
  14009. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14010. * @param radius The radius of the cylinder to emit from
  14011. * @param height The height of the emission cylinder
  14012. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14013. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14014. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14015. * @returns the emitter
  14016. */
  14017. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14018. /**
  14019. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14020. * @param radius The radius of the cone to emit from
  14021. * @param angle The base angle of the cone
  14022. * @returns the emitter
  14023. */
  14024. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14025. /**
  14026. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14027. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14028. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14029. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14030. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14031. * @returns the emitter
  14032. */
  14033. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14034. /**
  14035. * Get hosting scene
  14036. * @returns the scene
  14037. */
  14038. getScene(): Scene;
  14039. }
  14040. }
  14041. declare module "babylonjs/Meshes/transformNode" {
  14042. import { DeepImmutable } from "babylonjs/types";
  14043. import { Observable } from "babylonjs/Misc/observable";
  14044. import { Nullable } from "babylonjs/types";
  14045. import { Camera } from "babylonjs/Cameras/camera";
  14046. import { Scene } from "babylonjs/scene";
  14047. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14048. import { Node } from "babylonjs/node";
  14049. import { Bone } from "babylonjs/Bones/bone";
  14050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14051. import { Space } from "babylonjs/Maths/math.axis";
  14052. /**
  14053. * 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.
  14054. * @see https://doc.babylonjs.com/how_to/transformnode
  14055. */
  14056. export class TransformNode extends Node {
  14057. /**
  14058. * Object will not rotate to face the camera
  14059. */
  14060. static BILLBOARDMODE_NONE: number;
  14061. /**
  14062. * Object will rotate to face the camera but only on the x axis
  14063. */
  14064. static BILLBOARDMODE_X: number;
  14065. /**
  14066. * Object will rotate to face the camera but only on the y axis
  14067. */
  14068. static BILLBOARDMODE_Y: number;
  14069. /**
  14070. * Object will rotate to face the camera but only on the z axis
  14071. */
  14072. static BILLBOARDMODE_Z: number;
  14073. /**
  14074. * Object will rotate to face the camera
  14075. */
  14076. static BILLBOARDMODE_ALL: number;
  14077. /**
  14078. * Object will rotate to face the camera's position instead of orientation
  14079. */
  14080. static BILLBOARDMODE_USE_POSITION: number;
  14081. private _forward;
  14082. private _forwardInverted;
  14083. private _up;
  14084. private _right;
  14085. private _rightInverted;
  14086. private _position;
  14087. private _rotation;
  14088. private _rotationQuaternion;
  14089. protected _scaling: Vector3;
  14090. protected _isDirty: boolean;
  14091. private _transformToBoneReferal;
  14092. private _isAbsoluteSynced;
  14093. private _billboardMode;
  14094. /**
  14095. * Gets or sets the billboard mode. Default is 0.
  14096. *
  14097. * | Value | Type | Description |
  14098. * | --- | --- | --- |
  14099. * | 0 | BILLBOARDMODE_NONE | |
  14100. * | 1 | BILLBOARDMODE_X | |
  14101. * | 2 | BILLBOARDMODE_Y | |
  14102. * | 4 | BILLBOARDMODE_Z | |
  14103. * | 7 | BILLBOARDMODE_ALL | |
  14104. *
  14105. */
  14106. get billboardMode(): number;
  14107. set billboardMode(value: number);
  14108. private _preserveParentRotationForBillboard;
  14109. /**
  14110. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14111. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14112. */
  14113. get preserveParentRotationForBillboard(): boolean;
  14114. set preserveParentRotationForBillboard(value: boolean);
  14115. /**
  14116. * 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
  14117. */
  14118. scalingDeterminant: number;
  14119. private _infiniteDistance;
  14120. /**
  14121. * Gets or sets the distance of the object to max, often used by skybox
  14122. */
  14123. get infiniteDistance(): boolean;
  14124. set infiniteDistance(value: boolean);
  14125. /**
  14126. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14127. * By default the system will update normals to compensate
  14128. */
  14129. ignoreNonUniformScaling: boolean;
  14130. /**
  14131. * 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
  14132. */
  14133. reIntegrateRotationIntoRotationQuaternion: boolean;
  14134. /** @hidden */
  14135. _poseMatrix: Nullable<Matrix>;
  14136. /** @hidden */
  14137. _localMatrix: Matrix;
  14138. private _usePivotMatrix;
  14139. private _absolutePosition;
  14140. private _absoluteScaling;
  14141. private _absoluteRotationQuaternion;
  14142. private _pivotMatrix;
  14143. private _pivotMatrixInverse;
  14144. protected _postMultiplyPivotMatrix: boolean;
  14145. protected _isWorldMatrixFrozen: boolean;
  14146. /** @hidden */
  14147. _indexInSceneTransformNodesArray: number;
  14148. /**
  14149. * An event triggered after the world matrix is updated
  14150. */
  14151. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14152. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14153. /**
  14154. * Gets a string identifying the name of the class
  14155. * @returns "TransformNode" string
  14156. */
  14157. getClassName(): string;
  14158. /**
  14159. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14160. */
  14161. get position(): Vector3;
  14162. set position(newPosition: Vector3);
  14163. /**
  14164. * 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)).
  14165. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14166. */
  14167. get rotation(): Vector3;
  14168. set rotation(newRotation: Vector3);
  14169. /**
  14170. * 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)).
  14171. */
  14172. get scaling(): Vector3;
  14173. set scaling(newScaling: Vector3);
  14174. /**
  14175. * 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).
  14176. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14177. */
  14178. get rotationQuaternion(): Nullable<Quaternion>;
  14179. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14180. /**
  14181. * The forward direction of that transform in world space.
  14182. */
  14183. get forward(): Vector3;
  14184. /**
  14185. * The up direction of that transform in world space.
  14186. */
  14187. get up(): Vector3;
  14188. /**
  14189. * The right direction of that transform in world space.
  14190. */
  14191. get right(): Vector3;
  14192. /**
  14193. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14194. * @param matrix the matrix to copy the pose from
  14195. * @returns this TransformNode.
  14196. */
  14197. updatePoseMatrix(matrix: Matrix): TransformNode;
  14198. /**
  14199. * Returns the mesh Pose matrix.
  14200. * @returns the pose matrix
  14201. */
  14202. getPoseMatrix(): Matrix;
  14203. /** @hidden */
  14204. _isSynchronized(): boolean;
  14205. /** @hidden */
  14206. _initCache(): void;
  14207. /**
  14208. * Flag the transform node as dirty (Forcing it to update everything)
  14209. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14210. * @returns this transform node
  14211. */
  14212. markAsDirty(property: string): TransformNode;
  14213. /**
  14214. * Returns the current mesh absolute position.
  14215. * Returns a Vector3.
  14216. */
  14217. get absolutePosition(): Vector3;
  14218. /**
  14219. * Returns the current mesh absolute scaling.
  14220. * Returns a Vector3.
  14221. */
  14222. get absoluteScaling(): Vector3;
  14223. /**
  14224. * Returns the current mesh absolute rotation.
  14225. * Returns a Quaternion.
  14226. */
  14227. get absoluteRotationQuaternion(): Quaternion;
  14228. /**
  14229. * Sets a new matrix to apply before all other transformation
  14230. * @param matrix defines the transform matrix
  14231. * @returns the current TransformNode
  14232. */
  14233. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14234. /**
  14235. * Sets a new pivot matrix to the current node
  14236. * @param matrix defines the new pivot matrix to use
  14237. * @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
  14238. * @returns the current TransformNode
  14239. */
  14240. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14241. /**
  14242. * Returns the mesh pivot matrix.
  14243. * Default : Identity.
  14244. * @returns the matrix
  14245. */
  14246. getPivotMatrix(): Matrix;
  14247. /**
  14248. * Instantiate (when possible) or clone that node with its hierarchy
  14249. * @param newParent defines the new parent to use for the instance (or clone)
  14250. * @param options defines options to configure how copy is done
  14251. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14252. * @returns an instance (or a clone) of the current node with its hiearchy
  14253. */
  14254. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14255. doNotInstantiate: boolean;
  14256. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14257. /**
  14258. * Prevents the World matrix to be computed any longer
  14259. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14260. * @returns the TransformNode.
  14261. */
  14262. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14263. /**
  14264. * Allows back the World matrix computation.
  14265. * @returns the TransformNode.
  14266. */
  14267. unfreezeWorldMatrix(): this;
  14268. /**
  14269. * True if the World matrix has been frozen.
  14270. */
  14271. get isWorldMatrixFrozen(): boolean;
  14272. /**
  14273. * Retuns the mesh absolute position in the World.
  14274. * @returns a Vector3.
  14275. */
  14276. getAbsolutePosition(): Vector3;
  14277. /**
  14278. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14279. * @param absolutePosition the absolute position to set
  14280. * @returns the TransformNode.
  14281. */
  14282. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14283. /**
  14284. * Sets the mesh position in its local space.
  14285. * @param vector3 the position to set in localspace
  14286. * @returns the TransformNode.
  14287. */
  14288. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14289. /**
  14290. * Returns the mesh position in the local space from the current World matrix values.
  14291. * @returns a new Vector3.
  14292. */
  14293. getPositionExpressedInLocalSpace(): Vector3;
  14294. /**
  14295. * Translates the mesh along the passed Vector3 in its local space.
  14296. * @param vector3 the distance to translate in localspace
  14297. * @returns the TransformNode.
  14298. */
  14299. locallyTranslate(vector3: Vector3): TransformNode;
  14300. private static _lookAtVectorCache;
  14301. /**
  14302. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14303. * @param targetPoint the position (must be in same space as current mesh) to look at
  14304. * @param yawCor optional yaw (y-axis) correction in radians
  14305. * @param pitchCor optional pitch (x-axis) correction in radians
  14306. * @param rollCor optional roll (z-axis) correction in radians
  14307. * @param space the choosen space of the target
  14308. * @returns the TransformNode.
  14309. */
  14310. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14311. /**
  14312. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14313. * This Vector3 is expressed in the World space.
  14314. * @param localAxis axis to rotate
  14315. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14316. */
  14317. getDirection(localAxis: Vector3): Vector3;
  14318. /**
  14319. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14320. * localAxis is expressed in the mesh local space.
  14321. * result is computed in the Wordl space from the mesh World matrix.
  14322. * @param localAxis axis to rotate
  14323. * @param result the resulting transformnode
  14324. * @returns this TransformNode.
  14325. */
  14326. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14327. /**
  14328. * Sets this transform node rotation to the given local axis.
  14329. * @param localAxis the axis in local space
  14330. * @param yawCor optional yaw (y-axis) correction in radians
  14331. * @param pitchCor optional pitch (x-axis) correction in radians
  14332. * @param rollCor optional roll (z-axis) correction in radians
  14333. * @returns this TransformNode
  14334. */
  14335. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14336. /**
  14337. * Sets a new pivot point to the current node
  14338. * @param point defines the new pivot point to use
  14339. * @param space defines if the point is in world or local space (local by default)
  14340. * @returns the current TransformNode
  14341. */
  14342. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14343. /**
  14344. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14345. * @returns the pivot point
  14346. */
  14347. getPivotPoint(): Vector3;
  14348. /**
  14349. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14350. * @param result the vector3 to store the result
  14351. * @returns this TransformNode.
  14352. */
  14353. getPivotPointToRef(result: Vector3): TransformNode;
  14354. /**
  14355. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14356. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14357. */
  14358. getAbsolutePivotPoint(): Vector3;
  14359. /**
  14360. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14361. * @param result vector3 to store the result
  14362. * @returns this TransformNode.
  14363. */
  14364. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14365. /**
  14366. * Defines the passed node as the parent of the current node.
  14367. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14368. * @see https://doc.babylonjs.com/how_to/parenting
  14369. * @param node the node ot set as the parent
  14370. * @returns this TransformNode.
  14371. */
  14372. setParent(node: Nullable<Node>): TransformNode;
  14373. private _nonUniformScaling;
  14374. /**
  14375. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14376. */
  14377. get nonUniformScaling(): boolean;
  14378. /** @hidden */
  14379. _updateNonUniformScalingState(value: boolean): boolean;
  14380. /**
  14381. * Attach the current TransformNode to another TransformNode associated with a bone
  14382. * @param bone Bone affecting the TransformNode
  14383. * @param affectedTransformNode TransformNode associated with the bone
  14384. * @returns this object
  14385. */
  14386. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14387. /**
  14388. * Detach the transform node if its associated with a bone
  14389. * @returns this object
  14390. */
  14391. detachFromBone(): TransformNode;
  14392. private static _rotationAxisCache;
  14393. /**
  14394. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14395. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14396. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14397. * The passed axis is also normalized.
  14398. * @param axis the axis to rotate around
  14399. * @param amount the amount to rotate in radians
  14400. * @param space Space to rotate in (Default: local)
  14401. * @returns the TransformNode.
  14402. */
  14403. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14404. /**
  14405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14406. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14407. * The passed axis is also normalized. .
  14408. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14409. * @param point the point to rotate around
  14410. * @param axis the axis to rotate around
  14411. * @param amount the amount to rotate in radians
  14412. * @returns the TransformNode
  14413. */
  14414. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14415. /**
  14416. * Translates the mesh along the axis vector for the passed distance in the given space.
  14417. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14418. * @param axis the axis to translate in
  14419. * @param distance the distance to translate
  14420. * @param space Space to rotate in (Default: local)
  14421. * @returns the TransformNode.
  14422. */
  14423. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14424. /**
  14425. * Adds a rotation step to the mesh current rotation.
  14426. * x, y, z are Euler angles expressed in radians.
  14427. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14428. * This means this rotation is made in the mesh local space only.
  14429. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14430. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14431. * ```javascript
  14432. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14433. * ```
  14434. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14435. * 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.
  14436. * @param x Rotation to add
  14437. * @param y Rotation to add
  14438. * @param z Rotation to add
  14439. * @returns the TransformNode.
  14440. */
  14441. addRotation(x: number, y: number, z: number): TransformNode;
  14442. /**
  14443. * @hidden
  14444. */
  14445. protected _getEffectiveParent(): Nullable<Node>;
  14446. /**
  14447. * Computes the world matrix of the node
  14448. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14449. * @returns the world matrix
  14450. */
  14451. computeWorldMatrix(force?: boolean): Matrix;
  14452. /**
  14453. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14454. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14455. */
  14456. resetLocalMatrix(independentOfChildren?: boolean): void;
  14457. protected _afterComputeWorldMatrix(): void;
  14458. /**
  14459. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14460. * @param func callback function to add
  14461. *
  14462. * @returns the TransformNode.
  14463. */
  14464. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14465. /**
  14466. * Removes a registered callback function.
  14467. * @param func callback function to remove
  14468. * @returns the TransformNode.
  14469. */
  14470. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14471. /**
  14472. * Gets the position of the current mesh in camera space
  14473. * @param camera defines the camera to use
  14474. * @returns a position
  14475. */
  14476. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14477. /**
  14478. * Returns the distance from the mesh to the active camera
  14479. * @param camera defines the camera to use
  14480. * @returns the distance
  14481. */
  14482. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14483. /**
  14484. * Clone the current transform node
  14485. * @param name Name of the new clone
  14486. * @param newParent New parent for the clone
  14487. * @param doNotCloneChildren Do not clone children hierarchy
  14488. * @returns the new transform node
  14489. */
  14490. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14491. /**
  14492. * Serializes the objects information.
  14493. * @param currentSerializationObject defines the object to serialize in
  14494. * @returns the serialized object
  14495. */
  14496. serialize(currentSerializationObject?: any): any;
  14497. /**
  14498. * Returns a new TransformNode object parsed from the source provided.
  14499. * @param parsedTransformNode is the source.
  14500. * @param scene the scne the object belongs to
  14501. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14502. * @returns a new TransformNode object parsed from the source provided.
  14503. */
  14504. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14505. /**
  14506. * Get all child-transformNodes of this node
  14507. * @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
  14508. * @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
  14509. * @returns an array of TransformNode
  14510. */
  14511. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14512. /**
  14513. * Releases resources associated with this transform node.
  14514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14516. */
  14517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14518. /**
  14519. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14520. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14521. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14522. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14523. * @returns the current mesh
  14524. */
  14525. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14526. private _syncAbsoluteScalingAndRotation;
  14527. }
  14528. }
  14529. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14530. /**
  14531. * Class used to override all child animations of a given target
  14532. */
  14533. export class AnimationPropertiesOverride {
  14534. /**
  14535. * Gets or sets a value indicating if animation blending must be used
  14536. */
  14537. enableBlending: boolean;
  14538. /**
  14539. * Gets or sets the blending speed to use when enableBlending is true
  14540. */
  14541. blendingSpeed: number;
  14542. /**
  14543. * Gets or sets the default loop mode to use
  14544. */
  14545. loopMode: number;
  14546. }
  14547. }
  14548. declare module "babylonjs/Bones/bone" {
  14549. import { Skeleton } from "babylonjs/Bones/skeleton";
  14550. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14551. import { Nullable } from "babylonjs/types";
  14552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14553. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14554. import { Node } from "babylonjs/node";
  14555. import { Space } from "babylonjs/Maths/math.axis";
  14556. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14557. /**
  14558. * Class used to store bone information
  14559. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14560. */
  14561. export class Bone extends Node {
  14562. /**
  14563. * defines the bone name
  14564. */
  14565. name: string;
  14566. private static _tmpVecs;
  14567. private static _tmpQuat;
  14568. private static _tmpMats;
  14569. /**
  14570. * Gets the list of child bones
  14571. */
  14572. children: Bone[];
  14573. /** Gets the animations associated with this bone */
  14574. animations: import("babylonjs/Animations/animation").Animation[];
  14575. /**
  14576. * Gets or sets bone length
  14577. */
  14578. length: number;
  14579. /**
  14580. * @hidden Internal only
  14581. * Set this value to map this bone to a different index in the transform matrices
  14582. * Set this value to -1 to exclude the bone from the transform matrices
  14583. */
  14584. _index: Nullable<number>;
  14585. private _skeleton;
  14586. private _localMatrix;
  14587. private _restPose;
  14588. private _baseMatrix;
  14589. private _absoluteTransform;
  14590. private _invertedAbsoluteTransform;
  14591. private _parent;
  14592. private _scalingDeterminant;
  14593. private _worldTransform;
  14594. private _localScaling;
  14595. private _localRotation;
  14596. private _localPosition;
  14597. private _needToDecompose;
  14598. private _needToCompose;
  14599. /** @hidden */
  14600. _linkedTransformNode: Nullable<TransformNode>;
  14601. /** @hidden */
  14602. _waitingTransformNodeId: Nullable<string>;
  14603. /** @hidden */
  14604. get _matrix(): Matrix;
  14605. /** @hidden */
  14606. set _matrix(value: Matrix);
  14607. /**
  14608. * Create a new bone
  14609. * @param name defines the bone name
  14610. * @param skeleton defines the parent skeleton
  14611. * @param parentBone defines the parent (can be null if the bone is the root)
  14612. * @param localMatrix defines the local matrix
  14613. * @param restPose defines the rest pose matrix
  14614. * @param baseMatrix defines the base matrix
  14615. * @param index defines index of the bone in the hiearchy
  14616. */
  14617. constructor(
  14618. /**
  14619. * defines the bone name
  14620. */
  14621. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14622. /**
  14623. * Gets the current object class name.
  14624. * @return the class name
  14625. */
  14626. getClassName(): string;
  14627. /**
  14628. * Gets the parent skeleton
  14629. * @returns a skeleton
  14630. */
  14631. getSkeleton(): Skeleton;
  14632. /**
  14633. * Gets parent bone
  14634. * @returns a bone or null if the bone is the root of the bone hierarchy
  14635. */
  14636. getParent(): Nullable<Bone>;
  14637. /**
  14638. * Returns an array containing the root bones
  14639. * @returns an array containing the root bones
  14640. */
  14641. getChildren(): Array<Bone>;
  14642. /**
  14643. * Gets the node index in matrix array generated for rendering
  14644. * @returns the node index
  14645. */
  14646. getIndex(): number;
  14647. /**
  14648. * Sets the parent bone
  14649. * @param parent defines the parent (can be null if the bone is the root)
  14650. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14651. */
  14652. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14653. /**
  14654. * Gets the local matrix
  14655. * @returns a matrix
  14656. */
  14657. getLocalMatrix(): Matrix;
  14658. /**
  14659. * Gets the base matrix (initial matrix which remains unchanged)
  14660. * @returns a matrix
  14661. */
  14662. getBaseMatrix(): Matrix;
  14663. /**
  14664. * Gets the rest pose matrix
  14665. * @returns a matrix
  14666. */
  14667. getRestPose(): Matrix;
  14668. /**
  14669. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14670. */
  14671. getWorldMatrix(): Matrix;
  14672. /**
  14673. * Sets the local matrix to rest pose matrix
  14674. */
  14675. returnToRest(): void;
  14676. /**
  14677. * Gets the inverse of the absolute transform matrix.
  14678. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14679. * @returns a matrix
  14680. */
  14681. getInvertedAbsoluteTransform(): Matrix;
  14682. /**
  14683. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14684. * @returns a matrix
  14685. */
  14686. getAbsoluteTransform(): Matrix;
  14687. /**
  14688. * Links with the given transform node.
  14689. * The local matrix of this bone is copied from the transform node every frame.
  14690. * @param transformNode defines the transform node to link to
  14691. */
  14692. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14693. /**
  14694. * Gets the node used to drive the bone's transformation
  14695. * @returns a transform node or null
  14696. */
  14697. getTransformNode(): Nullable<TransformNode>;
  14698. /** Gets or sets current position (in local space) */
  14699. get position(): Vector3;
  14700. set position(newPosition: Vector3);
  14701. /** Gets or sets current rotation (in local space) */
  14702. get rotation(): Vector3;
  14703. set rotation(newRotation: Vector3);
  14704. /** Gets or sets current rotation quaternion (in local space) */
  14705. get rotationQuaternion(): Quaternion;
  14706. set rotationQuaternion(newRotation: Quaternion);
  14707. /** Gets or sets current scaling (in local space) */
  14708. get scaling(): Vector3;
  14709. set scaling(newScaling: Vector3);
  14710. /**
  14711. * Gets the animation properties override
  14712. */
  14713. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14714. private _decompose;
  14715. private _compose;
  14716. /**
  14717. * Update the base and local matrices
  14718. * @param matrix defines the new base or local matrix
  14719. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14720. * @param updateLocalMatrix defines if the local matrix should be updated
  14721. */
  14722. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14723. /** @hidden */
  14724. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14725. /**
  14726. * Flag the bone as dirty (Forcing it to update everything)
  14727. */
  14728. markAsDirty(): void;
  14729. /** @hidden */
  14730. _markAsDirtyAndCompose(): void;
  14731. private _markAsDirtyAndDecompose;
  14732. /**
  14733. * Translate the bone in local or world space
  14734. * @param vec The amount to translate the bone
  14735. * @param space The space that the translation is in
  14736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14737. */
  14738. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14739. /**
  14740. * Set the postion of the bone in local or world space
  14741. * @param position The position to set the bone
  14742. * @param space The space that the position is in
  14743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14744. */
  14745. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14746. /**
  14747. * Set the absolute position of the bone (world space)
  14748. * @param position The position to set the bone
  14749. * @param mesh The mesh that this bone is attached to
  14750. */
  14751. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14752. /**
  14753. * Scale the bone on the x, y and z axes (in local space)
  14754. * @param x The amount to scale the bone on the x axis
  14755. * @param y The amount to scale the bone on the y axis
  14756. * @param z The amount to scale the bone on the z axis
  14757. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14758. */
  14759. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14760. /**
  14761. * Set the bone scaling in local space
  14762. * @param scale defines the scaling vector
  14763. */
  14764. setScale(scale: Vector3): void;
  14765. /**
  14766. * Gets the current scaling in local space
  14767. * @returns the current scaling vector
  14768. */
  14769. getScale(): Vector3;
  14770. /**
  14771. * Gets the current scaling in local space and stores it in a target vector
  14772. * @param result defines the target vector
  14773. */
  14774. getScaleToRef(result: Vector3): void;
  14775. /**
  14776. * Set the yaw, pitch, and roll of the bone in local or world space
  14777. * @param yaw The rotation of the bone on the y axis
  14778. * @param pitch The rotation of the bone on the x axis
  14779. * @param roll The rotation of the bone on the z axis
  14780. * @param space The space that the axes of rotation are in
  14781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14782. */
  14783. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14784. /**
  14785. * Add a rotation to the bone on an axis in local or world space
  14786. * @param axis The axis to rotate the bone on
  14787. * @param amount The amount to rotate the bone
  14788. * @param space The space that the axis is in
  14789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14790. */
  14791. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14792. /**
  14793. * Set the rotation of the bone to a particular axis angle in local or world space
  14794. * @param axis The axis to rotate the bone on
  14795. * @param angle The angle that the bone should be rotated to
  14796. * @param space The space that the axis is in
  14797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14798. */
  14799. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14800. /**
  14801. * Set the euler rotation of the bone in local of world space
  14802. * @param rotation The euler rotation that the bone should be set to
  14803. * @param space The space that the rotation is in
  14804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14805. */
  14806. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14807. /**
  14808. * Set the quaternion rotation of the bone in local of world space
  14809. * @param quat The quaternion rotation that the bone should be set to
  14810. * @param space The space that the rotation is in
  14811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14812. */
  14813. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14814. /**
  14815. * Set the rotation matrix of the bone in local of world space
  14816. * @param rotMat The rotation matrix that the bone should be set to
  14817. * @param space The space that the rotation is in
  14818. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14819. */
  14820. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14821. private _rotateWithMatrix;
  14822. private _getNegativeRotationToRef;
  14823. /**
  14824. * Get the position of the bone in local or world space
  14825. * @param space The space that the returned position is in
  14826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14827. * @returns The position of the bone
  14828. */
  14829. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14830. /**
  14831. * Copy the position of the bone to a vector3 in local or world space
  14832. * @param space The space that the returned position is in
  14833. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14834. * @param result The vector3 to copy the position to
  14835. */
  14836. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14837. /**
  14838. * Get the absolute position of the bone (world space)
  14839. * @param mesh The mesh that this bone is attached to
  14840. * @returns The absolute position of the bone
  14841. */
  14842. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14843. /**
  14844. * Copy the absolute position of the bone (world space) to the result param
  14845. * @param mesh The mesh that this bone is attached to
  14846. * @param result The vector3 to copy the absolute position to
  14847. */
  14848. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14849. /**
  14850. * Compute the absolute transforms of this bone and its children
  14851. */
  14852. computeAbsoluteTransforms(): void;
  14853. /**
  14854. * Get the world direction from an axis that is in the local space of the bone
  14855. * @param localAxis The local direction that is used to compute the world direction
  14856. * @param mesh The mesh that this bone is attached to
  14857. * @returns The world direction
  14858. */
  14859. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14860. /**
  14861. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14862. * @param localAxis The local direction that is used to compute the world direction
  14863. * @param mesh The mesh that this bone is attached to
  14864. * @param result The vector3 that the world direction will be copied to
  14865. */
  14866. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14867. /**
  14868. * Get the euler rotation of the bone in local or world space
  14869. * @param space The space that the rotation should be in
  14870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14871. * @returns The euler rotation
  14872. */
  14873. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14874. /**
  14875. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14876. * @param space The space that the rotation should be in
  14877. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14878. * @param result The vector3 that the rotation should be copied to
  14879. */
  14880. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14881. /**
  14882. * Get the quaternion rotation of the bone in either local or world space
  14883. * @param space The space that the rotation should be in
  14884. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14885. * @returns The quaternion rotation
  14886. */
  14887. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14888. /**
  14889. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14890. * @param space The space that the rotation should be in
  14891. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14892. * @param result The quaternion that the rotation should be copied to
  14893. */
  14894. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14895. /**
  14896. * Get the rotation matrix of the bone in local or world space
  14897. * @param space The space that the rotation should be in
  14898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14899. * @returns The rotation matrix
  14900. */
  14901. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14902. /**
  14903. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14904. * @param space The space that the rotation should be in
  14905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14906. * @param result The quaternion that the rotation should be copied to
  14907. */
  14908. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14909. /**
  14910. * Get the world position of a point that is in the local space of the bone
  14911. * @param position The local position
  14912. * @param mesh The mesh that this bone is attached to
  14913. * @returns The world position
  14914. */
  14915. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14916. /**
  14917. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14918. * @param position The local position
  14919. * @param mesh The mesh that this bone is attached to
  14920. * @param result The vector3 that the world position should be copied to
  14921. */
  14922. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14923. /**
  14924. * Get the local position of a point that is in world space
  14925. * @param position The world position
  14926. * @param mesh The mesh that this bone is attached to
  14927. * @returns The local position
  14928. */
  14929. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14930. /**
  14931. * Get the local position of a point that is in world space and copy it to the result param
  14932. * @param position The world position
  14933. * @param mesh The mesh that this bone is attached to
  14934. * @param result The vector3 that the local position should be copied to
  14935. */
  14936. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14937. }
  14938. }
  14939. declare module "babylonjs/Animations/runtimeAnimation" {
  14940. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14941. import { Animatable } from "babylonjs/Animations/animatable";
  14942. import { Scene } from "babylonjs/scene";
  14943. /**
  14944. * Defines a runtime animation
  14945. */
  14946. export class RuntimeAnimation {
  14947. private _events;
  14948. /**
  14949. * The current frame of the runtime animation
  14950. */
  14951. private _currentFrame;
  14952. /**
  14953. * The animation used by the runtime animation
  14954. */
  14955. private _animation;
  14956. /**
  14957. * The target of the runtime animation
  14958. */
  14959. private _target;
  14960. /**
  14961. * The initiating animatable
  14962. */
  14963. private _host;
  14964. /**
  14965. * The original value of the runtime animation
  14966. */
  14967. private _originalValue;
  14968. /**
  14969. * The original blend value of the runtime animation
  14970. */
  14971. private _originalBlendValue;
  14972. /**
  14973. * The offsets cache of the runtime animation
  14974. */
  14975. private _offsetsCache;
  14976. /**
  14977. * The high limits cache of the runtime animation
  14978. */
  14979. private _highLimitsCache;
  14980. /**
  14981. * Specifies if the runtime animation has been stopped
  14982. */
  14983. private _stopped;
  14984. /**
  14985. * The blending factor of the runtime animation
  14986. */
  14987. private _blendingFactor;
  14988. /**
  14989. * The BabylonJS scene
  14990. */
  14991. private _scene;
  14992. /**
  14993. * The current value of the runtime animation
  14994. */
  14995. private _currentValue;
  14996. /** @hidden */
  14997. _animationState: _IAnimationState;
  14998. /**
  14999. * The active target of the runtime animation
  15000. */
  15001. private _activeTargets;
  15002. private _currentActiveTarget;
  15003. private _directTarget;
  15004. /**
  15005. * The target path of the runtime animation
  15006. */
  15007. private _targetPath;
  15008. /**
  15009. * The weight of the runtime animation
  15010. */
  15011. private _weight;
  15012. /**
  15013. * The ratio offset of the runtime animation
  15014. */
  15015. private _ratioOffset;
  15016. /**
  15017. * The previous delay of the runtime animation
  15018. */
  15019. private _previousDelay;
  15020. /**
  15021. * The previous ratio of the runtime animation
  15022. */
  15023. private _previousRatio;
  15024. private _enableBlending;
  15025. private _keys;
  15026. private _minFrame;
  15027. private _maxFrame;
  15028. private _minValue;
  15029. private _maxValue;
  15030. private _targetIsArray;
  15031. /**
  15032. * Gets the current frame of the runtime animation
  15033. */
  15034. get currentFrame(): number;
  15035. /**
  15036. * Gets the weight of the runtime animation
  15037. */
  15038. get weight(): number;
  15039. /**
  15040. * Gets the current value of the runtime animation
  15041. */
  15042. get currentValue(): any;
  15043. /**
  15044. * Gets the target path of the runtime animation
  15045. */
  15046. get targetPath(): string;
  15047. /**
  15048. * Gets the actual target of the runtime animation
  15049. */
  15050. get target(): any;
  15051. /**
  15052. * Gets the additive state of the runtime animation
  15053. */
  15054. get isAdditive(): boolean;
  15055. /** @hidden */
  15056. _onLoop: () => void;
  15057. /**
  15058. * Create a new RuntimeAnimation object
  15059. * @param target defines the target of the animation
  15060. * @param animation defines the source animation object
  15061. * @param scene defines the hosting scene
  15062. * @param host defines the initiating Animatable
  15063. */
  15064. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15065. private _preparePath;
  15066. /**
  15067. * Gets the animation from the runtime animation
  15068. */
  15069. get animation(): Animation;
  15070. /**
  15071. * Resets the runtime animation to the beginning
  15072. * @param restoreOriginal defines whether to restore the target property to the original value
  15073. */
  15074. reset(restoreOriginal?: boolean): void;
  15075. /**
  15076. * Specifies if the runtime animation is stopped
  15077. * @returns Boolean specifying if the runtime animation is stopped
  15078. */
  15079. isStopped(): boolean;
  15080. /**
  15081. * Disposes of the runtime animation
  15082. */
  15083. dispose(): void;
  15084. /**
  15085. * Apply the interpolated value to the target
  15086. * @param currentValue defines the value computed by the animation
  15087. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15088. */
  15089. setValue(currentValue: any, weight: number): void;
  15090. private _getOriginalValues;
  15091. private _setValue;
  15092. /**
  15093. * Gets the loop pmode of the runtime animation
  15094. * @returns Loop Mode
  15095. */
  15096. private _getCorrectLoopMode;
  15097. /**
  15098. * Move the current animation to a given frame
  15099. * @param frame defines the frame to move to
  15100. */
  15101. goToFrame(frame: number): void;
  15102. /**
  15103. * @hidden Internal use only
  15104. */
  15105. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15106. /**
  15107. * Execute the current animation
  15108. * @param delay defines the delay to add to the current frame
  15109. * @param from defines the lower bound of the animation range
  15110. * @param to defines the upper bound of the animation range
  15111. * @param loop defines if the current animation must loop
  15112. * @param speedRatio defines the current speed ratio
  15113. * @param weight defines the weight of the animation (default is -1 so no weight)
  15114. * @param onLoop optional callback called when animation loops
  15115. * @returns a boolean indicating if the animation is running
  15116. */
  15117. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15118. }
  15119. }
  15120. declare module "babylonjs/Animations/animatable" {
  15121. import { Animation } from "babylonjs/Animations/animation";
  15122. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15123. import { Nullable } from "babylonjs/types";
  15124. import { Observable } from "babylonjs/Misc/observable";
  15125. import { Scene } from "babylonjs/scene";
  15126. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15127. import { Node } from "babylonjs/node";
  15128. /**
  15129. * Class used to store an actual running animation
  15130. */
  15131. export class Animatable {
  15132. /** defines the target object */
  15133. target: any;
  15134. /** defines the starting frame number (default is 0) */
  15135. fromFrame: number;
  15136. /** defines the ending frame number (default is 100) */
  15137. toFrame: number;
  15138. /** defines if the animation must loop (default is false) */
  15139. loopAnimation: boolean;
  15140. /** defines a callback to call when animation ends if it is not looping */
  15141. onAnimationEnd?: (() => void) | null | undefined;
  15142. /** defines a callback to call when animation loops */
  15143. onAnimationLoop?: (() => void) | null | undefined;
  15144. /** defines whether the animation should be evaluated additively */
  15145. isAdditive: boolean;
  15146. private _localDelayOffset;
  15147. private _pausedDelay;
  15148. private _runtimeAnimations;
  15149. private _paused;
  15150. private _scene;
  15151. private _speedRatio;
  15152. private _weight;
  15153. private _syncRoot;
  15154. /**
  15155. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15156. * This will only apply for non looping animation (default is true)
  15157. */
  15158. disposeOnEnd: boolean;
  15159. /**
  15160. * Gets a boolean indicating if the animation has started
  15161. */
  15162. animationStarted: boolean;
  15163. /**
  15164. * Observer raised when the animation ends
  15165. */
  15166. onAnimationEndObservable: Observable<Animatable>;
  15167. /**
  15168. * Observer raised when the animation loops
  15169. */
  15170. onAnimationLoopObservable: Observable<Animatable>;
  15171. /**
  15172. * Gets the root Animatable used to synchronize and normalize animations
  15173. */
  15174. get syncRoot(): Nullable<Animatable>;
  15175. /**
  15176. * Gets the current frame of the first RuntimeAnimation
  15177. * Used to synchronize Animatables
  15178. */
  15179. get masterFrame(): number;
  15180. /**
  15181. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15182. */
  15183. get weight(): number;
  15184. set weight(value: number);
  15185. /**
  15186. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15187. */
  15188. get speedRatio(): number;
  15189. set speedRatio(value: number);
  15190. /**
  15191. * Creates a new Animatable
  15192. * @param scene defines the hosting scene
  15193. * @param target defines the target object
  15194. * @param fromFrame defines the starting frame number (default is 0)
  15195. * @param toFrame defines the ending frame number (default is 100)
  15196. * @param loopAnimation defines if the animation must loop (default is false)
  15197. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15198. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15199. * @param animations defines a group of animation to add to the new Animatable
  15200. * @param onAnimationLoop defines a callback to call when animation loops
  15201. * @param isAdditive defines whether the animation should be evaluated additively
  15202. */
  15203. constructor(scene: Scene,
  15204. /** defines the target object */
  15205. target: any,
  15206. /** defines the starting frame number (default is 0) */
  15207. fromFrame?: number,
  15208. /** defines the ending frame number (default is 100) */
  15209. toFrame?: number,
  15210. /** defines if the animation must loop (default is false) */
  15211. loopAnimation?: boolean, speedRatio?: number,
  15212. /** defines a callback to call when animation ends if it is not looping */
  15213. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15214. /** defines a callback to call when animation loops */
  15215. onAnimationLoop?: (() => void) | null | undefined,
  15216. /** defines whether the animation should be evaluated additively */
  15217. isAdditive?: boolean);
  15218. /**
  15219. * Synchronize and normalize current Animatable with a source Animatable
  15220. * This is useful when using animation weights and when animations are not of the same length
  15221. * @param root defines the root Animatable to synchronize with
  15222. * @returns the current Animatable
  15223. */
  15224. syncWith(root: Animatable): Animatable;
  15225. /**
  15226. * Gets the list of runtime animations
  15227. * @returns an array of RuntimeAnimation
  15228. */
  15229. getAnimations(): RuntimeAnimation[];
  15230. /**
  15231. * Adds more animations to the current animatable
  15232. * @param target defines the target of the animations
  15233. * @param animations defines the new animations to add
  15234. */
  15235. appendAnimations(target: any, animations: Animation[]): void;
  15236. /**
  15237. * Gets the source animation for a specific property
  15238. * @param property defines the propertyu to look for
  15239. * @returns null or the source animation for the given property
  15240. */
  15241. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15242. /**
  15243. * Gets the runtime animation for a specific property
  15244. * @param property defines the propertyu to look for
  15245. * @returns null or the runtime animation for the given property
  15246. */
  15247. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15248. /**
  15249. * Resets the animatable to its original state
  15250. */
  15251. reset(): void;
  15252. /**
  15253. * Allows the animatable to blend with current running animations
  15254. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15255. * @param blendingSpeed defines the blending speed to use
  15256. */
  15257. enableBlending(blendingSpeed: number): void;
  15258. /**
  15259. * Disable animation blending
  15260. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15261. */
  15262. disableBlending(): void;
  15263. /**
  15264. * Jump directly to a given frame
  15265. * @param frame defines the frame to jump to
  15266. */
  15267. goToFrame(frame: number): void;
  15268. /**
  15269. * Pause the animation
  15270. */
  15271. pause(): void;
  15272. /**
  15273. * Restart the animation
  15274. */
  15275. restart(): void;
  15276. private _raiseOnAnimationEnd;
  15277. /**
  15278. * Stop and delete the current animation
  15279. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15280. * @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)
  15281. */
  15282. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15283. /**
  15284. * Wait asynchronously for the animation to end
  15285. * @returns a promise which will be fullfilled when the animation ends
  15286. */
  15287. waitAsync(): Promise<Animatable>;
  15288. /** @hidden */
  15289. _animate(delay: number): boolean;
  15290. }
  15291. module "babylonjs/scene" {
  15292. interface Scene {
  15293. /** @hidden */
  15294. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15295. /** @hidden */
  15296. _processLateAnimationBindingsForMatrices(holder: {
  15297. totalWeight: number;
  15298. totalAdditiveWeight: number;
  15299. animations: RuntimeAnimation[];
  15300. additiveAnimations: RuntimeAnimation[];
  15301. originalValue: Matrix;
  15302. }): any;
  15303. /** @hidden */
  15304. _processLateAnimationBindingsForQuaternions(holder: {
  15305. totalWeight: number;
  15306. totalAdditiveWeight: number;
  15307. animations: RuntimeAnimation[];
  15308. additiveAnimations: RuntimeAnimation[];
  15309. originalValue: Quaternion;
  15310. }, refQuaternion: Quaternion): Quaternion;
  15311. /** @hidden */
  15312. _processLateAnimationBindings(): void;
  15313. /**
  15314. * Will start the animation sequence of a given target
  15315. * @param target defines the target
  15316. * @param from defines from which frame should animation start
  15317. * @param to defines until which frame should animation run.
  15318. * @param weight defines the weight to apply to the animation (1.0 by default)
  15319. * @param loop defines if the animation loops
  15320. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15321. * @param onAnimationEnd defines the function to be executed when the animation ends
  15322. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15323. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15324. * @param onAnimationLoop defines the callback to call when an animation loops
  15325. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15326. * @returns the animatable object created for this animation
  15327. */
  15328. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15329. /**
  15330. * Will start the animation sequence of a given target
  15331. * @param target defines the target
  15332. * @param from defines from which frame should animation start
  15333. * @param to defines until which frame should animation run.
  15334. * @param loop defines if the animation loops
  15335. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15336. * @param onAnimationEnd defines the function to be executed when the animation ends
  15337. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15338. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15339. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15340. * @param onAnimationLoop defines the callback to call when an animation loops
  15341. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15342. * @returns the animatable object created for this animation
  15343. */
  15344. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15345. /**
  15346. * Will start the animation sequence of a given target and its hierarchy
  15347. * @param target defines the target
  15348. * @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.
  15349. * @param from defines from which frame should animation start
  15350. * @param to defines until which frame should animation run.
  15351. * @param loop defines if the animation loops
  15352. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15353. * @param onAnimationEnd defines the function to be executed when the animation ends
  15354. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15355. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15356. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15357. * @param onAnimationLoop defines the callback to call when an animation loops
  15358. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15359. * @returns the list of created animatables
  15360. */
  15361. 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, isAdditive?: boolean): Animatable[];
  15362. /**
  15363. * Begin a new animation on a given node
  15364. * @param target defines the target where the animation will take place
  15365. * @param animations defines the list of animations to start
  15366. * @param from defines the initial value
  15367. * @param to defines the final value
  15368. * @param loop defines if you want animation to loop (off by default)
  15369. * @param speedRatio defines the speed ratio to apply to all animations
  15370. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15371. * @param onAnimationLoop defines the callback to call when an animation loops
  15372. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15373. * @returns the list of created animatables
  15374. */
  15375. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15376. /**
  15377. * Begin a new animation on a given node and its hierarchy
  15378. * @param target defines the root node where the animation will take place
  15379. * @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.
  15380. * @param animations defines the list of animations to start
  15381. * @param from defines the initial value
  15382. * @param to defines the final value
  15383. * @param loop defines if you want animation to loop (off by default)
  15384. * @param speedRatio defines the speed ratio to apply to all animations
  15385. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15386. * @param onAnimationLoop defines the callback to call when an animation loops
  15387. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15388. * @returns the list of animatables created for all nodes
  15389. */
  15390. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15391. /**
  15392. * Gets the animatable associated with a specific target
  15393. * @param target defines the target of the animatable
  15394. * @returns the required animatable if found
  15395. */
  15396. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15397. /**
  15398. * Gets all animatables associated with a given target
  15399. * @param target defines the target to look animatables for
  15400. * @returns an array of Animatables
  15401. */
  15402. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15403. /**
  15404. * Stops and removes all animations that have been applied to the scene
  15405. */
  15406. stopAllAnimations(): void;
  15407. /**
  15408. * Gets the current delta time used by animation engine
  15409. */
  15410. deltaTime: number;
  15411. }
  15412. }
  15413. module "babylonjs/Bones/bone" {
  15414. interface Bone {
  15415. /**
  15416. * Copy an animation range from another bone
  15417. * @param source defines the source bone
  15418. * @param rangeName defines the range name to copy
  15419. * @param frameOffset defines the frame offset
  15420. * @param rescaleAsRequired defines if rescaling must be applied if required
  15421. * @param skelDimensionsRatio defines the scaling ratio
  15422. * @returns true if operation was successful
  15423. */
  15424. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15425. }
  15426. }
  15427. }
  15428. declare module "babylonjs/Bones/skeleton" {
  15429. import { Bone } from "babylonjs/Bones/bone";
  15430. import { Observable } from "babylonjs/Misc/observable";
  15431. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15432. import { Scene } from "babylonjs/scene";
  15433. import { Nullable } from "babylonjs/types";
  15434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15435. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15436. import { Animatable } from "babylonjs/Animations/animatable";
  15437. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15438. import { Animation } from "babylonjs/Animations/animation";
  15439. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15440. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15442. /**
  15443. * Class used to handle skinning animations
  15444. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15445. */
  15446. export class Skeleton implements IAnimatable {
  15447. /** defines the skeleton name */
  15448. name: string;
  15449. /** defines the skeleton Id */
  15450. id: string;
  15451. /**
  15452. * Defines the list of child bones
  15453. */
  15454. bones: Bone[];
  15455. /**
  15456. * Defines an estimate of the dimension of the skeleton at rest
  15457. */
  15458. dimensionsAtRest: Vector3;
  15459. /**
  15460. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15461. */
  15462. needInitialSkinMatrix: boolean;
  15463. /**
  15464. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15465. */
  15466. overrideMesh: Nullable<AbstractMesh>;
  15467. /**
  15468. * Gets the list of animations attached to this skeleton
  15469. */
  15470. animations: Array<Animation>;
  15471. private _scene;
  15472. private _isDirty;
  15473. private _transformMatrices;
  15474. private _transformMatrixTexture;
  15475. private _meshesWithPoseMatrix;
  15476. private _animatables;
  15477. private _identity;
  15478. private _synchronizedWithMesh;
  15479. private _ranges;
  15480. private _lastAbsoluteTransformsUpdateId;
  15481. private _canUseTextureForBones;
  15482. private _uniqueId;
  15483. /** @hidden */
  15484. _numBonesWithLinkedTransformNode: number;
  15485. /** @hidden */
  15486. _hasWaitingData: Nullable<boolean>;
  15487. /**
  15488. * Specifies if the skeleton should be serialized
  15489. */
  15490. doNotSerialize: boolean;
  15491. private _useTextureToStoreBoneMatrices;
  15492. /**
  15493. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15494. * Please note that this option is not available if the hardware does not support it
  15495. */
  15496. get useTextureToStoreBoneMatrices(): boolean;
  15497. set useTextureToStoreBoneMatrices(value: boolean);
  15498. private _animationPropertiesOverride;
  15499. /**
  15500. * Gets or sets the animation properties override
  15501. */
  15502. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15503. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15504. /**
  15505. * List of inspectable custom properties (used by the Inspector)
  15506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15507. */
  15508. inspectableCustomProperties: IInspectable[];
  15509. /**
  15510. * An observable triggered before computing the skeleton's matrices
  15511. */
  15512. onBeforeComputeObservable: Observable<Skeleton>;
  15513. /**
  15514. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15515. */
  15516. get isUsingTextureForMatrices(): boolean;
  15517. /**
  15518. * Gets the unique ID of this skeleton
  15519. */
  15520. get uniqueId(): number;
  15521. /**
  15522. * Creates a new skeleton
  15523. * @param name defines the skeleton name
  15524. * @param id defines the skeleton Id
  15525. * @param scene defines the hosting scene
  15526. */
  15527. constructor(
  15528. /** defines the skeleton name */
  15529. name: string,
  15530. /** defines the skeleton Id */
  15531. id: string, scene: Scene);
  15532. /**
  15533. * Gets the current object class name.
  15534. * @return the class name
  15535. */
  15536. getClassName(): string;
  15537. /**
  15538. * Returns an array containing the root bones
  15539. * @returns an array containing the root bones
  15540. */
  15541. getChildren(): Array<Bone>;
  15542. /**
  15543. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15544. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15545. * @returns a Float32Array containing matrices data
  15546. */
  15547. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15548. /**
  15549. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15550. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15551. * @returns a raw texture containing the data
  15552. */
  15553. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15554. /**
  15555. * Gets the current hosting scene
  15556. * @returns a scene object
  15557. */
  15558. getScene(): Scene;
  15559. /**
  15560. * Gets a string representing the current skeleton data
  15561. * @param fullDetails defines a boolean indicating if we want a verbose version
  15562. * @returns a string representing the current skeleton data
  15563. */
  15564. toString(fullDetails?: boolean): string;
  15565. /**
  15566. * Get bone's index searching by name
  15567. * @param name defines bone's name to search for
  15568. * @return the indice of the bone. Returns -1 if not found
  15569. */
  15570. getBoneIndexByName(name: string): number;
  15571. /**
  15572. * Creater a new animation range
  15573. * @param name defines the name of the range
  15574. * @param from defines the start key
  15575. * @param to defines the end key
  15576. */
  15577. createAnimationRange(name: string, from: number, to: number): void;
  15578. /**
  15579. * Delete a specific animation range
  15580. * @param name defines the name of the range
  15581. * @param deleteFrames defines if frames must be removed as well
  15582. */
  15583. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15584. /**
  15585. * Gets a specific animation range
  15586. * @param name defines the name of the range to look for
  15587. * @returns the requested animation range or null if not found
  15588. */
  15589. getAnimationRange(name: string): Nullable<AnimationRange>;
  15590. /**
  15591. * Gets the list of all animation ranges defined on this skeleton
  15592. * @returns an array
  15593. */
  15594. getAnimationRanges(): Nullable<AnimationRange>[];
  15595. /**
  15596. * Copy animation range from a source skeleton.
  15597. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15598. * @param source defines the source skeleton
  15599. * @param name defines the name of the range to copy
  15600. * @param rescaleAsRequired defines if rescaling must be applied if required
  15601. * @returns true if operation was successful
  15602. */
  15603. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15604. /**
  15605. * Forces the skeleton to go to rest pose
  15606. */
  15607. returnToRest(): void;
  15608. private _getHighestAnimationFrame;
  15609. /**
  15610. * Begin a specific animation range
  15611. * @param name defines the name of the range to start
  15612. * @param loop defines if looping must be turned on (false by default)
  15613. * @param speedRatio defines the speed ratio to apply (1 by default)
  15614. * @param onAnimationEnd defines a callback which will be called when animation will end
  15615. * @returns a new animatable
  15616. */
  15617. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15618. /**
  15619. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15620. * @param skeleton defines the Skeleton containing the animation range to convert
  15621. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15622. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15623. * @returns the original skeleton
  15624. */
  15625. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15626. /** @hidden */
  15627. _markAsDirty(): void;
  15628. /** @hidden */
  15629. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15630. /** @hidden */
  15631. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15632. private _computeTransformMatrices;
  15633. /**
  15634. * Build all resources required to render a skeleton
  15635. */
  15636. prepare(): void;
  15637. /**
  15638. * Gets the list of animatables currently running for this skeleton
  15639. * @returns an array of animatables
  15640. */
  15641. getAnimatables(): IAnimatable[];
  15642. /**
  15643. * Clone the current skeleton
  15644. * @param name defines the name of the new skeleton
  15645. * @param id defines the id of the new skeleton
  15646. * @returns the new skeleton
  15647. */
  15648. clone(name: string, id?: string): Skeleton;
  15649. /**
  15650. * Enable animation blending for this skeleton
  15651. * @param blendingSpeed defines the blending speed to apply
  15652. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15653. */
  15654. enableBlending(blendingSpeed?: number): void;
  15655. /**
  15656. * Releases all resources associated with the current skeleton
  15657. */
  15658. dispose(): void;
  15659. /**
  15660. * Serialize the skeleton in a JSON object
  15661. * @returns a JSON object
  15662. */
  15663. serialize(): any;
  15664. /**
  15665. * Creates a new skeleton from serialized data
  15666. * @param parsedSkeleton defines the serialized data
  15667. * @param scene defines the hosting scene
  15668. * @returns a new skeleton
  15669. */
  15670. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15671. /**
  15672. * Compute all node absolute transforms
  15673. * @param forceUpdate defines if computation must be done even if cache is up to date
  15674. */
  15675. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15676. /**
  15677. * Gets the root pose matrix
  15678. * @returns a matrix
  15679. */
  15680. getPoseMatrix(): Nullable<Matrix>;
  15681. /**
  15682. * Sorts bones per internal index
  15683. */
  15684. sortBones(): void;
  15685. private _sortBones;
  15686. }
  15687. }
  15688. declare module "babylonjs/Meshes/instancedMesh" {
  15689. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15690. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15691. import { Camera } from "babylonjs/Cameras/camera";
  15692. import { Node } from "babylonjs/node";
  15693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15694. import { Mesh } from "babylonjs/Meshes/mesh";
  15695. import { Material } from "babylonjs/Materials/material";
  15696. import { Skeleton } from "babylonjs/Bones/skeleton";
  15697. import { Light } from "babylonjs/Lights/light";
  15698. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15699. /**
  15700. * Creates an instance based on a source mesh.
  15701. */
  15702. export class InstancedMesh extends AbstractMesh {
  15703. private _sourceMesh;
  15704. private _currentLOD;
  15705. /** @hidden */
  15706. _indexInSourceMeshInstanceArray: number;
  15707. constructor(name: string, source: Mesh);
  15708. /**
  15709. * Returns the string "InstancedMesh".
  15710. */
  15711. getClassName(): string;
  15712. /** Gets the list of lights affecting that mesh */
  15713. get lightSources(): Light[];
  15714. _resyncLightSources(): void;
  15715. _resyncLightSource(light: Light): void;
  15716. _removeLightSource(light: Light, dispose: boolean): void;
  15717. /**
  15718. * If the source mesh receives shadows
  15719. */
  15720. get receiveShadows(): boolean;
  15721. /**
  15722. * The material of the source mesh
  15723. */
  15724. get material(): Nullable<Material>;
  15725. /**
  15726. * Visibility of the source mesh
  15727. */
  15728. get visibility(): number;
  15729. /**
  15730. * Skeleton of the source mesh
  15731. */
  15732. get skeleton(): Nullable<Skeleton>;
  15733. /**
  15734. * Rendering ground id of the source mesh
  15735. */
  15736. get renderingGroupId(): number;
  15737. set renderingGroupId(value: number);
  15738. /**
  15739. * Returns the total number of vertices (integer).
  15740. */
  15741. getTotalVertices(): number;
  15742. /**
  15743. * Returns a positive integer : the total number of indices in this mesh geometry.
  15744. * @returns the numner of indices or zero if the mesh has no geometry.
  15745. */
  15746. getTotalIndices(): number;
  15747. /**
  15748. * The source mesh of the instance
  15749. */
  15750. get sourceMesh(): Mesh;
  15751. /**
  15752. * Is this node ready to be used/rendered
  15753. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15754. * @return {boolean} is it ready
  15755. */
  15756. isReady(completeCheck?: boolean): boolean;
  15757. /**
  15758. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15759. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15760. * @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.
  15761. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15762. */
  15763. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15764. /**
  15765. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15766. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15767. * The `data` are either a numeric array either a Float32Array.
  15768. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15769. * 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).
  15770. * Note that a new underlying VertexBuffer object is created each call.
  15771. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15772. *
  15773. * Possible `kind` values :
  15774. * - VertexBuffer.PositionKind
  15775. * - VertexBuffer.UVKind
  15776. * - VertexBuffer.UV2Kind
  15777. * - VertexBuffer.UV3Kind
  15778. * - VertexBuffer.UV4Kind
  15779. * - VertexBuffer.UV5Kind
  15780. * - VertexBuffer.UV6Kind
  15781. * - VertexBuffer.ColorKind
  15782. * - VertexBuffer.MatricesIndicesKind
  15783. * - VertexBuffer.MatricesIndicesExtraKind
  15784. * - VertexBuffer.MatricesWeightsKind
  15785. * - VertexBuffer.MatricesWeightsExtraKind
  15786. *
  15787. * Returns the Mesh.
  15788. */
  15789. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15790. /**
  15791. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15792. * If the mesh has no geometry, it is simply returned as it is.
  15793. * The `data` are either a numeric array either a Float32Array.
  15794. * No new underlying VertexBuffer object is created.
  15795. * 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.
  15796. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15797. *
  15798. * Possible `kind` values :
  15799. * - VertexBuffer.PositionKind
  15800. * - VertexBuffer.UVKind
  15801. * - VertexBuffer.UV2Kind
  15802. * - VertexBuffer.UV3Kind
  15803. * - VertexBuffer.UV4Kind
  15804. * - VertexBuffer.UV5Kind
  15805. * - VertexBuffer.UV6Kind
  15806. * - VertexBuffer.ColorKind
  15807. * - VertexBuffer.MatricesIndicesKind
  15808. * - VertexBuffer.MatricesIndicesExtraKind
  15809. * - VertexBuffer.MatricesWeightsKind
  15810. * - VertexBuffer.MatricesWeightsExtraKind
  15811. *
  15812. * Returns the Mesh.
  15813. */
  15814. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15815. /**
  15816. * Sets the mesh indices.
  15817. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15818. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15819. * This method creates a new index buffer each call.
  15820. * Returns the Mesh.
  15821. */
  15822. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15823. /**
  15824. * Boolean : True if the mesh owns the requested kind of data.
  15825. */
  15826. isVerticesDataPresent(kind: string): boolean;
  15827. /**
  15828. * Returns an array of indices (IndicesArray).
  15829. */
  15830. getIndices(): Nullable<IndicesArray>;
  15831. get _positions(): Nullable<Vector3[]>;
  15832. /**
  15833. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15834. * This means the mesh underlying bounding box and sphere are recomputed.
  15835. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15836. * @returns the current mesh
  15837. */
  15838. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15839. /** @hidden */
  15840. _preActivate(): InstancedMesh;
  15841. /** @hidden */
  15842. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15843. /** @hidden */
  15844. _postActivate(): void;
  15845. getWorldMatrix(): Matrix;
  15846. get isAnInstance(): boolean;
  15847. /**
  15848. * Returns the current associated LOD AbstractMesh.
  15849. */
  15850. getLOD(camera: Camera): AbstractMesh;
  15851. /** @hidden */
  15852. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15853. /** @hidden */
  15854. _syncSubMeshes(): InstancedMesh;
  15855. /** @hidden */
  15856. _generatePointsArray(): boolean;
  15857. /**
  15858. * Creates a new InstancedMesh from the current mesh.
  15859. * - name (string) : the cloned mesh name
  15860. * - newParent (optional Node) : the optional Node to parent the clone to.
  15861. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15862. *
  15863. * Returns the clone.
  15864. */
  15865. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15866. /**
  15867. * Disposes the InstancedMesh.
  15868. * Returns nothing.
  15869. */
  15870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15871. }
  15872. module "babylonjs/Meshes/mesh" {
  15873. interface Mesh {
  15874. /**
  15875. * Register a custom buffer that will be instanced
  15876. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15877. * @param kind defines the buffer kind
  15878. * @param stride defines the stride in floats
  15879. */
  15880. registerInstancedBuffer(kind: string, stride: number): void;
  15881. /** @hidden */
  15882. _userInstancedBuffersStorage: {
  15883. data: {
  15884. [key: string]: Float32Array;
  15885. };
  15886. sizes: {
  15887. [key: string]: number;
  15888. };
  15889. vertexBuffers: {
  15890. [key: string]: Nullable<VertexBuffer>;
  15891. };
  15892. strides: {
  15893. [key: string]: number;
  15894. };
  15895. };
  15896. }
  15897. }
  15898. module "babylonjs/Meshes/abstractMesh" {
  15899. interface AbstractMesh {
  15900. /**
  15901. * Object used to store instanced buffers defined by user
  15902. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15903. */
  15904. instancedBuffers: {
  15905. [key: string]: any;
  15906. };
  15907. }
  15908. }
  15909. }
  15910. declare module "babylonjs/Materials/shaderMaterial" {
  15911. import { Nullable } from "babylonjs/types";
  15912. import { Scene } from "babylonjs/scene";
  15913. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15915. import { Mesh } from "babylonjs/Meshes/mesh";
  15916. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15918. import { Effect } from "babylonjs/Materials/effect";
  15919. import { Material } from "babylonjs/Materials/material";
  15920. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15921. /**
  15922. * Defines the options associated with the creation of a shader material.
  15923. */
  15924. export interface IShaderMaterialOptions {
  15925. /**
  15926. * Does the material work in alpha blend mode
  15927. */
  15928. needAlphaBlending: boolean;
  15929. /**
  15930. * Does the material work in alpha test mode
  15931. */
  15932. needAlphaTesting: boolean;
  15933. /**
  15934. * The list of attribute names used in the shader
  15935. */
  15936. attributes: string[];
  15937. /**
  15938. * The list of unifrom names used in the shader
  15939. */
  15940. uniforms: string[];
  15941. /**
  15942. * The list of UBO names used in the shader
  15943. */
  15944. uniformBuffers: string[];
  15945. /**
  15946. * The list of sampler names used in the shader
  15947. */
  15948. samplers: string[];
  15949. /**
  15950. * The list of defines used in the shader
  15951. */
  15952. defines: string[];
  15953. }
  15954. /**
  15955. * 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.
  15956. *
  15957. * This returned material effects how the mesh will look based on the code in the shaders.
  15958. *
  15959. * @see http://doc.babylonjs.com/how_to/shader_material
  15960. */
  15961. export class ShaderMaterial extends Material {
  15962. private _shaderPath;
  15963. private _options;
  15964. private _textures;
  15965. private _textureArrays;
  15966. private _floats;
  15967. private _ints;
  15968. private _floatsArrays;
  15969. private _colors3;
  15970. private _colors3Arrays;
  15971. private _colors4;
  15972. private _colors4Arrays;
  15973. private _vectors2;
  15974. private _vectors3;
  15975. private _vectors4;
  15976. private _matrices;
  15977. private _matrixArrays;
  15978. private _matrices3x3;
  15979. private _matrices2x2;
  15980. private _vectors2Arrays;
  15981. private _vectors3Arrays;
  15982. private _vectors4Arrays;
  15983. private _cachedWorldViewMatrix;
  15984. private _cachedWorldViewProjectionMatrix;
  15985. private _renderId;
  15986. private _multiview;
  15987. private _cachedDefines;
  15988. /**
  15989. * Instantiate a new shader material.
  15990. * 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.
  15991. * This returned material effects how the mesh will look based on the code in the shaders.
  15992. * @see http://doc.babylonjs.com/how_to/shader_material
  15993. * @param name Define the name of the material in the scene
  15994. * @param scene Define the scene the material belongs to
  15995. * @param shaderPath Defines the route to the shader code in one of three ways:
  15996. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15997. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15998. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15999. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16000. * @param options Define the options used to create the shader
  16001. */
  16002. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16003. /**
  16004. * Gets the shader path used to define the shader code
  16005. * It can be modified to trigger a new compilation
  16006. */
  16007. get shaderPath(): any;
  16008. /**
  16009. * Sets the shader path used to define the shader code
  16010. * It can be modified to trigger a new compilation
  16011. */
  16012. set shaderPath(shaderPath: any);
  16013. /**
  16014. * Gets the options used to compile the shader.
  16015. * They can be modified to trigger a new compilation
  16016. */
  16017. get options(): IShaderMaterialOptions;
  16018. /**
  16019. * Gets the current class name of the material e.g. "ShaderMaterial"
  16020. * Mainly use in serialization.
  16021. * @returns the class name
  16022. */
  16023. getClassName(): string;
  16024. /**
  16025. * Specifies if the material will require alpha blending
  16026. * @returns a boolean specifying if alpha blending is needed
  16027. */
  16028. needAlphaBlending(): boolean;
  16029. /**
  16030. * Specifies if this material should be rendered in alpha test mode
  16031. * @returns a boolean specifying if an alpha test is needed.
  16032. */
  16033. needAlphaTesting(): boolean;
  16034. private _checkUniform;
  16035. /**
  16036. * Set a texture in the shader.
  16037. * @param name Define the name of the uniform samplers as defined in the shader
  16038. * @param texture Define the texture to bind to this sampler
  16039. * @return the material itself allowing "fluent" like uniform updates
  16040. */
  16041. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16042. /**
  16043. * Set a texture array in the shader.
  16044. * @param name Define the name of the uniform sampler array as defined in the shader
  16045. * @param textures Define the list of textures to bind to this sampler
  16046. * @return the material itself allowing "fluent" like uniform updates
  16047. */
  16048. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16049. /**
  16050. * Set a float in the shader.
  16051. * @param name Define the name of the uniform as defined in the shader
  16052. * @param value Define the value to give to the uniform
  16053. * @return the material itself allowing "fluent" like uniform updates
  16054. */
  16055. setFloat(name: string, value: number): ShaderMaterial;
  16056. /**
  16057. * Set a int in the shader.
  16058. * @param name Define the name of the uniform as defined in the shader
  16059. * @param value Define the value to give to the uniform
  16060. * @return the material itself allowing "fluent" like uniform updates
  16061. */
  16062. setInt(name: string, value: number): ShaderMaterial;
  16063. /**
  16064. * Set an array of floats in the shader.
  16065. * @param name Define the name of the uniform as defined in the shader
  16066. * @param value Define the value to give to the uniform
  16067. * @return the material itself allowing "fluent" like uniform updates
  16068. */
  16069. setFloats(name: string, value: number[]): ShaderMaterial;
  16070. /**
  16071. * Set a vec3 in the shader from a Color3.
  16072. * @param name Define the name of the uniform as defined in the shader
  16073. * @param value Define the value to give to the uniform
  16074. * @return the material itself allowing "fluent" like uniform updates
  16075. */
  16076. setColor3(name: string, value: Color3): ShaderMaterial;
  16077. /**
  16078. * Set a vec3 array in the shader from a Color3 array.
  16079. * @param name Define the name of the uniform as defined in the shader
  16080. * @param value Define the value to give to the uniform
  16081. * @return the material itself allowing "fluent" like uniform updates
  16082. */
  16083. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16084. /**
  16085. * Set a vec4 in the shader from a Color4.
  16086. * @param name Define the name of the uniform as defined in the shader
  16087. * @param value Define the value to give to the uniform
  16088. * @return the material itself allowing "fluent" like uniform updates
  16089. */
  16090. setColor4(name: string, value: Color4): ShaderMaterial;
  16091. /**
  16092. * Set a vec4 array in the shader from a Color4 array.
  16093. * @param name Define the name of the uniform as defined in the shader
  16094. * @param value Define the value to give to the uniform
  16095. * @return the material itself allowing "fluent" like uniform updates
  16096. */
  16097. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16098. /**
  16099. * Set a vec2 in the shader from a Vector2.
  16100. * @param name Define the name of the uniform as defined in the shader
  16101. * @param value Define the value to give to the uniform
  16102. * @return the material itself allowing "fluent" like uniform updates
  16103. */
  16104. setVector2(name: string, value: Vector2): ShaderMaterial;
  16105. /**
  16106. * Set a vec3 in the shader from a Vector3.
  16107. * @param name Define the name of the uniform as defined in the shader
  16108. * @param value Define the value to give to the uniform
  16109. * @return the material itself allowing "fluent" like uniform updates
  16110. */
  16111. setVector3(name: string, value: Vector3): ShaderMaterial;
  16112. /**
  16113. * Set a vec4 in the shader from a Vector4.
  16114. * @param name Define the name of the uniform as defined in the shader
  16115. * @param value Define the value to give to the uniform
  16116. * @return the material itself allowing "fluent" like uniform updates
  16117. */
  16118. setVector4(name: string, value: Vector4): ShaderMaterial;
  16119. /**
  16120. * Set a mat4 in the shader from a Matrix.
  16121. * @param name Define the name of the uniform as defined in the shader
  16122. * @param value Define the value to give to the uniform
  16123. * @return the material itself allowing "fluent" like uniform updates
  16124. */
  16125. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16126. /**
  16127. * Set a float32Array in the shader from a matrix array.
  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 material itself allowing "fluent" like uniform updates
  16131. */
  16132. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16133. /**
  16134. * Set a mat3 in the shader from a Float32Array.
  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 material itself allowing "fluent" like uniform updates
  16138. */
  16139. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16140. /**
  16141. * Set a mat2 in the shader from a Float32Array.
  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 material itself allowing "fluent" like uniform updates
  16145. */
  16146. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16147. /**
  16148. * Set a vec2 array in the shader from a number array.
  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 material itself allowing "fluent" like uniform updates
  16152. */
  16153. setArray2(name: string, value: number[]): ShaderMaterial;
  16154. /**
  16155. * Set a vec3 array in the shader from a number array.
  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 material itself allowing "fluent" like uniform updates
  16159. */
  16160. setArray3(name: string, value: number[]): ShaderMaterial;
  16161. /**
  16162. * Set a vec4 array in the shader from a number array.
  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 material itself allowing "fluent" like uniform updates
  16166. */
  16167. setArray4(name: string, value: number[]): ShaderMaterial;
  16168. private _checkCache;
  16169. /**
  16170. * Specifies that the submesh is ready to be used
  16171. * @param mesh defines the mesh to check
  16172. * @param subMesh defines which submesh to check
  16173. * @param useInstances specifies that instances should be used
  16174. * @returns a boolean indicating that the submesh is ready or not
  16175. */
  16176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16177. /**
  16178. * Checks if the material is ready to render the requested mesh
  16179. * @param mesh Define the mesh to render
  16180. * @param useInstances Define whether or not the material is used with instances
  16181. * @returns true if ready, otherwise false
  16182. */
  16183. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16184. /**
  16185. * Binds the world matrix to the material
  16186. * @param world defines the world transformation matrix
  16187. * @param effectOverride - If provided, use this effect instead of internal effect
  16188. */
  16189. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16190. /**
  16191. * Binds the submesh to this material by preparing the effect and shader to draw
  16192. * @param world defines the world transformation matrix
  16193. * @param mesh defines the mesh containing the submesh
  16194. * @param subMesh defines the submesh to bind the material to
  16195. */
  16196. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16197. /**
  16198. * Binds the material to the mesh
  16199. * @param world defines the world transformation matrix
  16200. * @param mesh defines the mesh to bind the material to
  16201. * @param effectOverride - If provided, use this effect instead of internal effect
  16202. */
  16203. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16204. protected _afterBind(mesh?: Mesh): void;
  16205. /**
  16206. * Gets the active textures from the material
  16207. * @returns an array of textures
  16208. */
  16209. getActiveTextures(): BaseTexture[];
  16210. /**
  16211. * Specifies if the material uses a texture
  16212. * @param texture defines the texture to check against the material
  16213. * @returns a boolean specifying if the material uses the texture
  16214. */
  16215. hasTexture(texture: BaseTexture): boolean;
  16216. /**
  16217. * Makes a duplicate of the material, and gives it a new name
  16218. * @param name defines the new name for the duplicated material
  16219. * @returns the cloned material
  16220. */
  16221. clone(name: string): ShaderMaterial;
  16222. /**
  16223. * Disposes the material
  16224. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16225. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16226. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16227. */
  16228. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16229. /**
  16230. * Serializes this material in a JSON representation
  16231. * @returns the serialized material object
  16232. */
  16233. serialize(): any;
  16234. /**
  16235. * Creates a shader material from parsed shader material data
  16236. * @param source defines the JSON represnetation of the material
  16237. * @param scene defines the hosting scene
  16238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16239. * @returns a new material
  16240. */
  16241. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16242. }
  16243. }
  16244. declare module "babylonjs/Shaders/color.fragment" {
  16245. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16246. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16247. /** @hidden */
  16248. export var colorPixelShader: {
  16249. name: string;
  16250. shader: string;
  16251. };
  16252. }
  16253. declare module "babylonjs/Shaders/color.vertex" {
  16254. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16255. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16257. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16258. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16259. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16260. /** @hidden */
  16261. export var colorVertexShader: {
  16262. name: string;
  16263. shader: string;
  16264. };
  16265. }
  16266. declare module "babylonjs/Meshes/linesMesh" {
  16267. import { Nullable } from "babylonjs/types";
  16268. import { Scene } from "babylonjs/scene";
  16269. import { Color3 } from "babylonjs/Maths/math.color";
  16270. import { Node } from "babylonjs/node";
  16271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16272. import { Mesh } from "babylonjs/Meshes/mesh";
  16273. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16274. import { Effect } from "babylonjs/Materials/effect";
  16275. import { Material } from "babylonjs/Materials/material";
  16276. import "babylonjs/Shaders/color.fragment";
  16277. import "babylonjs/Shaders/color.vertex";
  16278. /**
  16279. * Line mesh
  16280. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16281. */
  16282. export class LinesMesh extends Mesh {
  16283. /**
  16284. * If vertex color should be applied to the mesh
  16285. */
  16286. readonly useVertexColor?: boolean | undefined;
  16287. /**
  16288. * If vertex alpha should be applied to the mesh
  16289. */
  16290. readonly useVertexAlpha?: boolean | undefined;
  16291. /**
  16292. * Color of the line (Default: White)
  16293. */
  16294. color: Color3;
  16295. /**
  16296. * Alpha of the line (Default: 1)
  16297. */
  16298. alpha: number;
  16299. /**
  16300. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16301. * This margin is expressed in world space coordinates, so its value may vary.
  16302. * Default value is 0.1
  16303. */
  16304. intersectionThreshold: number;
  16305. private _colorShader;
  16306. private color4;
  16307. /**
  16308. * Creates a new LinesMesh
  16309. * @param name defines the name
  16310. * @param scene defines the hosting scene
  16311. * @param parent defines the parent mesh if any
  16312. * @param source defines the optional source LinesMesh used to clone data from
  16313. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16314. * When false, achieved by calling a clone(), also passing False.
  16315. * This will make creation of children, recursive.
  16316. * @param useVertexColor defines if this LinesMesh supports vertex color
  16317. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16318. */
  16319. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16320. /**
  16321. * If vertex color should be applied to the mesh
  16322. */
  16323. useVertexColor?: boolean | undefined,
  16324. /**
  16325. * If vertex alpha should be applied to the mesh
  16326. */
  16327. useVertexAlpha?: boolean | undefined);
  16328. private _addClipPlaneDefine;
  16329. private _removeClipPlaneDefine;
  16330. isReady(): boolean;
  16331. /**
  16332. * Returns the string "LineMesh"
  16333. */
  16334. getClassName(): string;
  16335. /**
  16336. * @hidden
  16337. */
  16338. get material(): Material;
  16339. /**
  16340. * @hidden
  16341. */
  16342. set material(value: Material);
  16343. /**
  16344. * @hidden
  16345. */
  16346. get checkCollisions(): boolean;
  16347. /** @hidden */
  16348. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16349. /** @hidden */
  16350. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16351. /**
  16352. * Disposes of the line mesh
  16353. * @param doNotRecurse If children should be disposed
  16354. */
  16355. dispose(doNotRecurse?: boolean): void;
  16356. /**
  16357. * Returns a new LineMesh object cloned from the current one.
  16358. */
  16359. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16360. /**
  16361. * Creates a new InstancedLinesMesh object from the mesh model.
  16362. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16363. * @param name defines the name of the new instance
  16364. * @returns a new InstancedLinesMesh
  16365. */
  16366. createInstance(name: string): InstancedLinesMesh;
  16367. }
  16368. /**
  16369. * Creates an instance based on a source LinesMesh
  16370. */
  16371. export class InstancedLinesMesh extends InstancedMesh {
  16372. /**
  16373. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16374. * This margin is expressed in world space coordinates, so its value may vary.
  16375. * Initilized with the intersectionThreshold value of the source LinesMesh
  16376. */
  16377. intersectionThreshold: number;
  16378. constructor(name: string, source: LinesMesh);
  16379. /**
  16380. * Returns the string "InstancedLinesMesh".
  16381. */
  16382. getClassName(): string;
  16383. }
  16384. }
  16385. declare module "babylonjs/Shaders/line.fragment" {
  16386. /** @hidden */
  16387. export var linePixelShader: {
  16388. name: string;
  16389. shader: string;
  16390. };
  16391. }
  16392. declare module "babylonjs/Shaders/line.vertex" {
  16393. /** @hidden */
  16394. export var lineVertexShader: {
  16395. name: string;
  16396. shader: string;
  16397. };
  16398. }
  16399. declare module "babylonjs/Rendering/edgesRenderer" {
  16400. import { Nullable } from "babylonjs/types";
  16401. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16403. import { Vector3 } from "babylonjs/Maths/math.vector";
  16404. import { IDisposable } from "babylonjs/scene";
  16405. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16406. import "babylonjs/Shaders/line.fragment";
  16407. import "babylonjs/Shaders/line.vertex";
  16408. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16409. module "babylonjs/Meshes/abstractMesh" {
  16410. interface AbstractMesh {
  16411. /**
  16412. * Gets the edgesRenderer associated with the mesh
  16413. */
  16414. edgesRenderer: Nullable<EdgesRenderer>;
  16415. }
  16416. }
  16417. module "babylonjs/Meshes/linesMesh" {
  16418. interface LinesMesh {
  16419. /**
  16420. * Enables the edge rendering mode on the mesh.
  16421. * This mode makes the mesh edges visible
  16422. * @param epsilon defines the maximal distance between two angles to detect a face
  16423. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16424. * @returns the currentAbstractMesh
  16425. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16426. */
  16427. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16428. }
  16429. }
  16430. module "babylonjs/Meshes/linesMesh" {
  16431. interface InstancedLinesMesh {
  16432. /**
  16433. * Enables the edge rendering mode on the mesh.
  16434. * This mode makes the mesh edges visible
  16435. * @param epsilon defines the maximal distance between two angles to detect a face
  16436. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16437. * @returns the current InstancedLinesMesh
  16438. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16439. */
  16440. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16441. }
  16442. }
  16443. /**
  16444. * Defines the minimum contract an Edges renderer should follow.
  16445. */
  16446. export interface IEdgesRenderer extends IDisposable {
  16447. /**
  16448. * Gets or sets a boolean indicating if the edgesRenderer is active
  16449. */
  16450. isEnabled: boolean;
  16451. /**
  16452. * Renders the edges of the attached mesh,
  16453. */
  16454. render(): void;
  16455. /**
  16456. * Checks wether or not the edges renderer is ready to render.
  16457. * @return true if ready, otherwise false.
  16458. */
  16459. isReady(): boolean;
  16460. }
  16461. /**
  16462. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16463. */
  16464. export class EdgesRenderer implements IEdgesRenderer {
  16465. /**
  16466. * Define the size of the edges with an orthographic camera
  16467. */
  16468. edgesWidthScalerForOrthographic: number;
  16469. /**
  16470. * Define the size of the edges with a perspective camera
  16471. */
  16472. edgesWidthScalerForPerspective: number;
  16473. protected _source: AbstractMesh;
  16474. protected _linesPositions: number[];
  16475. protected _linesNormals: number[];
  16476. protected _linesIndices: number[];
  16477. protected _epsilon: number;
  16478. protected _indicesCount: number;
  16479. protected _lineShader: ShaderMaterial;
  16480. protected _ib: DataBuffer;
  16481. protected _buffers: {
  16482. [key: string]: Nullable<VertexBuffer>;
  16483. };
  16484. protected _checkVerticesInsteadOfIndices: boolean;
  16485. private _meshRebuildObserver;
  16486. private _meshDisposeObserver;
  16487. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16488. isEnabled: boolean;
  16489. /**
  16490. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16491. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16492. * @param source Mesh used to create edges
  16493. * @param epsilon sum of angles in adjacency to check for edge
  16494. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16495. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16496. */
  16497. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16498. protected _prepareRessources(): void;
  16499. /** @hidden */
  16500. _rebuild(): void;
  16501. /**
  16502. * Releases the required resources for the edges renderer
  16503. */
  16504. dispose(): void;
  16505. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16506. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16507. /**
  16508. * Checks if the pair of p0 and p1 is en edge
  16509. * @param faceIndex
  16510. * @param edge
  16511. * @param faceNormals
  16512. * @param p0
  16513. * @param p1
  16514. * @private
  16515. */
  16516. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16517. /**
  16518. * push line into the position, normal and index buffer
  16519. * @protected
  16520. */
  16521. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16522. /**
  16523. * Generates lines edges from adjacencjes
  16524. * @private
  16525. */
  16526. _generateEdgesLines(): void;
  16527. /**
  16528. * Checks wether or not the edges renderer is ready to render.
  16529. * @return true if ready, otherwise false.
  16530. */
  16531. isReady(): boolean;
  16532. /**
  16533. * Renders the edges of the attached mesh,
  16534. */
  16535. render(): void;
  16536. }
  16537. /**
  16538. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16539. */
  16540. export class LineEdgesRenderer extends EdgesRenderer {
  16541. /**
  16542. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16543. * @param source LineMesh used to generate edges
  16544. * @param epsilon not important (specified angle for edge detection)
  16545. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16546. */
  16547. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16548. /**
  16549. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16550. */
  16551. _generateEdgesLines(): void;
  16552. }
  16553. }
  16554. declare module "babylonjs/Rendering/renderingGroup" {
  16555. import { SmartArray } from "babylonjs/Misc/smartArray";
  16556. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16558. import { Nullable } from "babylonjs/types";
  16559. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16560. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16561. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16562. import { Material } from "babylonjs/Materials/material";
  16563. import { Scene } from "babylonjs/scene";
  16564. /**
  16565. * This represents the object necessary to create a rendering group.
  16566. * This is exclusively used and created by the rendering manager.
  16567. * To modify the behavior, you use the available helpers in your scene or meshes.
  16568. * @hidden
  16569. */
  16570. export class RenderingGroup {
  16571. index: number;
  16572. private static _zeroVector;
  16573. private _scene;
  16574. private _opaqueSubMeshes;
  16575. private _transparentSubMeshes;
  16576. private _alphaTestSubMeshes;
  16577. private _depthOnlySubMeshes;
  16578. private _particleSystems;
  16579. private _spriteManagers;
  16580. private _opaqueSortCompareFn;
  16581. private _alphaTestSortCompareFn;
  16582. private _transparentSortCompareFn;
  16583. private _renderOpaque;
  16584. private _renderAlphaTest;
  16585. private _renderTransparent;
  16586. /** @hidden */
  16587. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16588. onBeforeTransparentRendering: () => void;
  16589. /**
  16590. * Set the opaque sort comparison function.
  16591. * If null the sub meshes will be render in the order they were created
  16592. */
  16593. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16594. /**
  16595. * Set the alpha test sort comparison function.
  16596. * If null the sub meshes will be render in the order they were created
  16597. */
  16598. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16599. /**
  16600. * Set the transparent sort comparison function.
  16601. * If null the sub meshes will be render in the order they were created
  16602. */
  16603. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16604. /**
  16605. * Creates a new rendering group.
  16606. * @param index The rendering group index
  16607. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16608. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16609. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16610. */
  16611. 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>);
  16612. /**
  16613. * Render all the sub meshes contained in the group.
  16614. * @param customRenderFunction Used to override the default render behaviour of the group.
  16615. * @returns true if rendered some submeshes.
  16616. */
  16617. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16618. /**
  16619. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16620. * @param subMeshes The submeshes to render
  16621. */
  16622. private renderOpaqueSorted;
  16623. /**
  16624. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16625. * @param subMeshes The submeshes to render
  16626. */
  16627. private renderAlphaTestSorted;
  16628. /**
  16629. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16630. * @param subMeshes The submeshes to render
  16631. */
  16632. private renderTransparentSorted;
  16633. /**
  16634. * Renders the submeshes in a specified order.
  16635. * @param subMeshes The submeshes to sort before render
  16636. * @param sortCompareFn The comparison function use to sort
  16637. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16638. * @param transparent Specifies to activate blending if true
  16639. */
  16640. private static renderSorted;
  16641. /**
  16642. * Renders the submeshes in the order they were dispatched (no sort applied).
  16643. * @param subMeshes The submeshes to render
  16644. */
  16645. private static renderUnsorted;
  16646. /**
  16647. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16648. * are rendered back to front if in the same alpha index.
  16649. *
  16650. * @param a The first submesh
  16651. * @param b The second submesh
  16652. * @returns The result of the comparison
  16653. */
  16654. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16655. /**
  16656. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16657. * are rendered back to front.
  16658. *
  16659. * @param a The first submesh
  16660. * @param b The second submesh
  16661. * @returns The result of the comparison
  16662. */
  16663. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16664. /**
  16665. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16666. * are rendered front to back (prevent overdraw).
  16667. *
  16668. * @param a The first submesh
  16669. * @param b The second submesh
  16670. * @returns The result of the comparison
  16671. */
  16672. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16673. /**
  16674. * Resets the different lists of submeshes to prepare a new frame.
  16675. */
  16676. prepare(): void;
  16677. dispose(): void;
  16678. /**
  16679. * Inserts the submesh in its correct queue depending on its material.
  16680. * @param subMesh The submesh to dispatch
  16681. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16682. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16683. */
  16684. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16685. dispatchSprites(spriteManager: ISpriteManager): void;
  16686. dispatchParticles(particleSystem: IParticleSystem): void;
  16687. private _renderParticles;
  16688. private _renderSprites;
  16689. }
  16690. }
  16691. declare module "babylonjs/Rendering/renderingManager" {
  16692. import { Nullable } from "babylonjs/types";
  16693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16695. import { SmartArray } from "babylonjs/Misc/smartArray";
  16696. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16697. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16698. import { Material } from "babylonjs/Materials/material";
  16699. import { Scene } from "babylonjs/scene";
  16700. import { Camera } from "babylonjs/Cameras/camera";
  16701. /**
  16702. * Interface describing the different options available in the rendering manager
  16703. * regarding Auto Clear between groups.
  16704. */
  16705. export interface IRenderingManagerAutoClearSetup {
  16706. /**
  16707. * Defines whether or not autoclear is enable.
  16708. */
  16709. autoClear: boolean;
  16710. /**
  16711. * Defines whether or not to autoclear the depth buffer.
  16712. */
  16713. depth: boolean;
  16714. /**
  16715. * Defines whether or not to autoclear the stencil buffer.
  16716. */
  16717. stencil: boolean;
  16718. }
  16719. /**
  16720. * This class is used by the onRenderingGroupObservable
  16721. */
  16722. export class RenderingGroupInfo {
  16723. /**
  16724. * The Scene that being rendered
  16725. */
  16726. scene: Scene;
  16727. /**
  16728. * The camera currently used for the rendering pass
  16729. */
  16730. camera: Nullable<Camera>;
  16731. /**
  16732. * The ID of the renderingGroup being processed
  16733. */
  16734. renderingGroupId: number;
  16735. }
  16736. /**
  16737. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16738. * It is enable to manage the different groups as well as the different necessary sort functions.
  16739. * This should not be used directly aside of the few static configurations
  16740. */
  16741. export class RenderingManager {
  16742. /**
  16743. * The max id used for rendering groups (not included)
  16744. */
  16745. static MAX_RENDERINGGROUPS: number;
  16746. /**
  16747. * The min id used for rendering groups (included)
  16748. */
  16749. static MIN_RENDERINGGROUPS: number;
  16750. /**
  16751. * Used to globally prevent autoclearing scenes.
  16752. */
  16753. static AUTOCLEAR: boolean;
  16754. /**
  16755. * @hidden
  16756. */
  16757. _useSceneAutoClearSetup: boolean;
  16758. private _scene;
  16759. private _renderingGroups;
  16760. private _depthStencilBufferAlreadyCleaned;
  16761. private _autoClearDepthStencil;
  16762. private _customOpaqueSortCompareFn;
  16763. private _customAlphaTestSortCompareFn;
  16764. private _customTransparentSortCompareFn;
  16765. private _renderingGroupInfo;
  16766. /**
  16767. * Instantiates a new rendering group for a particular scene
  16768. * @param scene Defines the scene the groups belongs to
  16769. */
  16770. constructor(scene: Scene);
  16771. private _clearDepthStencilBuffer;
  16772. /**
  16773. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16774. * @hidden
  16775. */
  16776. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16777. /**
  16778. * Resets the different information of the group to prepare a new frame
  16779. * @hidden
  16780. */
  16781. reset(): void;
  16782. /**
  16783. * Dispose and release the group and its associated resources.
  16784. * @hidden
  16785. */
  16786. dispose(): void;
  16787. /**
  16788. * Clear the info related to rendering groups preventing retention points during dispose.
  16789. */
  16790. freeRenderingGroups(): void;
  16791. private _prepareRenderingGroup;
  16792. /**
  16793. * Add a sprite manager to the rendering manager in order to render it this frame.
  16794. * @param spriteManager Define the sprite manager to render
  16795. */
  16796. dispatchSprites(spriteManager: ISpriteManager): void;
  16797. /**
  16798. * Add a particle system to the rendering manager in order to render it this frame.
  16799. * @param particleSystem Define the particle system to render
  16800. */
  16801. dispatchParticles(particleSystem: IParticleSystem): void;
  16802. /**
  16803. * Add a submesh to the manager in order to render it this frame
  16804. * @param subMesh The submesh to dispatch
  16805. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16806. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16807. */
  16808. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16809. /**
  16810. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16811. * This allowed control for front to back rendering or reversly depending of the special needs.
  16812. *
  16813. * @param renderingGroupId The rendering group id corresponding to its index
  16814. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16815. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16816. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16817. */
  16818. 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;
  16819. /**
  16820. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16821. *
  16822. * @param renderingGroupId The rendering group id corresponding to its index
  16823. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16824. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16825. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16826. */
  16827. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16828. /**
  16829. * Gets the current auto clear configuration for one rendering group of the rendering
  16830. * manager.
  16831. * @param index the rendering group index to get the information for
  16832. * @returns The auto clear setup for the requested rendering group
  16833. */
  16834. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16835. }
  16836. }
  16837. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16838. import { SmartArray } from "babylonjs/Misc/smartArray";
  16839. import { Nullable } from "babylonjs/types";
  16840. import { Scene } from "babylonjs/scene";
  16841. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16844. import { Mesh } from "babylonjs/Meshes/mesh";
  16845. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16846. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16847. import { Effect } from "babylonjs/Materials/effect";
  16848. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16849. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16850. import "babylonjs/Shaders/shadowMap.fragment";
  16851. import "babylonjs/Shaders/shadowMap.vertex";
  16852. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16853. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  16854. import { Observable } from "babylonjs/Misc/observable";
  16855. /**
  16856. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16857. */
  16858. export interface ICustomShaderOptions {
  16859. /**
  16860. * Gets or sets the custom shader name to use
  16861. */
  16862. shaderName: string;
  16863. /**
  16864. * The list of attribute names used in the shader
  16865. */
  16866. attributes?: string[];
  16867. /**
  16868. * The list of unifrom names used in the shader
  16869. */
  16870. uniforms?: string[];
  16871. /**
  16872. * The list of sampler names used in the shader
  16873. */
  16874. samplers?: string[];
  16875. /**
  16876. * The list of defines used in the shader
  16877. */
  16878. defines?: string[];
  16879. }
  16880. /**
  16881. * Interface to implement to create a shadow generator compatible with BJS.
  16882. */
  16883. export interface IShadowGenerator {
  16884. /**
  16885. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16886. * @returns The render target texture if present otherwise, null
  16887. */
  16888. getShadowMap(): Nullable<RenderTargetTexture>;
  16889. /**
  16890. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16891. * @param subMesh The submesh we want to render in the shadow map
  16892. * @param useInstances Defines wether will draw in the map using instances
  16893. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16894. * @returns true if ready otherwise, false
  16895. */
  16896. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16897. /**
  16898. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16899. * @param defines Defines of the material we want to update
  16900. * @param lightIndex Index of the light in the enabled light list of the material
  16901. */
  16902. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16903. /**
  16904. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16905. * defined in the generator but impacting the effect).
  16906. * It implies the unifroms available on the materials are the standard BJS ones.
  16907. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16908. * @param effect The effect we are binfing the information for
  16909. */
  16910. bindShadowLight(lightIndex: string, effect: Effect): void;
  16911. /**
  16912. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16913. * (eq to shadow prjection matrix * light transform matrix)
  16914. * @returns The transform matrix used to create the shadow map
  16915. */
  16916. getTransformMatrix(): Matrix;
  16917. /**
  16918. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16919. * Cube and 2D textures for instance.
  16920. */
  16921. recreateShadowMap(): void;
  16922. /**
  16923. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16924. * @param onCompiled Callback triggered at the and of the effects compilation
  16925. * @param options Sets of optional options forcing the compilation with different modes
  16926. */
  16927. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16928. useInstances: boolean;
  16929. }>): void;
  16930. /**
  16931. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16932. * @param options Sets of optional options forcing the compilation with different modes
  16933. * @returns A promise that resolves when the compilation completes
  16934. */
  16935. forceCompilationAsync(options?: Partial<{
  16936. useInstances: boolean;
  16937. }>): Promise<void>;
  16938. /**
  16939. * Serializes the shadow generator setup to a json object.
  16940. * @returns The serialized JSON object
  16941. */
  16942. serialize(): any;
  16943. /**
  16944. * Disposes the Shadow map and related Textures and effects.
  16945. */
  16946. dispose(): void;
  16947. }
  16948. /**
  16949. * Default implementation IShadowGenerator.
  16950. * This is the main object responsible of generating shadows in the framework.
  16951. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16952. */
  16953. export class ShadowGenerator implements IShadowGenerator {
  16954. /**
  16955. * Name of the shadow generator class
  16956. */
  16957. static CLASSNAME: string;
  16958. /**
  16959. * Shadow generator mode None: no filtering applied.
  16960. */
  16961. static readonly FILTER_NONE: number;
  16962. /**
  16963. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16964. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16965. */
  16966. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16967. /**
  16968. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16969. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16970. */
  16971. static readonly FILTER_POISSONSAMPLING: number;
  16972. /**
  16973. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16974. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16975. */
  16976. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16977. /**
  16978. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16979. * edge artifacts on steep falloff.
  16980. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16981. */
  16982. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16983. /**
  16984. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16985. * edge artifacts on steep falloff.
  16986. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16987. */
  16988. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16989. /**
  16990. * Shadow generator mode PCF: Percentage Closer Filtering
  16991. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16992. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16993. */
  16994. static readonly FILTER_PCF: number;
  16995. /**
  16996. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16997. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16998. * Contact Hardening
  16999. */
  17000. static readonly FILTER_PCSS: number;
  17001. /**
  17002. * Reserved for PCF and PCSS
  17003. * Highest Quality.
  17004. *
  17005. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17006. *
  17007. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17008. */
  17009. static readonly QUALITY_HIGH: number;
  17010. /**
  17011. * Reserved for PCF and PCSS
  17012. * Good tradeoff for quality/perf cross devices
  17013. *
  17014. * Execute PCF on a 3*3 kernel.
  17015. *
  17016. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17017. */
  17018. static readonly QUALITY_MEDIUM: number;
  17019. /**
  17020. * Reserved for PCF and PCSS
  17021. * The lowest quality but the fastest.
  17022. *
  17023. * Execute PCF on a 1*1 kernel.
  17024. *
  17025. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17026. */
  17027. static readonly QUALITY_LOW: number;
  17028. /** Gets or sets the custom shader name to use */
  17029. customShaderOptions: ICustomShaderOptions;
  17030. /**
  17031. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17032. */
  17033. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17034. /**
  17035. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17036. */
  17037. onAfterShadowMapRenderObservable: Observable<Effect>;
  17038. /**
  17039. * Observable triggered before a mesh is rendered in the shadow map.
  17040. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17041. */
  17042. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17043. /**
  17044. * Observable triggered after a mesh is rendered in the shadow map.
  17045. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17046. */
  17047. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17048. protected _bias: number;
  17049. /**
  17050. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17051. */
  17052. get bias(): number;
  17053. /**
  17054. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17055. */
  17056. set bias(bias: number);
  17057. protected _normalBias: number;
  17058. /**
  17059. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17060. */
  17061. get normalBias(): number;
  17062. /**
  17063. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17064. */
  17065. set normalBias(normalBias: number);
  17066. protected _blurBoxOffset: number;
  17067. /**
  17068. * Gets the blur box offset: offset applied during the blur pass.
  17069. * Only useful if useKernelBlur = false
  17070. */
  17071. get blurBoxOffset(): number;
  17072. /**
  17073. * Sets the blur box offset: offset applied during the blur pass.
  17074. * Only useful if useKernelBlur = false
  17075. */
  17076. set blurBoxOffset(value: number);
  17077. protected _blurScale: number;
  17078. /**
  17079. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17080. * 2 means half of the size.
  17081. */
  17082. get blurScale(): number;
  17083. /**
  17084. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17085. * 2 means half of the size.
  17086. */
  17087. set blurScale(value: number);
  17088. protected _blurKernel: number;
  17089. /**
  17090. * Gets the blur kernel: kernel size of the blur pass.
  17091. * Only useful if useKernelBlur = true
  17092. */
  17093. get blurKernel(): number;
  17094. /**
  17095. * Sets the blur kernel: kernel size of the blur pass.
  17096. * Only useful if useKernelBlur = true
  17097. */
  17098. set blurKernel(value: number);
  17099. protected _useKernelBlur: boolean;
  17100. /**
  17101. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17102. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17103. */
  17104. get useKernelBlur(): boolean;
  17105. /**
  17106. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17107. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17108. */
  17109. set useKernelBlur(value: boolean);
  17110. protected _depthScale: number;
  17111. /**
  17112. * Gets the depth scale used in ESM mode.
  17113. */
  17114. get depthScale(): number;
  17115. /**
  17116. * Sets the depth scale used in ESM mode.
  17117. * This can override the scale stored on the light.
  17118. */
  17119. set depthScale(value: number);
  17120. protected _validateFilter(filter: number): number;
  17121. protected _filter: number;
  17122. /**
  17123. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17124. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17125. */
  17126. get filter(): number;
  17127. /**
  17128. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17129. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17130. */
  17131. set filter(value: number);
  17132. /**
  17133. * Gets if the current filter is set to Poisson Sampling.
  17134. */
  17135. get usePoissonSampling(): boolean;
  17136. /**
  17137. * Sets the current filter to Poisson Sampling.
  17138. */
  17139. set usePoissonSampling(value: boolean);
  17140. /**
  17141. * Gets if the current filter is set to ESM.
  17142. */
  17143. get useExponentialShadowMap(): boolean;
  17144. /**
  17145. * Sets the current filter is to ESM.
  17146. */
  17147. set useExponentialShadowMap(value: boolean);
  17148. /**
  17149. * Gets if the current filter is set to filtered ESM.
  17150. */
  17151. get useBlurExponentialShadowMap(): boolean;
  17152. /**
  17153. * Gets if the current filter is set to filtered ESM.
  17154. */
  17155. set useBlurExponentialShadowMap(value: boolean);
  17156. /**
  17157. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17158. * exponential to prevent steep falloff artifacts).
  17159. */
  17160. get useCloseExponentialShadowMap(): boolean;
  17161. /**
  17162. * Sets the current filter to "close ESM" (using the inverse of the
  17163. * exponential to prevent steep falloff artifacts).
  17164. */
  17165. set useCloseExponentialShadowMap(value: boolean);
  17166. /**
  17167. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17168. * exponential to prevent steep falloff artifacts).
  17169. */
  17170. get useBlurCloseExponentialShadowMap(): boolean;
  17171. /**
  17172. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17173. * exponential to prevent steep falloff artifacts).
  17174. */
  17175. set useBlurCloseExponentialShadowMap(value: boolean);
  17176. /**
  17177. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17178. */
  17179. get usePercentageCloserFiltering(): boolean;
  17180. /**
  17181. * Sets the current filter to "PCF" (percentage closer filtering).
  17182. */
  17183. set usePercentageCloserFiltering(value: boolean);
  17184. protected _filteringQuality: number;
  17185. /**
  17186. * Gets the PCF or PCSS Quality.
  17187. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17188. */
  17189. get filteringQuality(): number;
  17190. /**
  17191. * Sets the PCF or PCSS Quality.
  17192. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17193. */
  17194. set filteringQuality(filteringQuality: number);
  17195. /**
  17196. * Gets if the current filter is set to "PCSS" (contact hardening).
  17197. */
  17198. get useContactHardeningShadow(): boolean;
  17199. /**
  17200. * Sets the current filter to "PCSS" (contact hardening).
  17201. */
  17202. set useContactHardeningShadow(value: boolean);
  17203. protected _contactHardeningLightSizeUVRatio: number;
  17204. /**
  17205. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17206. * Using a ratio helps keeping shape stability independently of the map size.
  17207. *
  17208. * It does not account for the light projection as it was having too much
  17209. * instability during the light setup or during light position changes.
  17210. *
  17211. * Only valid if useContactHardeningShadow is true.
  17212. */
  17213. get contactHardeningLightSizeUVRatio(): number;
  17214. /**
  17215. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17216. * Using a ratio helps keeping shape stability independently of the map size.
  17217. *
  17218. * It does not account for the light projection as it was having too much
  17219. * instability during the light setup or during light position changes.
  17220. *
  17221. * Only valid if useContactHardeningShadow is true.
  17222. */
  17223. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17224. protected _darkness: number;
  17225. /** Gets or sets the actual darkness of a shadow */
  17226. get darkness(): number;
  17227. set darkness(value: number);
  17228. /**
  17229. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17230. * 0 means strongest and 1 would means no shadow.
  17231. * @returns the darkness.
  17232. */
  17233. getDarkness(): number;
  17234. /**
  17235. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17236. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17237. * @returns the shadow generator allowing fluent coding.
  17238. */
  17239. setDarkness(darkness: number): ShadowGenerator;
  17240. protected _transparencyShadow: boolean;
  17241. /** Gets or sets the ability to have transparent shadow */
  17242. get transparencyShadow(): boolean;
  17243. set transparencyShadow(value: boolean);
  17244. /**
  17245. * Sets the ability to have transparent shadow (boolean).
  17246. * @param transparent True if transparent else False
  17247. * @returns the shadow generator allowing fluent coding
  17248. */
  17249. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17250. /**
  17251. * Enables or disables shadows with varying strength based on the transparency
  17252. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17253. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17254. * mesh.visibility * alphaTexture.a
  17255. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17256. */
  17257. enableSoftTransparentShadow: boolean;
  17258. protected _shadowMap: Nullable<RenderTargetTexture>;
  17259. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17260. /**
  17261. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17262. * @returns The render target texture if present otherwise, null
  17263. */
  17264. getShadowMap(): Nullable<RenderTargetTexture>;
  17265. /**
  17266. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17267. * @returns The render target texture if the shadow map is present otherwise, null
  17268. */
  17269. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17270. /**
  17271. * Gets the class name of that object
  17272. * @returns "ShadowGenerator"
  17273. */
  17274. getClassName(): string;
  17275. /**
  17276. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17277. * @param mesh Mesh to add
  17278. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17279. * @returns the Shadow Generator itself
  17280. */
  17281. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17282. /**
  17283. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17284. * @param mesh Mesh to remove
  17285. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17286. * @returns the Shadow Generator itself
  17287. */
  17288. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17289. /**
  17290. * Controls the extent to which the shadows fade out at the edge of the frustum
  17291. */
  17292. frustumEdgeFalloff: number;
  17293. protected _light: IShadowLight;
  17294. /**
  17295. * Returns the associated light object.
  17296. * @returns the light generating the shadow
  17297. */
  17298. getLight(): IShadowLight;
  17299. /**
  17300. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17301. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17302. * It might on the other hand introduce peter panning.
  17303. */
  17304. forceBackFacesOnly: boolean;
  17305. protected _scene: Scene;
  17306. protected _lightDirection: Vector3;
  17307. protected _effect: Effect;
  17308. protected _viewMatrix: Matrix;
  17309. protected _projectionMatrix: Matrix;
  17310. protected _transformMatrix: Matrix;
  17311. protected _cachedPosition: Vector3;
  17312. protected _cachedDirection: Vector3;
  17313. protected _cachedDefines: string;
  17314. protected _currentRenderID: number;
  17315. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17316. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17317. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17318. protected _blurPostProcesses: PostProcess[];
  17319. protected _mapSize: number;
  17320. protected _currentFaceIndex: number;
  17321. protected _currentFaceIndexCache: number;
  17322. protected _textureType: number;
  17323. protected _defaultTextureMatrix: Matrix;
  17324. protected _storedUniqueId: Nullable<number>;
  17325. /** @hidden */
  17326. static _SceneComponentInitialization: (scene: Scene) => void;
  17327. /**
  17328. * Creates a ShadowGenerator object.
  17329. * A ShadowGenerator is the required tool to use the shadows.
  17330. * Each light casting shadows needs to use its own ShadowGenerator.
  17331. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17332. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17333. * @param light The light object generating the shadows.
  17334. * @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.
  17335. */
  17336. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17337. protected _initializeGenerator(): void;
  17338. protected _createTargetRenderTexture(): void;
  17339. protected _initializeShadowMap(): void;
  17340. protected _initializeBlurRTTAndPostProcesses(): void;
  17341. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17342. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17343. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17344. protected _applyFilterValues(): void;
  17345. /**
  17346. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17347. * @param onCompiled Callback triggered at the and of the effects compilation
  17348. * @param options Sets of optional options forcing the compilation with different modes
  17349. */
  17350. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17351. useInstances: boolean;
  17352. }>): void;
  17353. /**
  17354. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17355. * @param options Sets of optional options forcing the compilation with different modes
  17356. * @returns A promise that resolves when the compilation completes
  17357. */
  17358. forceCompilationAsync(options?: Partial<{
  17359. useInstances: boolean;
  17360. }>): Promise<void>;
  17361. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17362. private _prepareShadowDefines;
  17363. /**
  17364. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17365. * @param subMesh The submesh we want to render in the shadow map
  17366. * @param useInstances Defines wether will draw in the map using instances
  17367. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17368. * @returns true if ready otherwise, false
  17369. */
  17370. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17371. /**
  17372. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17373. * @param defines Defines of the material we want to update
  17374. * @param lightIndex Index of the light in the enabled light list of the material
  17375. */
  17376. prepareDefines(defines: any, lightIndex: number): void;
  17377. /**
  17378. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17379. * defined in the generator but impacting the effect).
  17380. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17381. * @param effect The effect we are binfing the information for
  17382. */
  17383. bindShadowLight(lightIndex: string, effect: Effect): void;
  17384. /**
  17385. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17386. * (eq to shadow prjection matrix * light transform matrix)
  17387. * @returns The transform matrix used to create the shadow map
  17388. */
  17389. getTransformMatrix(): Matrix;
  17390. /**
  17391. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17392. * Cube and 2D textures for instance.
  17393. */
  17394. recreateShadowMap(): void;
  17395. protected _disposeBlurPostProcesses(): void;
  17396. protected _disposeRTTandPostProcesses(): void;
  17397. /**
  17398. * Disposes the ShadowGenerator.
  17399. * Returns nothing.
  17400. */
  17401. dispose(): void;
  17402. /**
  17403. * Serializes the shadow generator setup to a json object.
  17404. * @returns The serialized JSON object
  17405. */
  17406. serialize(): any;
  17407. /**
  17408. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17409. * @param parsedShadowGenerator The JSON object to parse
  17410. * @param scene The scene to create the shadow map for
  17411. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17412. * @returns The parsed shadow generator
  17413. */
  17414. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17415. }
  17416. }
  17417. declare module "babylonjs/Lights/light" {
  17418. import { Nullable } from "babylonjs/types";
  17419. import { Scene } from "babylonjs/scene";
  17420. import { Vector3 } from "babylonjs/Maths/math.vector";
  17421. import { Color3 } from "babylonjs/Maths/math.color";
  17422. import { Node } from "babylonjs/node";
  17423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17424. import { Effect } from "babylonjs/Materials/effect";
  17425. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17426. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17427. /**
  17428. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17429. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17430. * 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.
  17431. */
  17432. export abstract class Light extends Node {
  17433. /**
  17434. * Falloff Default: light is falling off following the material specification:
  17435. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17436. */
  17437. static readonly FALLOFF_DEFAULT: number;
  17438. /**
  17439. * Falloff Physical: light is falling off following the inverse squared distance law.
  17440. */
  17441. static readonly FALLOFF_PHYSICAL: number;
  17442. /**
  17443. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17444. * to enhance interoperability with other engines.
  17445. */
  17446. static readonly FALLOFF_GLTF: number;
  17447. /**
  17448. * Falloff Standard: light is falling off like in the standard material
  17449. * to enhance interoperability with other materials.
  17450. */
  17451. static readonly FALLOFF_STANDARD: number;
  17452. /**
  17453. * If every light affecting the material is in this lightmapMode,
  17454. * material.lightmapTexture adds or multiplies
  17455. * (depends on material.useLightmapAsShadowmap)
  17456. * after every other light calculations.
  17457. */
  17458. static readonly LIGHTMAP_DEFAULT: number;
  17459. /**
  17460. * material.lightmapTexture as only diffuse lighting from this light
  17461. * adds only specular lighting from this light
  17462. * adds dynamic shadows
  17463. */
  17464. static readonly LIGHTMAP_SPECULAR: number;
  17465. /**
  17466. * material.lightmapTexture as only lighting
  17467. * no light calculation from this light
  17468. * only adds dynamic shadows from this light
  17469. */
  17470. static readonly LIGHTMAP_SHADOWSONLY: number;
  17471. /**
  17472. * Each light type uses the default quantity according to its type:
  17473. * point/spot lights use luminous intensity
  17474. * directional lights use illuminance
  17475. */
  17476. static readonly INTENSITYMODE_AUTOMATIC: number;
  17477. /**
  17478. * lumen (lm)
  17479. */
  17480. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17481. /**
  17482. * candela (lm/sr)
  17483. */
  17484. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17485. /**
  17486. * lux (lm/m^2)
  17487. */
  17488. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17489. /**
  17490. * nit (cd/m^2)
  17491. */
  17492. static readonly INTENSITYMODE_LUMINANCE: number;
  17493. /**
  17494. * Light type const id of the point light.
  17495. */
  17496. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17497. /**
  17498. * Light type const id of the directional light.
  17499. */
  17500. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17501. /**
  17502. * Light type const id of the spot light.
  17503. */
  17504. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17505. /**
  17506. * Light type const id of the hemispheric light.
  17507. */
  17508. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17509. /**
  17510. * Diffuse gives the basic color to an object.
  17511. */
  17512. diffuse: Color3;
  17513. /**
  17514. * Specular produces a highlight color on an object.
  17515. * Note: This is note affecting PBR materials.
  17516. */
  17517. specular: Color3;
  17518. /**
  17519. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17520. * falling off base on range or angle.
  17521. * This can be set to any values in Light.FALLOFF_x.
  17522. *
  17523. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17524. * other types of materials.
  17525. */
  17526. falloffType: number;
  17527. /**
  17528. * Strength of the light.
  17529. * Note: By default it is define in the framework own unit.
  17530. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17531. */
  17532. intensity: number;
  17533. private _range;
  17534. protected _inverseSquaredRange: number;
  17535. /**
  17536. * Defines how far from the source the light is impacting in scene units.
  17537. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17538. */
  17539. get range(): number;
  17540. /**
  17541. * Defines how far from the source the light is impacting in scene units.
  17542. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17543. */
  17544. set range(value: number);
  17545. /**
  17546. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17547. * of light.
  17548. */
  17549. private _photometricScale;
  17550. private _intensityMode;
  17551. /**
  17552. * Gets the photometric scale used to interpret the intensity.
  17553. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17554. */
  17555. get intensityMode(): number;
  17556. /**
  17557. * Sets the photometric scale used to interpret the intensity.
  17558. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17559. */
  17560. set intensityMode(value: number);
  17561. private _radius;
  17562. /**
  17563. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17564. */
  17565. get radius(): number;
  17566. /**
  17567. * sets the light radius used by PBR Materials to simulate soft area lights.
  17568. */
  17569. set radius(value: number);
  17570. private _renderPriority;
  17571. /**
  17572. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17573. * exceeding the number allowed of the materials.
  17574. */
  17575. renderPriority: number;
  17576. private _shadowEnabled;
  17577. /**
  17578. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17579. * the current shadow generator.
  17580. */
  17581. get shadowEnabled(): boolean;
  17582. /**
  17583. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17584. * the current shadow generator.
  17585. */
  17586. set shadowEnabled(value: boolean);
  17587. private _includedOnlyMeshes;
  17588. /**
  17589. * Gets the only meshes impacted by this light.
  17590. */
  17591. get includedOnlyMeshes(): AbstractMesh[];
  17592. /**
  17593. * Sets the only meshes impacted by this light.
  17594. */
  17595. set includedOnlyMeshes(value: AbstractMesh[]);
  17596. private _excludedMeshes;
  17597. /**
  17598. * Gets the meshes not impacted by this light.
  17599. */
  17600. get excludedMeshes(): AbstractMesh[];
  17601. /**
  17602. * Sets the meshes not impacted by this light.
  17603. */
  17604. set excludedMeshes(value: AbstractMesh[]);
  17605. private _excludeWithLayerMask;
  17606. /**
  17607. * Gets the layer id use to find what meshes are not impacted by the light.
  17608. * Inactive if 0
  17609. */
  17610. get excludeWithLayerMask(): number;
  17611. /**
  17612. * Sets the layer id use to find what meshes are not impacted by the light.
  17613. * Inactive if 0
  17614. */
  17615. set excludeWithLayerMask(value: number);
  17616. private _includeOnlyWithLayerMask;
  17617. /**
  17618. * Gets the layer id use to find what meshes are impacted by the light.
  17619. * Inactive if 0
  17620. */
  17621. get includeOnlyWithLayerMask(): number;
  17622. /**
  17623. * Sets the layer id use to find what meshes are impacted by the light.
  17624. * Inactive if 0
  17625. */
  17626. set includeOnlyWithLayerMask(value: number);
  17627. private _lightmapMode;
  17628. /**
  17629. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17630. */
  17631. get lightmapMode(): number;
  17632. /**
  17633. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17634. */
  17635. set lightmapMode(value: number);
  17636. /**
  17637. * Shadow generator associted to the light.
  17638. * @hidden Internal use only.
  17639. */
  17640. _shadowGenerator: Nullable<IShadowGenerator>;
  17641. /**
  17642. * @hidden Internal use only.
  17643. */
  17644. _excludedMeshesIds: string[];
  17645. /**
  17646. * @hidden Internal use only.
  17647. */
  17648. _includedOnlyMeshesIds: string[];
  17649. /**
  17650. * The current light unifom buffer.
  17651. * @hidden Internal use only.
  17652. */
  17653. _uniformBuffer: UniformBuffer;
  17654. /** @hidden */
  17655. _renderId: number;
  17656. /**
  17657. * Creates a Light object in the scene.
  17658. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17659. * @param name The firendly name of the light
  17660. * @param scene The scene the light belongs too
  17661. */
  17662. constructor(name: string, scene: Scene);
  17663. protected abstract _buildUniformLayout(): void;
  17664. /**
  17665. * Sets the passed Effect "effect" with the Light information.
  17666. * @param effect The effect to update
  17667. * @param lightIndex The index of the light in the effect to update
  17668. * @returns The light
  17669. */
  17670. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17671. /**
  17672. * Sets the passed Effect "effect" with the Light textures.
  17673. * @param effect The effect to update
  17674. * @param lightIndex The index of the light in the effect to update
  17675. * @returns The light
  17676. */
  17677. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17678. /**
  17679. * Binds the lights information from the scene to the effect for the given mesh.
  17680. * @param lightIndex Light index
  17681. * @param scene The scene where the light belongs to
  17682. * @param effect The effect we are binding the data to
  17683. * @param useSpecular Defines if specular is supported
  17684. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17685. */
  17686. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17687. /**
  17688. * Sets the passed Effect "effect" with the Light information.
  17689. * @param effect The effect to update
  17690. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17691. * @returns The light
  17692. */
  17693. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17694. /**
  17695. * Returns the string "Light".
  17696. * @returns the class name
  17697. */
  17698. getClassName(): string;
  17699. /** @hidden */
  17700. readonly _isLight: boolean;
  17701. /**
  17702. * Converts the light information to a readable string for debug purpose.
  17703. * @param fullDetails Supports for multiple levels of logging within scene loading
  17704. * @returns the human readable light info
  17705. */
  17706. toString(fullDetails?: boolean): string;
  17707. /** @hidden */
  17708. protected _syncParentEnabledState(): void;
  17709. /**
  17710. * Set the enabled state of this node.
  17711. * @param value - the new enabled state
  17712. */
  17713. setEnabled(value: boolean): void;
  17714. /**
  17715. * Returns the Light associated shadow generator if any.
  17716. * @return the associated shadow generator.
  17717. */
  17718. getShadowGenerator(): Nullable<IShadowGenerator>;
  17719. /**
  17720. * Returns a Vector3, the absolute light position in the World.
  17721. * @returns the world space position of the light
  17722. */
  17723. getAbsolutePosition(): Vector3;
  17724. /**
  17725. * Specifies if the light will affect the passed mesh.
  17726. * @param mesh The mesh to test against the light
  17727. * @return true the mesh is affected otherwise, false.
  17728. */
  17729. canAffectMesh(mesh: AbstractMesh): boolean;
  17730. /**
  17731. * Sort function to order lights for rendering.
  17732. * @param a First Light object to compare to second.
  17733. * @param b Second Light object to compare first.
  17734. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17735. */
  17736. static CompareLightsPriority(a: Light, b: Light): number;
  17737. /**
  17738. * Releases resources associated with this node.
  17739. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17740. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17741. */
  17742. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17743. /**
  17744. * Returns the light type ID (integer).
  17745. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17746. */
  17747. getTypeID(): number;
  17748. /**
  17749. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17750. * @returns the scaled intensity in intensity mode unit
  17751. */
  17752. getScaledIntensity(): number;
  17753. /**
  17754. * Returns a new Light object, named "name", from the current one.
  17755. * @param name The name of the cloned light
  17756. * @param newParent The parent of this light, if it has one
  17757. * @returns the new created light
  17758. */
  17759. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  17760. /**
  17761. * Serializes the current light into a Serialization object.
  17762. * @returns the serialized object.
  17763. */
  17764. serialize(): any;
  17765. /**
  17766. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17767. * This new light is named "name" and added to the passed scene.
  17768. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17769. * @param name The friendly name of the light
  17770. * @param scene The scene the new light will belong to
  17771. * @returns the constructor function
  17772. */
  17773. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17774. /**
  17775. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17776. * @param parsedLight The JSON representation of the light
  17777. * @param scene The scene to create the parsed light in
  17778. * @returns the created light after parsing
  17779. */
  17780. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17781. private _hookArrayForExcluded;
  17782. private _hookArrayForIncludedOnly;
  17783. private _resyncMeshes;
  17784. /**
  17785. * Forces the meshes to update their light related information in their rendering used effects
  17786. * @hidden Internal Use Only
  17787. */
  17788. _markMeshesAsLightDirty(): void;
  17789. /**
  17790. * Recomputes the cached photometric scale if needed.
  17791. */
  17792. private _computePhotometricScale;
  17793. /**
  17794. * Returns the Photometric Scale according to the light type and intensity mode.
  17795. */
  17796. private _getPhotometricScale;
  17797. /**
  17798. * Reorder the light in the scene according to their defined priority.
  17799. * @hidden Internal Use Only
  17800. */
  17801. _reorderLightsInScene(): void;
  17802. /**
  17803. * Prepares the list of defines specific to the light type.
  17804. * @param defines the list of defines
  17805. * @param lightIndex defines the index of the light for the effect
  17806. */
  17807. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17808. }
  17809. }
  17810. declare module "babylonjs/Actions/action" {
  17811. import { Observable } from "babylonjs/Misc/observable";
  17812. import { Condition } from "babylonjs/Actions/condition";
  17813. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17814. import { ActionManager } from "babylonjs/Actions/actionManager";
  17815. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17816. /**
  17817. * Interface used to define Action
  17818. */
  17819. export interface IAction {
  17820. /**
  17821. * Trigger for the action
  17822. */
  17823. trigger: number;
  17824. /** Options of the trigger */
  17825. triggerOptions: any;
  17826. /**
  17827. * Gets the trigger parameters
  17828. * @returns the trigger parameters
  17829. */
  17830. getTriggerParameter(): any;
  17831. /**
  17832. * Internal only - executes current action event
  17833. * @hidden
  17834. */
  17835. _executeCurrent(evt?: ActionEvent): void;
  17836. /**
  17837. * Serialize placeholder for child classes
  17838. * @param parent of child
  17839. * @returns the serialized object
  17840. */
  17841. serialize(parent: any): any;
  17842. /**
  17843. * Internal only
  17844. * @hidden
  17845. */
  17846. _prepare(): void;
  17847. /**
  17848. * Internal only - manager for action
  17849. * @hidden
  17850. */
  17851. _actionManager: AbstractActionManager;
  17852. /**
  17853. * Adds action to chain of actions, may be a DoNothingAction
  17854. * @param action defines the next action to execute
  17855. * @returns The action passed in
  17856. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17857. */
  17858. then(action: IAction): IAction;
  17859. }
  17860. /**
  17861. * The action to be carried out following a trigger
  17862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17863. */
  17864. export class Action implements IAction {
  17865. /** the trigger, with or without parameters, for the action */
  17866. triggerOptions: any;
  17867. /**
  17868. * Trigger for the action
  17869. */
  17870. trigger: number;
  17871. /**
  17872. * Internal only - manager for action
  17873. * @hidden
  17874. */
  17875. _actionManager: ActionManager;
  17876. private _nextActiveAction;
  17877. private _child;
  17878. private _condition?;
  17879. private _triggerParameter;
  17880. /**
  17881. * An event triggered prior to action being executed.
  17882. */
  17883. onBeforeExecuteObservable: Observable<Action>;
  17884. /**
  17885. * Creates a new Action
  17886. * @param triggerOptions the trigger, with or without parameters, for the action
  17887. * @param condition an optional determinant of action
  17888. */
  17889. constructor(
  17890. /** the trigger, with or without parameters, for the action */
  17891. triggerOptions: any, condition?: Condition);
  17892. /**
  17893. * Internal only
  17894. * @hidden
  17895. */
  17896. _prepare(): void;
  17897. /**
  17898. * Gets the trigger parameters
  17899. * @returns the trigger parameters
  17900. */
  17901. getTriggerParameter(): any;
  17902. /**
  17903. * Internal only - executes current action event
  17904. * @hidden
  17905. */
  17906. _executeCurrent(evt?: ActionEvent): void;
  17907. /**
  17908. * Execute placeholder for child classes
  17909. * @param evt optional action event
  17910. */
  17911. execute(evt?: ActionEvent): void;
  17912. /**
  17913. * Skips to next active action
  17914. */
  17915. skipToNextActiveAction(): void;
  17916. /**
  17917. * Adds action to chain of actions, may be a DoNothingAction
  17918. * @param action defines the next action to execute
  17919. * @returns The action passed in
  17920. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17921. */
  17922. then(action: Action): Action;
  17923. /**
  17924. * Internal only
  17925. * @hidden
  17926. */
  17927. _getProperty(propertyPath: string): string;
  17928. /**
  17929. * Internal only
  17930. * @hidden
  17931. */
  17932. _getEffectiveTarget(target: any, propertyPath: string): any;
  17933. /**
  17934. * Serialize placeholder for child classes
  17935. * @param parent of child
  17936. * @returns the serialized object
  17937. */
  17938. serialize(parent: any): any;
  17939. /**
  17940. * Internal only called by serialize
  17941. * @hidden
  17942. */
  17943. protected _serialize(serializedAction: any, parent?: any): any;
  17944. /**
  17945. * Internal only
  17946. * @hidden
  17947. */
  17948. static _SerializeValueAsString: (value: any) => string;
  17949. /**
  17950. * Internal only
  17951. * @hidden
  17952. */
  17953. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17954. name: string;
  17955. targetType: string;
  17956. value: string;
  17957. };
  17958. }
  17959. }
  17960. declare module "babylonjs/Actions/condition" {
  17961. import { ActionManager } from "babylonjs/Actions/actionManager";
  17962. /**
  17963. * A Condition applied to an Action
  17964. */
  17965. export class Condition {
  17966. /**
  17967. * Internal only - manager for action
  17968. * @hidden
  17969. */
  17970. _actionManager: ActionManager;
  17971. /**
  17972. * Internal only
  17973. * @hidden
  17974. */
  17975. _evaluationId: number;
  17976. /**
  17977. * Internal only
  17978. * @hidden
  17979. */
  17980. _currentResult: boolean;
  17981. /**
  17982. * Creates a new Condition
  17983. * @param actionManager the manager of the action the condition is applied to
  17984. */
  17985. constructor(actionManager: ActionManager);
  17986. /**
  17987. * Check if the current condition is valid
  17988. * @returns a boolean
  17989. */
  17990. isValid(): boolean;
  17991. /**
  17992. * Internal only
  17993. * @hidden
  17994. */
  17995. _getProperty(propertyPath: string): string;
  17996. /**
  17997. * Internal only
  17998. * @hidden
  17999. */
  18000. _getEffectiveTarget(target: any, propertyPath: string): any;
  18001. /**
  18002. * Serialize placeholder for child classes
  18003. * @returns the serialized object
  18004. */
  18005. serialize(): any;
  18006. /**
  18007. * Internal only
  18008. * @hidden
  18009. */
  18010. protected _serialize(serializedCondition: any): any;
  18011. }
  18012. /**
  18013. * Defines specific conditional operators as extensions of Condition
  18014. */
  18015. export class ValueCondition extends Condition {
  18016. /** path to specify the property of the target the conditional operator uses */
  18017. propertyPath: string;
  18018. /** the value compared by the conditional operator against the current value of the property */
  18019. value: any;
  18020. /** the conditional operator, default ValueCondition.IsEqual */
  18021. operator: number;
  18022. /**
  18023. * Internal only
  18024. * @hidden
  18025. */
  18026. private static _IsEqual;
  18027. /**
  18028. * Internal only
  18029. * @hidden
  18030. */
  18031. private static _IsDifferent;
  18032. /**
  18033. * Internal only
  18034. * @hidden
  18035. */
  18036. private static _IsGreater;
  18037. /**
  18038. * Internal only
  18039. * @hidden
  18040. */
  18041. private static _IsLesser;
  18042. /**
  18043. * returns the number for IsEqual
  18044. */
  18045. static get IsEqual(): number;
  18046. /**
  18047. * Returns the number for IsDifferent
  18048. */
  18049. static get IsDifferent(): number;
  18050. /**
  18051. * Returns the number for IsGreater
  18052. */
  18053. static get IsGreater(): number;
  18054. /**
  18055. * Returns the number for IsLesser
  18056. */
  18057. static get IsLesser(): number;
  18058. /**
  18059. * Internal only The action manager for the condition
  18060. * @hidden
  18061. */
  18062. _actionManager: ActionManager;
  18063. /**
  18064. * Internal only
  18065. * @hidden
  18066. */
  18067. private _target;
  18068. /**
  18069. * Internal only
  18070. * @hidden
  18071. */
  18072. private _effectiveTarget;
  18073. /**
  18074. * Internal only
  18075. * @hidden
  18076. */
  18077. private _property;
  18078. /**
  18079. * Creates a new ValueCondition
  18080. * @param actionManager manager for the action the condition applies to
  18081. * @param target for the action
  18082. * @param propertyPath path to specify the property of the target the conditional operator uses
  18083. * @param value the value compared by the conditional operator against the current value of the property
  18084. * @param operator the conditional operator, default ValueCondition.IsEqual
  18085. */
  18086. constructor(actionManager: ActionManager, target: any,
  18087. /** path to specify the property of the target the conditional operator uses */
  18088. propertyPath: string,
  18089. /** the value compared by the conditional operator against the current value of the property */
  18090. value: any,
  18091. /** the conditional operator, default ValueCondition.IsEqual */
  18092. operator?: number);
  18093. /**
  18094. * Compares the given value with the property value for the specified conditional operator
  18095. * @returns the result of the comparison
  18096. */
  18097. isValid(): boolean;
  18098. /**
  18099. * Serialize the ValueCondition into a JSON compatible object
  18100. * @returns serialization object
  18101. */
  18102. serialize(): any;
  18103. /**
  18104. * Gets the name of the conditional operator for the ValueCondition
  18105. * @param operator the conditional operator
  18106. * @returns the name
  18107. */
  18108. static GetOperatorName(operator: number): string;
  18109. }
  18110. /**
  18111. * Defines a predicate condition as an extension of Condition
  18112. */
  18113. export class PredicateCondition extends Condition {
  18114. /** defines the predicate function used to validate the condition */
  18115. predicate: () => boolean;
  18116. /**
  18117. * Internal only - manager for action
  18118. * @hidden
  18119. */
  18120. _actionManager: ActionManager;
  18121. /**
  18122. * Creates a new PredicateCondition
  18123. * @param actionManager manager for the action the condition applies to
  18124. * @param predicate defines the predicate function used to validate the condition
  18125. */
  18126. constructor(actionManager: ActionManager,
  18127. /** defines the predicate function used to validate the condition */
  18128. predicate: () => boolean);
  18129. /**
  18130. * @returns the validity of the predicate condition
  18131. */
  18132. isValid(): boolean;
  18133. }
  18134. /**
  18135. * Defines a state condition as an extension of Condition
  18136. */
  18137. export class StateCondition extends Condition {
  18138. /** Value to compare with target state */
  18139. value: string;
  18140. /**
  18141. * Internal only - manager for action
  18142. * @hidden
  18143. */
  18144. _actionManager: ActionManager;
  18145. /**
  18146. * Internal only
  18147. * @hidden
  18148. */
  18149. private _target;
  18150. /**
  18151. * Creates a new StateCondition
  18152. * @param actionManager manager for the action the condition applies to
  18153. * @param target of the condition
  18154. * @param value to compare with target state
  18155. */
  18156. constructor(actionManager: ActionManager, target: any,
  18157. /** Value to compare with target state */
  18158. value: string);
  18159. /**
  18160. * Gets a boolean indicating if the current condition is met
  18161. * @returns the validity of the state
  18162. */
  18163. isValid(): boolean;
  18164. /**
  18165. * Serialize the StateCondition into a JSON compatible object
  18166. * @returns serialization object
  18167. */
  18168. serialize(): any;
  18169. }
  18170. }
  18171. declare module "babylonjs/Actions/directActions" {
  18172. import { Action } from "babylonjs/Actions/action";
  18173. import { Condition } from "babylonjs/Actions/condition";
  18174. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18175. /**
  18176. * This defines an action responsible to toggle a boolean once triggered.
  18177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18178. */
  18179. export class SwitchBooleanAction extends Action {
  18180. /**
  18181. * The path to the boolean property in the target object
  18182. */
  18183. propertyPath: string;
  18184. private _target;
  18185. private _effectiveTarget;
  18186. private _property;
  18187. /**
  18188. * Instantiate the action
  18189. * @param triggerOptions defines the trigger options
  18190. * @param target defines the object containing the boolean
  18191. * @param propertyPath defines the path to the boolean property in the target object
  18192. * @param condition defines the trigger related conditions
  18193. */
  18194. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18195. /** @hidden */
  18196. _prepare(): void;
  18197. /**
  18198. * Execute the action toggle the boolean value.
  18199. */
  18200. execute(): void;
  18201. /**
  18202. * Serializes the actions and its related information.
  18203. * @param parent defines the object to serialize in
  18204. * @returns the serialized object
  18205. */
  18206. serialize(parent: any): any;
  18207. }
  18208. /**
  18209. * This defines an action responsible to set a the state field of the target
  18210. * to a desired value once triggered.
  18211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18212. */
  18213. export class SetStateAction extends Action {
  18214. /**
  18215. * The value to store in the state field.
  18216. */
  18217. value: string;
  18218. private _target;
  18219. /**
  18220. * Instantiate the action
  18221. * @param triggerOptions defines the trigger options
  18222. * @param target defines the object containing the state property
  18223. * @param value defines the value to store in the state field
  18224. * @param condition defines the trigger related conditions
  18225. */
  18226. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18227. /**
  18228. * Execute the action and store the value on the target state property.
  18229. */
  18230. execute(): void;
  18231. /**
  18232. * Serializes the actions and its related information.
  18233. * @param parent defines the object to serialize in
  18234. * @returns the serialized object
  18235. */
  18236. serialize(parent: any): any;
  18237. }
  18238. /**
  18239. * This defines an action responsible to set a property of the target
  18240. * to a desired value once triggered.
  18241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18242. */
  18243. export class SetValueAction extends Action {
  18244. /**
  18245. * The path of the property to set in the target.
  18246. */
  18247. propertyPath: string;
  18248. /**
  18249. * The value to set in the property
  18250. */
  18251. value: any;
  18252. private _target;
  18253. private _effectiveTarget;
  18254. private _property;
  18255. /**
  18256. * Instantiate the action
  18257. * @param triggerOptions defines the trigger options
  18258. * @param target defines the object containing the property
  18259. * @param propertyPath defines the path of the property to set in the target
  18260. * @param value defines the value to set in the property
  18261. * @param condition defines the trigger related conditions
  18262. */
  18263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18264. /** @hidden */
  18265. _prepare(): void;
  18266. /**
  18267. * Execute the action and set the targetted property to the desired value.
  18268. */
  18269. execute(): void;
  18270. /**
  18271. * Serializes the actions and its related information.
  18272. * @param parent defines the object to serialize in
  18273. * @returns the serialized object
  18274. */
  18275. serialize(parent: any): any;
  18276. }
  18277. /**
  18278. * This defines an action responsible to increment the target value
  18279. * to a desired value once triggered.
  18280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18281. */
  18282. export class IncrementValueAction extends Action {
  18283. /**
  18284. * The path of the property to increment in the target.
  18285. */
  18286. propertyPath: string;
  18287. /**
  18288. * The value we should increment the property by.
  18289. */
  18290. value: any;
  18291. private _target;
  18292. private _effectiveTarget;
  18293. private _property;
  18294. /**
  18295. * Instantiate the action
  18296. * @param triggerOptions defines the trigger options
  18297. * @param target defines the object containing the property
  18298. * @param propertyPath defines the path of the property to increment in the target
  18299. * @param value defines the value value we should increment the property by
  18300. * @param condition defines the trigger related conditions
  18301. */
  18302. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18303. /** @hidden */
  18304. _prepare(): void;
  18305. /**
  18306. * Execute the action and increment the target of the value amount.
  18307. */
  18308. execute(): void;
  18309. /**
  18310. * Serializes the actions and its related information.
  18311. * @param parent defines the object to serialize in
  18312. * @returns the serialized object
  18313. */
  18314. serialize(parent: any): any;
  18315. }
  18316. /**
  18317. * This defines an action responsible to start an animation once triggered.
  18318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18319. */
  18320. export class PlayAnimationAction extends Action {
  18321. /**
  18322. * Where the animation should start (animation frame)
  18323. */
  18324. from: number;
  18325. /**
  18326. * Where the animation should stop (animation frame)
  18327. */
  18328. to: number;
  18329. /**
  18330. * Define if the animation should loop or stop after the first play.
  18331. */
  18332. loop?: boolean;
  18333. private _target;
  18334. /**
  18335. * Instantiate the action
  18336. * @param triggerOptions defines the trigger options
  18337. * @param target defines the target animation or animation name
  18338. * @param from defines from where the animation should start (animation frame)
  18339. * @param end defines where the animation should stop (animation frame)
  18340. * @param loop defines if the animation should loop or stop after the first play
  18341. * @param condition defines the trigger related conditions
  18342. */
  18343. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18344. /** @hidden */
  18345. _prepare(): void;
  18346. /**
  18347. * Execute the action and play the animation.
  18348. */
  18349. execute(): void;
  18350. /**
  18351. * Serializes the actions and its related information.
  18352. * @param parent defines the object to serialize in
  18353. * @returns the serialized object
  18354. */
  18355. serialize(parent: any): any;
  18356. }
  18357. /**
  18358. * This defines an action responsible to stop an animation once triggered.
  18359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18360. */
  18361. export class StopAnimationAction extends Action {
  18362. private _target;
  18363. /**
  18364. * Instantiate the action
  18365. * @param triggerOptions defines the trigger options
  18366. * @param target defines the target animation or animation name
  18367. * @param condition defines the trigger related conditions
  18368. */
  18369. constructor(triggerOptions: any, target: any, condition?: Condition);
  18370. /** @hidden */
  18371. _prepare(): void;
  18372. /**
  18373. * Execute the action and stop the animation.
  18374. */
  18375. execute(): void;
  18376. /**
  18377. * Serializes the actions and its related information.
  18378. * @param parent defines the object to serialize in
  18379. * @returns the serialized object
  18380. */
  18381. serialize(parent: any): any;
  18382. }
  18383. /**
  18384. * This defines an action responsible that does nothing once triggered.
  18385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18386. */
  18387. export class DoNothingAction extends Action {
  18388. /**
  18389. * Instantiate the action
  18390. * @param triggerOptions defines the trigger options
  18391. * @param condition defines the trigger related conditions
  18392. */
  18393. constructor(triggerOptions?: any, condition?: Condition);
  18394. /**
  18395. * Execute the action and do nothing.
  18396. */
  18397. execute(): void;
  18398. /**
  18399. * Serializes the actions and its related information.
  18400. * @param parent defines the object to serialize in
  18401. * @returns the serialized object
  18402. */
  18403. serialize(parent: any): any;
  18404. }
  18405. /**
  18406. * This defines an action responsible to trigger several actions once triggered.
  18407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18408. */
  18409. export class CombineAction extends Action {
  18410. /**
  18411. * The list of aggregated animations to run.
  18412. */
  18413. children: Action[];
  18414. /**
  18415. * Instantiate the action
  18416. * @param triggerOptions defines the trigger options
  18417. * @param children defines the list of aggregated animations to run
  18418. * @param condition defines the trigger related conditions
  18419. */
  18420. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18421. /** @hidden */
  18422. _prepare(): void;
  18423. /**
  18424. * Execute the action and executes all the aggregated actions.
  18425. */
  18426. execute(evt: ActionEvent): void;
  18427. /**
  18428. * Serializes the actions and its related information.
  18429. * @param parent defines the object to serialize in
  18430. * @returns the serialized object
  18431. */
  18432. serialize(parent: any): any;
  18433. }
  18434. /**
  18435. * This defines an action responsible to run code (external event) once triggered.
  18436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18437. */
  18438. export class ExecuteCodeAction extends Action {
  18439. /**
  18440. * The callback function to run.
  18441. */
  18442. func: (evt: ActionEvent) => void;
  18443. /**
  18444. * Instantiate the action
  18445. * @param triggerOptions defines the trigger options
  18446. * @param func defines the callback function to run
  18447. * @param condition defines the trigger related conditions
  18448. */
  18449. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18450. /**
  18451. * Execute the action and run the attached code.
  18452. */
  18453. execute(evt: ActionEvent): void;
  18454. }
  18455. /**
  18456. * This defines an action responsible to set the parent property of the target once triggered.
  18457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18458. */
  18459. export class SetParentAction extends Action {
  18460. private _parent;
  18461. private _target;
  18462. /**
  18463. * Instantiate the action
  18464. * @param triggerOptions defines the trigger options
  18465. * @param target defines the target containing the parent property
  18466. * @param parent defines from where the animation should start (animation frame)
  18467. * @param condition defines the trigger related conditions
  18468. */
  18469. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18470. /** @hidden */
  18471. _prepare(): void;
  18472. /**
  18473. * Execute the action and set the parent property.
  18474. */
  18475. execute(): void;
  18476. /**
  18477. * Serializes the actions and its related information.
  18478. * @param parent defines the object to serialize in
  18479. * @returns the serialized object
  18480. */
  18481. serialize(parent: any): any;
  18482. }
  18483. }
  18484. declare module "babylonjs/Actions/actionManager" {
  18485. import { Nullable } from "babylonjs/types";
  18486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18487. import { Scene } from "babylonjs/scene";
  18488. import { IAction } from "babylonjs/Actions/action";
  18489. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18490. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18491. /**
  18492. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18493. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18495. */
  18496. export class ActionManager extends AbstractActionManager {
  18497. /**
  18498. * Nothing
  18499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18500. */
  18501. static readonly NothingTrigger: number;
  18502. /**
  18503. * On pick
  18504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18505. */
  18506. static readonly OnPickTrigger: number;
  18507. /**
  18508. * On left pick
  18509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18510. */
  18511. static readonly OnLeftPickTrigger: number;
  18512. /**
  18513. * On right pick
  18514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18515. */
  18516. static readonly OnRightPickTrigger: number;
  18517. /**
  18518. * On center pick
  18519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18520. */
  18521. static readonly OnCenterPickTrigger: number;
  18522. /**
  18523. * On pick down
  18524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18525. */
  18526. static readonly OnPickDownTrigger: number;
  18527. /**
  18528. * On double pick
  18529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18530. */
  18531. static readonly OnDoublePickTrigger: number;
  18532. /**
  18533. * On pick up
  18534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18535. */
  18536. static readonly OnPickUpTrigger: number;
  18537. /**
  18538. * On pick out.
  18539. * This trigger will only be raised if you also declared a OnPickDown
  18540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18541. */
  18542. static readonly OnPickOutTrigger: number;
  18543. /**
  18544. * On long press
  18545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18546. */
  18547. static readonly OnLongPressTrigger: number;
  18548. /**
  18549. * On pointer over
  18550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18551. */
  18552. static readonly OnPointerOverTrigger: number;
  18553. /**
  18554. * On pointer out
  18555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18556. */
  18557. static readonly OnPointerOutTrigger: number;
  18558. /**
  18559. * On every frame
  18560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18561. */
  18562. static readonly OnEveryFrameTrigger: number;
  18563. /**
  18564. * On intersection enter
  18565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18566. */
  18567. static readonly OnIntersectionEnterTrigger: number;
  18568. /**
  18569. * On intersection exit
  18570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18571. */
  18572. static readonly OnIntersectionExitTrigger: number;
  18573. /**
  18574. * On key down
  18575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18576. */
  18577. static readonly OnKeyDownTrigger: number;
  18578. /**
  18579. * On key up
  18580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18581. */
  18582. static readonly OnKeyUpTrigger: number;
  18583. private _scene;
  18584. /**
  18585. * Creates a new action manager
  18586. * @param scene defines the hosting scene
  18587. */
  18588. constructor(scene: Scene);
  18589. /**
  18590. * Releases all associated resources
  18591. */
  18592. dispose(): void;
  18593. /**
  18594. * Gets hosting scene
  18595. * @returns the hosting scene
  18596. */
  18597. getScene(): Scene;
  18598. /**
  18599. * Does this action manager handles actions of any of the given triggers
  18600. * @param triggers defines the triggers to be tested
  18601. * @return a boolean indicating whether one (or more) of the triggers is handled
  18602. */
  18603. hasSpecificTriggers(triggers: number[]): boolean;
  18604. /**
  18605. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18606. * speed.
  18607. * @param triggerA defines the trigger to be tested
  18608. * @param triggerB defines the trigger to be tested
  18609. * @return a boolean indicating whether one (or more) of the triggers is handled
  18610. */
  18611. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18612. /**
  18613. * Does this action manager handles actions of a given trigger
  18614. * @param trigger defines the trigger to be tested
  18615. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18616. * @return whether the trigger is handled
  18617. */
  18618. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18619. /**
  18620. * Does this action manager has pointer triggers
  18621. */
  18622. get hasPointerTriggers(): boolean;
  18623. /**
  18624. * Does this action manager has pick triggers
  18625. */
  18626. get hasPickTriggers(): boolean;
  18627. /**
  18628. * Registers an action to this action manager
  18629. * @param action defines the action to be registered
  18630. * @return the action amended (prepared) after registration
  18631. */
  18632. registerAction(action: IAction): Nullable<IAction>;
  18633. /**
  18634. * Unregisters an action to this action manager
  18635. * @param action defines the action to be unregistered
  18636. * @return a boolean indicating whether the action has been unregistered
  18637. */
  18638. unregisterAction(action: IAction): Boolean;
  18639. /**
  18640. * Process a specific trigger
  18641. * @param trigger defines the trigger to process
  18642. * @param evt defines the event details to be processed
  18643. */
  18644. processTrigger(trigger: number, evt?: IActionEvent): void;
  18645. /** @hidden */
  18646. _getEffectiveTarget(target: any, propertyPath: string): any;
  18647. /** @hidden */
  18648. _getProperty(propertyPath: string): string;
  18649. /**
  18650. * Serialize this manager to a JSON object
  18651. * @param name defines the property name to store this manager
  18652. * @returns a JSON representation of this manager
  18653. */
  18654. serialize(name: string): any;
  18655. /**
  18656. * Creates a new ActionManager from a JSON data
  18657. * @param parsedActions defines the JSON data to read from
  18658. * @param object defines the hosting mesh
  18659. * @param scene defines the hosting scene
  18660. */
  18661. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18662. /**
  18663. * Get a trigger name by index
  18664. * @param trigger defines the trigger index
  18665. * @returns a trigger name
  18666. */
  18667. static GetTriggerName(trigger: number): string;
  18668. }
  18669. }
  18670. declare module "babylonjs/Sprites/sprite" {
  18671. import { Vector3 } from "babylonjs/Maths/math.vector";
  18672. import { Nullable } from "babylonjs/types";
  18673. import { ActionManager } from "babylonjs/Actions/actionManager";
  18674. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18675. import { Color4 } from "babylonjs/Maths/math.color";
  18676. import { Observable } from "babylonjs/Misc/observable";
  18677. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  18678. import { Animation } from "babylonjs/Animations/animation";
  18679. /**
  18680. * Class used to represent a sprite
  18681. * @see http://doc.babylonjs.com/babylon101/sprites
  18682. */
  18683. export class Sprite implements IAnimatable {
  18684. /** defines the name */
  18685. name: string;
  18686. /** Gets or sets the current world position */
  18687. position: Vector3;
  18688. /** Gets or sets the main color */
  18689. color: Color4;
  18690. /** Gets or sets the width */
  18691. width: number;
  18692. /** Gets or sets the height */
  18693. height: number;
  18694. /** Gets or sets rotation angle */
  18695. angle: number;
  18696. /** Gets or sets the cell index in the sprite sheet */
  18697. cellIndex: number;
  18698. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18699. cellRef: string;
  18700. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18701. invertU: boolean;
  18702. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18703. invertV: boolean;
  18704. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18705. disposeWhenFinishedAnimating: boolean;
  18706. /** Gets the list of attached animations */
  18707. animations: Nullable<Array<Animation>>;
  18708. /** Gets or sets a boolean indicating if the sprite can be picked */
  18709. isPickable: boolean;
  18710. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18711. useAlphaForPicking: boolean;
  18712. /** @hidden */
  18713. _xOffset: number;
  18714. /** @hidden */
  18715. _yOffset: number;
  18716. /** @hidden */
  18717. _xSize: number;
  18718. /** @hidden */
  18719. _ySize: number;
  18720. /**
  18721. * Gets or sets the associated action manager
  18722. */
  18723. actionManager: Nullable<ActionManager>;
  18724. /**
  18725. * An event triggered when the control has been disposed
  18726. */
  18727. onDisposeObservable: Observable<Sprite>;
  18728. private _animationStarted;
  18729. private _loopAnimation;
  18730. private _fromIndex;
  18731. private _toIndex;
  18732. private _delay;
  18733. private _direction;
  18734. private _manager;
  18735. private _time;
  18736. private _onAnimationEnd;
  18737. /**
  18738. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18739. */
  18740. isVisible: boolean;
  18741. /**
  18742. * Gets or sets the sprite size
  18743. */
  18744. get size(): number;
  18745. set size(value: number);
  18746. /**
  18747. * Gets or sets the unique id of the sprite
  18748. */
  18749. uniqueId: number;
  18750. /**
  18751. * Gets the manager of this sprite
  18752. */
  18753. get manager(): ISpriteManager;
  18754. /**
  18755. * Creates a new Sprite
  18756. * @param name defines the name
  18757. * @param manager defines the manager
  18758. */
  18759. constructor(
  18760. /** defines the name */
  18761. name: string, manager: ISpriteManager);
  18762. /**
  18763. * Returns the string "Sprite"
  18764. * @returns "Sprite"
  18765. */
  18766. getClassName(): string;
  18767. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  18768. get fromIndex(): number;
  18769. set fromIndex(value: number);
  18770. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  18771. get toIndex(): number;
  18772. set toIndex(value: number);
  18773. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  18774. get loopAnimation(): boolean;
  18775. set loopAnimation(value: boolean);
  18776. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  18777. get delay(): number;
  18778. set delay(value: number);
  18779. /**
  18780. * Starts an animation
  18781. * @param from defines the initial key
  18782. * @param to defines the end key
  18783. * @param loop defines if the animation must loop
  18784. * @param delay defines the start delay (in ms)
  18785. * @param onAnimationEnd defines a callback to call when animation ends
  18786. */
  18787. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18788. /** Stops current animation (if any) */
  18789. stopAnimation(): void;
  18790. /** @hidden */
  18791. _animate(deltaTime: number): void;
  18792. /** Release associated resources */
  18793. dispose(): void;
  18794. }
  18795. }
  18796. declare module "babylonjs/Collisions/pickingInfo" {
  18797. import { Nullable } from "babylonjs/types";
  18798. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18800. import { Sprite } from "babylonjs/Sprites/sprite";
  18801. import { Ray } from "babylonjs/Culling/ray";
  18802. /**
  18803. * Information about the result of picking within a scene
  18804. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18805. */
  18806. export class PickingInfo {
  18807. /** @hidden */
  18808. _pickingUnavailable: boolean;
  18809. /**
  18810. * If the pick collided with an object
  18811. */
  18812. hit: boolean;
  18813. /**
  18814. * Distance away where the pick collided
  18815. */
  18816. distance: number;
  18817. /**
  18818. * The location of pick collision
  18819. */
  18820. pickedPoint: Nullable<Vector3>;
  18821. /**
  18822. * The mesh corresponding the the pick collision
  18823. */
  18824. pickedMesh: Nullable<AbstractMesh>;
  18825. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18826. bu: number;
  18827. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18828. bv: number;
  18829. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18830. faceId: number;
  18831. /** Id of the the submesh that was picked */
  18832. subMeshId: number;
  18833. /** If a sprite was picked, this will be the sprite the pick collided with */
  18834. pickedSprite: Nullable<Sprite>;
  18835. /**
  18836. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18837. */
  18838. originMesh: Nullable<AbstractMesh>;
  18839. /**
  18840. * The ray that was used to perform the picking.
  18841. */
  18842. ray: Nullable<Ray>;
  18843. /**
  18844. * Gets the normal correspodning to the face the pick collided with
  18845. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18846. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18847. * @returns The normal correspodning to the face the pick collided with
  18848. */
  18849. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18850. /**
  18851. * Gets the texture coordinates of where the pick occured
  18852. * @returns the vector containing the coordnates of the texture
  18853. */
  18854. getTextureCoordinates(): Nullable<Vector2>;
  18855. }
  18856. }
  18857. declare module "babylonjs/Events/pointerEvents" {
  18858. import { Nullable } from "babylonjs/types";
  18859. import { Vector2 } from "babylonjs/Maths/math.vector";
  18860. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18861. import { Ray } from "babylonjs/Culling/ray";
  18862. /**
  18863. * Gather the list of pointer event types as constants.
  18864. */
  18865. export class PointerEventTypes {
  18866. /**
  18867. * 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.
  18868. */
  18869. static readonly POINTERDOWN: number;
  18870. /**
  18871. * The pointerup event is fired when a pointer is no longer active.
  18872. */
  18873. static readonly POINTERUP: number;
  18874. /**
  18875. * The pointermove event is fired when a pointer changes coordinates.
  18876. */
  18877. static readonly POINTERMOVE: number;
  18878. /**
  18879. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18880. */
  18881. static readonly POINTERWHEEL: number;
  18882. /**
  18883. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18884. */
  18885. static readonly POINTERPICK: number;
  18886. /**
  18887. * The pointertap event is fired when a the object has been touched and released without drag.
  18888. */
  18889. static readonly POINTERTAP: number;
  18890. /**
  18891. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18892. */
  18893. static readonly POINTERDOUBLETAP: number;
  18894. }
  18895. /**
  18896. * Base class of pointer info types.
  18897. */
  18898. export class PointerInfoBase {
  18899. /**
  18900. * Defines the type of event (PointerEventTypes)
  18901. */
  18902. type: number;
  18903. /**
  18904. * Defines the related dom event
  18905. */
  18906. event: PointerEvent | MouseWheelEvent;
  18907. /**
  18908. * Instantiates the base class of pointers info.
  18909. * @param type Defines the type of event (PointerEventTypes)
  18910. * @param event Defines the related dom event
  18911. */
  18912. constructor(
  18913. /**
  18914. * Defines the type of event (PointerEventTypes)
  18915. */
  18916. type: number,
  18917. /**
  18918. * Defines the related dom event
  18919. */
  18920. event: PointerEvent | MouseWheelEvent);
  18921. }
  18922. /**
  18923. * This class is used to store pointer related info for the onPrePointerObservable event.
  18924. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18925. */
  18926. export class PointerInfoPre extends PointerInfoBase {
  18927. /**
  18928. * Ray from a pointer if availible (eg. 6dof controller)
  18929. */
  18930. ray: Nullable<Ray>;
  18931. /**
  18932. * Defines the local position of the pointer on the canvas.
  18933. */
  18934. localPosition: Vector2;
  18935. /**
  18936. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18937. */
  18938. skipOnPointerObservable: boolean;
  18939. /**
  18940. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18941. * @param type Defines the type of event (PointerEventTypes)
  18942. * @param event Defines the related dom event
  18943. * @param localX Defines the local x coordinates of the pointer when the event occured
  18944. * @param localY Defines the local y coordinates of the pointer when the event occured
  18945. */
  18946. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18947. }
  18948. /**
  18949. * This type contains all the data related to a pointer event in Babylon.js.
  18950. * 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.
  18951. */
  18952. export class PointerInfo extends PointerInfoBase {
  18953. /**
  18954. * Defines the picking info associated to the info (if any)\
  18955. */
  18956. pickInfo: Nullable<PickingInfo>;
  18957. /**
  18958. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18959. * @param type Defines the type of event (PointerEventTypes)
  18960. * @param event Defines the related dom event
  18961. * @param pickInfo Defines the picking info associated to the info (if any)\
  18962. */
  18963. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18964. /**
  18965. * Defines the picking info associated to the info (if any)\
  18966. */
  18967. pickInfo: Nullable<PickingInfo>);
  18968. }
  18969. /**
  18970. * Data relating to a touch event on the screen.
  18971. */
  18972. export interface PointerTouch {
  18973. /**
  18974. * X coordinate of touch.
  18975. */
  18976. x: number;
  18977. /**
  18978. * Y coordinate of touch.
  18979. */
  18980. y: number;
  18981. /**
  18982. * Id of touch. Unique for each finger.
  18983. */
  18984. pointerId: number;
  18985. /**
  18986. * Event type passed from DOM.
  18987. */
  18988. type: any;
  18989. }
  18990. }
  18991. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18992. import { Observable } from "babylonjs/Misc/observable";
  18993. import { Nullable } from "babylonjs/types";
  18994. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18995. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18996. /**
  18997. * Manage the mouse inputs to control the movement of a free camera.
  18998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18999. */
  19000. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19001. /**
  19002. * Define if touch is enabled in the mouse input
  19003. */
  19004. touchEnabled: boolean;
  19005. /**
  19006. * Defines the camera the input is attached to.
  19007. */
  19008. camera: FreeCamera;
  19009. /**
  19010. * Defines the buttons associated with the input to handle camera move.
  19011. */
  19012. buttons: number[];
  19013. /**
  19014. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19015. */
  19016. angularSensibility: number;
  19017. private _pointerInput;
  19018. private _onMouseMove;
  19019. private _observer;
  19020. private previousPosition;
  19021. /**
  19022. * Observable for when a pointer move event occurs containing the move offset
  19023. */
  19024. onPointerMovedObservable: Observable<{
  19025. offsetX: number;
  19026. offsetY: number;
  19027. }>;
  19028. /**
  19029. * @hidden
  19030. * If the camera should be rotated automatically based on pointer movement
  19031. */
  19032. _allowCameraRotation: boolean;
  19033. /**
  19034. * Manage the mouse inputs to control the movement of a free camera.
  19035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19036. * @param touchEnabled Defines if touch is enabled or not
  19037. */
  19038. constructor(
  19039. /**
  19040. * Define if touch is enabled in the mouse input
  19041. */
  19042. touchEnabled?: boolean);
  19043. /**
  19044. * Attach the input controls to a specific dom element to get the input from.
  19045. * @param element Defines the element the controls should be listened from
  19046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19047. */
  19048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19049. /**
  19050. * Called on JS contextmenu event.
  19051. * Override this method to provide functionality.
  19052. */
  19053. protected onContextMenu(evt: PointerEvent): void;
  19054. /**
  19055. * Detach the current controls from the specified dom element.
  19056. * @param element Defines the element to stop listening the inputs from
  19057. */
  19058. detachControl(element: Nullable<HTMLElement>): void;
  19059. /**
  19060. * Gets the class name of the current intput.
  19061. * @returns the class name
  19062. */
  19063. getClassName(): string;
  19064. /**
  19065. * Get the friendly name associated with the input class.
  19066. * @returns the input friendly name
  19067. */
  19068. getSimpleName(): string;
  19069. }
  19070. }
  19071. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19072. import { Nullable } from "babylonjs/types";
  19073. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19075. /**
  19076. * Manage the touch inputs to control the movement of a free camera.
  19077. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19078. */
  19079. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19080. /**
  19081. * Defines the camera the input is attached to.
  19082. */
  19083. camera: FreeCamera;
  19084. /**
  19085. * Defines the touch sensibility for rotation.
  19086. * The higher the faster.
  19087. */
  19088. touchAngularSensibility: number;
  19089. /**
  19090. * Defines the touch sensibility for move.
  19091. * The higher the faster.
  19092. */
  19093. touchMoveSensibility: number;
  19094. private _offsetX;
  19095. private _offsetY;
  19096. private _pointerPressed;
  19097. private _pointerInput;
  19098. private _observer;
  19099. private _onLostFocus;
  19100. /**
  19101. * Attach the input controls to a specific dom element to get the input from.
  19102. * @param element Defines the element the controls should be listened from
  19103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19104. */
  19105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19106. /**
  19107. * Detach the current controls from the specified dom element.
  19108. * @param element Defines the element to stop listening the inputs from
  19109. */
  19110. detachControl(element: Nullable<HTMLElement>): void;
  19111. /**
  19112. * Update the current camera state depending on the inputs that have been used this frame.
  19113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19114. */
  19115. checkInputs(): void;
  19116. /**
  19117. * Gets the class name of the current intput.
  19118. * @returns the class name
  19119. */
  19120. getClassName(): string;
  19121. /**
  19122. * Get the friendly name associated with the input class.
  19123. * @returns the input friendly name
  19124. */
  19125. getSimpleName(): string;
  19126. }
  19127. }
  19128. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19129. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19130. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19131. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19132. import { Nullable } from "babylonjs/types";
  19133. /**
  19134. * Default Inputs manager for the FreeCamera.
  19135. * It groups all the default supported inputs for ease of use.
  19136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19137. */
  19138. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19139. /**
  19140. * @hidden
  19141. */
  19142. _mouseInput: Nullable<FreeCameraMouseInput>;
  19143. /**
  19144. * Instantiates a new FreeCameraInputsManager.
  19145. * @param camera Defines the camera the inputs belong to
  19146. */
  19147. constructor(camera: FreeCamera);
  19148. /**
  19149. * Add keyboard input support to the input manager.
  19150. * @returns the current input manager
  19151. */
  19152. addKeyboard(): FreeCameraInputsManager;
  19153. /**
  19154. * Add mouse input support to the input manager.
  19155. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19156. * @returns the current input manager
  19157. */
  19158. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19159. /**
  19160. * Removes the mouse input support from the manager
  19161. * @returns the current input manager
  19162. */
  19163. removeMouse(): FreeCameraInputsManager;
  19164. /**
  19165. * Add touch input support to the input manager.
  19166. * @returns the current input manager
  19167. */
  19168. addTouch(): FreeCameraInputsManager;
  19169. /**
  19170. * Remove all attached input methods from a camera
  19171. */
  19172. clear(): void;
  19173. }
  19174. }
  19175. declare module "babylonjs/Cameras/freeCamera" {
  19176. import { Vector3 } from "babylonjs/Maths/math.vector";
  19177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19178. import { Scene } from "babylonjs/scene";
  19179. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19180. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19181. /**
  19182. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19183. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19184. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19185. */
  19186. export class FreeCamera extends TargetCamera {
  19187. /**
  19188. * Define the collision ellipsoid of the camera.
  19189. * This is helpful to simulate a camera body like the player body around the camera
  19190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19191. */
  19192. ellipsoid: Vector3;
  19193. /**
  19194. * Define an offset for the position of the ellipsoid around the camera.
  19195. * This can be helpful to determine the center of the body near the gravity center of the body
  19196. * instead of its head.
  19197. */
  19198. ellipsoidOffset: Vector3;
  19199. /**
  19200. * Enable or disable collisions of the camera with the rest of the scene objects.
  19201. */
  19202. checkCollisions: boolean;
  19203. /**
  19204. * Enable or disable gravity on the camera.
  19205. */
  19206. applyGravity: boolean;
  19207. /**
  19208. * Define the input manager associated to the camera.
  19209. */
  19210. inputs: FreeCameraInputsManager;
  19211. /**
  19212. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19213. * Higher values reduce sensitivity.
  19214. */
  19215. get angularSensibility(): number;
  19216. /**
  19217. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19218. * Higher values reduce sensitivity.
  19219. */
  19220. set angularSensibility(value: number);
  19221. /**
  19222. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19223. */
  19224. get keysUp(): number[];
  19225. set keysUp(value: number[]);
  19226. /**
  19227. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19228. */
  19229. get keysUpward(): number[];
  19230. set keysUpward(value: number[]);
  19231. /**
  19232. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19233. */
  19234. get keysDown(): number[];
  19235. set keysDown(value: number[]);
  19236. /**
  19237. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19238. */
  19239. get keysDownward(): number[];
  19240. set keysDownward(value: number[]);
  19241. /**
  19242. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19243. */
  19244. get keysLeft(): number[];
  19245. set keysLeft(value: number[]);
  19246. /**
  19247. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19248. */
  19249. get keysRight(): number[];
  19250. set keysRight(value: number[]);
  19251. /**
  19252. * Event raised when the camera collide with a mesh in the scene.
  19253. */
  19254. onCollide: (collidedMesh: AbstractMesh) => void;
  19255. private _collider;
  19256. private _needMoveForGravity;
  19257. private _oldPosition;
  19258. private _diffPosition;
  19259. private _newPosition;
  19260. /** @hidden */
  19261. _localDirection: Vector3;
  19262. /** @hidden */
  19263. _transformedDirection: Vector3;
  19264. /**
  19265. * Instantiates a Free Camera.
  19266. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19267. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19268. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19269. * @param name Define the name of the camera in the scene
  19270. * @param position Define the start position of the camera in the scene
  19271. * @param scene Define the scene the camera belongs to
  19272. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19273. */
  19274. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19275. /**
  19276. * Attached controls to the current camera.
  19277. * @param element Defines the element the controls should be listened from
  19278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19279. */
  19280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19281. /**
  19282. * Detach the current controls from the camera.
  19283. * The camera will stop reacting to inputs.
  19284. * @param element Defines the element to stop listening the inputs from
  19285. */
  19286. detachControl(element: HTMLElement): void;
  19287. private _collisionMask;
  19288. /**
  19289. * Define a collision mask to limit the list of object the camera can collide with
  19290. */
  19291. get collisionMask(): number;
  19292. set collisionMask(mask: number);
  19293. /** @hidden */
  19294. _collideWithWorld(displacement: Vector3): void;
  19295. private _onCollisionPositionChange;
  19296. /** @hidden */
  19297. _checkInputs(): void;
  19298. /** @hidden */
  19299. _decideIfNeedsToMove(): boolean;
  19300. /** @hidden */
  19301. _updatePosition(): void;
  19302. /**
  19303. * Destroy the camera and release the current resources hold by it.
  19304. */
  19305. dispose(): void;
  19306. /**
  19307. * Gets the current object class name.
  19308. * @return the class name
  19309. */
  19310. getClassName(): string;
  19311. }
  19312. }
  19313. declare module "babylonjs/Gamepads/gamepad" {
  19314. import { Observable } from "babylonjs/Misc/observable";
  19315. /**
  19316. * Represents a gamepad control stick position
  19317. */
  19318. export class StickValues {
  19319. /**
  19320. * The x component of the control stick
  19321. */
  19322. x: number;
  19323. /**
  19324. * The y component of the control stick
  19325. */
  19326. y: number;
  19327. /**
  19328. * Initializes the gamepad x and y control stick values
  19329. * @param x The x component of the gamepad control stick value
  19330. * @param y The y component of the gamepad control stick value
  19331. */
  19332. constructor(
  19333. /**
  19334. * The x component of the control stick
  19335. */
  19336. x: number,
  19337. /**
  19338. * The y component of the control stick
  19339. */
  19340. y: number);
  19341. }
  19342. /**
  19343. * An interface which manages callbacks for gamepad button changes
  19344. */
  19345. export interface GamepadButtonChanges {
  19346. /**
  19347. * Called when a gamepad has been changed
  19348. */
  19349. changed: boolean;
  19350. /**
  19351. * Called when a gamepad press event has been triggered
  19352. */
  19353. pressChanged: boolean;
  19354. /**
  19355. * Called when a touch event has been triggered
  19356. */
  19357. touchChanged: boolean;
  19358. /**
  19359. * Called when a value has changed
  19360. */
  19361. valueChanged: boolean;
  19362. }
  19363. /**
  19364. * Represents a gamepad
  19365. */
  19366. export class Gamepad {
  19367. /**
  19368. * The id of the gamepad
  19369. */
  19370. id: string;
  19371. /**
  19372. * The index of the gamepad
  19373. */
  19374. index: number;
  19375. /**
  19376. * The browser gamepad
  19377. */
  19378. browserGamepad: any;
  19379. /**
  19380. * Specifies what type of gamepad this represents
  19381. */
  19382. type: number;
  19383. private _leftStick;
  19384. private _rightStick;
  19385. /** @hidden */
  19386. _isConnected: boolean;
  19387. private _leftStickAxisX;
  19388. private _leftStickAxisY;
  19389. private _rightStickAxisX;
  19390. private _rightStickAxisY;
  19391. /**
  19392. * Triggered when the left control stick has been changed
  19393. */
  19394. private _onleftstickchanged;
  19395. /**
  19396. * Triggered when the right control stick has been changed
  19397. */
  19398. private _onrightstickchanged;
  19399. /**
  19400. * Represents a gamepad controller
  19401. */
  19402. static GAMEPAD: number;
  19403. /**
  19404. * Represents a generic controller
  19405. */
  19406. static GENERIC: number;
  19407. /**
  19408. * Represents an XBox controller
  19409. */
  19410. static XBOX: number;
  19411. /**
  19412. * Represents a pose-enabled controller
  19413. */
  19414. static POSE_ENABLED: number;
  19415. /**
  19416. * Represents an Dual Shock controller
  19417. */
  19418. static DUALSHOCK: number;
  19419. /**
  19420. * Specifies whether the left control stick should be Y-inverted
  19421. */
  19422. protected _invertLeftStickY: boolean;
  19423. /**
  19424. * Specifies if the gamepad has been connected
  19425. */
  19426. get isConnected(): boolean;
  19427. /**
  19428. * Initializes the gamepad
  19429. * @param id The id of the gamepad
  19430. * @param index The index of the gamepad
  19431. * @param browserGamepad The browser gamepad
  19432. * @param leftStickX The x component of the left joystick
  19433. * @param leftStickY The y component of the left joystick
  19434. * @param rightStickX The x component of the right joystick
  19435. * @param rightStickY The y component of the right joystick
  19436. */
  19437. constructor(
  19438. /**
  19439. * The id of the gamepad
  19440. */
  19441. id: string,
  19442. /**
  19443. * The index of the gamepad
  19444. */
  19445. index: number,
  19446. /**
  19447. * The browser gamepad
  19448. */
  19449. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19450. /**
  19451. * Callback triggered when the left joystick has changed
  19452. * @param callback
  19453. */
  19454. onleftstickchanged(callback: (values: StickValues) => void): void;
  19455. /**
  19456. * Callback triggered when the right joystick has changed
  19457. * @param callback
  19458. */
  19459. onrightstickchanged(callback: (values: StickValues) => void): void;
  19460. /**
  19461. * Gets the left joystick
  19462. */
  19463. get leftStick(): StickValues;
  19464. /**
  19465. * Sets the left joystick values
  19466. */
  19467. set leftStick(newValues: StickValues);
  19468. /**
  19469. * Gets the right joystick
  19470. */
  19471. get rightStick(): StickValues;
  19472. /**
  19473. * Sets the right joystick value
  19474. */
  19475. set rightStick(newValues: StickValues);
  19476. /**
  19477. * Updates the gamepad joystick positions
  19478. */
  19479. update(): void;
  19480. /**
  19481. * Disposes the gamepad
  19482. */
  19483. dispose(): void;
  19484. }
  19485. /**
  19486. * Represents a generic gamepad
  19487. */
  19488. export class GenericPad extends Gamepad {
  19489. private _buttons;
  19490. private _onbuttondown;
  19491. private _onbuttonup;
  19492. /**
  19493. * Observable triggered when a button has been pressed
  19494. */
  19495. onButtonDownObservable: Observable<number>;
  19496. /**
  19497. * Observable triggered when a button has been released
  19498. */
  19499. onButtonUpObservable: Observable<number>;
  19500. /**
  19501. * Callback triggered when a button has been pressed
  19502. * @param callback Called when a button has been pressed
  19503. */
  19504. onbuttondown(callback: (buttonPressed: number) => void): void;
  19505. /**
  19506. * Callback triggered when a button has been released
  19507. * @param callback Called when a button has been released
  19508. */
  19509. onbuttonup(callback: (buttonReleased: number) => void): void;
  19510. /**
  19511. * Initializes the generic gamepad
  19512. * @param id The id of the generic gamepad
  19513. * @param index The index of the generic gamepad
  19514. * @param browserGamepad The browser gamepad
  19515. */
  19516. constructor(id: string, index: number, browserGamepad: any);
  19517. private _setButtonValue;
  19518. /**
  19519. * Updates the generic gamepad
  19520. */
  19521. update(): void;
  19522. /**
  19523. * Disposes the generic gamepad
  19524. */
  19525. dispose(): void;
  19526. }
  19527. }
  19528. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19529. import { Observable } from "babylonjs/Misc/observable";
  19530. import { Nullable } from "babylonjs/types";
  19531. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19532. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19534. import { Ray } from "babylonjs/Culling/ray";
  19535. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19536. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19537. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19538. /**
  19539. * Defines the types of pose enabled controllers that are supported
  19540. */
  19541. export enum PoseEnabledControllerType {
  19542. /**
  19543. * HTC Vive
  19544. */
  19545. VIVE = 0,
  19546. /**
  19547. * Oculus Rift
  19548. */
  19549. OCULUS = 1,
  19550. /**
  19551. * Windows mixed reality
  19552. */
  19553. WINDOWS = 2,
  19554. /**
  19555. * Samsung gear VR
  19556. */
  19557. GEAR_VR = 3,
  19558. /**
  19559. * Google Daydream
  19560. */
  19561. DAYDREAM = 4,
  19562. /**
  19563. * Generic
  19564. */
  19565. GENERIC = 5
  19566. }
  19567. /**
  19568. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19569. */
  19570. export interface MutableGamepadButton {
  19571. /**
  19572. * Value of the button/trigger
  19573. */
  19574. value: number;
  19575. /**
  19576. * If the button/trigger is currently touched
  19577. */
  19578. touched: boolean;
  19579. /**
  19580. * If the button/trigger is currently pressed
  19581. */
  19582. pressed: boolean;
  19583. }
  19584. /**
  19585. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19586. * @hidden
  19587. */
  19588. export interface ExtendedGamepadButton extends GamepadButton {
  19589. /**
  19590. * If the button/trigger is currently pressed
  19591. */
  19592. readonly pressed: boolean;
  19593. /**
  19594. * If the button/trigger is currently touched
  19595. */
  19596. readonly touched: boolean;
  19597. /**
  19598. * Value of the button/trigger
  19599. */
  19600. readonly value: number;
  19601. }
  19602. /** @hidden */
  19603. export interface _GamePadFactory {
  19604. /**
  19605. * Returns whether or not the current gamepad can be created for this type of controller.
  19606. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19607. * @returns true if it can be created, otherwise false
  19608. */
  19609. canCreate(gamepadInfo: any): boolean;
  19610. /**
  19611. * Creates a new instance of the Gamepad.
  19612. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19613. * @returns the new gamepad instance
  19614. */
  19615. create(gamepadInfo: any): Gamepad;
  19616. }
  19617. /**
  19618. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19619. */
  19620. export class PoseEnabledControllerHelper {
  19621. /** @hidden */
  19622. static _ControllerFactories: _GamePadFactory[];
  19623. /** @hidden */
  19624. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19625. /**
  19626. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19627. * @param vrGamepad the gamepad to initialized
  19628. * @returns a vr controller of the type the gamepad identified as
  19629. */
  19630. static InitiateController(vrGamepad: any): Gamepad;
  19631. }
  19632. /**
  19633. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19634. */
  19635. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19636. /**
  19637. * If the controller is used in a webXR session
  19638. */
  19639. isXR: boolean;
  19640. private _deviceRoomPosition;
  19641. private _deviceRoomRotationQuaternion;
  19642. /**
  19643. * The device position in babylon space
  19644. */
  19645. devicePosition: Vector3;
  19646. /**
  19647. * The device rotation in babylon space
  19648. */
  19649. deviceRotationQuaternion: Quaternion;
  19650. /**
  19651. * The scale factor of the device in babylon space
  19652. */
  19653. deviceScaleFactor: number;
  19654. /**
  19655. * (Likely devicePosition should be used instead) The device position in its room space
  19656. */
  19657. position: Vector3;
  19658. /**
  19659. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19660. */
  19661. rotationQuaternion: Quaternion;
  19662. /**
  19663. * The type of controller (Eg. Windows mixed reality)
  19664. */
  19665. controllerType: PoseEnabledControllerType;
  19666. protected _calculatedPosition: Vector3;
  19667. private _calculatedRotation;
  19668. /**
  19669. * The raw pose from the device
  19670. */
  19671. rawPose: DevicePose;
  19672. private _trackPosition;
  19673. private _maxRotationDistFromHeadset;
  19674. private _draggedRoomRotation;
  19675. /**
  19676. * @hidden
  19677. */
  19678. _disableTrackPosition(fixedPosition: Vector3): void;
  19679. /**
  19680. * Internal, the mesh attached to the controller
  19681. * @hidden
  19682. */
  19683. _mesh: Nullable<AbstractMesh>;
  19684. private _poseControlledCamera;
  19685. private _leftHandSystemQuaternion;
  19686. /**
  19687. * Internal, matrix used to convert room space to babylon space
  19688. * @hidden
  19689. */
  19690. _deviceToWorld: Matrix;
  19691. /**
  19692. * Node to be used when casting a ray from the controller
  19693. * @hidden
  19694. */
  19695. _pointingPoseNode: Nullable<TransformNode>;
  19696. /**
  19697. * Name of the child mesh that can be used to cast a ray from the controller
  19698. */
  19699. static readonly POINTING_POSE: string;
  19700. /**
  19701. * Creates a new PoseEnabledController from a gamepad
  19702. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19703. */
  19704. constructor(browserGamepad: any);
  19705. private _workingMatrix;
  19706. /**
  19707. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19708. */
  19709. update(): void;
  19710. /**
  19711. * Updates only the pose device and mesh without doing any button event checking
  19712. */
  19713. protected _updatePoseAndMesh(): void;
  19714. /**
  19715. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19716. * @param poseData raw pose fromthe device
  19717. */
  19718. updateFromDevice(poseData: DevicePose): void;
  19719. /**
  19720. * @hidden
  19721. */
  19722. _meshAttachedObservable: Observable<AbstractMesh>;
  19723. /**
  19724. * Attaches a mesh to the controller
  19725. * @param mesh the mesh to be attached
  19726. */
  19727. attachToMesh(mesh: AbstractMesh): void;
  19728. /**
  19729. * Attaches the controllers mesh to a camera
  19730. * @param camera the camera the mesh should be attached to
  19731. */
  19732. attachToPoseControlledCamera(camera: TargetCamera): void;
  19733. /**
  19734. * Disposes of the controller
  19735. */
  19736. dispose(): void;
  19737. /**
  19738. * The mesh that is attached to the controller
  19739. */
  19740. get mesh(): Nullable<AbstractMesh>;
  19741. /**
  19742. * Gets the ray of the controller in the direction the controller is pointing
  19743. * @param length the length the resulting ray should be
  19744. * @returns a ray in the direction the controller is pointing
  19745. */
  19746. getForwardRay(length?: number): Ray;
  19747. }
  19748. }
  19749. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19750. import { Observable } from "babylonjs/Misc/observable";
  19751. import { Scene } from "babylonjs/scene";
  19752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19753. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19754. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19755. import { Nullable } from "babylonjs/types";
  19756. /**
  19757. * Defines the WebVRController object that represents controllers tracked in 3D space
  19758. */
  19759. export abstract class WebVRController extends PoseEnabledController {
  19760. /**
  19761. * Internal, the default controller model for the controller
  19762. */
  19763. protected _defaultModel: Nullable<AbstractMesh>;
  19764. /**
  19765. * Fired when the trigger state has changed
  19766. */
  19767. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19768. /**
  19769. * Fired when the main button state has changed
  19770. */
  19771. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19772. /**
  19773. * Fired when the secondary button state has changed
  19774. */
  19775. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19776. /**
  19777. * Fired when the pad state has changed
  19778. */
  19779. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19780. /**
  19781. * Fired when controllers stick values have changed
  19782. */
  19783. onPadValuesChangedObservable: Observable<StickValues>;
  19784. /**
  19785. * Array of button availible on the controller
  19786. */
  19787. protected _buttons: Array<MutableGamepadButton>;
  19788. private _onButtonStateChange;
  19789. /**
  19790. * Fired when a controller button's state has changed
  19791. * @param callback the callback containing the button that was modified
  19792. */
  19793. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19794. /**
  19795. * X and Y axis corresponding to the controllers joystick
  19796. */
  19797. pad: StickValues;
  19798. /**
  19799. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19800. */
  19801. hand: string;
  19802. /**
  19803. * The default controller model for the controller
  19804. */
  19805. get defaultModel(): Nullable<AbstractMesh>;
  19806. /**
  19807. * Creates a new WebVRController from a gamepad
  19808. * @param vrGamepad the gamepad that the WebVRController should be created from
  19809. */
  19810. constructor(vrGamepad: any);
  19811. /**
  19812. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19813. */
  19814. update(): void;
  19815. /**
  19816. * Function to be called when a button is modified
  19817. */
  19818. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19819. /**
  19820. * Loads a mesh and attaches it to the controller
  19821. * @param scene the scene the mesh should be added to
  19822. * @param meshLoaded callback for when the mesh has been loaded
  19823. */
  19824. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19825. private _setButtonValue;
  19826. private _changes;
  19827. private _checkChanges;
  19828. /**
  19829. * Disposes of th webVRCOntroller
  19830. */
  19831. dispose(): void;
  19832. }
  19833. }
  19834. declare module "babylonjs/Lights/hemisphericLight" {
  19835. import { Nullable } from "babylonjs/types";
  19836. import { Scene } from "babylonjs/scene";
  19837. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19838. import { Color3 } from "babylonjs/Maths/math.color";
  19839. import { Effect } from "babylonjs/Materials/effect";
  19840. import { Light } from "babylonjs/Lights/light";
  19841. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19842. /**
  19843. * The HemisphericLight simulates the ambient environment light,
  19844. * so the passed direction is the light reflection direction, not the incoming direction.
  19845. */
  19846. export class HemisphericLight extends Light {
  19847. /**
  19848. * The groundColor is the light in the opposite direction to the one specified during creation.
  19849. * 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.
  19850. */
  19851. groundColor: Color3;
  19852. /**
  19853. * The light reflection direction, not the incoming direction.
  19854. */
  19855. direction: Vector3;
  19856. /**
  19857. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19858. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19859. * The HemisphericLight can't cast shadows.
  19860. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19861. * @param name The friendly name of the light
  19862. * @param direction The direction of the light reflection
  19863. * @param scene The scene the light belongs to
  19864. */
  19865. constructor(name: string, direction: Vector3, scene: Scene);
  19866. protected _buildUniformLayout(): void;
  19867. /**
  19868. * Returns the string "HemisphericLight".
  19869. * @return The class name
  19870. */
  19871. getClassName(): string;
  19872. /**
  19873. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19874. * Returns the updated direction.
  19875. * @param target The target the direction should point to
  19876. * @return The computed direction
  19877. */
  19878. setDirectionToTarget(target: Vector3): Vector3;
  19879. /**
  19880. * Returns the shadow generator associated to the light.
  19881. * @returns Always null for hemispheric lights because it does not support shadows.
  19882. */
  19883. getShadowGenerator(): Nullable<IShadowGenerator>;
  19884. /**
  19885. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19886. * @param effect The effect to update
  19887. * @param lightIndex The index of the light in the effect to update
  19888. * @returns The hemispheric light
  19889. */
  19890. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19891. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19892. /**
  19893. * Computes the world matrix of the node
  19894. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19895. * @param useWasUpdatedFlag defines a reserved property
  19896. * @returns the world matrix
  19897. */
  19898. computeWorldMatrix(): Matrix;
  19899. /**
  19900. * Returns the integer 3.
  19901. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19902. */
  19903. getTypeID(): number;
  19904. /**
  19905. * Prepares the list of defines specific to the light type.
  19906. * @param defines the list of defines
  19907. * @param lightIndex defines the index of the light for the effect
  19908. */
  19909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19910. }
  19911. }
  19912. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19913. /** @hidden */
  19914. export var vrMultiviewToSingleviewPixelShader: {
  19915. name: string;
  19916. shader: string;
  19917. };
  19918. }
  19919. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19920. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19921. import { Scene } from "babylonjs/scene";
  19922. /**
  19923. * Renders to multiple views with a single draw call
  19924. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19925. */
  19926. export class MultiviewRenderTarget extends RenderTargetTexture {
  19927. /**
  19928. * Creates a multiview render target
  19929. * @param scene scene used with the render target
  19930. * @param size the size of the render target (used for each view)
  19931. */
  19932. constructor(scene: Scene, size?: number | {
  19933. width: number;
  19934. height: number;
  19935. } | {
  19936. ratio: number;
  19937. });
  19938. /**
  19939. * @hidden
  19940. * @param faceIndex the face index, if its a cube texture
  19941. */
  19942. _bindFrameBuffer(faceIndex?: number): void;
  19943. /**
  19944. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19945. * @returns the view count
  19946. */
  19947. getViewCount(): number;
  19948. }
  19949. }
  19950. declare module "babylonjs/Maths/math.frustum" {
  19951. import { Matrix } from "babylonjs/Maths/math.vector";
  19952. import { DeepImmutable } from "babylonjs/types";
  19953. import { Plane } from "babylonjs/Maths/math.plane";
  19954. /**
  19955. * Represents a camera frustum
  19956. */
  19957. export class Frustum {
  19958. /**
  19959. * Gets the planes representing the frustum
  19960. * @param transform matrix to be applied to the returned planes
  19961. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19962. */
  19963. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19964. /**
  19965. * Gets the near frustum plane transformed by the transform matrix
  19966. * @param transform transformation matrix to be applied to the resulting frustum plane
  19967. * @param frustumPlane the resuling frustum plane
  19968. */
  19969. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19970. /**
  19971. * Gets the far frustum plane transformed by the transform matrix
  19972. * @param transform transformation matrix to be applied to the resulting frustum plane
  19973. * @param frustumPlane the resuling frustum plane
  19974. */
  19975. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19976. /**
  19977. * Gets the left frustum plane transformed by the transform matrix
  19978. * @param transform transformation matrix to be applied to the resulting frustum plane
  19979. * @param frustumPlane the resuling frustum plane
  19980. */
  19981. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19982. /**
  19983. * Gets the right frustum plane transformed by the transform matrix
  19984. * @param transform transformation matrix to be applied to the resulting frustum plane
  19985. * @param frustumPlane the resuling frustum plane
  19986. */
  19987. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19988. /**
  19989. * Gets the top frustum plane transformed by the transform matrix
  19990. * @param transform transformation matrix to be applied to the resulting frustum plane
  19991. * @param frustumPlane the resuling frustum plane
  19992. */
  19993. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19994. /**
  19995. * Gets the bottom frustum plane transformed by the transform matrix
  19996. * @param transform transformation matrix to be applied to the resulting frustum plane
  19997. * @param frustumPlane the resuling frustum plane
  19998. */
  19999. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20000. /**
  20001. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  20002. * @param transform transformation matrix to be applied to the resulting frustum planes
  20003. * @param frustumPlanes the resuling frustum planes
  20004. */
  20005. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  20006. }
  20007. }
  20008. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20009. import { Camera } from "babylonjs/Cameras/camera";
  20010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20011. import { Nullable } from "babylonjs/types";
  20012. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20013. import { Matrix } from "babylonjs/Maths/math.vector";
  20014. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20015. module "babylonjs/Engines/engine" {
  20016. interface Engine {
  20017. /**
  20018. * Creates a new multiview render target
  20019. * @param width defines the width of the texture
  20020. * @param height defines the height of the texture
  20021. * @returns the created multiview texture
  20022. */
  20023. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20024. /**
  20025. * Binds a multiview framebuffer to be drawn to
  20026. * @param multiviewTexture texture to bind
  20027. */
  20028. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20029. }
  20030. }
  20031. module "babylonjs/Cameras/camera" {
  20032. interface Camera {
  20033. /**
  20034. * @hidden
  20035. * 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)
  20036. */
  20037. _useMultiviewToSingleView: boolean;
  20038. /**
  20039. * @hidden
  20040. * 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)
  20041. */
  20042. _multiviewTexture: Nullable<RenderTargetTexture>;
  20043. /**
  20044. * @hidden
  20045. * ensures the multiview texture of the camera exists and has the specified width/height
  20046. * @param width height to set on the multiview texture
  20047. * @param height width to set on the multiview texture
  20048. */
  20049. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20050. }
  20051. }
  20052. module "babylonjs/scene" {
  20053. interface Scene {
  20054. /** @hidden */
  20055. _transformMatrixR: Matrix;
  20056. /** @hidden */
  20057. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20058. /** @hidden */
  20059. _createMultiviewUbo(): void;
  20060. /** @hidden */
  20061. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20062. /** @hidden */
  20063. _renderMultiviewToSingleView(camera: Camera): void;
  20064. }
  20065. }
  20066. }
  20067. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20068. import { Camera } from "babylonjs/Cameras/camera";
  20069. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20070. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20071. import "babylonjs/Engines/Extensions/engine.multiview";
  20072. /**
  20073. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20074. * This will not be used for webXR as it supports displaying texture arrays directly
  20075. */
  20076. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20077. /**
  20078. * Initializes a VRMultiviewToSingleview
  20079. * @param name name of the post process
  20080. * @param camera camera to be applied to
  20081. * @param scaleFactor scaling factor to the size of the output texture
  20082. */
  20083. constructor(name: string, camera: Camera, scaleFactor: number);
  20084. }
  20085. }
  20086. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20087. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20088. import { Nullable } from "babylonjs/types";
  20089. import { Size } from "babylonjs/Maths/math.size";
  20090. import { Observable } from "babylonjs/Misc/observable";
  20091. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20092. /**
  20093. * Interface used to define additional presentation attributes
  20094. */
  20095. export interface IVRPresentationAttributes {
  20096. /**
  20097. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20098. */
  20099. highRefreshRate: boolean;
  20100. /**
  20101. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20102. */
  20103. foveationLevel: number;
  20104. }
  20105. module "babylonjs/Engines/engine" {
  20106. interface Engine {
  20107. /** @hidden */
  20108. _vrDisplay: any;
  20109. /** @hidden */
  20110. _vrSupported: boolean;
  20111. /** @hidden */
  20112. _oldSize: Size;
  20113. /** @hidden */
  20114. _oldHardwareScaleFactor: number;
  20115. /** @hidden */
  20116. _vrExclusivePointerMode: boolean;
  20117. /** @hidden */
  20118. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20119. /** @hidden */
  20120. _onVRDisplayPointerRestricted: () => void;
  20121. /** @hidden */
  20122. _onVRDisplayPointerUnrestricted: () => void;
  20123. /** @hidden */
  20124. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20125. /** @hidden */
  20126. _onVrDisplayDisconnect: Nullable<() => void>;
  20127. /** @hidden */
  20128. _onVrDisplayPresentChange: Nullable<() => void>;
  20129. /**
  20130. * Observable signaled when VR display mode changes
  20131. */
  20132. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20133. /**
  20134. * Observable signaled when VR request present is complete
  20135. */
  20136. onVRRequestPresentComplete: Observable<boolean>;
  20137. /**
  20138. * Observable signaled when VR request present starts
  20139. */
  20140. onVRRequestPresentStart: Observable<Engine>;
  20141. /**
  20142. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20143. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20144. */
  20145. isInVRExclusivePointerMode: boolean;
  20146. /**
  20147. * Gets a boolean indicating if a webVR device was detected
  20148. * @returns true if a webVR device was detected
  20149. */
  20150. isVRDevicePresent(): boolean;
  20151. /**
  20152. * Gets the current webVR device
  20153. * @returns the current webVR device (or null)
  20154. */
  20155. getVRDevice(): any;
  20156. /**
  20157. * Initializes a webVR display and starts listening to display change events
  20158. * The onVRDisplayChangedObservable will be notified upon these changes
  20159. * @returns A promise containing a VRDisplay and if vr is supported
  20160. */
  20161. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20162. /** @hidden */
  20163. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20164. /**
  20165. * Gets or sets the presentation attributes used to configure VR rendering
  20166. */
  20167. vrPresentationAttributes?: IVRPresentationAttributes;
  20168. /**
  20169. * Call this function to switch to webVR mode
  20170. * Will do nothing if webVR is not supported or if there is no webVR device
  20171. * @param options the webvr options provided to the camera. mainly used for multiview
  20172. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20173. */
  20174. enableVR(options: WebVROptions): void;
  20175. /** @hidden */
  20176. _onVRFullScreenTriggered(): void;
  20177. }
  20178. }
  20179. }
  20180. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20181. import { Nullable } from "babylonjs/types";
  20182. import { Observable } from "babylonjs/Misc/observable";
  20183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20184. import { Scene } from "babylonjs/scene";
  20185. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20186. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20187. import { Node } from "babylonjs/node";
  20188. import { Ray } from "babylonjs/Culling/ray";
  20189. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20190. import "babylonjs/Engines/Extensions/engine.webVR";
  20191. /**
  20192. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20193. * IMPORTANT!! The data is right-hand data.
  20194. * @export
  20195. * @interface DevicePose
  20196. */
  20197. export interface DevicePose {
  20198. /**
  20199. * The position of the device, values in array are [x,y,z].
  20200. */
  20201. readonly position: Nullable<Float32Array>;
  20202. /**
  20203. * The linearVelocity of the device, values in array are [x,y,z].
  20204. */
  20205. readonly linearVelocity: Nullable<Float32Array>;
  20206. /**
  20207. * The linearAcceleration of the device, values in array are [x,y,z].
  20208. */
  20209. readonly linearAcceleration: Nullable<Float32Array>;
  20210. /**
  20211. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20212. */
  20213. readonly orientation: Nullable<Float32Array>;
  20214. /**
  20215. * The angularVelocity of the device, values in array are [x,y,z].
  20216. */
  20217. readonly angularVelocity: Nullable<Float32Array>;
  20218. /**
  20219. * The angularAcceleration of the device, values in array are [x,y,z].
  20220. */
  20221. readonly angularAcceleration: Nullable<Float32Array>;
  20222. }
  20223. /**
  20224. * Interface representing a pose controlled object in Babylon.
  20225. * A pose controlled object has both regular pose values as well as pose values
  20226. * from an external device such as a VR head mounted display
  20227. */
  20228. export interface PoseControlled {
  20229. /**
  20230. * The position of the object in babylon space.
  20231. */
  20232. position: Vector3;
  20233. /**
  20234. * The rotation quaternion of the object in babylon space.
  20235. */
  20236. rotationQuaternion: Quaternion;
  20237. /**
  20238. * The position of the device in babylon space.
  20239. */
  20240. devicePosition?: Vector3;
  20241. /**
  20242. * The rotation quaternion of the device in babylon space.
  20243. */
  20244. deviceRotationQuaternion: Quaternion;
  20245. /**
  20246. * The raw pose coming from the device.
  20247. */
  20248. rawPose: Nullable<DevicePose>;
  20249. /**
  20250. * The scale of the device to be used when translating from device space to babylon space.
  20251. */
  20252. deviceScaleFactor: number;
  20253. /**
  20254. * Updates the poseControlled values based on the input device pose.
  20255. * @param poseData the pose data to update the object with
  20256. */
  20257. updateFromDevice(poseData: DevicePose): void;
  20258. }
  20259. /**
  20260. * Set of options to customize the webVRCamera
  20261. */
  20262. export interface WebVROptions {
  20263. /**
  20264. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20265. */
  20266. trackPosition?: boolean;
  20267. /**
  20268. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20269. */
  20270. positionScale?: number;
  20271. /**
  20272. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20273. */
  20274. displayName?: string;
  20275. /**
  20276. * Should the native controller meshes be initialized. (default: true)
  20277. */
  20278. controllerMeshes?: boolean;
  20279. /**
  20280. * Creating a default HemiLight only on controllers. (default: true)
  20281. */
  20282. defaultLightingOnControllers?: boolean;
  20283. /**
  20284. * If you don't want to use the default VR button of the helper. (default: false)
  20285. */
  20286. useCustomVRButton?: boolean;
  20287. /**
  20288. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20289. */
  20290. customVRButton?: HTMLButtonElement;
  20291. /**
  20292. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20293. */
  20294. rayLength?: number;
  20295. /**
  20296. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20297. */
  20298. defaultHeight?: number;
  20299. /**
  20300. * If multiview should be used if availible (default: false)
  20301. */
  20302. useMultiview?: boolean;
  20303. }
  20304. /**
  20305. * This represents a WebVR camera.
  20306. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20307. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20308. */
  20309. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20310. private webVROptions;
  20311. /**
  20312. * @hidden
  20313. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20314. */
  20315. _vrDevice: any;
  20316. /**
  20317. * The rawPose of the vrDevice.
  20318. */
  20319. rawPose: Nullable<DevicePose>;
  20320. private _onVREnabled;
  20321. private _specsVersion;
  20322. private _attached;
  20323. private _frameData;
  20324. protected _descendants: Array<Node>;
  20325. private _deviceRoomPosition;
  20326. /** @hidden */
  20327. _deviceRoomRotationQuaternion: Quaternion;
  20328. private _standingMatrix;
  20329. /**
  20330. * Represents device position in babylon space.
  20331. */
  20332. devicePosition: Vector3;
  20333. /**
  20334. * Represents device rotation in babylon space.
  20335. */
  20336. deviceRotationQuaternion: Quaternion;
  20337. /**
  20338. * The scale of the device to be used when translating from device space to babylon space.
  20339. */
  20340. deviceScaleFactor: number;
  20341. private _deviceToWorld;
  20342. private _worldToDevice;
  20343. /**
  20344. * References to the webVR controllers for the vrDevice.
  20345. */
  20346. controllers: Array<WebVRController>;
  20347. /**
  20348. * Emits an event when a controller is attached.
  20349. */
  20350. onControllersAttachedObservable: Observable<WebVRController[]>;
  20351. /**
  20352. * Emits an event when a controller's mesh has been loaded;
  20353. */
  20354. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20355. /**
  20356. * Emits an event when the HMD's pose has been updated.
  20357. */
  20358. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20359. private _poseSet;
  20360. /**
  20361. * If the rig cameras be used as parent instead of this camera.
  20362. */
  20363. rigParenting: boolean;
  20364. private _lightOnControllers;
  20365. private _defaultHeight?;
  20366. /**
  20367. * Instantiates a WebVRFreeCamera.
  20368. * @param name The name of the WebVRFreeCamera
  20369. * @param position The starting anchor position for the camera
  20370. * @param scene The scene the camera belongs to
  20371. * @param webVROptions a set of customizable options for the webVRCamera
  20372. */
  20373. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20374. /**
  20375. * Gets the device distance from the ground in meters.
  20376. * @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.
  20377. */
  20378. deviceDistanceToRoomGround(): number;
  20379. /**
  20380. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20381. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20382. */
  20383. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20384. /**
  20385. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20386. * @returns A promise with a boolean set to if the standing matrix is supported.
  20387. */
  20388. useStandingMatrixAsync(): Promise<boolean>;
  20389. /**
  20390. * Disposes the camera
  20391. */
  20392. dispose(): void;
  20393. /**
  20394. * Gets a vrController by name.
  20395. * @param name The name of the controller to retreive
  20396. * @returns the controller matching the name specified or null if not found
  20397. */
  20398. getControllerByName(name: string): Nullable<WebVRController>;
  20399. private _leftController;
  20400. /**
  20401. * The controller corresponding to the users left hand.
  20402. */
  20403. get leftController(): Nullable<WebVRController>;
  20404. private _rightController;
  20405. /**
  20406. * The controller corresponding to the users right hand.
  20407. */
  20408. get rightController(): Nullable<WebVRController>;
  20409. /**
  20410. * Casts a ray forward from the vrCamera's gaze.
  20411. * @param length Length of the ray (default: 100)
  20412. * @returns the ray corresponding to the gaze
  20413. */
  20414. getForwardRay(length?: number): Ray;
  20415. /**
  20416. * @hidden
  20417. * Updates the camera based on device's frame data
  20418. */
  20419. _checkInputs(): void;
  20420. /**
  20421. * Updates the poseControlled values based on the input device pose.
  20422. * @param poseData Pose coming from the device
  20423. */
  20424. updateFromDevice(poseData: DevicePose): void;
  20425. private _htmlElementAttached;
  20426. private _detachIfAttached;
  20427. /**
  20428. * WebVR's attach control will start broadcasting frames to the device.
  20429. * Note that in certain browsers (chrome for example) this function must be called
  20430. * within a user-interaction callback. Example:
  20431. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20432. *
  20433. * @param element html element to attach the vrDevice to
  20434. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20435. */
  20436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20437. /**
  20438. * Detaches the camera from the html element and disables VR
  20439. *
  20440. * @param element html element to detach from
  20441. */
  20442. detachControl(element: HTMLElement): void;
  20443. /**
  20444. * @returns the name of this class
  20445. */
  20446. getClassName(): string;
  20447. /**
  20448. * Calls resetPose on the vrDisplay
  20449. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20450. */
  20451. resetToCurrentRotation(): void;
  20452. /**
  20453. * @hidden
  20454. * Updates the rig cameras (left and right eye)
  20455. */
  20456. _updateRigCameras(): void;
  20457. private _workingVector;
  20458. private _oneVector;
  20459. private _workingMatrix;
  20460. private updateCacheCalled;
  20461. private _correctPositionIfNotTrackPosition;
  20462. /**
  20463. * @hidden
  20464. * Updates the cached values of the camera
  20465. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20466. */
  20467. _updateCache(ignoreParentClass?: boolean): void;
  20468. /**
  20469. * @hidden
  20470. * Get current device position in babylon world
  20471. */
  20472. _computeDevicePosition(): void;
  20473. /**
  20474. * Updates the current device position and rotation in the babylon world
  20475. */
  20476. update(): void;
  20477. /**
  20478. * @hidden
  20479. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20480. * @returns an identity matrix
  20481. */
  20482. _getViewMatrix(): Matrix;
  20483. private _tmpMatrix;
  20484. /**
  20485. * This function is called by the two RIG cameras.
  20486. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20487. * @hidden
  20488. */
  20489. _getWebVRViewMatrix(): Matrix;
  20490. /** @hidden */
  20491. _getWebVRProjectionMatrix(): Matrix;
  20492. private _onGamepadConnectedObserver;
  20493. private _onGamepadDisconnectedObserver;
  20494. private _updateCacheWhenTrackingDisabledObserver;
  20495. /**
  20496. * Initializes the controllers and their meshes
  20497. */
  20498. initControllers(): void;
  20499. }
  20500. }
  20501. declare module "babylonjs/PostProcesses/postProcess" {
  20502. import { Nullable } from "babylonjs/types";
  20503. import { SmartArray } from "babylonjs/Misc/smartArray";
  20504. import { Observable } from "babylonjs/Misc/observable";
  20505. import { Vector2 } from "babylonjs/Maths/math.vector";
  20506. import { Camera } from "babylonjs/Cameras/camera";
  20507. import { Effect } from "babylonjs/Materials/effect";
  20508. import "babylonjs/Shaders/postprocess.vertex";
  20509. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20510. import { Engine } from "babylonjs/Engines/engine";
  20511. import { Color4 } from "babylonjs/Maths/math.color";
  20512. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20514. /**
  20515. * Size options for a post process
  20516. */
  20517. export type PostProcessOptions = {
  20518. width: number;
  20519. height: number;
  20520. };
  20521. /**
  20522. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20523. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20524. */
  20525. export class PostProcess {
  20526. /** Name of the PostProcess. */
  20527. name: string;
  20528. /**
  20529. * Gets or sets the unique id of the post process
  20530. */
  20531. uniqueId: number;
  20532. /**
  20533. * Width of the texture to apply the post process on
  20534. */
  20535. width: number;
  20536. /**
  20537. * Height of the texture to apply the post process on
  20538. */
  20539. height: number;
  20540. /**
  20541. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20542. * @hidden
  20543. */
  20544. _outputTexture: Nullable<InternalTexture>;
  20545. /**
  20546. * Sampling mode used by the shader
  20547. * See https://doc.babylonjs.com/classes/3.1/texture
  20548. */
  20549. renderTargetSamplingMode: number;
  20550. /**
  20551. * Clear color to use when screen clearing
  20552. */
  20553. clearColor: Color4;
  20554. /**
  20555. * If the buffer needs to be cleared before applying the post process. (default: true)
  20556. * Should be set to false if shader will overwrite all previous pixels.
  20557. */
  20558. autoClear: boolean;
  20559. /**
  20560. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20561. */
  20562. alphaMode: number;
  20563. /**
  20564. * Sets the setAlphaBlendConstants of the babylon engine
  20565. */
  20566. alphaConstants: Color4;
  20567. /**
  20568. * Animations to be used for the post processing
  20569. */
  20570. animations: import("babylonjs/Animations/animation").Animation[];
  20571. /**
  20572. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20573. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20574. */
  20575. enablePixelPerfectMode: boolean;
  20576. /**
  20577. * Force the postprocess to be applied without taking in account viewport
  20578. */
  20579. forceFullscreenViewport: boolean;
  20580. /**
  20581. * List of inspectable custom properties (used by the Inspector)
  20582. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20583. */
  20584. inspectableCustomProperties: IInspectable[];
  20585. /**
  20586. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20587. *
  20588. * | Value | Type | Description |
  20589. * | ----- | ----------------------------------- | ----------- |
  20590. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20591. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20592. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20593. *
  20594. */
  20595. scaleMode: number;
  20596. /**
  20597. * Force textures to be a power of two (default: false)
  20598. */
  20599. alwaysForcePOT: boolean;
  20600. private _samples;
  20601. /**
  20602. * Number of sample textures (default: 1)
  20603. */
  20604. get samples(): number;
  20605. set samples(n: number);
  20606. /**
  20607. * Modify the scale of the post process to be the same as the viewport (default: false)
  20608. */
  20609. adaptScaleToCurrentViewport: boolean;
  20610. private _camera;
  20611. private _scene;
  20612. private _engine;
  20613. private _options;
  20614. private _reusable;
  20615. private _textureType;
  20616. private _textureFormat;
  20617. /**
  20618. * Smart array of input and output textures for the post process.
  20619. * @hidden
  20620. */
  20621. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20622. /**
  20623. * The index in _textures that corresponds to the output texture.
  20624. * @hidden
  20625. */
  20626. _currentRenderTextureInd: number;
  20627. private _effect;
  20628. private _samplers;
  20629. private _fragmentUrl;
  20630. private _vertexUrl;
  20631. private _parameters;
  20632. private _scaleRatio;
  20633. protected _indexParameters: any;
  20634. private _shareOutputWithPostProcess;
  20635. private _texelSize;
  20636. private _forcedOutputTexture;
  20637. /**
  20638. * Returns the fragment url or shader name used in the post process.
  20639. * @returns the fragment url or name in the shader store.
  20640. */
  20641. getEffectName(): string;
  20642. /**
  20643. * An event triggered when the postprocess is activated.
  20644. */
  20645. onActivateObservable: Observable<Camera>;
  20646. private _onActivateObserver;
  20647. /**
  20648. * A function that is added to the onActivateObservable
  20649. */
  20650. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20651. /**
  20652. * An event triggered when the postprocess changes its size.
  20653. */
  20654. onSizeChangedObservable: Observable<PostProcess>;
  20655. private _onSizeChangedObserver;
  20656. /**
  20657. * A function that is added to the onSizeChangedObservable
  20658. */
  20659. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20660. /**
  20661. * An event triggered when the postprocess applies its effect.
  20662. */
  20663. onApplyObservable: Observable<Effect>;
  20664. private _onApplyObserver;
  20665. /**
  20666. * A function that is added to the onApplyObservable
  20667. */
  20668. set onApply(callback: (effect: Effect) => void);
  20669. /**
  20670. * An event triggered before rendering the postprocess
  20671. */
  20672. onBeforeRenderObservable: Observable<Effect>;
  20673. private _onBeforeRenderObserver;
  20674. /**
  20675. * A function that is added to the onBeforeRenderObservable
  20676. */
  20677. set onBeforeRender(callback: (effect: Effect) => void);
  20678. /**
  20679. * An event triggered after rendering the postprocess
  20680. */
  20681. onAfterRenderObservable: Observable<Effect>;
  20682. private _onAfterRenderObserver;
  20683. /**
  20684. * A function that is added to the onAfterRenderObservable
  20685. */
  20686. set onAfterRender(callback: (efect: Effect) => void);
  20687. /**
  20688. * 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
  20689. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20690. */
  20691. get inputTexture(): InternalTexture;
  20692. set inputTexture(value: InternalTexture);
  20693. /**
  20694. * Gets the camera which post process is applied to.
  20695. * @returns The camera the post process is applied to.
  20696. */
  20697. getCamera(): Camera;
  20698. /**
  20699. * Gets the texel size of the postprocess.
  20700. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20701. */
  20702. get texelSize(): Vector2;
  20703. /**
  20704. * Creates a new instance PostProcess
  20705. * @param name The name of the PostProcess.
  20706. * @param fragmentUrl The url of the fragment shader to be used.
  20707. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20708. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20709. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20710. * @param camera The camera to apply the render pass to.
  20711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20712. * @param engine The engine which the post process will be applied. (default: current engine)
  20713. * @param reusable If the post process can be reused on the same frame. (default: false)
  20714. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20715. * @param textureType Type of textures used when performing the post process. (default: 0)
  20716. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20717. * @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
  20718. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20719. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20720. */
  20721. constructor(
  20722. /** Name of the PostProcess. */
  20723. 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, textureFormat?: number);
  20724. /**
  20725. * Gets a string idenfifying the name of the class
  20726. * @returns "PostProcess" string
  20727. */
  20728. getClassName(): string;
  20729. /**
  20730. * Gets the engine which this post process belongs to.
  20731. * @returns The engine the post process was enabled with.
  20732. */
  20733. getEngine(): Engine;
  20734. /**
  20735. * The effect that is created when initializing the post process.
  20736. * @returns The created effect corresponding the the postprocess.
  20737. */
  20738. getEffect(): Effect;
  20739. /**
  20740. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20741. * @param postProcess The post process to share the output with.
  20742. * @returns This post process.
  20743. */
  20744. shareOutputWith(postProcess: PostProcess): PostProcess;
  20745. /**
  20746. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20747. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20748. */
  20749. useOwnOutput(): void;
  20750. /**
  20751. * Updates the effect with the current post process compile time values and recompiles the shader.
  20752. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20753. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20754. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20755. * @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
  20756. * @param onCompiled Called when the shader has been compiled.
  20757. * @param onError Called if there is an error when compiling a shader.
  20758. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  20759. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  20760. */
  20761. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  20762. /**
  20763. * The post process is reusable if it can be used multiple times within one frame.
  20764. * @returns If the post process is reusable
  20765. */
  20766. isReusable(): boolean;
  20767. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20768. markTextureDirty(): void;
  20769. /**
  20770. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20771. * 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.
  20772. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20773. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20774. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20775. * @returns The target texture that was bound to be written to.
  20776. */
  20777. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20778. /**
  20779. * If the post process is supported.
  20780. */
  20781. get isSupported(): boolean;
  20782. /**
  20783. * The aspect ratio of the output texture.
  20784. */
  20785. get aspectRatio(): number;
  20786. /**
  20787. * Get a value indicating if the post-process is ready to be used
  20788. * @returns true if the post-process is ready (shader is compiled)
  20789. */
  20790. isReady(): boolean;
  20791. /**
  20792. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20793. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20794. */
  20795. apply(): Nullable<Effect>;
  20796. private _disposeTextures;
  20797. /**
  20798. * Disposes the post process.
  20799. * @param camera The camera to dispose the post process on.
  20800. */
  20801. dispose(camera?: Camera): void;
  20802. }
  20803. }
  20804. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20805. /** @hidden */
  20806. export var kernelBlurVaryingDeclaration: {
  20807. name: string;
  20808. shader: string;
  20809. };
  20810. }
  20811. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20812. /** @hidden */
  20813. export var kernelBlurFragment: {
  20814. name: string;
  20815. shader: string;
  20816. };
  20817. }
  20818. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20819. /** @hidden */
  20820. export var kernelBlurFragment2: {
  20821. name: string;
  20822. shader: string;
  20823. };
  20824. }
  20825. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20826. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20827. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20828. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20829. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20830. /** @hidden */
  20831. export var kernelBlurPixelShader: {
  20832. name: string;
  20833. shader: string;
  20834. };
  20835. }
  20836. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20837. /** @hidden */
  20838. export var kernelBlurVertex: {
  20839. name: string;
  20840. shader: string;
  20841. };
  20842. }
  20843. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20844. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20845. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20846. /** @hidden */
  20847. export var kernelBlurVertexShader: {
  20848. name: string;
  20849. shader: string;
  20850. };
  20851. }
  20852. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20853. import { Vector2 } from "babylonjs/Maths/math.vector";
  20854. import { Nullable } from "babylonjs/types";
  20855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20856. import { Camera } from "babylonjs/Cameras/camera";
  20857. import { Effect } from "babylonjs/Materials/effect";
  20858. import { Engine } from "babylonjs/Engines/engine";
  20859. import "babylonjs/Shaders/kernelBlur.fragment";
  20860. import "babylonjs/Shaders/kernelBlur.vertex";
  20861. /**
  20862. * The Blur Post Process which blurs an image based on a kernel and direction.
  20863. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20864. */
  20865. export class BlurPostProcess extends PostProcess {
  20866. /** The direction in which to blur the image. */
  20867. direction: Vector2;
  20868. private blockCompilation;
  20869. protected _kernel: number;
  20870. protected _idealKernel: number;
  20871. protected _packedFloat: boolean;
  20872. private _staticDefines;
  20873. /**
  20874. * Sets the length in pixels of the blur sample region
  20875. */
  20876. set kernel(v: number);
  20877. /**
  20878. * Gets the length in pixels of the blur sample region
  20879. */
  20880. get kernel(): number;
  20881. /**
  20882. * Sets wether or not the blur needs to unpack/repack floats
  20883. */
  20884. set packedFloat(v: boolean);
  20885. /**
  20886. * Gets wether or not the blur is unpacking/repacking floats
  20887. */
  20888. get packedFloat(): boolean;
  20889. /**
  20890. * Creates a new instance BlurPostProcess
  20891. * @param name The name of the effect.
  20892. * @param direction The direction in which to blur the image.
  20893. * @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.
  20894. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20895. * @param camera The camera to apply the render pass to.
  20896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20897. * @param engine The engine which the post process will be applied. (default: current engine)
  20898. * @param reusable If the post process can be reused on the same frame. (default: false)
  20899. * @param textureType Type of textures used when performing the post process. (default: 0)
  20900. * @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)
  20901. */
  20902. constructor(name: string,
  20903. /** The direction in which to blur the image. */
  20904. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20905. /**
  20906. * Updates the effect with the current post process compile time values and recompiles the shader.
  20907. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20908. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20909. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20910. * @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
  20911. * @param onCompiled Called when the shader has been compiled.
  20912. * @param onError Called if there is an error when compiling a shader.
  20913. */
  20914. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20915. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20916. /**
  20917. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20918. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20919. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20920. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20921. * The gaps between physical kernels are compensated for in the weighting of the samples
  20922. * @param idealKernel Ideal blur kernel.
  20923. * @return Nearest best kernel.
  20924. */
  20925. protected _nearestBestKernel(idealKernel: number): number;
  20926. /**
  20927. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20928. * @param x The point on the Gaussian distribution to sample.
  20929. * @return the value of the Gaussian function at x.
  20930. */
  20931. protected _gaussianWeight(x: number): number;
  20932. /**
  20933. * Generates a string that can be used as a floating point number in GLSL.
  20934. * @param x Value to print.
  20935. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20936. * @return GLSL float string.
  20937. */
  20938. protected _glslFloat(x: number, decimalFigures?: number): string;
  20939. }
  20940. }
  20941. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20942. import { Scene } from "babylonjs/scene";
  20943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20944. import { Plane } from "babylonjs/Maths/math.plane";
  20945. /**
  20946. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20947. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20948. * You can then easily use it as a reflectionTexture on a flat surface.
  20949. * In case the surface is not a plane, please consider relying on reflection probes.
  20950. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20951. */
  20952. export class MirrorTexture extends RenderTargetTexture {
  20953. private scene;
  20954. /**
  20955. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20956. * 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.
  20957. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20958. */
  20959. mirrorPlane: Plane;
  20960. /**
  20961. * Define the blur ratio used to blur the reflection if needed.
  20962. */
  20963. set blurRatio(value: number);
  20964. get blurRatio(): number;
  20965. /**
  20966. * Define the adaptive blur kernel used to blur the reflection if needed.
  20967. * This will autocompute the closest best match for the `blurKernel`
  20968. */
  20969. set adaptiveBlurKernel(value: number);
  20970. /**
  20971. * Define the blur kernel used to blur the reflection if needed.
  20972. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20973. */
  20974. set blurKernel(value: number);
  20975. /**
  20976. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20977. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20978. */
  20979. set blurKernelX(value: number);
  20980. get blurKernelX(): number;
  20981. /**
  20982. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20983. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20984. */
  20985. set blurKernelY(value: number);
  20986. get blurKernelY(): number;
  20987. private _autoComputeBlurKernel;
  20988. protected _onRatioRescale(): void;
  20989. private _updateGammaSpace;
  20990. private _imageProcessingConfigChangeObserver;
  20991. private _transformMatrix;
  20992. private _mirrorMatrix;
  20993. private _savedViewMatrix;
  20994. private _blurX;
  20995. private _blurY;
  20996. private _adaptiveBlurKernel;
  20997. private _blurKernelX;
  20998. private _blurKernelY;
  20999. private _blurRatio;
  21000. /**
  21001. * Instantiates a Mirror Texture.
  21002. * Mirror texture can be used to simulate the view from a mirror in a scene.
  21003. * It will dynamically be rendered every frame to adapt to the camera point of view.
  21004. * You can then easily use it as a reflectionTexture on a flat surface.
  21005. * In case the surface is not a plane, please consider relying on reflection probes.
  21006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  21007. * @param name
  21008. * @param size
  21009. * @param scene
  21010. * @param generateMipMaps
  21011. * @param type
  21012. * @param samplingMode
  21013. * @param generateDepthBuffer
  21014. */
  21015. constructor(name: string, size: number | {
  21016. width: number;
  21017. height: number;
  21018. } | {
  21019. ratio: number;
  21020. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  21021. private _preparePostProcesses;
  21022. /**
  21023. * Clone the mirror texture.
  21024. * @returns the cloned texture
  21025. */
  21026. clone(): MirrorTexture;
  21027. /**
  21028. * Serialize the texture to a JSON representation you could use in Parse later on
  21029. * @returns the serialized JSON representation
  21030. */
  21031. serialize(): any;
  21032. /**
  21033. * Dispose the texture and release its associated resources.
  21034. */
  21035. dispose(): void;
  21036. }
  21037. }
  21038. declare module "babylonjs/Materials/Textures/texture" {
  21039. import { Observable } from "babylonjs/Misc/observable";
  21040. import { Nullable } from "babylonjs/types";
  21041. import { Matrix } from "babylonjs/Maths/math.vector";
  21042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21043. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21044. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  21045. import { Scene } from "babylonjs/scene";
  21046. /**
  21047. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21048. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21049. */
  21050. export class Texture extends BaseTexture {
  21051. /**
  21052. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  21053. */
  21054. static SerializeBuffers: boolean;
  21055. /** @hidden */
  21056. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  21057. /** @hidden */
  21058. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  21059. /** @hidden */
  21060. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  21061. /** nearest is mag = nearest and min = nearest and mip = linear */
  21062. static readonly NEAREST_SAMPLINGMODE: number;
  21063. /** nearest is mag = nearest and min = nearest and mip = linear */
  21064. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  21065. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21066. static readonly BILINEAR_SAMPLINGMODE: number;
  21067. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21068. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  21069. /** Trilinear is mag = linear and min = linear and mip = linear */
  21070. static readonly TRILINEAR_SAMPLINGMODE: number;
  21071. /** Trilinear is mag = linear and min = linear and mip = linear */
  21072. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  21073. /** mag = nearest and min = nearest and mip = nearest */
  21074. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  21075. /** mag = nearest and min = linear and mip = nearest */
  21076. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  21077. /** mag = nearest and min = linear and mip = linear */
  21078. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  21079. /** mag = nearest and min = linear and mip = none */
  21080. static readonly NEAREST_LINEAR: number;
  21081. /** mag = nearest and min = nearest and mip = none */
  21082. static readonly NEAREST_NEAREST: number;
  21083. /** mag = linear and min = nearest and mip = nearest */
  21084. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  21085. /** mag = linear and min = nearest and mip = linear */
  21086. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  21087. /** mag = linear and min = linear and mip = none */
  21088. static readonly LINEAR_LINEAR: number;
  21089. /** mag = linear and min = nearest and mip = none */
  21090. static readonly LINEAR_NEAREST: number;
  21091. /** Explicit coordinates mode */
  21092. static readonly EXPLICIT_MODE: number;
  21093. /** Spherical coordinates mode */
  21094. static readonly SPHERICAL_MODE: number;
  21095. /** Planar coordinates mode */
  21096. static readonly PLANAR_MODE: number;
  21097. /** Cubic coordinates mode */
  21098. static readonly CUBIC_MODE: number;
  21099. /** Projection coordinates mode */
  21100. static readonly PROJECTION_MODE: number;
  21101. /** Inverse Cubic coordinates mode */
  21102. static readonly SKYBOX_MODE: number;
  21103. /** Inverse Cubic coordinates mode */
  21104. static readonly INVCUBIC_MODE: number;
  21105. /** Equirectangular coordinates mode */
  21106. static readonly EQUIRECTANGULAR_MODE: number;
  21107. /** Equirectangular Fixed coordinates mode */
  21108. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  21109. /** Equirectangular Fixed Mirrored coordinates mode */
  21110. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  21111. /** Texture is not repeating outside of 0..1 UVs */
  21112. static readonly CLAMP_ADDRESSMODE: number;
  21113. /** Texture is repeating outside of 0..1 UVs */
  21114. static readonly WRAP_ADDRESSMODE: number;
  21115. /** Texture is repeating and mirrored */
  21116. static readonly MIRROR_ADDRESSMODE: number;
  21117. /**
  21118. * 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
  21119. */
  21120. static UseSerializedUrlIfAny: boolean;
  21121. /**
  21122. * Define the url of the texture.
  21123. */
  21124. url: Nullable<string>;
  21125. /**
  21126. * Define an offset on the texture to offset the u coordinates of the UVs
  21127. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21128. */
  21129. uOffset: number;
  21130. /**
  21131. * Define an offset on the texture to offset the v coordinates of the UVs
  21132. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21133. */
  21134. vOffset: number;
  21135. /**
  21136. * Define an offset on the texture to scale the u coordinates of the UVs
  21137. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21138. */
  21139. uScale: number;
  21140. /**
  21141. * Define an offset on the texture to scale the v coordinates of the UVs
  21142. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21143. */
  21144. vScale: number;
  21145. /**
  21146. * Define an offset on the texture to rotate around the u coordinates of the UVs
  21147. * @see http://doc.babylonjs.com/how_to/more_materials
  21148. */
  21149. uAng: number;
  21150. /**
  21151. * Define an offset on the texture to rotate around the v coordinates of the UVs
  21152. * @see http://doc.babylonjs.com/how_to/more_materials
  21153. */
  21154. vAng: number;
  21155. /**
  21156. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  21157. * @see http://doc.babylonjs.com/how_to/more_materials
  21158. */
  21159. wAng: number;
  21160. /**
  21161. * Defines the center of rotation (U)
  21162. */
  21163. uRotationCenter: number;
  21164. /**
  21165. * Defines the center of rotation (V)
  21166. */
  21167. vRotationCenter: number;
  21168. /**
  21169. * Defines the center of rotation (W)
  21170. */
  21171. wRotationCenter: number;
  21172. /**
  21173. * Are mip maps generated for this texture or not.
  21174. */
  21175. get noMipmap(): boolean;
  21176. /**
  21177. * List of inspectable custom properties (used by the Inspector)
  21178. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21179. */
  21180. inspectableCustomProperties: Nullable<IInspectable[]>;
  21181. private _noMipmap;
  21182. /** @hidden */
  21183. _invertY: boolean;
  21184. private _rowGenerationMatrix;
  21185. private _cachedTextureMatrix;
  21186. private _projectionModeMatrix;
  21187. private _t0;
  21188. private _t1;
  21189. private _t2;
  21190. private _cachedUOffset;
  21191. private _cachedVOffset;
  21192. private _cachedUScale;
  21193. private _cachedVScale;
  21194. private _cachedUAng;
  21195. private _cachedVAng;
  21196. private _cachedWAng;
  21197. private _cachedProjectionMatrixId;
  21198. private _cachedCoordinatesMode;
  21199. /** @hidden */
  21200. protected _initialSamplingMode: number;
  21201. /** @hidden */
  21202. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21203. private _deleteBuffer;
  21204. protected _format: Nullable<number>;
  21205. private _delayedOnLoad;
  21206. private _delayedOnError;
  21207. private _mimeType?;
  21208. /**
  21209. * Observable triggered once the texture has been loaded.
  21210. */
  21211. onLoadObservable: Observable<Texture>;
  21212. protected _isBlocking: boolean;
  21213. /**
  21214. * Is the texture preventing material to render while loading.
  21215. * If false, a default texture will be used instead of the loading one during the preparation step.
  21216. */
  21217. set isBlocking(value: boolean);
  21218. get isBlocking(): boolean;
  21219. /**
  21220. * Get the current sampling mode associated with the texture.
  21221. */
  21222. get samplingMode(): number;
  21223. /**
  21224. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21225. */
  21226. get invertY(): boolean;
  21227. /**
  21228. * Instantiates a new texture.
  21229. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21230. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21231. * @param url defines the url of the picture to load as a texture
  21232. * @param sceneOrEngine defines the scene or engine the texture will belong to
  21233. * @param noMipmap defines if the texture will require mip maps or not
  21234. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21235. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21236. * @param onLoad defines a callback triggered when the texture has been loaded
  21237. * @param onError defines a callback triggered when an error occurred during the loading session
  21238. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21239. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21240. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21241. * @param mimeType defines an optional mime type information
  21242. */
  21243. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  21244. /**
  21245. * Update the url (and optional buffer) of this texture if url was null during construction.
  21246. * @param url the url of the texture
  21247. * @param buffer the buffer of the texture (defaults to null)
  21248. * @param onLoad callback called when the texture is loaded (defaults to null)
  21249. */
  21250. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21251. /**
  21252. * Finish the loading sequence of a texture flagged as delayed load.
  21253. * @hidden
  21254. */
  21255. delayLoad(): void;
  21256. private _prepareRowForTextureGeneration;
  21257. /**
  21258. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21259. * @returns the transform matrix of the texture.
  21260. */
  21261. getTextureMatrix(uBase?: number): Matrix;
  21262. /**
  21263. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21264. * @returns The reflection texture transform
  21265. */
  21266. getReflectionTextureMatrix(): Matrix;
  21267. /**
  21268. * Clones the texture.
  21269. * @returns the cloned texture
  21270. */
  21271. clone(): Texture;
  21272. /**
  21273. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21274. * @returns The JSON representation of the texture
  21275. */
  21276. serialize(): any;
  21277. /**
  21278. * Get the current class name of the texture useful for serialization or dynamic coding.
  21279. * @returns "Texture"
  21280. */
  21281. getClassName(): string;
  21282. /**
  21283. * Dispose the texture and release its associated resources.
  21284. */
  21285. dispose(): void;
  21286. /**
  21287. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21288. * @param parsedTexture Define the JSON representation of the texture
  21289. * @param scene Define the scene the parsed texture should be instantiated in
  21290. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21291. * @returns The parsed texture if successful
  21292. */
  21293. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21294. /**
  21295. * Creates a texture from its base 64 representation.
  21296. * @param data Define the base64 payload without the data: prefix
  21297. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21298. * @param scene Define the scene the texture should belong to
  21299. * @param noMipmap Forces the texture to not create mip map information if true
  21300. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21301. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21302. * @param onLoad define a callback triggered when the texture has been loaded
  21303. * @param onError define a callback triggered when an error occurred during the loading session
  21304. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21305. * @returns the created texture
  21306. */
  21307. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21308. /**
  21309. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21310. * @param data Define the base64 payload without the data: prefix
  21311. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21312. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21313. * @param scene Define the scene the texture should belong to
  21314. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21315. * @param noMipmap Forces the texture to not create mip map information if true
  21316. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21317. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21318. * @param onLoad define a callback triggered when the texture has been loaded
  21319. * @param onError define a callback triggered when an error occurred during the loading session
  21320. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21321. * @returns the created texture
  21322. */
  21323. 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;
  21324. }
  21325. }
  21326. declare module "babylonjs/PostProcesses/postProcessManager" {
  21327. import { Nullable } from "babylonjs/types";
  21328. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21329. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21330. import { Scene } from "babylonjs/scene";
  21331. /**
  21332. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21333. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21334. */
  21335. export class PostProcessManager {
  21336. private _scene;
  21337. private _indexBuffer;
  21338. private _vertexBuffers;
  21339. /**
  21340. * Creates a new instance PostProcess
  21341. * @param scene The scene that the post process is associated with.
  21342. */
  21343. constructor(scene: Scene);
  21344. private _prepareBuffers;
  21345. private _buildIndexBuffer;
  21346. /**
  21347. * Rebuilds the vertex buffers of the manager.
  21348. * @hidden
  21349. */
  21350. _rebuild(): void;
  21351. /**
  21352. * Prepares a frame to be run through a post process.
  21353. * @param sourceTexture The input texture to the post procesess. (default: null)
  21354. * @param postProcesses An array of post processes to be run. (default: null)
  21355. * @returns True if the post processes were able to be run.
  21356. * @hidden
  21357. */
  21358. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21359. /**
  21360. * Manually render a set of post processes to a texture.
  21361. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  21362. * @param postProcesses An array of post processes to be run.
  21363. * @param targetTexture The target texture to render to.
  21364. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21365. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21366. * @param lodLevel defines which lod of the texture to render to
  21367. */
  21368. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21369. /**
  21370. * Finalize the result of the output of the postprocesses.
  21371. * @param doNotPresent If true the result will not be displayed to the screen.
  21372. * @param targetTexture The target texture to render to.
  21373. * @param faceIndex The index of the face to bind the target texture to.
  21374. * @param postProcesses The array of post processes to render.
  21375. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21376. * @hidden
  21377. */
  21378. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21379. /**
  21380. * Disposes of the post process manager.
  21381. */
  21382. dispose(): void;
  21383. }
  21384. }
  21385. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21386. import { Observable } from "babylonjs/Misc/observable";
  21387. import { SmartArray } from "babylonjs/Misc/smartArray";
  21388. import { Nullable, Immutable } from "babylonjs/types";
  21389. import { Camera } from "babylonjs/Cameras/camera";
  21390. import { Scene } from "babylonjs/scene";
  21391. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21392. import { Color4 } from "babylonjs/Maths/math.color";
  21393. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21396. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21397. import { Texture } from "babylonjs/Materials/Textures/texture";
  21398. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21399. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21400. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21401. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21402. import { Engine } from "babylonjs/Engines/engine";
  21403. /**
  21404. * This Helps creating a texture that will be created from a camera in your scene.
  21405. * It is basically a dynamic texture that could be used to create special effects for instance.
  21406. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21407. */
  21408. export class RenderTargetTexture extends Texture {
  21409. isCube: boolean;
  21410. /**
  21411. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21412. */
  21413. static readonly REFRESHRATE_RENDER_ONCE: number;
  21414. /**
  21415. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21416. */
  21417. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21418. /**
  21419. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21420. * the central point of your effect and can save a lot of performances.
  21421. */
  21422. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21423. /**
  21424. * Use this predicate to dynamically define the list of mesh you want to render.
  21425. * If set, the renderList property will be overwritten.
  21426. */
  21427. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21428. private _renderList;
  21429. /**
  21430. * Use this list to define the list of mesh you want to render.
  21431. */
  21432. get renderList(): Nullable<Array<AbstractMesh>>;
  21433. set renderList(value: Nullable<Array<AbstractMesh>>);
  21434. /**
  21435. * Use this function to overload the renderList array at rendering time.
  21436. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21437. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21438. * the cube (if the RTT is a cube, else layerOrFace=0).
  21439. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21440. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21441. * hold dummy elements!
  21442. */
  21443. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21444. private _hookArray;
  21445. /**
  21446. * Define if particles should be rendered in your texture.
  21447. */
  21448. renderParticles: boolean;
  21449. /**
  21450. * Define if sprites should be rendered in your texture.
  21451. */
  21452. renderSprites: boolean;
  21453. /**
  21454. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21455. */
  21456. coordinatesMode: number;
  21457. /**
  21458. * Define the camera used to render the texture.
  21459. */
  21460. activeCamera: Nullable<Camera>;
  21461. /**
  21462. * Override the mesh isReady function with your own one.
  21463. */
  21464. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21465. /**
  21466. * Override the render function of the texture with your own one.
  21467. */
  21468. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21469. /**
  21470. * Define if camera post processes should be use while rendering the texture.
  21471. */
  21472. useCameraPostProcesses: boolean;
  21473. /**
  21474. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21475. */
  21476. ignoreCameraViewport: boolean;
  21477. private _postProcessManager;
  21478. private _postProcesses;
  21479. private _resizeObserver;
  21480. /**
  21481. * An event triggered when the texture is unbind.
  21482. */
  21483. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21484. /**
  21485. * An event triggered when the texture is unbind.
  21486. */
  21487. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21488. private _onAfterUnbindObserver;
  21489. /**
  21490. * Set a after unbind callback in the texture.
  21491. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21492. */
  21493. set onAfterUnbind(callback: () => void);
  21494. /**
  21495. * An event triggered before rendering the texture
  21496. */
  21497. onBeforeRenderObservable: Observable<number>;
  21498. private _onBeforeRenderObserver;
  21499. /**
  21500. * Set a before render callback in the texture.
  21501. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21502. */
  21503. set onBeforeRender(callback: (faceIndex: number) => void);
  21504. /**
  21505. * An event triggered after rendering the texture
  21506. */
  21507. onAfterRenderObservable: Observable<number>;
  21508. private _onAfterRenderObserver;
  21509. /**
  21510. * Set a after render callback in the texture.
  21511. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21512. */
  21513. set onAfterRender(callback: (faceIndex: number) => void);
  21514. /**
  21515. * An event triggered after the texture clear
  21516. */
  21517. onClearObservable: Observable<Engine>;
  21518. private _onClearObserver;
  21519. /**
  21520. * Set a clear callback in the texture.
  21521. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21522. */
  21523. set onClear(callback: (Engine: Engine) => void);
  21524. /**
  21525. * An event triggered when the texture is resized.
  21526. */
  21527. onResizeObservable: Observable<RenderTargetTexture>;
  21528. /**
  21529. * Define the clear color of the Render Target if it should be different from the scene.
  21530. */
  21531. clearColor: Color4;
  21532. protected _size: number | {
  21533. width: number;
  21534. height: number;
  21535. layers?: number;
  21536. };
  21537. protected _initialSizeParameter: number | {
  21538. width: number;
  21539. height: number;
  21540. } | {
  21541. ratio: number;
  21542. };
  21543. protected _sizeRatio: Nullable<number>;
  21544. /** @hidden */
  21545. _generateMipMaps: boolean;
  21546. protected _renderingManager: RenderingManager;
  21547. /** @hidden */
  21548. _waitingRenderList: string[];
  21549. protected _doNotChangeAspectRatio: boolean;
  21550. protected _currentRefreshId: number;
  21551. protected _refreshRate: number;
  21552. protected _textureMatrix: Matrix;
  21553. protected _samples: number;
  21554. protected _renderTargetOptions: RenderTargetCreationOptions;
  21555. /**
  21556. * Gets render target creation options that were used.
  21557. */
  21558. get renderTargetOptions(): RenderTargetCreationOptions;
  21559. protected _onRatioRescale(): void;
  21560. /**
  21561. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21562. * It must define where the camera used to render the texture is set
  21563. */
  21564. boundingBoxPosition: Vector3;
  21565. private _boundingBoxSize;
  21566. /**
  21567. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21568. * When defined, the cubemap will switch to local mode
  21569. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21570. * @example https://www.babylonjs-playground.com/#RNASML
  21571. */
  21572. set boundingBoxSize(value: Vector3);
  21573. get boundingBoxSize(): Vector3;
  21574. /**
  21575. * In case the RTT has been created with a depth texture, get the associated
  21576. * depth texture.
  21577. * Otherwise, return null.
  21578. */
  21579. get depthStencilTexture(): Nullable<InternalTexture>;
  21580. /**
  21581. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21582. * or used a shadow, depth texture...
  21583. * @param name The friendly name of the texture
  21584. * @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)
  21585. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21586. * @param generateMipMaps True if mip maps need to be generated after render.
  21587. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21588. * @param type The type of the buffer in the RTT (int, half float, float...)
  21589. * @param isCube True if a cube texture needs to be created
  21590. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21591. * @param generateDepthBuffer True to generate a depth buffer
  21592. * @param generateStencilBuffer True to generate a stencil buffer
  21593. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21594. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21595. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21596. */
  21597. constructor(name: string, size: number | {
  21598. width: number;
  21599. height: number;
  21600. layers?: number;
  21601. } | {
  21602. ratio: number;
  21603. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21604. /**
  21605. * Creates a depth stencil texture.
  21606. * This is only available in WebGL 2 or with the depth texture extension available.
  21607. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21608. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21609. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21610. */
  21611. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21612. private _processSizeParameter;
  21613. /**
  21614. * Define the number of samples to use in case of MSAA.
  21615. * It defaults to one meaning no MSAA has been enabled.
  21616. */
  21617. get samples(): number;
  21618. set samples(value: number);
  21619. /**
  21620. * Resets the refresh counter of the texture and start bak from scratch.
  21621. * Could be useful to regenerate the texture if it is setup to render only once.
  21622. */
  21623. resetRefreshCounter(): void;
  21624. /**
  21625. * Define the refresh rate of the texture or the rendering frequency.
  21626. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21627. */
  21628. get refreshRate(): number;
  21629. set refreshRate(value: number);
  21630. /**
  21631. * Adds a post process to the render target rendering passes.
  21632. * @param postProcess define the post process to add
  21633. */
  21634. addPostProcess(postProcess: PostProcess): void;
  21635. /**
  21636. * Clear all the post processes attached to the render target
  21637. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21638. */
  21639. clearPostProcesses(dispose?: boolean): void;
  21640. /**
  21641. * Remove one of the post process from the list of attached post processes to the texture
  21642. * @param postProcess define the post process to remove from the list
  21643. */
  21644. removePostProcess(postProcess: PostProcess): void;
  21645. /** @hidden */
  21646. _shouldRender(): boolean;
  21647. /**
  21648. * Gets the actual render size of the texture.
  21649. * @returns the width of the render size
  21650. */
  21651. getRenderSize(): number;
  21652. /**
  21653. * Gets the actual render width of the texture.
  21654. * @returns the width of the render size
  21655. */
  21656. getRenderWidth(): number;
  21657. /**
  21658. * Gets the actual render height of the texture.
  21659. * @returns the height of the render size
  21660. */
  21661. getRenderHeight(): number;
  21662. /**
  21663. * Gets the actual number of layers of the texture.
  21664. * @returns the number of layers
  21665. */
  21666. getRenderLayers(): number;
  21667. /**
  21668. * Get if the texture can be rescaled or not.
  21669. */
  21670. get canRescale(): boolean;
  21671. /**
  21672. * Resize the texture using a ratio.
  21673. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21674. */
  21675. scale(ratio: number): void;
  21676. /**
  21677. * Get the texture reflection matrix used to rotate/transform the reflection.
  21678. * @returns the reflection matrix
  21679. */
  21680. getReflectionTextureMatrix(): Matrix;
  21681. /**
  21682. * Resize the texture to a new desired size.
  21683. * Be carrefull as it will recreate all the data in the new texture.
  21684. * @param size Define the new size. It can be:
  21685. * - a number for squared texture,
  21686. * - an object containing { width: number, height: number }
  21687. * - or an object containing a ratio { ratio: number }
  21688. */
  21689. resize(size: number | {
  21690. width: number;
  21691. height: number;
  21692. } | {
  21693. ratio: number;
  21694. }): void;
  21695. private _defaultRenderListPrepared;
  21696. /**
  21697. * Renders all the objects from the render list into the texture.
  21698. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21699. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21700. */
  21701. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21702. private _bestReflectionRenderTargetDimension;
  21703. private _prepareRenderingManager;
  21704. /**
  21705. * @hidden
  21706. * @param faceIndex face index to bind to if this is a cubetexture
  21707. * @param layer defines the index of the texture to bind in the array
  21708. */
  21709. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21710. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21711. private renderToTarget;
  21712. /**
  21713. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21714. * This allowed control for front to back rendering or reversly depending of the special needs.
  21715. *
  21716. * @param renderingGroupId The rendering group id corresponding to its index
  21717. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21718. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21719. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21720. */
  21721. 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;
  21722. /**
  21723. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21724. *
  21725. * @param renderingGroupId The rendering group id corresponding to its index
  21726. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21727. */
  21728. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21729. /**
  21730. * Clones the texture.
  21731. * @returns the cloned texture
  21732. */
  21733. clone(): RenderTargetTexture;
  21734. /**
  21735. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21736. * @returns The JSON representation of the texture
  21737. */
  21738. serialize(): any;
  21739. /**
  21740. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21741. */
  21742. disposeFramebufferObjects(): void;
  21743. /**
  21744. * Dispose the texture and release its associated resources.
  21745. */
  21746. dispose(): void;
  21747. /** @hidden */
  21748. _rebuild(): void;
  21749. /**
  21750. * Clear the info related to rendering groups preventing retention point in material dispose.
  21751. */
  21752. freeRenderingGroups(): void;
  21753. /**
  21754. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21755. * @returns the view count
  21756. */
  21757. getViewCount(): number;
  21758. }
  21759. }
  21760. declare module "babylonjs/Misc/guid" {
  21761. /**
  21762. * Class used to manipulate GUIDs
  21763. */
  21764. export class GUID {
  21765. /**
  21766. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21767. * Be aware Math.random() could cause collisions, but:
  21768. * "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"
  21769. * @returns a pseudo random id
  21770. */
  21771. static RandomId(): string;
  21772. }
  21773. }
  21774. declare module "babylonjs/Materials/shadowDepthWrapper" {
  21775. import { Nullable } from "babylonjs/types";
  21776. import { Scene } from "babylonjs/scene";
  21777. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21778. import { Material } from "babylonjs/Materials/material";
  21779. import { Effect } from "babylonjs/Materials/effect";
  21780. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  21781. /**
  21782. * Options to be used when creating a shadow depth material
  21783. */
  21784. export interface IIOptionShadowDepthMaterial {
  21785. /** Variables in the vertex shader code that need to have their names remapped.
  21786. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21787. * "var_name" should be either: worldPos or vNormalW
  21788. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21789. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21790. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21791. */
  21792. remappedVariables?: string[];
  21793. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21794. standalone?: boolean;
  21795. }
  21796. /**
  21797. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21798. */
  21799. export class ShadowDepthWrapper {
  21800. private _scene;
  21801. private _options?;
  21802. private _baseMaterial;
  21803. private _onEffectCreatedObserver;
  21804. private _subMeshToEffect;
  21805. private _subMeshToDepthEffect;
  21806. private _meshes;
  21807. /** @hidden */
  21808. _matriceNames: any;
  21809. /** Gets the standalone status of the wrapper */
  21810. get standalone(): boolean;
  21811. /** Gets the base material the wrapper is built upon */
  21812. get baseMaterial(): Material;
  21813. /**
  21814. * Instantiate a new shadow depth wrapper.
  21815. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21816. * generate the shadow depth map. For more information, please refer to the documentation:
  21817. * https://doc.babylonjs.com/babylon101/shadows
  21818. * @param baseMaterial Material to wrap
  21819. * @param scene Define the scene the material belongs to
  21820. * @param options Options used to create the wrapper
  21821. */
  21822. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21823. /**
  21824. * Gets the effect to use to generate the depth map
  21825. * @param subMesh subMesh to get the effect for
  21826. * @param shadowGenerator shadow generator to get the effect for
  21827. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21828. */
  21829. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21830. /**
  21831. * Specifies that the submesh is ready to be used for depth rendering
  21832. * @param subMesh submesh to check
  21833. * @param defines the list of defines to take into account when checking the effect
  21834. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21835. * @param useInstances specifies that instances should be used
  21836. * @returns a boolean indicating that the submesh is ready or not
  21837. */
  21838. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21839. /**
  21840. * Disposes the resources
  21841. */
  21842. dispose(): void;
  21843. private _makeEffect;
  21844. }
  21845. }
  21846. declare module "babylonjs/Materials/material" {
  21847. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21848. import { SmartArray } from "babylonjs/Misc/smartArray";
  21849. import { Observable } from "babylonjs/Misc/observable";
  21850. import { Nullable } from "babylonjs/types";
  21851. import { Scene } from "babylonjs/scene";
  21852. import { Matrix } from "babylonjs/Maths/math.vector";
  21853. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21855. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21856. import { Effect } from "babylonjs/Materials/effect";
  21857. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21859. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21860. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21861. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  21862. import { Mesh } from "babylonjs/Meshes/mesh";
  21863. import { Animation } from "babylonjs/Animations/animation";
  21864. /**
  21865. * Options for compiling materials.
  21866. */
  21867. export interface IMaterialCompilationOptions {
  21868. /**
  21869. * Defines whether clip planes are enabled.
  21870. */
  21871. clipPlane: boolean;
  21872. /**
  21873. * Defines whether instances are enabled.
  21874. */
  21875. useInstances: boolean;
  21876. }
  21877. /**
  21878. * Base class for the main features of a material in Babylon.js
  21879. */
  21880. export class Material implements IAnimatable {
  21881. /**
  21882. * Returns the triangle fill mode
  21883. */
  21884. static readonly TriangleFillMode: number;
  21885. /**
  21886. * Returns the wireframe mode
  21887. */
  21888. static readonly WireFrameFillMode: number;
  21889. /**
  21890. * Returns the point fill mode
  21891. */
  21892. static readonly PointFillMode: number;
  21893. /**
  21894. * Returns the point list draw mode
  21895. */
  21896. static readonly PointListDrawMode: number;
  21897. /**
  21898. * Returns the line list draw mode
  21899. */
  21900. static readonly LineListDrawMode: number;
  21901. /**
  21902. * Returns the line loop draw mode
  21903. */
  21904. static readonly LineLoopDrawMode: number;
  21905. /**
  21906. * Returns the line strip draw mode
  21907. */
  21908. static readonly LineStripDrawMode: number;
  21909. /**
  21910. * Returns the triangle strip draw mode
  21911. */
  21912. static readonly TriangleStripDrawMode: number;
  21913. /**
  21914. * Returns the triangle fan draw mode
  21915. */
  21916. static readonly TriangleFanDrawMode: number;
  21917. /**
  21918. * Stores the clock-wise side orientation
  21919. */
  21920. static readonly ClockWiseSideOrientation: number;
  21921. /**
  21922. * Stores the counter clock-wise side orientation
  21923. */
  21924. static readonly CounterClockWiseSideOrientation: number;
  21925. /**
  21926. * The dirty texture flag value
  21927. */
  21928. static readonly TextureDirtyFlag: number;
  21929. /**
  21930. * The dirty light flag value
  21931. */
  21932. static readonly LightDirtyFlag: number;
  21933. /**
  21934. * The dirty fresnel flag value
  21935. */
  21936. static readonly FresnelDirtyFlag: number;
  21937. /**
  21938. * The dirty attribute flag value
  21939. */
  21940. static readonly AttributesDirtyFlag: number;
  21941. /**
  21942. * The dirty misc flag value
  21943. */
  21944. static readonly MiscDirtyFlag: number;
  21945. /**
  21946. * The all dirty flag value
  21947. */
  21948. static readonly AllDirtyFlag: number;
  21949. /**
  21950. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21951. */
  21952. static readonly MATERIAL_OPAQUE: number;
  21953. /**
  21954. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21955. */
  21956. static readonly MATERIAL_ALPHATEST: number;
  21957. /**
  21958. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21959. */
  21960. static readonly MATERIAL_ALPHABLEND: number;
  21961. /**
  21962. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21963. * They are also discarded below the alpha cutoff threshold to improve performances.
  21964. */
  21965. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21966. /**
  21967. * Custom callback helping to override the default shader used in the material.
  21968. */
  21969. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21970. /**
  21971. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21972. */
  21973. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21974. /**
  21975. * The ID of the material
  21976. */
  21977. id: string;
  21978. /**
  21979. * Gets or sets the unique id of the material
  21980. */
  21981. uniqueId: number;
  21982. /**
  21983. * The name of the material
  21984. */
  21985. name: string;
  21986. /**
  21987. * Gets or sets user defined metadata
  21988. */
  21989. metadata: any;
  21990. /**
  21991. * For internal use only. Please do not use.
  21992. */
  21993. reservedDataStore: any;
  21994. /**
  21995. * Specifies if the ready state should be checked on each call
  21996. */
  21997. checkReadyOnEveryCall: boolean;
  21998. /**
  21999. * Specifies if the ready state should be checked once
  22000. */
  22001. checkReadyOnlyOnce: boolean;
  22002. /**
  22003. * The state of the material
  22004. */
  22005. state: string;
  22006. /**
  22007. * The alpha value of the material
  22008. */
  22009. protected _alpha: number;
  22010. /**
  22011. * List of inspectable custom properties (used by the Inspector)
  22012. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22013. */
  22014. inspectableCustomProperties: IInspectable[];
  22015. /**
  22016. * Sets the alpha value of the material
  22017. */
  22018. set alpha(value: number);
  22019. /**
  22020. * Gets the alpha value of the material
  22021. */
  22022. get alpha(): number;
  22023. /**
  22024. * Specifies if back face culling is enabled
  22025. */
  22026. protected _backFaceCulling: boolean;
  22027. /**
  22028. * Sets the back-face culling state
  22029. */
  22030. set backFaceCulling(value: boolean);
  22031. /**
  22032. * Gets the back-face culling state
  22033. */
  22034. get backFaceCulling(): boolean;
  22035. /**
  22036. * Stores the value for side orientation
  22037. */
  22038. sideOrientation: number;
  22039. /**
  22040. * Callback triggered when the material is compiled
  22041. */
  22042. onCompiled: Nullable<(effect: Effect) => void>;
  22043. /**
  22044. * Callback triggered when an error occurs
  22045. */
  22046. onError: Nullable<(effect: Effect, errors: string) => void>;
  22047. /**
  22048. * Callback triggered to get the render target textures
  22049. */
  22050. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22051. /**
  22052. * Gets a boolean indicating that current material needs to register RTT
  22053. */
  22054. get hasRenderTargetTextures(): boolean;
  22055. /**
  22056. * Specifies if the material should be serialized
  22057. */
  22058. doNotSerialize: boolean;
  22059. /**
  22060. * @hidden
  22061. */
  22062. _storeEffectOnSubMeshes: boolean;
  22063. /**
  22064. * Stores the animations for the material
  22065. */
  22066. animations: Nullable<Array<Animation>>;
  22067. /**
  22068. * An event triggered when the material is disposed
  22069. */
  22070. onDisposeObservable: Observable<Material>;
  22071. /**
  22072. * An observer which watches for dispose events
  22073. */
  22074. private _onDisposeObserver;
  22075. private _onUnBindObservable;
  22076. /**
  22077. * Called during a dispose event
  22078. */
  22079. set onDispose(callback: () => void);
  22080. private _onBindObservable;
  22081. /**
  22082. * An event triggered when the material is bound
  22083. */
  22084. get onBindObservable(): Observable<AbstractMesh>;
  22085. /**
  22086. * An observer which watches for bind events
  22087. */
  22088. private _onBindObserver;
  22089. /**
  22090. * Called during a bind event
  22091. */
  22092. set onBind(callback: (Mesh: AbstractMesh) => void);
  22093. /**
  22094. * An event triggered when the material is unbound
  22095. */
  22096. get onUnBindObservable(): Observable<Material>;
  22097. protected _onEffectCreatedObservable: Nullable<Observable<{
  22098. effect: Effect;
  22099. subMesh: Nullable<SubMesh>;
  22100. }>>;
  22101. /**
  22102. * An event triggered when the effect is (re)created
  22103. */
  22104. get onEffectCreatedObservable(): Observable<{
  22105. effect: Effect;
  22106. subMesh: Nullable<SubMesh>;
  22107. }>;
  22108. /**
  22109. * Stores the value of the alpha mode
  22110. */
  22111. private _alphaMode;
  22112. /**
  22113. * Sets the value of the alpha mode.
  22114. *
  22115. * | Value | Type | Description |
  22116. * | --- | --- | --- |
  22117. * | 0 | ALPHA_DISABLE | |
  22118. * | 1 | ALPHA_ADD | |
  22119. * | 2 | ALPHA_COMBINE | |
  22120. * | 3 | ALPHA_SUBTRACT | |
  22121. * | 4 | ALPHA_MULTIPLY | |
  22122. * | 5 | ALPHA_MAXIMIZED | |
  22123. * | 6 | ALPHA_ONEONE | |
  22124. * | 7 | ALPHA_PREMULTIPLIED | |
  22125. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22126. * | 9 | ALPHA_INTERPOLATE | |
  22127. * | 10 | ALPHA_SCREENMODE | |
  22128. *
  22129. */
  22130. set alphaMode(value: number);
  22131. /**
  22132. * Gets the value of the alpha mode
  22133. */
  22134. get alphaMode(): number;
  22135. /**
  22136. * Stores the state of the need depth pre-pass value
  22137. */
  22138. private _needDepthPrePass;
  22139. /**
  22140. * Sets the need depth pre-pass value
  22141. */
  22142. set needDepthPrePass(value: boolean);
  22143. /**
  22144. * Gets the depth pre-pass value
  22145. */
  22146. get needDepthPrePass(): boolean;
  22147. /**
  22148. * Specifies if depth writing should be disabled
  22149. */
  22150. disableDepthWrite: boolean;
  22151. /**
  22152. * Specifies if color writing should be disabled
  22153. */
  22154. disableColorWrite: boolean;
  22155. /**
  22156. * Specifies if depth writing should be forced
  22157. */
  22158. forceDepthWrite: boolean;
  22159. /**
  22160. * Specifies the depth function that should be used. 0 means the default engine function
  22161. */
  22162. depthFunction: number;
  22163. /**
  22164. * Specifies if there should be a separate pass for culling
  22165. */
  22166. separateCullingPass: boolean;
  22167. /**
  22168. * Stores the state specifing if fog should be enabled
  22169. */
  22170. private _fogEnabled;
  22171. /**
  22172. * Sets the state for enabling fog
  22173. */
  22174. set fogEnabled(value: boolean);
  22175. /**
  22176. * Gets the value of the fog enabled state
  22177. */
  22178. get fogEnabled(): boolean;
  22179. /**
  22180. * Stores the size of points
  22181. */
  22182. pointSize: number;
  22183. /**
  22184. * Stores the z offset value
  22185. */
  22186. zOffset: number;
  22187. get wireframe(): boolean;
  22188. /**
  22189. * Sets the state of wireframe mode
  22190. */
  22191. set wireframe(value: boolean);
  22192. /**
  22193. * Gets the value specifying if point clouds are enabled
  22194. */
  22195. get pointsCloud(): boolean;
  22196. /**
  22197. * Sets the state of point cloud mode
  22198. */
  22199. set pointsCloud(value: boolean);
  22200. /**
  22201. * Gets the material fill mode
  22202. */
  22203. get fillMode(): number;
  22204. /**
  22205. * Sets the material fill mode
  22206. */
  22207. set fillMode(value: number);
  22208. /**
  22209. * @hidden
  22210. * Stores the effects for the material
  22211. */
  22212. _effect: Nullable<Effect>;
  22213. /**
  22214. * Specifies if uniform buffers should be used
  22215. */
  22216. private _useUBO;
  22217. /**
  22218. * Stores a reference to the scene
  22219. */
  22220. private _scene;
  22221. /**
  22222. * Stores the fill mode state
  22223. */
  22224. private _fillMode;
  22225. /**
  22226. * Specifies if the depth write state should be cached
  22227. */
  22228. private _cachedDepthWriteState;
  22229. /**
  22230. * Specifies if the color write state should be cached
  22231. */
  22232. private _cachedColorWriteState;
  22233. /**
  22234. * Specifies if the depth function state should be cached
  22235. */
  22236. private _cachedDepthFunctionState;
  22237. /**
  22238. * Stores the uniform buffer
  22239. */
  22240. protected _uniformBuffer: UniformBuffer;
  22241. /** @hidden */
  22242. _indexInSceneMaterialArray: number;
  22243. /** @hidden */
  22244. meshMap: Nullable<{
  22245. [id: string]: AbstractMesh | undefined;
  22246. }>;
  22247. /**
  22248. * Creates a material instance
  22249. * @param name defines the name of the material
  22250. * @param scene defines the scene to reference
  22251. * @param doNotAdd specifies if the material should be added to the scene
  22252. */
  22253. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22254. /**
  22255. * Returns a string representation of the current material
  22256. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22257. * @returns a string with material information
  22258. */
  22259. toString(fullDetails?: boolean): string;
  22260. /**
  22261. * Gets the class name of the material
  22262. * @returns a string with the class name of the material
  22263. */
  22264. getClassName(): string;
  22265. /**
  22266. * Specifies if updates for the material been locked
  22267. */
  22268. get isFrozen(): boolean;
  22269. /**
  22270. * Locks updates for the material
  22271. */
  22272. freeze(): void;
  22273. /**
  22274. * Unlocks updates for the material
  22275. */
  22276. unfreeze(): void;
  22277. /**
  22278. * Specifies if the material is ready to be used
  22279. * @param mesh defines the mesh to check
  22280. * @param useInstances specifies if instances should be used
  22281. * @returns a boolean indicating if the material is ready to be used
  22282. */
  22283. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22284. /**
  22285. * Specifies that the submesh is ready to be used
  22286. * @param mesh defines the mesh to check
  22287. * @param subMesh defines which submesh to check
  22288. * @param useInstances specifies that instances should be used
  22289. * @returns a boolean indicating that the submesh is ready or not
  22290. */
  22291. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22292. /**
  22293. * Returns the material effect
  22294. * @returns the effect associated with the material
  22295. */
  22296. getEffect(): Nullable<Effect>;
  22297. /**
  22298. * Returns the current scene
  22299. * @returns a Scene
  22300. */
  22301. getScene(): Scene;
  22302. /**
  22303. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22304. */
  22305. protected _forceAlphaTest: boolean;
  22306. /**
  22307. * The transparency mode of the material.
  22308. */
  22309. protected _transparencyMode: Nullable<number>;
  22310. /**
  22311. * Gets the current transparency mode.
  22312. */
  22313. get transparencyMode(): Nullable<number>;
  22314. /**
  22315. * Sets the transparency mode of the material.
  22316. *
  22317. * | Value | Type | Description |
  22318. * | ----- | ----------------------------------- | ----------- |
  22319. * | 0 | OPAQUE | |
  22320. * | 1 | ALPHATEST | |
  22321. * | 2 | ALPHABLEND | |
  22322. * | 3 | ALPHATESTANDBLEND | |
  22323. *
  22324. */
  22325. set transparencyMode(value: Nullable<number>);
  22326. /**
  22327. * Returns true if alpha blending should be disabled.
  22328. */
  22329. protected get _disableAlphaBlending(): boolean;
  22330. /**
  22331. * Specifies whether or not this material should be rendered in alpha blend mode.
  22332. * @returns a boolean specifying if alpha blending is needed
  22333. */
  22334. needAlphaBlending(): boolean;
  22335. /**
  22336. * Specifies if the mesh will require alpha blending
  22337. * @param mesh defines the mesh to check
  22338. * @returns a boolean specifying if alpha blending is needed for the mesh
  22339. */
  22340. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22341. /**
  22342. * Specifies whether or not this material should be rendered in alpha test mode.
  22343. * @returns a boolean specifying if an alpha test is needed.
  22344. */
  22345. needAlphaTesting(): boolean;
  22346. /**
  22347. * Specifies if material alpha testing should be turned on for the mesh
  22348. * @param mesh defines the mesh to check
  22349. */
  22350. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22351. /**
  22352. * Gets the texture used for the alpha test
  22353. * @returns the texture to use for alpha testing
  22354. */
  22355. getAlphaTestTexture(): Nullable<BaseTexture>;
  22356. /**
  22357. * Marks the material to indicate that it needs to be re-calculated
  22358. */
  22359. markDirty(): void;
  22360. /** @hidden */
  22361. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22362. /**
  22363. * Binds the material to the mesh
  22364. * @param world defines the world transformation matrix
  22365. * @param mesh defines the mesh to bind the material to
  22366. */
  22367. bind(world: Matrix, mesh?: Mesh): void;
  22368. /**
  22369. * Binds the submesh to the material
  22370. * @param world defines the world transformation matrix
  22371. * @param mesh defines the mesh containing the submesh
  22372. * @param subMesh defines the submesh to bind the material to
  22373. */
  22374. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22375. /**
  22376. * Binds the world matrix to the material
  22377. * @param world defines the world transformation matrix
  22378. */
  22379. bindOnlyWorldMatrix(world: Matrix): void;
  22380. /**
  22381. * Binds the scene's uniform buffer to the effect.
  22382. * @param effect defines the effect to bind to the scene uniform buffer
  22383. * @param sceneUbo defines the uniform buffer storing scene data
  22384. */
  22385. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22386. /**
  22387. * Binds the view matrix to the effect
  22388. * @param effect defines the effect to bind the view matrix to
  22389. */
  22390. bindView(effect: Effect): void;
  22391. /**
  22392. * Binds the view projection matrix to the effect
  22393. * @param effect defines the effect to bind the view projection matrix to
  22394. */
  22395. bindViewProjection(effect: Effect): void;
  22396. /**
  22397. * Processes to execute after binding the material to a mesh
  22398. * @param mesh defines the rendered mesh
  22399. */
  22400. protected _afterBind(mesh?: Mesh): void;
  22401. /**
  22402. * Unbinds the material from the mesh
  22403. */
  22404. unbind(): void;
  22405. /**
  22406. * Gets the active textures from the material
  22407. * @returns an array of textures
  22408. */
  22409. getActiveTextures(): BaseTexture[];
  22410. /**
  22411. * Specifies if the material uses a texture
  22412. * @param texture defines the texture to check against the material
  22413. * @returns a boolean specifying if the material uses the texture
  22414. */
  22415. hasTexture(texture: BaseTexture): boolean;
  22416. /**
  22417. * Makes a duplicate of the material, and gives it a new name
  22418. * @param name defines the new name for the duplicated material
  22419. * @returns the cloned material
  22420. */
  22421. clone(name: string): Nullable<Material>;
  22422. /**
  22423. * Gets the meshes bound to the material
  22424. * @returns an array of meshes bound to the material
  22425. */
  22426. getBindedMeshes(): AbstractMesh[];
  22427. /**
  22428. * Force shader compilation
  22429. * @param mesh defines the mesh associated with this material
  22430. * @param onCompiled defines a function to execute once the material is compiled
  22431. * @param options defines the options to configure the compilation
  22432. * @param onError defines a function to execute if the material fails compiling
  22433. */
  22434. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22435. /**
  22436. * Force shader compilation
  22437. * @param mesh defines the mesh that will use this material
  22438. * @param options defines additional options for compiling the shaders
  22439. * @returns a promise that resolves when the compilation completes
  22440. */
  22441. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22442. private static readonly _AllDirtyCallBack;
  22443. private static readonly _ImageProcessingDirtyCallBack;
  22444. private static readonly _TextureDirtyCallBack;
  22445. private static readonly _FresnelDirtyCallBack;
  22446. private static readonly _MiscDirtyCallBack;
  22447. private static readonly _LightsDirtyCallBack;
  22448. private static readonly _AttributeDirtyCallBack;
  22449. private static _FresnelAndMiscDirtyCallBack;
  22450. private static _TextureAndMiscDirtyCallBack;
  22451. private static readonly _DirtyCallbackArray;
  22452. private static readonly _RunDirtyCallBacks;
  22453. /**
  22454. * Marks a define in the material to indicate that it needs to be re-computed
  22455. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22456. */
  22457. markAsDirty(flag: number): void;
  22458. /**
  22459. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22460. * @param func defines a function which checks material defines against the submeshes
  22461. */
  22462. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22463. /**
  22464. * Indicates that we need to re-calculated for all submeshes
  22465. */
  22466. protected _markAllSubMeshesAsAllDirty(): void;
  22467. /**
  22468. * Indicates that image processing needs to be re-calculated for all submeshes
  22469. */
  22470. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22471. /**
  22472. * Indicates that textures need to be re-calculated for all submeshes
  22473. */
  22474. protected _markAllSubMeshesAsTexturesDirty(): void;
  22475. /**
  22476. * Indicates that fresnel needs to be re-calculated for all submeshes
  22477. */
  22478. protected _markAllSubMeshesAsFresnelDirty(): void;
  22479. /**
  22480. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22481. */
  22482. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22483. /**
  22484. * Indicates that lights need to be re-calculated for all submeshes
  22485. */
  22486. protected _markAllSubMeshesAsLightsDirty(): void;
  22487. /**
  22488. * Indicates that attributes need to be re-calculated for all submeshes
  22489. */
  22490. protected _markAllSubMeshesAsAttributesDirty(): void;
  22491. /**
  22492. * Indicates that misc needs to be re-calculated for all submeshes
  22493. */
  22494. protected _markAllSubMeshesAsMiscDirty(): void;
  22495. /**
  22496. * Indicates that textures and misc need to be re-calculated for all submeshes
  22497. */
  22498. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22499. /**
  22500. * Disposes the material
  22501. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22502. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22503. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22504. */
  22505. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22506. /** @hidden */
  22507. private releaseVertexArrayObject;
  22508. /**
  22509. * Serializes this material
  22510. * @returns the serialized material object
  22511. */
  22512. serialize(): any;
  22513. /**
  22514. * Creates a material from parsed material data
  22515. * @param parsedMaterial defines parsed material data
  22516. * @param scene defines the hosting scene
  22517. * @param rootUrl defines the root URL to use to load textures
  22518. * @returns a new material
  22519. */
  22520. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22521. }
  22522. }
  22523. declare module "babylonjs/Materials/multiMaterial" {
  22524. import { Nullable } from "babylonjs/types";
  22525. import { Scene } from "babylonjs/scene";
  22526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22527. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22529. import { Material } from "babylonjs/Materials/material";
  22530. /**
  22531. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22532. * separate meshes. This can be use to improve performances.
  22533. * @see http://doc.babylonjs.com/how_to/multi_materials
  22534. */
  22535. export class MultiMaterial extends Material {
  22536. private _subMaterials;
  22537. /**
  22538. * Gets or Sets the list of Materials used within the multi material.
  22539. * They need to be ordered according to the submeshes order in the associated mesh
  22540. */
  22541. get subMaterials(): Nullable<Material>[];
  22542. set subMaterials(value: Nullable<Material>[]);
  22543. /**
  22544. * Function used to align with Node.getChildren()
  22545. * @returns the list of Materials used within the multi material
  22546. */
  22547. getChildren(): Nullable<Material>[];
  22548. /**
  22549. * Instantiates a new Multi Material
  22550. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22551. * separate meshes. This can be use to improve performances.
  22552. * @see http://doc.babylonjs.com/how_to/multi_materials
  22553. * @param name Define the name in the scene
  22554. * @param scene Define the scene the material belongs to
  22555. */
  22556. constructor(name: string, scene: Scene);
  22557. private _hookArray;
  22558. /**
  22559. * Get one of the submaterial by its index in the submaterials array
  22560. * @param index The index to look the sub material at
  22561. * @returns The Material if the index has been defined
  22562. */
  22563. getSubMaterial(index: number): Nullable<Material>;
  22564. /**
  22565. * Get the list of active textures for the whole sub materials list.
  22566. * @returns All the textures that will be used during the rendering
  22567. */
  22568. getActiveTextures(): BaseTexture[];
  22569. /**
  22570. * Gets the current class name of the material e.g. "MultiMaterial"
  22571. * Mainly use in serialization.
  22572. * @returns the class name
  22573. */
  22574. getClassName(): string;
  22575. /**
  22576. * Checks if the material is ready to render the requested sub mesh
  22577. * @param mesh Define the mesh the submesh belongs to
  22578. * @param subMesh Define the sub mesh to look readyness for
  22579. * @param useInstances Define whether or not the material is used with instances
  22580. * @returns true if ready, otherwise false
  22581. */
  22582. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22583. /**
  22584. * Clones the current material and its related sub materials
  22585. * @param name Define the name of the newly cloned material
  22586. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22587. * @returns the cloned material
  22588. */
  22589. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22590. /**
  22591. * Serializes the materials into a JSON representation.
  22592. * @returns the JSON representation
  22593. */
  22594. serialize(): any;
  22595. /**
  22596. * Dispose the material and release its associated resources
  22597. * @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)
  22598. * @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)
  22599. * @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)
  22600. */
  22601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22602. /**
  22603. * Creates a MultiMaterial from parsed MultiMaterial data.
  22604. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22605. * @param scene defines the hosting scene
  22606. * @returns a new MultiMaterial
  22607. */
  22608. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22609. }
  22610. }
  22611. declare module "babylonjs/Meshes/subMesh" {
  22612. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22614. import { Engine } from "babylonjs/Engines/engine";
  22615. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22616. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22617. import { Effect } from "babylonjs/Materials/effect";
  22618. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22619. import { Plane } from "babylonjs/Maths/math.plane";
  22620. import { Collider } from "babylonjs/Collisions/collider";
  22621. import { Material } from "babylonjs/Materials/material";
  22622. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22624. import { Mesh } from "babylonjs/Meshes/mesh";
  22625. import { Ray } from "babylonjs/Culling/ray";
  22626. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22627. /**
  22628. * Base class for submeshes
  22629. */
  22630. export class BaseSubMesh {
  22631. /** @hidden */
  22632. _materialDefines: Nullable<MaterialDefines>;
  22633. /** @hidden */
  22634. _materialEffect: Nullable<Effect>;
  22635. /** @hidden */
  22636. _effectOverride: Nullable<Effect>;
  22637. /**
  22638. * Gets material defines used by the effect associated to the sub mesh
  22639. */
  22640. get materialDefines(): Nullable<MaterialDefines>;
  22641. /**
  22642. * Sets material defines used by the effect associated to the sub mesh
  22643. */
  22644. set materialDefines(defines: Nullable<MaterialDefines>);
  22645. /**
  22646. * Gets associated effect
  22647. */
  22648. get effect(): Nullable<Effect>;
  22649. /**
  22650. * Sets associated effect (effect used to render this submesh)
  22651. * @param effect defines the effect to associate with
  22652. * @param defines defines the set of defines used to compile this effect
  22653. */
  22654. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22655. }
  22656. /**
  22657. * Defines a subdivision inside a mesh
  22658. */
  22659. export class SubMesh extends BaseSubMesh implements ICullable {
  22660. /** the material index to use */
  22661. materialIndex: number;
  22662. /** vertex index start */
  22663. verticesStart: number;
  22664. /** vertices count */
  22665. verticesCount: number;
  22666. /** index start */
  22667. indexStart: number;
  22668. /** indices count */
  22669. indexCount: number;
  22670. /** @hidden */
  22671. _linesIndexCount: number;
  22672. private _mesh;
  22673. private _renderingMesh;
  22674. private _boundingInfo;
  22675. private _linesIndexBuffer;
  22676. /** @hidden */
  22677. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22678. /** @hidden */
  22679. _trianglePlanes: Plane[];
  22680. /** @hidden */
  22681. _lastColliderTransformMatrix: Nullable<Matrix>;
  22682. /** @hidden */
  22683. _renderId: number;
  22684. /** @hidden */
  22685. _alphaIndex: number;
  22686. /** @hidden */
  22687. _distanceToCamera: number;
  22688. /** @hidden */
  22689. _id: number;
  22690. private _currentMaterial;
  22691. /**
  22692. * Add a new submesh to a mesh
  22693. * @param materialIndex defines the material index to use
  22694. * @param verticesStart defines vertex index start
  22695. * @param verticesCount defines vertices count
  22696. * @param indexStart defines index start
  22697. * @param indexCount defines indices count
  22698. * @param mesh defines the parent mesh
  22699. * @param renderingMesh defines an optional rendering mesh
  22700. * @param createBoundingBox defines if bounding box should be created for this submesh
  22701. * @returns the new submesh
  22702. */
  22703. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22704. /**
  22705. * Creates a new submesh
  22706. * @param materialIndex defines the material index to use
  22707. * @param verticesStart defines vertex index start
  22708. * @param verticesCount defines vertices count
  22709. * @param indexStart defines index start
  22710. * @param indexCount defines indices count
  22711. * @param mesh defines the parent mesh
  22712. * @param renderingMesh defines an optional rendering mesh
  22713. * @param createBoundingBox defines if bounding box should be created for this submesh
  22714. */
  22715. constructor(
  22716. /** the material index to use */
  22717. materialIndex: number,
  22718. /** vertex index start */
  22719. verticesStart: number,
  22720. /** vertices count */
  22721. verticesCount: number,
  22722. /** index start */
  22723. indexStart: number,
  22724. /** indices count */
  22725. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22726. /**
  22727. * Returns true if this submesh covers the entire parent mesh
  22728. * @ignorenaming
  22729. */
  22730. get IsGlobal(): boolean;
  22731. /**
  22732. * Returns the submesh BoudingInfo object
  22733. * @returns current bounding info (or mesh's one if the submesh is global)
  22734. */
  22735. getBoundingInfo(): BoundingInfo;
  22736. /**
  22737. * Sets the submesh BoundingInfo
  22738. * @param boundingInfo defines the new bounding info to use
  22739. * @returns the SubMesh
  22740. */
  22741. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22742. /**
  22743. * Returns the mesh of the current submesh
  22744. * @return the parent mesh
  22745. */
  22746. getMesh(): AbstractMesh;
  22747. /**
  22748. * Returns the rendering mesh of the submesh
  22749. * @returns the rendering mesh (could be different from parent mesh)
  22750. */
  22751. getRenderingMesh(): Mesh;
  22752. /**
  22753. * Returns the submesh material
  22754. * @returns null or the current material
  22755. */
  22756. getMaterial(): Nullable<Material>;
  22757. /**
  22758. * Sets a new updated BoundingInfo object to the submesh
  22759. * @param data defines an optional position array to use to determine the bounding info
  22760. * @returns the SubMesh
  22761. */
  22762. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22763. /** @hidden */
  22764. _checkCollision(collider: Collider): boolean;
  22765. /**
  22766. * Updates the submesh BoundingInfo
  22767. * @param world defines the world matrix to use to update the bounding info
  22768. * @returns the submesh
  22769. */
  22770. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22771. /**
  22772. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22773. * @param frustumPlanes defines the frustum planes
  22774. * @returns true if the submesh is intersecting with the frustum
  22775. */
  22776. isInFrustum(frustumPlanes: Plane[]): boolean;
  22777. /**
  22778. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22779. * @param frustumPlanes defines the frustum planes
  22780. * @returns true if the submesh is inside the frustum
  22781. */
  22782. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22783. /**
  22784. * Renders the submesh
  22785. * @param enableAlphaMode defines if alpha needs to be used
  22786. * @returns the submesh
  22787. */
  22788. render(enableAlphaMode: boolean): SubMesh;
  22789. /**
  22790. * @hidden
  22791. */
  22792. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22793. /**
  22794. * Checks if the submesh intersects with a ray
  22795. * @param ray defines the ray to test
  22796. * @returns true is the passed ray intersects the submesh bounding box
  22797. */
  22798. canIntersects(ray: Ray): boolean;
  22799. /**
  22800. * Intersects current submesh with a ray
  22801. * @param ray defines the ray to test
  22802. * @param positions defines mesh's positions array
  22803. * @param indices defines mesh's indices array
  22804. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22805. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22806. * @returns intersection info or null if no intersection
  22807. */
  22808. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22809. /** @hidden */
  22810. private _intersectLines;
  22811. /** @hidden */
  22812. private _intersectUnIndexedLines;
  22813. /** @hidden */
  22814. private _intersectTriangles;
  22815. /** @hidden */
  22816. private _intersectUnIndexedTriangles;
  22817. /** @hidden */
  22818. _rebuild(): void;
  22819. /**
  22820. * Creates a new submesh from the passed mesh
  22821. * @param newMesh defines the new hosting mesh
  22822. * @param newRenderingMesh defines an optional rendering mesh
  22823. * @returns the new submesh
  22824. */
  22825. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22826. /**
  22827. * Release associated resources
  22828. */
  22829. dispose(): void;
  22830. /**
  22831. * Gets the class name
  22832. * @returns the string "SubMesh".
  22833. */
  22834. getClassName(): string;
  22835. /**
  22836. * Creates a new submesh from indices data
  22837. * @param materialIndex the index of the main mesh material
  22838. * @param startIndex the index where to start the copy in the mesh indices array
  22839. * @param indexCount the number of indices to copy then from the startIndex
  22840. * @param mesh the main mesh to create the submesh from
  22841. * @param renderingMesh the optional rendering mesh
  22842. * @returns a new submesh
  22843. */
  22844. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22845. }
  22846. }
  22847. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22848. /**
  22849. * Class used to represent data loading progression
  22850. */
  22851. export class SceneLoaderFlags {
  22852. private static _ForceFullSceneLoadingForIncremental;
  22853. private static _ShowLoadingScreen;
  22854. private static _CleanBoneMatrixWeights;
  22855. private static _loggingLevel;
  22856. /**
  22857. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22858. */
  22859. static get ForceFullSceneLoadingForIncremental(): boolean;
  22860. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22861. /**
  22862. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22863. */
  22864. static get ShowLoadingScreen(): boolean;
  22865. static set ShowLoadingScreen(value: boolean);
  22866. /**
  22867. * Defines the current logging level (while loading the scene)
  22868. * @ignorenaming
  22869. */
  22870. static get loggingLevel(): number;
  22871. static set loggingLevel(value: number);
  22872. /**
  22873. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22874. */
  22875. static get CleanBoneMatrixWeights(): boolean;
  22876. static set CleanBoneMatrixWeights(value: boolean);
  22877. }
  22878. }
  22879. declare module "babylonjs/Meshes/geometry" {
  22880. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22881. import { Scene } from "babylonjs/scene";
  22882. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22883. import { Engine } from "babylonjs/Engines/engine";
  22884. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22885. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22886. import { Effect } from "babylonjs/Materials/effect";
  22887. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22888. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22889. import { Mesh } from "babylonjs/Meshes/mesh";
  22890. /**
  22891. * Class used to store geometry data (vertex buffers + index buffer)
  22892. */
  22893. export class Geometry implements IGetSetVerticesData {
  22894. /**
  22895. * Gets or sets the ID of the geometry
  22896. */
  22897. id: string;
  22898. /**
  22899. * Gets or sets the unique ID of the geometry
  22900. */
  22901. uniqueId: number;
  22902. /**
  22903. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22904. */
  22905. delayLoadState: number;
  22906. /**
  22907. * Gets the file containing the data to load when running in delay load state
  22908. */
  22909. delayLoadingFile: Nullable<string>;
  22910. /**
  22911. * Callback called when the geometry is updated
  22912. */
  22913. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22914. private _scene;
  22915. private _engine;
  22916. private _meshes;
  22917. private _totalVertices;
  22918. /** @hidden */
  22919. _indices: IndicesArray;
  22920. /** @hidden */
  22921. _vertexBuffers: {
  22922. [key: string]: VertexBuffer;
  22923. };
  22924. private _isDisposed;
  22925. private _extend;
  22926. private _boundingBias;
  22927. /** @hidden */
  22928. _delayInfo: Array<string>;
  22929. private _indexBuffer;
  22930. private _indexBufferIsUpdatable;
  22931. /** @hidden */
  22932. _boundingInfo: Nullable<BoundingInfo>;
  22933. /** @hidden */
  22934. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22935. /** @hidden */
  22936. _softwareSkinningFrameId: number;
  22937. private _vertexArrayObjects;
  22938. private _updatable;
  22939. /** @hidden */
  22940. _positions: Nullable<Vector3[]>;
  22941. /**
  22942. * 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
  22943. */
  22944. get boundingBias(): Vector2;
  22945. /**
  22946. * 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
  22947. */
  22948. set boundingBias(value: Vector2);
  22949. /**
  22950. * Static function used to attach a new empty geometry to a mesh
  22951. * @param mesh defines the mesh to attach the geometry to
  22952. * @returns the new Geometry
  22953. */
  22954. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22955. /** Get the list of meshes using this geometry */
  22956. get meshes(): Mesh[];
  22957. /**
  22958. * Creates a new geometry
  22959. * @param id defines the unique ID
  22960. * @param scene defines the hosting scene
  22961. * @param vertexData defines the VertexData used to get geometry data
  22962. * @param updatable defines if geometry must be updatable (false by default)
  22963. * @param mesh defines the mesh that will be associated with the geometry
  22964. */
  22965. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22966. /**
  22967. * Gets the current extend of the geometry
  22968. */
  22969. get extend(): {
  22970. minimum: Vector3;
  22971. maximum: Vector3;
  22972. };
  22973. /**
  22974. * Gets the hosting scene
  22975. * @returns the hosting Scene
  22976. */
  22977. getScene(): Scene;
  22978. /**
  22979. * Gets the hosting engine
  22980. * @returns the hosting Engine
  22981. */
  22982. getEngine(): Engine;
  22983. /**
  22984. * Defines if the geometry is ready to use
  22985. * @returns true if the geometry is ready to be used
  22986. */
  22987. isReady(): boolean;
  22988. /**
  22989. * Gets a value indicating that the geometry should not be serialized
  22990. */
  22991. get doNotSerialize(): boolean;
  22992. /** @hidden */
  22993. _rebuild(): void;
  22994. /**
  22995. * Affects all geometry data in one call
  22996. * @param vertexData defines the geometry data
  22997. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22998. */
  22999. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23000. /**
  23001. * Set specific vertex data
  23002. * @param kind defines the data kind (Position, normal, etc...)
  23003. * @param data defines the vertex data to use
  23004. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23005. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23006. */
  23007. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23008. /**
  23009. * Removes a specific vertex data
  23010. * @param kind defines the data kind (Position, normal, etc...)
  23011. */
  23012. removeVerticesData(kind: string): void;
  23013. /**
  23014. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23015. * @param buffer defines the vertex buffer to use
  23016. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23017. */
  23018. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23019. /**
  23020. * Update a specific vertex buffer
  23021. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23022. * It will do nothing if the buffer is not updatable
  23023. * @param kind defines the data kind (Position, normal, etc...)
  23024. * @param data defines the data to use
  23025. * @param offset defines the offset in the target buffer where to store the data
  23026. * @param useBytes set to true if the offset is in bytes
  23027. */
  23028. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23029. /**
  23030. * Update a specific vertex buffer
  23031. * This function will create a new buffer if the current one is not updatable
  23032. * @param kind defines the data kind (Position, normal, etc...)
  23033. * @param data defines the data to use
  23034. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23035. */
  23036. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23037. private _updateBoundingInfo;
  23038. /** @hidden */
  23039. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23040. /**
  23041. * Gets total number of vertices
  23042. * @returns the total number of vertices
  23043. */
  23044. getTotalVertices(): number;
  23045. /**
  23046. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23047. * @param kind defines the data kind (Position, normal, etc...)
  23048. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23049. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23050. * @returns a float array containing vertex data
  23051. */
  23052. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23053. /**
  23054. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23055. * @param kind defines the data kind (Position, normal, etc...)
  23056. * @returns true if the vertex buffer with the specified kind is updatable
  23057. */
  23058. isVertexBufferUpdatable(kind: string): boolean;
  23059. /**
  23060. * Gets a specific vertex buffer
  23061. * @param kind defines the data kind (Position, normal, etc...)
  23062. * @returns a VertexBuffer
  23063. */
  23064. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23065. /**
  23066. * Returns all vertex buffers
  23067. * @return an object holding all vertex buffers indexed by kind
  23068. */
  23069. getVertexBuffers(): Nullable<{
  23070. [key: string]: VertexBuffer;
  23071. }>;
  23072. /**
  23073. * Gets a boolean indicating if specific vertex buffer is present
  23074. * @param kind defines the data kind (Position, normal, etc...)
  23075. * @returns true if data is present
  23076. */
  23077. isVerticesDataPresent(kind: string): boolean;
  23078. /**
  23079. * Gets a list of all attached data kinds (Position, normal, etc...)
  23080. * @returns a list of string containing all kinds
  23081. */
  23082. getVerticesDataKinds(): string[];
  23083. /**
  23084. * Update index buffer
  23085. * @param indices defines the indices to store in the index buffer
  23086. * @param offset defines the offset in the target buffer where to store the data
  23087. * @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)
  23088. */
  23089. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23090. /**
  23091. * Creates a new index buffer
  23092. * @param indices defines the indices to store in the index buffer
  23093. * @param totalVertices defines the total number of vertices (could be null)
  23094. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23095. */
  23096. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23097. /**
  23098. * Return the total number of indices
  23099. * @returns the total number of indices
  23100. */
  23101. getTotalIndices(): number;
  23102. /**
  23103. * Gets the index buffer array
  23104. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23105. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23106. * @returns the index buffer array
  23107. */
  23108. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23109. /**
  23110. * Gets the index buffer
  23111. * @return the index buffer
  23112. */
  23113. getIndexBuffer(): Nullable<DataBuffer>;
  23114. /** @hidden */
  23115. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23116. /**
  23117. * Release the associated resources for a specific mesh
  23118. * @param mesh defines the source mesh
  23119. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23120. */
  23121. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23122. /**
  23123. * Apply current geometry to a given mesh
  23124. * @param mesh defines the mesh to apply geometry to
  23125. */
  23126. applyToMesh(mesh: Mesh): void;
  23127. private _updateExtend;
  23128. private _applyToMesh;
  23129. private notifyUpdate;
  23130. /**
  23131. * Load the geometry if it was flagged as delay loaded
  23132. * @param scene defines the hosting scene
  23133. * @param onLoaded defines a callback called when the geometry is loaded
  23134. */
  23135. load(scene: Scene, onLoaded?: () => void): void;
  23136. private _queueLoad;
  23137. /**
  23138. * Invert the geometry to move from a right handed system to a left handed one.
  23139. */
  23140. toLeftHanded(): void;
  23141. /** @hidden */
  23142. _resetPointsArrayCache(): void;
  23143. /** @hidden */
  23144. _generatePointsArray(): boolean;
  23145. /**
  23146. * Gets a value indicating if the geometry is disposed
  23147. * @returns true if the geometry was disposed
  23148. */
  23149. isDisposed(): boolean;
  23150. private _disposeVertexArrayObjects;
  23151. /**
  23152. * Free all associated resources
  23153. */
  23154. dispose(): void;
  23155. /**
  23156. * Clone the current geometry into a new geometry
  23157. * @param id defines the unique ID of the new geometry
  23158. * @returns a new geometry object
  23159. */
  23160. copy(id: string): Geometry;
  23161. /**
  23162. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23163. * @return a JSON representation of the current geometry data (without the vertices data)
  23164. */
  23165. serialize(): any;
  23166. private toNumberArray;
  23167. /**
  23168. * Serialize all vertices data into a JSON oject
  23169. * @returns a JSON representation of the current geometry data
  23170. */
  23171. serializeVerticeData(): any;
  23172. /**
  23173. * Extracts a clone of a mesh geometry
  23174. * @param mesh defines the source mesh
  23175. * @param id defines the unique ID of the new geometry object
  23176. * @returns the new geometry object
  23177. */
  23178. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23179. /**
  23180. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23181. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23182. * Be aware Math.random() could cause collisions, but:
  23183. * "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"
  23184. * @returns a string containing a new GUID
  23185. */
  23186. static RandomId(): string;
  23187. /** @hidden */
  23188. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23189. private static _CleanMatricesWeights;
  23190. /**
  23191. * Create a new geometry from persisted data (Using .babylon file format)
  23192. * @param parsedVertexData defines the persisted data
  23193. * @param scene defines the hosting scene
  23194. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23195. * @returns the new geometry object
  23196. */
  23197. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23198. }
  23199. }
  23200. declare module "babylonjs/Meshes/mesh.vertexData" {
  23201. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23202. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23203. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  23204. import { Geometry } from "babylonjs/Meshes/geometry";
  23205. import { Mesh } from "babylonjs/Meshes/mesh";
  23206. /**
  23207. * Define an interface for all classes that will get and set the data on vertices
  23208. */
  23209. export interface IGetSetVerticesData {
  23210. /**
  23211. * Gets a boolean indicating if specific vertex data is present
  23212. * @param kind defines the vertex data kind to use
  23213. * @returns true is data kind is present
  23214. */
  23215. isVerticesDataPresent(kind: string): boolean;
  23216. /**
  23217. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23218. * @param kind defines the data kind (Position, normal, etc...)
  23219. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23220. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23221. * @returns a float array containing vertex data
  23222. */
  23223. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23224. /**
  23225. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23226. * @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.
  23227. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23228. * @returns the indices array or an empty array if the mesh has no geometry
  23229. */
  23230. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23231. /**
  23232. * Set specific vertex data
  23233. * @param kind defines the data kind (Position, normal, etc...)
  23234. * @param data defines the vertex data to use
  23235. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23236. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23237. */
  23238. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23239. /**
  23240. * Update a specific associated vertex buffer
  23241. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23242. * - VertexBuffer.PositionKind
  23243. * - VertexBuffer.UVKind
  23244. * - VertexBuffer.UV2Kind
  23245. * - VertexBuffer.UV3Kind
  23246. * - VertexBuffer.UV4Kind
  23247. * - VertexBuffer.UV5Kind
  23248. * - VertexBuffer.UV6Kind
  23249. * - VertexBuffer.ColorKind
  23250. * - VertexBuffer.MatricesIndicesKind
  23251. * - VertexBuffer.MatricesIndicesExtraKind
  23252. * - VertexBuffer.MatricesWeightsKind
  23253. * - VertexBuffer.MatricesWeightsExtraKind
  23254. * @param data defines the data source
  23255. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23256. * @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)
  23257. */
  23258. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23259. /**
  23260. * Creates a new index buffer
  23261. * @param indices defines the indices to store in the index buffer
  23262. * @param totalVertices defines the total number of vertices (could be null)
  23263. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23264. */
  23265. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23266. }
  23267. /**
  23268. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23269. */
  23270. export class VertexData {
  23271. /**
  23272. * Mesh side orientation : usually the external or front surface
  23273. */
  23274. static readonly FRONTSIDE: number;
  23275. /**
  23276. * Mesh side orientation : usually the internal or back surface
  23277. */
  23278. static readonly BACKSIDE: number;
  23279. /**
  23280. * Mesh side orientation : both internal and external or front and back surfaces
  23281. */
  23282. static readonly DOUBLESIDE: number;
  23283. /**
  23284. * Mesh side orientation : by default, `FRONTSIDE`
  23285. */
  23286. static readonly DEFAULTSIDE: number;
  23287. /**
  23288. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23289. */
  23290. positions: Nullable<FloatArray>;
  23291. /**
  23292. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23293. */
  23294. normals: Nullable<FloatArray>;
  23295. /**
  23296. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23297. */
  23298. tangents: Nullable<FloatArray>;
  23299. /**
  23300. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23301. */
  23302. uvs: Nullable<FloatArray>;
  23303. /**
  23304. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23305. */
  23306. uvs2: Nullable<FloatArray>;
  23307. /**
  23308. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23309. */
  23310. uvs3: Nullable<FloatArray>;
  23311. /**
  23312. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23313. */
  23314. uvs4: Nullable<FloatArray>;
  23315. /**
  23316. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23317. */
  23318. uvs5: Nullable<FloatArray>;
  23319. /**
  23320. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23321. */
  23322. uvs6: Nullable<FloatArray>;
  23323. /**
  23324. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23325. */
  23326. colors: Nullable<FloatArray>;
  23327. /**
  23328. * 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).
  23329. */
  23330. matricesIndices: Nullable<FloatArray>;
  23331. /**
  23332. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23333. */
  23334. matricesWeights: Nullable<FloatArray>;
  23335. /**
  23336. * An array extending the number of possible indices
  23337. */
  23338. matricesIndicesExtra: Nullable<FloatArray>;
  23339. /**
  23340. * An array extending the number of possible weights when the number of indices is extended
  23341. */
  23342. matricesWeightsExtra: Nullable<FloatArray>;
  23343. /**
  23344. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23345. */
  23346. indices: Nullable<IndicesArray>;
  23347. /**
  23348. * Uses the passed data array to set the set the values for the specified kind of data
  23349. * @param data a linear array of floating numbers
  23350. * @param kind the type of data that is being set, eg positions, colors etc
  23351. */
  23352. set(data: FloatArray, kind: string): void;
  23353. /**
  23354. * Associates the vertexData to the passed Mesh.
  23355. * Sets it as updatable or not (default `false`)
  23356. * @param mesh the mesh the vertexData is applied to
  23357. * @param updatable when used and having the value true allows new data to update the vertexData
  23358. * @returns the VertexData
  23359. */
  23360. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23361. /**
  23362. * Associates the vertexData to the passed Geometry.
  23363. * Sets it as updatable or not (default `false`)
  23364. * @param geometry the geometry the vertexData is applied to
  23365. * @param updatable when used and having the value true allows new data to update the vertexData
  23366. * @returns VertexData
  23367. */
  23368. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23369. /**
  23370. * Updates the associated mesh
  23371. * @param mesh the mesh to be updated
  23372. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23373. * @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
  23374. * @returns VertexData
  23375. */
  23376. updateMesh(mesh: Mesh): VertexData;
  23377. /**
  23378. * Updates the associated geometry
  23379. * @param geometry the geometry to be updated
  23380. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23381. * @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
  23382. * @returns VertexData.
  23383. */
  23384. updateGeometry(geometry: Geometry): VertexData;
  23385. private _applyTo;
  23386. private _update;
  23387. /**
  23388. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23389. * @param matrix the transforming matrix
  23390. * @returns the VertexData
  23391. */
  23392. transform(matrix: Matrix): VertexData;
  23393. /**
  23394. * Merges the passed VertexData into the current one
  23395. * @param other the VertexData to be merged into the current one
  23396. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23397. * @returns the modified VertexData
  23398. */
  23399. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23400. private _mergeElement;
  23401. private _validate;
  23402. /**
  23403. * Serializes the VertexData
  23404. * @returns a serialized object
  23405. */
  23406. serialize(): any;
  23407. /**
  23408. * Extracts the vertexData from a mesh
  23409. * @param mesh the mesh from which to extract the VertexData
  23410. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23411. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23412. * @returns the object VertexData associated to the passed mesh
  23413. */
  23414. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23415. /**
  23416. * Extracts the vertexData from the geometry
  23417. * @param geometry the geometry from which to extract the VertexData
  23418. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23419. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23420. * @returns the object VertexData associated to the passed mesh
  23421. */
  23422. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23423. private static _ExtractFrom;
  23424. /**
  23425. * Creates the VertexData for a Ribbon
  23426. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23427. * * pathArray array of paths, each of which an array of successive Vector3
  23428. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23429. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23430. * * 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
  23431. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23432. * * 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)
  23433. * * 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)
  23434. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23435. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23436. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23437. * @returns the VertexData of the ribbon
  23438. */
  23439. static CreateRibbon(options: {
  23440. pathArray: Vector3[][];
  23441. closeArray?: boolean;
  23442. closePath?: boolean;
  23443. offset?: number;
  23444. sideOrientation?: number;
  23445. frontUVs?: Vector4;
  23446. backUVs?: Vector4;
  23447. invertUV?: boolean;
  23448. uvs?: Vector2[];
  23449. colors?: Color4[];
  23450. }): VertexData;
  23451. /**
  23452. * Creates the VertexData for a box
  23453. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23454. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23455. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23456. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23457. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23458. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23459. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23461. * * 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)
  23462. * * 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)
  23463. * @returns the VertexData of the box
  23464. */
  23465. static CreateBox(options: {
  23466. size?: number;
  23467. width?: number;
  23468. height?: number;
  23469. depth?: number;
  23470. faceUV?: Vector4[];
  23471. faceColors?: Color4[];
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. }): VertexData;
  23476. /**
  23477. * Creates the VertexData for a tiled box
  23478. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23479. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23480. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23481. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23483. * @returns the VertexData of the box
  23484. */
  23485. static CreateTiledBox(options: {
  23486. pattern?: number;
  23487. width?: number;
  23488. height?: number;
  23489. depth?: number;
  23490. tileSize?: number;
  23491. tileWidth?: number;
  23492. tileHeight?: number;
  23493. alignHorizontal?: number;
  23494. alignVertical?: number;
  23495. faceUV?: Vector4[];
  23496. faceColors?: Color4[];
  23497. sideOrientation?: number;
  23498. }): VertexData;
  23499. /**
  23500. * Creates the VertexData for a tiled plane
  23501. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23502. * * pattern a limited pattern arrangement depending on the number
  23503. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23504. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23505. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23507. * * 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)
  23508. * * 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)
  23509. * @returns the VertexData of the tiled plane
  23510. */
  23511. static CreateTiledPlane(options: {
  23512. pattern?: number;
  23513. tileSize?: number;
  23514. tileWidth?: number;
  23515. tileHeight?: number;
  23516. size?: number;
  23517. width?: number;
  23518. height?: number;
  23519. alignHorizontal?: number;
  23520. alignVertical?: number;
  23521. sideOrientation?: number;
  23522. frontUVs?: Vector4;
  23523. backUVs?: Vector4;
  23524. }): VertexData;
  23525. /**
  23526. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23527. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23528. * * segments sets the number of horizontal strips optional, default 32
  23529. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23530. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23531. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23532. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23533. * * 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
  23534. * * 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
  23535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23536. * * 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)
  23537. * * 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)
  23538. * @returns the VertexData of the ellipsoid
  23539. */
  23540. static CreateSphere(options: {
  23541. segments?: number;
  23542. diameter?: number;
  23543. diameterX?: number;
  23544. diameterY?: number;
  23545. diameterZ?: number;
  23546. arc?: number;
  23547. slice?: number;
  23548. sideOrientation?: number;
  23549. frontUVs?: Vector4;
  23550. backUVs?: Vector4;
  23551. }): VertexData;
  23552. /**
  23553. * Creates the VertexData for a cylinder, cone or prism
  23554. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23555. * * height sets the height (y direction) of the cylinder, optional, default 2
  23556. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23557. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23558. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23559. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23560. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23561. * * 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
  23562. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23563. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23564. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23565. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23566. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23567. * * 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)
  23568. * * 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)
  23569. * @returns the VertexData of the cylinder, cone or prism
  23570. */
  23571. static CreateCylinder(options: {
  23572. height?: number;
  23573. diameterTop?: number;
  23574. diameterBottom?: number;
  23575. diameter?: number;
  23576. tessellation?: number;
  23577. subdivisions?: number;
  23578. arc?: number;
  23579. faceColors?: Color4[];
  23580. faceUV?: Vector4[];
  23581. hasRings?: boolean;
  23582. enclose?: boolean;
  23583. sideOrientation?: number;
  23584. frontUVs?: Vector4;
  23585. backUVs?: Vector4;
  23586. }): VertexData;
  23587. /**
  23588. * Creates the VertexData for a torus
  23589. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23590. * * diameter the diameter of the torus, optional default 1
  23591. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23592. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23594. * * 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)
  23595. * * 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)
  23596. * @returns the VertexData of the torus
  23597. */
  23598. static CreateTorus(options: {
  23599. diameter?: number;
  23600. thickness?: number;
  23601. tessellation?: number;
  23602. sideOrientation?: number;
  23603. frontUVs?: Vector4;
  23604. backUVs?: Vector4;
  23605. }): VertexData;
  23606. /**
  23607. * Creates the VertexData of the LineSystem
  23608. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23609. * - lines an array of lines, each line being an array of successive Vector3
  23610. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23611. * @returns the VertexData of the LineSystem
  23612. */
  23613. static CreateLineSystem(options: {
  23614. lines: Vector3[][];
  23615. colors?: Nullable<Color4[][]>;
  23616. }): VertexData;
  23617. /**
  23618. * Create the VertexData for a DashedLines
  23619. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23620. * - points an array successive Vector3
  23621. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23622. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23623. * - dashNb the intended total number of dashes, optional, default 200
  23624. * @returns the VertexData for the DashedLines
  23625. */
  23626. static CreateDashedLines(options: {
  23627. points: Vector3[];
  23628. dashSize?: number;
  23629. gapSize?: number;
  23630. dashNb?: number;
  23631. }): VertexData;
  23632. /**
  23633. * Creates the VertexData for a Ground
  23634. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23635. * - width the width (x direction) of the ground, optional, default 1
  23636. * - height the height (z direction) of the ground, optional, default 1
  23637. * - subdivisions the number of subdivisions per side, optional, default 1
  23638. * @returns the VertexData of the Ground
  23639. */
  23640. static CreateGround(options: {
  23641. width?: number;
  23642. height?: number;
  23643. subdivisions?: number;
  23644. subdivisionsX?: number;
  23645. subdivisionsY?: number;
  23646. }): VertexData;
  23647. /**
  23648. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23649. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23650. * * xmin the ground minimum X coordinate, optional, default -1
  23651. * * zmin the ground minimum Z coordinate, optional, default -1
  23652. * * xmax the ground maximum X coordinate, optional, default 1
  23653. * * zmax the ground maximum Z coordinate, optional, default 1
  23654. * * 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}
  23655. * * 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}
  23656. * @returns the VertexData of the TiledGround
  23657. */
  23658. static CreateTiledGround(options: {
  23659. xmin: number;
  23660. zmin: number;
  23661. xmax: number;
  23662. zmax: number;
  23663. subdivisions?: {
  23664. w: number;
  23665. h: number;
  23666. };
  23667. precision?: {
  23668. w: number;
  23669. h: number;
  23670. };
  23671. }): VertexData;
  23672. /**
  23673. * Creates the VertexData of the Ground designed from a heightmap
  23674. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23675. * * width the width (x direction) of the ground
  23676. * * height the height (z direction) of the ground
  23677. * * subdivisions the number of subdivisions per side
  23678. * * minHeight the minimum altitude on the ground, optional, default 0
  23679. * * maxHeight the maximum altitude on the ground, optional default 1
  23680. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23681. * * buffer the array holding the image color data
  23682. * * bufferWidth the width of image
  23683. * * bufferHeight the height of image
  23684. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23685. * @returns the VertexData of the Ground designed from a heightmap
  23686. */
  23687. static CreateGroundFromHeightMap(options: {
  23688. width: number;
  23689. height: number;
  23690. subdivisions: number;
  23691. minHeight: number;
  23692. maxHeight: number;
  23693. colorFilter: Color3;
  23694. buffer: Uint8Array;
  23695. bufferWidth: number;
  23696. bufferHeight: number;
  23697. alphaFilter: number;
  23698. }): VertexData;
  23699. /**
  23700. * Creates the VertexData for a Plane
  23701. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23702. * * size sets the width and height of the plane to the value of size, optional default 1
  23703. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23704. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23705. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23706. * * 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)
  23707. * * 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)
  23708. * @returns the VertexData of the box
  23709. */
  23710. static CreatePlane(options: {
  23711. size?: number;
  23712. width?: number;
  23713. height?: number;
  23714. sideOrientation?: number;
  23715. frontUVs?: Vector4;
  23716. backUVs?: Vector4;
  23717. }): VertexData;
  23718. /**
  23719. * Creates the VertexData of the Disc or regular Polygon
  23720. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23721. * * radius the radius of the disc, optional default 0.5
  23722. * * tessellation the number of polygon sides, optional, default 64
  23723. * * 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
  23724. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23725. * * 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)
  23726. * * 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)
  23727. * @returns the VertexData of the box
  23728. */
  23729. static CreateDisc(options: {
  23730. radius?: number;
  23731. tessellation?: number;
  23732. arc?: number;
  23733. sideOrientation?: number;
  23734. frontUVs?: Vector4;
  23735. backUVs?: Vector4;
  23736. }): VertexData;
  23737. /**
  23738. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23739. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23740. * @param polygon a mesh built from polygonTriangulation.build()
  23741. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23742. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23743. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23744. * @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)
  23745. * @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)
  23746. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23747. * @returns the VertexData of the Polygon
  23748. */
  23749. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23750. /**
  23751. * Creates the VertexData of the IcoSphere
  23752. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23753. * * radius the radius of the IcoSphere, optional default 1
  23754. * * radiusX allows stretching in the x direction, optional, default radius
  23755. * * radiusY allows stretching in the y direction, optional, default radius
  23756. * * radiusZ allows stretching in the z direction, optional, default radius
  23757. * * flat when true creates a flat shaded mesh, optional, default true
  23758. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23760. * * 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)
  23761. * * 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)
  23762. * @returns the VertexData of the IcoSphere
  23763. */
  23764. static CreateIcoSphere(options: {
  23765. radius?: number;
  23766. radiusX?: number;
  23767. radiusY?: number;
  23768. radiusZ?: number;
  23769. flat?: boolean;
  23770. subdivisions?: number;
  23771. sideOrientation?: number;
  23772. frontUVs?: Vector4;
  23773. backUVs?: Vector4;
  23774. }): VertexData;
  23775. /**
  23776. * Creates the VertexData for a Polyhedron
  23777. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23778. * * type provided types are:
  23779. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23780. * * 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)
  23781. * * size the size of the IcoSphere, optional default 1
  23782. * * sizeX allows stretching in the x direction, optional, default size
  23783. * * sizeY allows stretching in the y direction, optional, default size
  23784. * * sizeZ allows stretching in the z direction, optional, default size
  23785. * * 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
  23786. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23787. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23788. * * flat when true creates a flat shaded mesh, optional, default true
  23789. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23790. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23791. * * 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)
  23792. * * 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)
  23793. * @returns the VertexData of the Polyhedron
  23794. */
  23795. static CreatePolyhedron(options: {
  23796. type?: number;
  23797. size?: number;
  23798. sizeX?: number;
  23799. sizeY?: number;
  23800. sizeZ?: number;
  23801. custom?: any;
  23802. faceUV?: Vector4[];
  23803. faceColors?: Color4[];
  23804. flat?: boolean;
  23805. sideOrientation?: number;
  23806. frontUVs?: Vector4;
  23807. backUVs?: Vector4;
  23808. }): VertexData;
  23809. /**
  23810. * Creates the VertexData for a TorusKnot
  23811. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23812. * * radius the radius of the torus knot, optional, default 2
  23813. * * tube the thickness of the tube, optional, default 0.5
  23814. * * radialSegments the number of sides on each tube segments, optional, default 32
  23815. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23816. * * p the number of windings around the z axis, optional, default 2
  23817. * * q the number of windings around the x axis, optional, default 3
  23818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23819. * * 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)
  23820. * * 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)
  23821. * @returns the VertexData of the Torus Knot
  23822. */
  23823. static CreateTorusKnot(options: {
  23824. radius?: number;
  23825. tube?: number;
  23826. radialSegments?: number;
  23827. tubularSegments?: number;
  23828. p?: number;
  23829. q?: number;
  23830. sideOrientation?: number;
  23831. frontUVs?: Vector4;
  23832. backUVs?: Vector4;
  23833. }): VertexData;
  23834. /**
  23835. * Compute normals for given positions and indices
  23836. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23837. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23838. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23839. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23840. * * facetNormals : optional array of facet normals (vector3)
  23841. * * facetPositions : optional array of facet positions (vector3)
  23842. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23843. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23844. * * bInfo : optional bounding info, required for facetPartitioning computation
  23845. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23846. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23847. * * useRightHandedSystem: optional boolean to for right handed system computation
  23848. * * depthSort : optional boolean to enable the facet depth sort computation
  23849. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23850. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23851. */
  23852. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23853. facetNormals?: any;
  23854. facetPositions?: any;
  23855. facetPartitioning?: any;
  23856. ratio?: number;
  23857. bInfo?: any;
  23858. bbSize?: Vector3;
  23859. subDiv?: any;
  23860. useRightHandedSystem?: boolean;
  23861. depthSort?: boolean;
  23862. distanceTo?: Vector3;
  23863. depthSortedFacets?: any;
  23864. }): void;
  23865. /** @hidden */
  23866. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23867. /**
  23868. * Applies VertexData created from the imported parameters to the geometry
  23869. * @param parsedVertexData the parsed data from an imported file
  23870. * @param geometry the geometry to apply the VertexData to
  23871. */
  23872. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23873. }
  23874. }
  23875. declare module "babylonjs/Morph/morphTarget" {
  23876. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23877. import { Observable } from "babylonjs/Misc/observable";
  23878. import { Nullable, FloatArray } from "babylonjs/types";
  23879. import { Scene } from "babylonjs/scene";
  23880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23881. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23882. /**
  23883. * Defines a target to use with MorphTargetManager
  23884. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23885. */
  23886. export class MorphTarget implements IAnimatable {
  23887. /** defines the name of the target */
  23888. name: string;
  23889. /**
  23890. * Gets or sets the list of animations
  23891. */
  23892. animations: import("babylonjs/Animations/animation").Animation[];
  23893. private _scene;
  23894. private _positions;
  23895. private _normals;
  23896. private _tangents;
  23897. private _uvs;
  23898. private _influence;
  23899. private _uniqueId;
  23900. /**
  23901. * Observable raised when the influence changes
  23902. */
  23903. onInfluenceChanged: Observable<boolean>;
  23904. /** @hidden */
  23905. _onDataLayoutChanged: Observable<void>;
  23906. /**
  23907. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23908. */
  23909. get influence(): number;
  23910. set influence(influence: number);
  23911. /**
  23912. * Gets or sets the id of the morph Target
  23913. */
  23914. id: string;
  23915. private _animationPropertiesOverride;
  23916. /**
  23917. * Gets or sets the animation properties override
  23918. */
  23919. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23920. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23921. /**
  23922. * Creates a new MorphTarget
  23923. * @param name defines the name of the target
  23924. * @param influence defines the influence to use
  23925. * @param scene defines the scene the morphtarget belongs to
  23926. */
  23927. constructor(
  23928. /** defines the name of the target */
  23929. name: string, influence?: number, scene?: Nullable<Scene>);
  23930. /**
  23931. * Gets the unique ID of this manager
  23932. */
  23933. get uniqueId(): number;
  23934. /**
  23935. * Gets a boolean defining if the target contains position data
  23936. */
  23937. get hasPositions(): boolean;
  23938. /**
  23939. * Gets a boolean defining if the target contains normal data
  23940. */
  23941. get hasNormals(): boolean;
  23942. /**
  23943. * Gets a boolean defining if the target contains tangent data
  23944. */
  23945. get hasTangents(): boolean;
  23946. /**
  23947. * Gets a boolean defining if the target contains texture coordinates data
  23948. */
  23949. get hasUVs(): boolean;
  23950. /**
  23951. * Affects position data to this target
  23952. * @param data defines the position data to use
  23953. */
  23954. setPositions(data: Nullable<FloatArray>): void;
  23955. /**
  23956. * Gets the position data stored in this target
  23957. * @returns a FloatArray containing the position data (or null if not present)
  23958. */
  23959. getPositions(): Nullable<FloatArray>;
  23960. /**
  23961. * Affects normal data to this target
  23962. * @param data defines the normal data to use
  23963. */
  23964. setNormals(data: Nullable<FloatArray>): void;
  23965. /**
  23966. * Gets the normal data stored in this target
  23967. * @returns a FloatArray containing the normal data (or null if not present)
  23968. */
  23969. getNormals(): Nullable<FloatArray>;
  23970. /**
  23971. * Affects tangent data to this target
  23972. * @param data defines the tangent data to use
  23973. */
  23974. setTangents(data: Nullable<FloatArray>): void;
  23975. /**
  23976. * Gets the tangent data stored in this target
  23977. * @returns a FloatArray containing the tangent data (or null if not present)
  23978. */
  23979. getTangents(): Nullable<FloatArray>;
  23980. /**
  23981. * Affects texture coordinates data to this target
  23982. * @param data defines the texture coordinates data to use
  23983. */
  23984. setUVs(data: Nullable<FloatArray>): void;
  23985. /**
  23986. * Gets the texture coordinates data stored in this target
  23987. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23988. */
  23989. getUVs(): Nullable<FloatArray>;
  23990. /**
  23991. * Clone the current target
  23992. * @returns a new MorphTarget
  23993. */
  23994. clone(): MorphTarget;
  23995. /**
  23996. * Serializes the current target into a Serialization object
  23997. * @returns the serialized object
  23998. */
  23999. serialize(): any;
  24000. /**
  24001. * Returns the string "MorphTarget"
  24002. * @returns "MorphTarget"
  24003. */
  24004. getClassName(): string;
  24005. /**
  24006. * Creates a new target from serialized data
  24007. * @param serializationObject defines the serialized data to use
  24008. * @returns a new MorphTarget
  24009. */
  24010. static Parse(serializationObject: any): MorphTarget;
  24011. /**
  24012. * Creates a MorphTarget from mesh data
  24013. * @param mesh defines the source mesh
  24014. * @param name defines the name to use for the new target
  24015. * @param influence defines the influence to attach to the target
  24016. * @returns a new MorphTarget
  24017. */
  24018. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24019. }
  24020. }
  24021. declare module "babylonjs/Morph/morphTargetManager" {
  24022. import { Nullable } from "babylonjs/types";
  24023. import { Scene } from "babylonjs/scene";
  24024. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  24025. /**
  24026. * This class is used to deform meshes using morphing between different targets
  24027. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24028. */
  24029. export class MorphTargetManager {
  24030. private _targets;
  24031. private _targetInfluenceChangedObservers;
  24032. private _targetDataLayoutChangedObservers;
  24033. private _activeTargets;
  24034. private _scene;
  24035. private _influences;
  24036. private _supportsNormals;
  24037. private _supportsTangents;
  24038. private _supportsUVs;
  24039. private _vertexCount;
  24040. private _uniqueId;
  24041. private _tempInfluences;
  24042. /**
  24043. * Gets or sets a boolean indicating if normals must be morphed
  24044. */
  24045. enableNormalMorphing: boolean;
  24046. /**
  24047. * Gets or sets a boolean indicating if tangents must be morphed
  24048. */
  24049. enableTangentMorphing: boolean;
  24050. /**
  24051. * Gets or sets a boolean indicating if UV must be morphed
  24052. */
  24053. enableUVMorphing: boolean;
  24054. /**
  24055. * Creates a new MorphTargetManager
  24056. * @param scene defines the current scene
  24057. */
  24058. constructor(scene?: Nullable<Scene>);
  24059. /**
  24060. * Gets the unique ID of this manager
  24061. */
  24062. get uniqueId(): number;
  24063. /**
  24064. * Gets the number of vertices handled by this manager
  24065. */
  24066. get vertexCount(): number;
  24067. /**
  24068. * Gets a boolean indicating if this manager supports morphing of normals
  24069. */
  24070. get supportsNormals(): boolean;
  24071. /**
  24072. * Gets a boolean indicating if this manager supports morphing of tangents
  24073. */
  24074. get supportsTangents(): boolean;
  24075. /**
  24076. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  24077. */
  24078. get supportsUVs(): boolean;
  24079. /**
  24080. * Gets the number of targets stored in this manager
  24081. */
  24082. get numTargets(): number;
  24083. /**
  24084. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24085. */
  24086. get numInfluencers(): number;
  24087. /**
  24088. * Gets the list of influences (one per target)
  24089. */
  24090. get influences(): Float32Array;
  24091. /**
  24092. * Gets the active target at specified index. An active target is a target with an influence > 0
  24093. * @param index defines the index to check
  24094. * @returns the requested target
  24095. */
  24096. getActiveTarget(index: number): MorphTarget;
  24097. /**
  24098. * Gets the target at specified index
  24099. * @param index defines the index to check
  24100. * @returns the requested target
  24101. */
  24102. getTarget(index: number): MorphTarget;
  24103. /**
  24104. * Add a new target to this manager
  24105. * @param target defines the target to add
  24106. */
  24107. addTarget(target: MorphTarget): void;
  24108. /**
  24109. * Removes a target from the manager
  24110. * @param target defines the target to remove
  24111. */
  24112. removeTarget(target: MorphTarget): void;
  24113. /**
  24114. * Clone the current manager
  24115. * @returns a new MorphTargetManager
  24116. */
  24117. clone(): MorphTargetManager;
  24118. /**
  24119. * Serializes the current manager into a Serialization object
  24120. * @returns the serialized object
  24121. */
  24122. serialize(): any;
  24123. private _syncActiveTargets;
  24124. /**
  24125. * Syncrhonize the targets with all the meshes using this morph target manager
  24126. */
  24127. synchronize(): void;
  24128. /**
  24129. * Creates a new MorphTargetManager from serialized data
  24130. * @param serializationObject defines the serialized data
  24131. * @param scene defines the hosting scene
  24132. * @returns the new MorphTargetManager
  24133. */
  24134. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24135. }
  24136. }
  24137. declare module "babylonjs/Meshes/meshLODLevel" {
  24138. import { Mesh } from "babylonjs/Meshes/mesh";
  24139. import { Nullable } from "babylonjs/types";
  24140. /**
  24141. * Class used to represent a specific level of detail of a mesh
  24142. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24143. */
  24144. export class MeshLODLevel {
  24145. /** Defines the distance where this level should start being displayed */
  24146. distance: number;
  24147. /** Defines the mesh to use to render this level */
  24148. mesh: Nullable<Mesh>;
  24149. /**
  24150. * Creates a new LOD level
  24151. * @param distance defines the distance where this level should star being displayed
  24152. * @param mesh defines the mesh to use to render this level
  24153. */
  24154. constructor(
  24155. /** Defines the distance where this level should start being displayed */
  24156. distance: number,
  24157. /** Defines the mesh to use to render this level */
  24158. mesh: Nullable<Mesh>);
  24159. }
  24160. }
  24161. declare module "babylonjs/Meshes/groundMesh" {
  24162. import { Scene } from "babylonjs/scene";
  24163. import { Vector3 } from "babylonjs/Maths/math.vector";
  24164. import { Mesh } from "babylonjs/Meshes/mesh";
  24165. /**
  24166. * Mesh representing the gorund
  24167. */
  24168. export class GroundMesh extends Mesh {
  24169. /** If octree should be generated */
  24170. generateOctree: boolean;
  24171. private _heightQuads;
  24172. /** @hidden */
  24173. _subdivisionsX: number;
  24174. /** @hidden */
  24175. _subdivisionsY: number;
  24176. /** @hidden */
  24177. _width: number;
  24178. /** @hidden */
  24179. _height: number;
  24180. /** @hidden */
  24181. _minX: number;
  24182. /** @hidden */
  24183. _maxX: number;
  24184. /** @hidden */
  24185. _minZ: number;
  24186. /** @hidden */
  24187. _maxZ: number;
  24188. constructor(name: string, scene: Scene);
  24189. /**
  24190. * "GroundMesh"
  24191. * @returns "GroundMesh"
  24192. */
  24193. getClassName(): string;
  24194. /**
  24195. * The minimum of x and y subdivisions
  24196. */
  24197. get subdivisions(): number;
  24198. /**
  24199. * X subdivisions
  24200. */
  24201. get subdivisionsX(): number;
  24202. /**
  24203. * Y subdivisions
  24204. */
  24205. get subdivisionsY(): number;
  24206. /**
  24207. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  24208. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24209. * @param chunksCount the number of subdivisions for x and y
  24210. * @param octreeBlocksSize (Default: 32)
  24211. */
  24212. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  24213. /**
  24214. * Returns a height (y) value in the Worl system :
  24215. * the ground altitude at the coordinates (x, z) expressed in the World system.
  24216. * @param x x coordinate
  24217. * @param z z coordinate
  24218. * @returns the ground y position if (x, z) are outside the ground surface.
  24219. */
  24220. getHeightAtCoordinates(x: number, z: number): number;
  24221. /**
  24222. * Returns a normalized vector (Vector3) orthogonal to the ground
  24223. * at the ground coordinates (x, z) expressed in the World system.
  24224. * @param x x coordinate
  24225. * @param z z coordinate
  24226. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  24227. */
  24228. getNormalAtCoordinates(x: number, z: number): Vector3;
  24229. /**
  24230. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  24231. * at the ground coordinates (x, z) expressed in the World system.
  24232. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  24233. * @param x x coordinate
  24234. * @param z z coordinate
  24235. * @param ref vector to store the result
  24236. * @returns the GroundMesh.
  24237. */
  24238. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  24239. /**
  24240. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  24241. * if the ground has been updated.
  24242. * This can be used in the render loop.
  24243. * @returns the GroundMesh.
  24244. */
  24245. updateCoordinateHeights(): GroundMesh;
  24246. private _getFacetAt;
  24247. private _initHeightQuads;
  24248. private _computeHeightQuads;
  24249. /**
  24250. * Serializes this ground mesh
  24251. * @param serializationObject object to write serialization to
  24252. */
  24253. serialize(serializationObject: any): void;
  24254. /**
  24255. * Parses a serialized ground mesh
  24256. * @param parsedMesh the serialized mesh
  24257. * @param scene the scene to create the ground mesh in
  24258. * @returns the created ground mesh
  24259. */
  24260. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  24261. }
  24262. }
  24263. declare module "babylonjs/Physics/physicsJoint" {
  24264. import { Vector3 } from "babylonjs/Maths/math.vector";
  24265. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  24266. /**
  24267. * Interface for Physics-Joint data
  24268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24269. */
  24270. export interface PhysicsJointData {
  24271. /**
  24272. * The main pivot of the joint
  24273. */
  24274. mainPivot?: Vector3;
  24275. /**
  24276. * The connected pivot of the joint
  24277. */
  24278. connectedPivot?: Vector3;
  24279. /**
  24280. * The main axis of the joint
  24281. */
  24282. mainAxis?: Vector3;
  24283. /**
  24284. * The connected axis of the joint
  24285. */
  24286. connectedAxis?: Vector3;
  24287. /**
  24288. * The collision of the joint
  24289. */
  24290. collision?: boolean;
  24291. /**
  24292. * Native Oimo/Cannon/Energy data
  24293. */
  24294. nativeParams?: any;
  24295. }
  24296. /**
  24297. * This is a holder class for the physics joint created by the physics plugin
  24298. * It holds a set of functions to control the underlying joint
  24299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24300. */
  24301. export class PhysicsJoint {
  24302. /**
  24303. * The type of the physics joint
  24304. */
  24305. type: number;
  24306. /**
  24307. * The data for the physics joint
  24308. */
  24309. jointData: PhysicsJointData;
  24310. private _physicsJoint;
  24311. protected _physicsPlugin: IPhysicsEnginePlugin;
  24312. /**
  24313. * Initializes the physics joint
  24314. * @param type The type of the physics joint
  24315. * @param jointData The data for the physics joint
  24316. */
  24317. constructor(
  24318. /**
  24319. * The type of the physics joint
  24320. */
  24321. type: number,
  24322. /**
  24323. * The data for the physics joint
  24324. */
  24325. jointData: PhysicsJointData);
  24326. /**
  24327. * Gets the physics joint
  24328. */
  24329. get physicsJoint(): any;
  24330. /**
  24331. * Sets the physics joint
  24332. */
  24333. set physicsJoint(newJoint: any);
  24334. /**
  24335. * Sets the physics plugin
  24336. */
  24337. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24338. /**
  24339. * Execute a function that is physics-plugin specific.
  24340. * @param {Function} func the function that will be executed.
  24341. * It accepts two parameters: the physics world and the physics joint
  24342. */
  24343. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24344. /**
  24345. * Distance-Joint type
  24346. */
  24347. static DistanceJoint: number;
  24348. /**
  24349. * Hinge-Joint type
  24350. */
  24351. static HingeJoint: number;
  24352. /**
  24353. * Ball-and-Socket joint type
  24354. */
  24355. static BallAndSocketJoint: number;
  24356. /**
  24357. * Wheel-Joint type
  24358. */
  24359. static WheelJoint: number;
  24360. /**
  24361. * Slider-Joint type
  24362. */
  24363. static SliderJoint: number;
  24364. /**
  24365. * Prismatic-Joint type
  24366. */
  24367. static PrismaticJoint: number;
  24368. /**
  24369. * Universal-Joint type
  24370. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24371. */
  24372. static UniversalJoint: number;
  24373. /**
  24374. * Hinge-Joint 2 type
  24375. */
  24376. static Hinge2Joint: number;
  24377. /**
  24378. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24379. */
  24380. static PointToPointJoint: number;
  24381. /**
  24382. * Spring-Joint type
  24383. */
  24384. static SpringJoint: number;
  24385. /**
  24386. * Lock-Joint type
  24387. */
  24388. static LockJoint: number;
  24389. }
  24390. /**
  24391. * A class representing a physics distance joint
  24392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24393. */
  24394. export class DistanceJoint extends PhysicsJoint {
  24395. /**
  24396. *
  24397. * @param jointData The data for the Distance-Joint
  24398. */
  24399. constructor(jointData: DistanceJointData);
  24400. /**
  24401. * Update the predefined distance.
  24402. * @param maxDistance The maximum preferred distance
  24403. * @param minDistance The minimum preferred distance
  24404. */
  24405. updateDistance(maxDistance: number, minDistance?: number): void;
  24406. }
  24407. /**
  24408. * Represents a Motor-Enabled Joint
  24409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24410. */
  24411. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24412. /**
  24413. * Initializes the Motor-Enabled Joint
  24414. * @param type The type of the joint
  24415. * @param jointData The physica joint data for the joint
  24416. */
  24417. constructor(type: number, jointData: PhysicsJointData);
  24418. /**
  24419. * Set the motor values.
  24420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24421. * @param force the force to apply
  24422. * @param maxForce max force for this motor.
  24423. */
  24424. setMotor(force?: number, maxForce?: number): void;
  24425. /**
  24426. * Set the motor's limits.
  24427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24428. * @param upperLimit The upper limit of the motor
  24429. * @param lowerLimit The lower limit of the motor
  24430. */
  24431. setLimit(upperLimit: number, lowerLimit?: number): void;
  24432. }
  24433. /**
  24434. * This class represents a single physics Hinge-Joint
  24435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24436. */
  24437. export class HingeJoint extends MotorEnabledJoint {
  24438. /**
  24439. * Initializes the Hinge-Joint
  24440. * @param jointData The joint data for the Hinge-Joint
  24441. */
  24442. constructor(jointData: PhysicsJointData);
  24443. /**
  24444. * Set the motor values.
  24445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24446. * @param {number} force the force to apply
  24447. * @param {number} maxForce max force for this motor.
  24448. */
  24449. setMotor(force?: number, maxForce?: number): void;
  24450. /**
  24451. * Set the motor's limits.
  24452. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24453. * @param upperLimit The upper limit of the motor
  24454. * @param lowerLimit The lower limit of the motor
  24455. */
  24456. setLimit(upperLimit: number, lowerLimit?: number): void;
  24457. }
  24458. /**
  24459. * This class represents a dual hinge physics joint (same as wheel joint)
  24460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24461. */
  24462. export class Hinge2Joint extends MotorEnabledJoint {
  24463. /**
  24464. * Initializes the Hinge2-Joint
  24465. * @param jointData The joint data for the Hinge2-Joint
  24466. */
  24467. constructor(jointData: PhysicsJointData);
  24468. /**
  24469. * Set the motor values.
  24470. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24471. * @param {number} targetSpeed the speed the motor is to reach
  24472. * @param {number} maxForce max force for this motor.
  24473. * @param {motorIndex} the motor's index, 0 or 1.
  24474. */
  24475. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24476. /**
  24477. * Set the motor limits.
  24478. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24479. * @param {number} upperLimit the upper limit
  24480. * @param {number} lowerLimit lower limit
  24481. * @param {motorIndex} the motor's index, 0 or 1.
  24482. */
  24483. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24484. }
  24485. /**
  24486. * Interface for a motor enabled joint
  24487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24488. */
  24489. export interface IMotorEnabledJoint {
  24490. /**
  24491. * Physics joint
  24492. */
  24493. physicsJoint: any;
  24494. /**
  24495. * Sets the motor of the motor-enabled joint
  24496. * @param force The force of the motor
  24497. * @param maxForce The maximum force of the motor
  24498. * @param motorIndex The index of the motor
  24499. */
  24500. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24501. /**
  24502. * Sets the limit of the motor
  24503. * @param upperLimit The upper limit of the motor
  24504. * @param lowerLimit The lower limit of the motor
  24505. * @param motorIndex The index of the motor
  24506. */
  24507. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24508. }
  24509. /**
  24510. * Joint data for a Distance-Joint
  24511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24512. */
  24513. export interface DistanceJointData extends PhysicsJointData {
  24514. /**
  24515. * Max distance the 2 joint objects can be apart
  24516. */
  24517. maxDistance: number;
  24518. }
  24519. /**
  24520. * Joint data from a spring joint
  24521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24522. */
  24523. export interface SpringJointData extends PhysicsJointData {
  24524. /**
  24525. * Length of the spring
  24526. */
  24527. length: number;
  24528. /**
  24529. * Stiffness of the spring
  24530. */
  24531. stiffness: number;
  24532. /**
  24533. * Damping of the spring
  24534. */
  24535. damping: number;
  24536. /** this callback will be called when applying the force to the impostors. */
  24537. forceApplicationCallback: () => void;
  24538. }
  24539. }
  24540. declare module "babylonjs/Physics/physicsRaycastResult" {
  24541. import { Vector3 } from "babylonjs/Maths/math.vector";
  24542. /**
  24543. * Holds the data for the raycast result
  24544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24545. */
  24546. export class PhysicsRaycastResult {
  24547. private _hasHit;
  24548. private _hitDistance;
  24549. private _hitNormalWorld;
  24550. private _hitPointWorld;
  24551. private _rayFromWorld;
  24552. private _rayToWorld;
  24553. /**
  24554. * Gets if there was a hit
  24555. */
  24556. get hasHit(): boolean;
  24557. /**
  24558. * Gets the distance from the hit
  24559. */
  24560. get hitDistance(): number;
  24561. /**
  24562. * Gets the hit normal/direction in the world
  24563. */
  24564. get hitNormalWorld(): Vector3;
  24565. /**
  24566. * Gets the hit point in the world
  24567. */
  24568. get hitPointWorld(): Vector3;
  24569. /**
  24570. * Gets the ray "start point" of the ray in the world
  24571. */
  24572. get rayFromWorld(): Vector3;
  24573. /**
  24574. * Gets the ray "end point" of the ray in the world
  24575. */
  24576. get rayToWorld(): Vector3;
  24577. /**
  24578. * Sets the hit data (normal & point in world space)
  24579. * @param hitNormalWorld defines the normal in world space
  24580. * @param hitPointWorld defines the point in world space
  24581. */
  24582. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24583. /**
  24584. * Sets the distance from the start point to the hit point
  24585. * @param distance
  24586. */
  24587. setHitDistance(distance: number): void;
  24588. /**
  24589. * Calculates the distance manually
  24590. */
  24591. calculateHitDistance(): void;
  24592. /**
  24593. * Resets all the values to default
  24594. * @param from The from point on world space
  24595. * @param to The to point on world space
  24596. */
  24597. reset(from?: Vector3, to?: Vector3): void;
  24598. }
  24599. /**
  24600. * Interface for the size containing width and height
  24601. */
  24602. interface IXYZ {
  24603. /**
  24604. * X
  24605. */
  24606. x: number;
  24607. /**
  24608. * Y
  24609. */
  24610. y: number;
  24611. /**
  24612. * Z
  24613. */
  24614. z: number;
  24615. }
  24616. }
  24617. declare module "babylonjs/Physics/IPhysicsEngine" {
  24618. import { Nullable } from "babylonjs/types";
  24619. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24621. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24622. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24623. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24624. /**
  24625. * Interface used to describe a physics joint
  24626. */
  24627. export interface PhysicsImpostorJoint {
  24628. /** Defines the main impostor to which the joint is linked */
  24629. mainImpostor: PhysicsImpostor;
  24630. /** Defines the impostor that is connected to the main impostor using this joint */
  24631. connectedImpostor: PhysicsImpostor;
  24632. /** Defines the joint itself */
  24633. joint: PhysicsJoint;
  24634. }
  24635. /** @hidden */
  24636. export interface IPhysicsEnginePlugin {
  24637. world: any;
  24638. name: string;
  24639. setGravity(gravity: Vector3): void;
  24640. setTimeStep(timeStep: number): void;
  24641. getTimeStep(): number;
  24642. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24643. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24644. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24645. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24646. removePhysicsBody(impostor: PhysicsImpostor): void;
  24647. generateJoint(joint: PhysicsImpostorJoint): void;
  24648. removeJoint(joint: PhysicsImpostorJoint): void;
  24649. isSupported(): boolean;
  24650. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24651. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24652. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24653. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24655. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24656. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24657. getBodyMass(impostor: PhysicsImpostor): number;
  24658. getBodyFriction(impostor: PhysicsImpostor): number;
  24659. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24660. getBodyRestitution(impostor: PhysicsImpostor): number;
  24661. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24662. getBodyPressure?(impostor: PhysicsImpostor): number;
  24663. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24664. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24665. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24666. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24667. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24668. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24669. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24670. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24671. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24672. sleepBody(impostor: PhysicsImpostor): void;
  24673. wakeUpBody(impostor: PhysicsImpostor): void;
  24674. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24675. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24676. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24677. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24678. getRadius(impostor: PhysicsImpostor): number;
  24679. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24680. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24681. dispose(): void;
  24682. }
  24683. /**
  24684. * Interface used to define a physics engine
  24685. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24686. */
  24687. export interface IPhysicsEngine {
  24688. /**
  24689. * Gets the gravity vector used by the simulation
  24690. */
  24691. gravity: Vector3;
  24692. /**
  24693. * Sets the gravity vector used by the simulation
  24694. * @param gravity defines the gravity vector to use
  24695. */
  24696. setGravity(gravity: Vector3): void;
  24697. /**
  24698. * Set the time step of the physics engine.
  24699. * Default is 1/60.
  24700. * To slow it down, enter 1/600 for example.
  24701. * To speed it up, 1/30
  24702. * @param newTimeStep the new timestep to apply to this world.
  24703. */
  24704. setTimeStep(newTimeStep: number): void;
  24705. /**
  24706. * Get the time step of the physics engine.
  24707. * @returns the current time step
  24708. */
  24709. getTimeStep(): number;
  24710. /**
  24711. * Set the sub time step of the physics engine.
  24712. * Default is 0 meaning there is no sub steps
  24713. * To increase physics resolution precision, set a small value (like 1 ms)
  24714. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24715. */
  24716. setSubTimeStep(subTimeStep: number): void;
  24717. /**
  24718. * Get the sub time step of the physics engine.
  24719. * @returns the current sub time step
  24720. */
  24721. getSubTimeStep(): number;
  24722. /**
  24723. * Release all resources
  24724. */
  24725. dispose(): void;
  24726. /**
  24727. * Gets the name of the current physics plugin
  24728. * @returns the name of the plugin
  24729. */
  24730. getPhysicsPluginName(): string;
  24731. /**
  24732. * Adding a new impostor for the impostor tracking.
  24733. * This will be done by the impostor itself.
  24734. * @param impostor the impostor to add
  24735. */
  24736. addImpostor(impostor: PhysicsImpostor): void;
  24737. /**
  24738. * Remove an impostor from the engine.
  24739. * This impostor and its mesh will not longer be updated by the physics engine.
  24740. * @param impostor the impostor to remove
  24741. */
  24742. removeImpostor(impostor: PhysicsImpostor): void;
  24743. /**
  24744. * Add a joint to the physics engine
  24745. * @param mainImpostor defines the main impostor to which the joint is added.
  24746. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24747. * @param joint defines the joint that will connect both impostors.
  24748. */
  24749. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24750. /**
  24751. * Removes a joint from the simulation
  24752. * @param mainImpostor defines the impostor used with the joint
  24753. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24754. * @param joint defines the joint to remove
  24755. */
  24756. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24757. /**
  24758. * Gets the current plugin used to run the simulation
  24759. * @returns current plugin
  24760. */
  24761. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24762. /**
  24763. * Gets the list of physic impostors
  24764. * @returns an array of PhysicsImpostor
  24765. */
  24766. getImpostors(): Array<PhysicsImpostor>;
  24767. /**
  24768. * Gets the impostor for a physics enabled object
  24769. * @param object defines the object impersonated by the impostor
  24770. * @returns the PhysicsImpostor or null if not found
  24771. */
  24772. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24773. /**
  24774. * Gets the impostor for a physics body object
  24775. * @param body defines physics body used by the impostor
  24776. * @returns the PhysicsImpostor or null if not found
  24777. */
  24778. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24779. /**
  24780. * Does a raycast in the physics world
  24781. * @param from when should the ray start?
  24782. * @param to when should the ray end?
  24783. * @returns PhysicsRaycastResult
  24784. */
  24785. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24786. /**
  24787. * Called by the scene. No need to call it.
  24788. * @param delta defines the timespam between frames
  24789. */
  24790. _step(delta: number): void;
  24791. }
  24792. }
  24793. declare module "babylonjs/Physics/physicsImpostor" {
  24794. import { Nullable, IndicesArray } from "babylonjs/types";
  24795. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24796. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24798. import { Scene } from "babylonjs/scene";
  24799. import { Bone } from "babylonjs/Bones/bone";
  24800. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24801. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24802. import { Space } from "babylonjs/Maths/math.axis";
  24803. /**
  24804. * The interface for the physics imposter parameters
  24805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24806. */
  24807. export interface PhysicsImpostorParameters {
  24808. /**
  24809. * The mass of the physics imposter
  24810. */
  24811. mass: number;
  24812. /**
  24813. * The friction of the physics imposter
  24814. */
  24815. friction?: number;
  24816. /**
  24817. * The coefficient of restitution of the physics imposter
  24818. */
  24819. restitution?: number;
  24820. /**
  24821. * The native options of the physics imposter
  24822. */
  24823. nativeOptions?: any;
  24824. /**
  24825. * Specifies if the parent should be ignored
  24826. */
  24827. ignoreParent?: boolean;
  24828. /**
  24829. * Specifies if bi-directional transformations should be disabled
  24830. */
  24831. disableBidirectionalTransformation?: boolean;
  24832. /**
  24833. * The pressure inside the physics imposter, soft object only
  24834. */
  24835. pressure?: number;
  24836. /**
  24837. * The stiffness the physics imposter, soft object only
  24838. */
  24839. stiffness?: number;
  24840. /**
  24841. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24842. */
  24843. velocityIterations?: number;
  24844. /**
  24845. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24846. */
  24847. positionIterations?: number;
  24848. /**
  24849. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24850. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24851. * Add to fix multiple points
  24852. */
  24853. fixedPoints?: number;
  24854. /**
  24855. * The collision margin around a soft object
  24856. */
  24857. margin?: number;
  24858. /**
  24859. * The collision margin around a soft object
  24860. */
  24861. damping?: number;
  24862. /**
  24863. * The path for a rope based on an extrusion
  24864. */
  24865. path?: any;
  24866. /**
  24867. * The shape of an extrusion used for a rope based on an extrusion
  24868. */
  24869. shape?: any;
  24870. }
  24871. /**
  24872. * Interface for a physics-enabled object
  24873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24874. */
  24875. export interface IPhysicsEnabledObject {
  24876. /**
  24877. * The position of the physics-enabled object
  24878. */
  24879. position: Vector3;
  24880. /**
  24881. * The rotation of the physics-enabled object
  24882. */
  24883. rotationQuaternion: Nullable<Quaternion>;
  24884. /**
  24885. * The scale of the physics-enabled object
  24886. */
  24887. scaling: Vector3;
  24888. /**
  24889. * The rotation of the physics-enabled object
  24890. */
  24891. rotation?: Vector3;
  24892. /**
  24893. * The parent of the physics-enabled object
  24894. */
  24895. parent?: any;
  24896. /**
  24897. * The bounding info of the physics-enabled object
  24898. * @returns The bounding info of the physics-enabled object
  24899. */
  24900. getBoundingInfo(): BoundingInfo;
  24901. /**
  24902. * Computes the world matrix
  24903. * @param force Specifies if the world matrix should be computed by force
  24904. * @returns A world matrix
  24905. */
  24906. computeWorldMatrix(force: boolean): Matrix;
  24907. /**
  24908. * Gets the world matrix
  24909. * @returns A world matrix
  24910. */
  24911. getWorldMatrix?(): Matrix;
  24912. /**
  24913. * Gets the child meshes
  24914. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24915. * @returns An array of abstract meshes
  24916. */
  24917. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24918. /**
  24919. * Gets the vertex data
  24920. * @param kind The type of vertex data
  24921. * @returns A nullable array of numbers, or a float32 array
  24922. */
  24923. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24924. /**
  24925. * Gets the indices from the mesh
  24926. * @returns A nullable array of index arrays
  24927. */
  24928. getIndices?(): Nullable<IndicesArray>;
  24929. /**
  24930. * Gets the scene from the mesh
  24931. * @returns the indices array or null
  24932. */
  24933. getScene?(): Scene;
  24934. /**
  24935. * Gets the absolute position from the mesh
  24936. * @returns the absolute position
  24937. */
  24938. getAbsolutePosition(): Vector3;
  24939. /**
  24940. * Gets the absolute pivot point from the mesh
  24941. * @returns the absolute pivot point
  24942. */
  24943. getAbsolutePivotPoint(): Vector3;
  24944. /**
  24945. * Rotates the mesh
  24946. * @param axis The axis of rotation
  24947. * @param amount The amount of rotation
  24948. * @param space The space of the rotation
  24949. * @returns The rotation transform node
  24950. */
  24951. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24952. /**
  24953. * Translates the mesh
  24954. * @param axis The axis of translation
  24955. * @param distance The distance of translation
  24956. * @param space The space of the translation
  24957. * @returns The transform node
  24958. */
  24959. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24960. /**
  24961. * Sets the absolute position of the mesh
  24962. * @param absolutePosition The absolute position of the mesh
  24963. * @returns The transform node
  24964. */
  24965. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24966. /**
  24967. * Gets the class name of the mesh
  24968. * @returns The class name
  24969. */
  24970. getClassName(): string;
  24971. }
  24972. /**
  24973. * Represents a physics imposter
  24974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24975. */
  24976. export class PhysicsImpostor {
  24977. /**
  24978. * The physics-enabled object used as the physics imposter
  24979. */
  24980. object: IPhysicsEnabledObject;
  24981. /**
  24982. * The type of the physics imposter
  24983. */
  24984. type: number;
  24985. private _options;
  24986. private _scene?;
  24987. /**
  24988. * The default object size of the imposter
  24989. */
  24990. static DEFAULT_OBJECT_SIZE: Vector3;
  24991. /**
  24992. * The identity quaternion of the imposter
  24993. */
  24994. static IDENTITY_QUATERNION: Quaternion;
  24995. /** @hidden */
  24996. _pluginData: any;
  24997. private _physicsEngine;
  24998. private _physicsBody;
  24999. private _bodyUpdateRequired;
  25000. private _onBeforePhysicsStepCallbacks;
  25001. private _onAfterPhysicsStepCallbacks;
  25002. /** @hidden */
  25003. _onPhysicsCollideCallbacks: Array<{
  25004. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  25005. otherImpostors: Array<PhysicsImpostor>;
  25006. }>;
  25007. private _deltaPosition;
  25008. private _deltaRotation;
  25009. private _deltaRotationConjugated;
  25010. /** @hidden */
  25011. _isFromLine: boolean;
  25012. private _parent;
  25013. private _isDisposed;
  25014. private static _tmpVecs;
  25015. private static _tmpQuat;
  25016. /**
  25017. * Specifies if the physics imposter is disposed
  25018. */
  25019. get isDisposed(): boolean;
  25020. /**
  25021. * Gets the mass of the physics imposter
  25022. */
  25023. get mass(): number;
  25024. set mass(value: number);
  25025. /**
  25026. * Gets the coefficient of friction
  25027. */
  25028. get friction(): number;
  25029. /**
  25030. * Sets the coefficient of friction
  25031. */
  25032. set friction(value: number);
  25033. /**
  25034. * Gets the coefficient of restitution
  25035. */
  25036. get restitution(): number;
  25037. /**
  25038. * Sets the coefficient of restitution
  25039. */
  25040. set restitution(value: number);
  25041. /**
  25042. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  25043. */
  25044. get pressure(): number;
  25045. /**
  25046. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  25047. */
  25048. set pressure(value: number);
  25049. /**
  25050. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  25051. */
  25052. get stiffness(): number;
  25053. /**
  25054. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  25055. */
  25056. set stiffness(value: number);
  25057. /**
  25058. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  25059. */
  25060. get velocityIterations(): number;
  25061. /**
  25062. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  25063. */
  25064. set velocityIterations(value: number);
  25065. /**
  25066. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25067. */
  25068. get positionIterations(): number;
  25069. /**
  25070. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25071. */
  25072. set positionIterations(value: number);
  25073. /**
  25074. * The unique id of the physics imposter
  25075. * set by the physics engine when adding this impostor to the array
  25076. */
  25077. uniqueId: number;
  25078. /**
  25079. * @hidden
  25080. */
  25081. soft: boolean;
  25082. /**
  25083. * @hidden
  25084. */
  25085. segments: number;
  25086. private _joints;
  25087. /**
  25088. * Initializes the physics imposter
  25089. * @param object The physics-enabled object used as the physics imposter
  25090. * @param type The type of the physics imposter
  25091. * @param _options The options for the physics imposter
  25092. * @param _scene The Babylon scene
  25093. */
  25094. constructor(
  25095. /**
  25096. * The physics-enabled object used as the physics imposter
  25097. */
  25098. object: IPhysicsEnabledObject,
  25099. /**
  25100. * The type of the physics imposter
  25101. */
  25102. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25103. /**
  25104. * This function will completly initialize this impostor.
  25105. * It will create a new body - but only if this mesh has no parent.
  25106. * If it has, this impostor will not be used other than to define the impostor
  25107. * of the child mesh.
  25108. * @hidden
  25109. */
  25110. _init(): void;
  25111. private _getPhysicsParent;
  25112. /**
  25113. * Should a new body be generated.
  25114. * @returns boolean specifying if body initialization is required
  25115. */
  25116. isBodyInitRequired(): boolean;
  25117. /**
  25118. * Sets the updated scaling
  25119. * @param updated Specifies if the scaling is updated
  25120. */
  25121. setScalingUpdated(): void;
  25122. /**
  25123. * Force a regeneration of this or the parent's impostor's body.
  25124. * Use under cautious - This will remove all joints already implemented.
  25125. */
  25126. forceUpdate(): void;
  25127. /**
  25128. * Gets the body that holds this impostor. Either its own, or its parent.
  25129. */
  25130. get physicsBody(): any;
  25131. /**
  25132. * Get the parent of the physics imposter
  25133. * @returns Physics imposter or null
  25134. */
  25135. get parent(): Nullable<PhysicsImpostor>;
  25136. /**
  25137. * Sets the parent of the physics imposter
  25138. */
  25139. set parent(value: Nullable<PhysicsImpostor>);
  25140. /**
  25141. * Set the physics body. Used mainly by the physics engine/plugin
  25142. */
  25143. set physicsBody(physicsBody: any);
  25144. /**
  25145. * Resets the update flags
  25146. */
  25147. resetUpdateFlags(): void;
  25148. /**
  25149. * Gets the object extend size
  25150. * @returns the object extend size
  25151. */
  25152. getObjectExtendSize(): Vector3;
  25153. /**
  25154. * Gets the object center
  25155. * @returns The object center
  25156. */
  25157. getObjectCenter(): Vector3;
  25158. /**
  25159. * Get a specific parameter from the options parameters
  25160. * @param paramName The object parameter name
  25161. * @returns The object parameter
  25162. */
  25163. getParam(paramName: string): any;
  25164. /**
  25165. * Sets a specific parameter in the options given to the physics plugin
  25166. * @param paramName The parameter name
  25167. * @param value The value of the parameter
  25168. */
  25169. setParam(paramName: string, value: number): void;
  25170. /**
  25171. * Specifically change the body's mass option. Won't recreate the physics body object
  25172. * @param mass The mass of the physics imposter
  25173. */
  25174. setMass(mass: number): void;
  25175. /**
  25176. * Gets the linear velocity
  25177. * @returns linear velocity or null
  25178. */
  25179. getLinearVelocity(): Nullable<Vector3>;
  25180. /**
  25181. * Sets the linear velocity
  25182. * @param velocity linear velocity or null
  25183. */
  25184. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25185. /**
  25186. * Gets the angular velocity
  25187. * @returns angular velocity or null
  25188. */
  25189. getAngularVelocity(): Nullable<Vector3>;
  25190. /**
  25191. * Sets the angular velocity
  25192. * @param velocity The velocity or null
  25193. */
  25194. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25195. /**
  25196. * Execute a function with the physics plugin native code
  25197. * Provide a function the will have two variables - the world object and the physics body object
  25198. * @param func The function to execute with the physics plugin native code
  25199. */
  25200. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25201. /**
  25202. * Register a function that will be executed before the physics world is stepping forward
  25203. * @param func The function to execute before the physics world is stepped forward
  25204. */
  25205. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25206. /**
  25207. * Unregister a function that will be executed before the physics world is stepping forward
  25208. * @param func The function to execute before the physics world is stepped forward
  25209. */
  25210. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25211. /**
  25212. * Register a function that will be executed after the physics step
  25213. * @param func The function to execute after physics step
  25214. */
  25215. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25216. /**
  25217. * Unregisters a function that will be executed after the physics step
  25218. * @param func The function to execute after physics step
  25219. */
  25220. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25221. /**
  25222. * register a function that will be executed when this impostor collides against a different body
  25223. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25224. * @param func Callback that is executed on collision
  25225. */
  25226. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25227. /**
  25228. * Unregisters the physics imposter on contact
  25229. * @param collideAgainst The physics object to collide against
  25230. * @param func Callback to execute on collision
  25231. */
  25232. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25233. private _tmpQuat;
  25234. private _tmpQuat2;
  25235. /**
  25236. * Get the parent rotation
  25237. * @returns The parent rotation
  25238. */
  25239. getParentsRotation(): Quaternion;
  25240. /**
  25241. * this function is executed by the physics engine.
  25242. */
  25243. beforeStep: () => void;
  25244. /**
  25245. * this function is executed by the physics engine
  25246. */
  25247. afterStep: () => void;
  25248. /**
  25249. * Legacy collision detection event support
  25250. */
  25251. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25252. /**
  25253. * event and body object due to cannon's event-based architecture.
  25254. */
  25255. onCollide: (e: {
  25256. body: any;
  25257. }) => void;
  25258. /**
  25259. * Apply a force
  25260. * @param force The force to apply
  25261. * @param contactPoint The contact point for the force
  25262. * @returns The physics imposter
  25263. */
  25264. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25265. /**
  25266. * Apply an impulse
  25267. * @param force The impulse force
  25268. * @param contactPoint The contact point for the impulse force
  25269. * @returns The physics imposter
  25270. */
  25271. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25272. /**
  25273. * A help function to create a joint
  25274. * @param otherImpostor A physics imposter used to create a joint
  25275. * @param jointType The type of joint
  25276. * @param jointData The data for the joint
  25277. * @returns The physics imposter
  25278. */
  25279. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25280. /**
  25281. * Add a joint to this impostor with a different impostor
  25282. * @param otherImpostor A physics imposter used to add a joint
  25283. * @param joint The joint to add
  25284. * @returns The physics imposter
  25285. */
  25286. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25287. /**
  25288. * Add an anchor to a cloth impostor
  25289. * @param otherImpostor rigid impostor to anchor to
  25290. * @param width ratio across width from 0 to 1
  25291. * @param height ratio up height from 0 to 1
  25292. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  25293. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  25294. * @returns impostor the soft imposter
  25295. */
  25296. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25297. /**
  25298. * Add a hook to a rope impostor
  25299. * @param otherImpostor rigid impostor to anchor to
  25300. * @param length ratio across rope from 0 to 1
  25301. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25302. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25303. * @returns impostor the rope imposter
  25304. */
  25305. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25306. /**
  25307. * Will keep this body still, in a sleep mode.
  25308. * @returns the physics imposter
  25309. */
  25310. sleep(): PhysicsImpostor;
  25311. /**
  25312. * Wake the body up.
  25313. * @returns The physics imposter
  25314. */
  25315. wakeUp(): PhysicsImpostor;
  25316. /**
  25317. * Clones the physics imposter
  25318. * @param newObject The physics imposter clones to this physics-enabled object
  25319. * @returns A nullable physics imposter
  25320. */
  25321. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25322. /**
  25323. * Disposes the physics imposter
  25324. */
  25325. dispose(): void;
  25326. /**
  25327. * Sets the delta position
  25328. * @param position The delta position amount
  25329. */
  25330. setDeltaPosition(position: Vector3): void;
  25331. /**
  25332. * Sets the delta rotation
  25333. * @param rotation The delta rotation amount
  25334. */
  25335. setDeltaRotation(rotation: Quaternion): void;
  25336. /**
  25337. * Gets the box size of the physics imposter and stores the result in the input parameter
  25338. * @param result Stores the box size
  25339. * @returns The physics imposter
  25340. */
  25341. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25342. /**
  25343. * Gets the radius of the physics imposter
  25344. * @returns Radius of the physics imposter
  25345. */
  25346. getRadius(): number;
  25347. /**
  25348. * Sync a bone with this impostor
  25349. * @param bone The bone to sync to the impostor.
  25350. * @param boneMesh The mesh that the bone is influencing.
  25351. * @param jointPivot The pivot of the joint / bone in local space.
  25352. * @param distToJoint Optional distance from the impostor to the joint.
  25353. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25354. */
  25355. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25356. /**
  25357. * Sync impostor to a bone
  25358. * @param bone The bone that the impostor will be synced to.
  25359. * @param boneMesh The mesh that the bone is influencing.
  25360. * @param jointPivot The pivot of the joint / bone in local space.
  25361. * @param distToJoint Optional distance from the impostor to the joint.
  25362. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25363. * @param boneAxis Optional vector3 axis the bone is aligned with
  25364. */
  25365. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25366. /**
  25367. * No-Imposter type
  25368. */
  25369. static NoImpostor: number;
  25370. /**
  25371. * Sphere-Imposter type
  25372. */
  25373. static SphereImpostor: number;
  25374. /**
  25375. * Box-Imposter type
  25376. */
  25377. static BoxImpostor: number;
  25378. /**
  25379. * Plane-Imposter type
  25380. */
  25381. static PlaneImpostor: number;
  25382. /**
  25383. * Mesh-imposter type
  25384. */
  25385. static MeshImpostor: number;
  25386. /**
  25387. * Capsule-Impostor type (Ammo.js plugin only)
  25388. */
  25389. static CapsuleImpostor: number;
  25390. /**
  25391. * Cylinder-Imposter type
  25392. */
  25393. static CylinderImpostor: number;
  25394. /**
  25395. * Particle-Imposter type
  25396. */
  25397. static ParticleImpostor: number;
  25398. /**
  25399. * Heightmap-Imposter type
  25400. */
  25401. static HeightmapImpostor: number;
  25402. /**
  25403. * ConvexHull-Impostor type (Ammo.js plugin only)
  25404. */
  25405. static ConvexHullImpostor: number;
  25406. /**
  25407. * Custom-Imposter type (Ammo.js plugin only)
  25408. */
  25409. static CustomImpostor: number;
  25410. /**
  25411. * Rope-Imposter type
  25412. */
  25413. static RopeImpostor: number;
  25414. /**
  25415. * Cloth-Imposter type
  25416. */
  25417. static ClothImpostor: number;
  25418. /**
  25419. * Softbody-Imposter type
  25420. */
  25421. static SoftbodyImpostor: number;
  25422. }
  25423. }
  25424. declare module "babylonjs/Meshes/mesh" {
  25425. import { Observable } from "babylonjs/Misc/observable";
  25426. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25427. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25428. import { Camera } from "babylonjs/Cameras/camera";
  25429. import { Scene } from "babylonjs/scene";
  25430. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25431. import { Color4 } from "babylonjs/Maths/math.color";
  25432. import { Engine } from "babylonjs/Engines/engine";
  25433. import { Node } from "babylonjs/node";
  25434. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25435. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25436. import { Buffer } from "babylonjs/Meshes/buffer";
  25437. import { Geometry } from "babylonjs/Meshes/geometry";
  25438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25439. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25440. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25441. import { Effect } from "babylonjs/Materials/effect";
  25442. import { Material } from "babylonjs/Materials/material";
  25443. import { Skeleton } from "babylonjs/Bones/skeleton";
  25444. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25445. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25446. import { Path3D } from "babylonjs/Maths/math.path";
  25447. import { Plane } from "babylonjs/Maths/math.plane";
  25448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25449. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25450. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25451. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25452. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25453. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25454. /**
  25455. * @hidden
  25456. **/
  25457. export class _CreationDataStorage {
  25458. closePath?: boolean;
  25459. closeArray?: boolean;
  25460. idx: number[];
  25461. dashSize: number;
  25462. gapSize: number;
  25463. path3D: Path3D;
  25464. pathArray: Vector3[][];
  25465. arc: number;
  25466. radius: number;
  25467. cap: number;
  25468. tessellation: number;
  25469. }
  25470. /**
  25471. * @hidden
  25472. **/
  25473. class _InstanceDataStorage {
  25474. visibleInstances: any;
  25475. batchCache: _InstancesBatch;
  25476. instancesBufferSize: number;
  25477. instancesBuffer: Nullable<Buffer>;
  25478. instancesData: Float32Array;
  25479. overridenInstanceCount: number;
  25480. isFrozen: boolean;
  25481. previousBatch: Nullable<_InstancesBatch>;
  25482. hardwareInstancedRendering: boolean;
  25483. sideOrientation: number;
  25484. manualUpdate: boolean;
  25485. }
  25486. /**
  25487. * @hidden
  25488. **/
  25489. export class _InstancesBatch {
  25490. mustReturn: boolean;
  25491. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25492. renderSelf: boolean[];
  25493. hardwareInstancedRendering: boolean[];
  25494. }
  25495. /**
  25496. * Class used to represent renderable models
  25497. */
  25498. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25499. /**
  25500. * Mesh side orientation : usually the external or front surface
  25501. */
  25502. static readonly FRONTSIDE: number;
  25503. /**
  25504. * Mesh side orientation : usually the internal or back surface
  25505. */
  25506. static readonly BACKSIDE: number;
  25507. /**
  25508. * Mesh side orientation : both internal and external or front and back surfaces
  25509. */
  25510. static readonly DOUBLESIDE: number;
  25511. /**
  25512. * Mesh side orientation : by default, `FRONTSIDE`
  25513. */
  25514. static readonly DEFAULTSIDE: number;
  25515. /**
  25516. * Mesh cap setting : no cap
  25517. */
  25518. static readonly NO_CAP: number;
  25519. /**
  25520. * Mesh cap setting : one cap at the beginning of the mesh
  25521. */
  25522. static readonly CAP_START: number;
  25523. /**
  25524. * Mesh cap setting : one cap at the end of the mesh
  25525. */
  25526. static readonly CAP_END: number;
  25527. /**
  25528. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25529. */
  25530. static readonly CAP_ALL: number;
  25531. /**
  25532. * Mesh pattern setting : no flip or rotate
  25533. */
  25534. static readonly NO_FLIP: number;
  25535. /**
  25536. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25537. */
  25538. static readonly FLIP_TILE: number;
  25539. /**
  25540. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25541. */
  25542. static readonly ROTATE_TILE: number;
  25543. /**
  25544. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25545. */
  25546. static readonly FLIP_ROW: number;
  25547. /**
  25548. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25549. */
  25550. static readonly ROTATE_ROW: number;
  25551. /**
  25552. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25553. */
  25554. static readonly FLIP_N_ROTATE_TILE: number;
  25555. /**
  25556. * Mesh pattern setting : rotate pattern and rotate
  25557. */
  25558. static readonly FLIP_N_ROTATE_ROW: number;
  25559. /**
  25560. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25561. */
  25562. static readonly CENTER: number;
  25563. /**
  25564. * Mesh tile positioning : part tiles on left
  25565. */
  25566. static readonly LEFT: number;
  25567. /**
  25568. * Mesh tile positioning : part tiles on right
  25569. */
  25570. static readonly RIGHT: number;
  25571. /**
  25572. * Mesh tile positioning : part tiles on top
  25573. */
  25574. static readonly TOP: number;
  25575. /**
  25576. * Mesh tile positioning : part tiles on bottom
  25577. */
  25578. static readonly BOTTOM: number;
  25579. /**
  25580. * Gets the default side orientation.
  25581. * @param orientation the orientation to value to attempt to get
  25582. * @returns the default orientation
  25583. * @hidden
  25584. */
  25585. static _GetDefaultSideOrientation(orientation?: number): number;
  25586. private _internalMeshDataInfo;
  25587. /**
  25588. * An event triggered before rendering the mesh
  25589. */
  25590. get onBeforeRenderObservable(): Observable<Mesh>;
  25591. /**
  25592. * An event triggered before binding the mesh
  25593. */
  25594. get onBeforeBindObservable(): Observable<Mesh>;
  25595. /**
  25596. * An event triggered after rendering the mesh
  25597. */
  25598. get onAfterRenderObservable(): Observable<Mesh>;
  25599. /**
  25600. * An event triggered before drawing the mesh
  25601. */
  25602. get onBeforeDrawObservable(): Observable<Mesh>;
  25603. private _onBeforeDrawObserver;
  25604. /**
  25605. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25606. */
  25607. set onBeforeDraw(callback: () => void);
  25608. get hasInstances(): boolean;
  25609. /**
  25610. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25611. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25612. */
  25613. delayLoadState: number;
  25614. /**
  25615. * Gets the list of instances created from this mesh
  25616. * it is not supposed to be modified manually.
  25617. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25618. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25619. */
  25620. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25621. /**
  25622. * Gets the file containing delay loading data for this mesh
  25623. */
  25624. delayLoadingFile: string;
  25625. /** @hidden */
  25626. _binaryInfo: any;
  25627. /**
  25628. * User defined function used to change how LOD level selection is done
  25629. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25630. */
  25631. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25632. /**
  25633. * Gets or sets the morph target manager
  25634. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25635. */
  25636. get morphTargetManager(): Nullable<MorphTargetManager>;
  25637. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25638. /** @hidden */
  25639. _creationDataStorage: Nullable<_CreationDataStorage>;
  25640. /** @hidden */
  25641. _geometry: Nullable<Geometry>;
  25642. /** @hidden */
  25643. _delayInfo: Array<string>;
  25644. /** @hidden */
  25645. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25646. /** @hidden */
  25647. _instanceDataStorage: _InstanceDataStorage;
  25648. private _effectiveMaterial;
  25649. /** @hidden */
  25650. _shouldGenerateFlatShading: boolean;
  25651. /** @hidden */
  25652. _originalBuilderSideOrientation: number;
  25653. /**
  25654. * Use this property to change the original side orientation defined at construction time
  25655. */
  25656. overrideMaterialSideOrientation: Nullable<number>;
  25657. /**
  25658. * Gets the source mesh (the one used to clone this one from)
  25659. */
  25660. get source(): Nullable<Mesh>;
  25661. /**
  25662. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25663. */
  25664. get isUnIndexed(): boolean;
  25665. set isUnIndexed(value: boolean);
  25666. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25667. get worldMatrixInstancedBuffer(): Float32Array;
  25668. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25669. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25670. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25671. /**
  25672. * @constructor
  25673. * @param name The value used by scene.getMeshByName() to do a lookup.
  25674. * @param scene The scene to add this mesh to.
  25675. * @param parent The parent of this mesh, if it has one
  25676. * @param source An optional Mesh from which geometry is shared, cloned.
  25677. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25678. * When false, achieved by calling a clone(), also passing False.
  25679. * This will make creation of children, recursive.
  25680. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25681. */
  25682. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25683. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25684. doNotInstantiate: boolean;
  25685. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25686. /**
  25687. * Gets the class name
  25688. * @returns the string "Mesh".
  25689. */
  25690. getClassName(): string;
  25691. /** @hidden */
  25692. get _isMesh(): boolean;
  25693. /**
  25694. * Returns a description of this mesh
  25695. * @param fullDetails define if full details about this mesh must be used
  25696. * @returns a descriptive string representing this mesh
  25697. */
  25698. toString(fullDetails?: boolean): string;
  25699. /** @hidden */
  25700. _unBindEffect(): void;
  25701. /**
  25702. * Gets a boolean indicating if this mesh has LOD
  25703. */
  25704. get hasLODLevels(): boolean;
  25705. /**
  25706. * Gets the list of MeshLODLevel associated with the current mesh
  25707. * @returns an array of MeshLODLevel
  25708. */
  25709. getLODLevels(): MeshLODLevel[];
  25710. private _sortLODLevels;
  25711. /**
  25712. * Add a mesh as LOD level triggered at the given distance.
  25713. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25714. * @param distance The distance from the center of the object to show this level
  25715. * @param mesh The mesh to be added as LOD level (can be null)
  25716. * @return This mesh (for chaining)
  25717. */
  25718. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25719. /**
  25720. * Returns the LOD level mesh at the passed distance or null if not found.
  25721. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25722. * @param distance The distance from the center of the object to show this level
  25723. * @returns a Mesh or `null`
  25724. */
  25725. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25726. /**
  25727. * Remove a mesh from the LOD array
  25728. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25729. * @param mesh defines the mesh to be removed
  25730. * @return This mesh (for chaining)
  25731. */
  25732. removeLODLevel(mesh: Mesh): Mesh;
  25733. /**
  25734. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25735. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25736. * @param camera defines the camera to use to compute distance
  25737. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25738. * @return This mesh (for chaining)
  25739. */
  25740. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25741. /**
  25742. * Gets the mesh internal Geometry object
  25743. */
  25744. get geometry(): Nullable<Geometry>;
  25745. /**
  25746. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25747. * @returns the total number of vertices
  25748. */
  25749. getTotalVertices(): number;
  25750. /**
  25751. * Returns the content of an associated vertex buffer
  25752. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25753. * - VertexBuffer.PositionKind
  25754. * - VertexBuffer.UVKind
  25755. * - VertexBuffer.UV2Kind
  25756. * - VertexBuffer.UV3Kind
  25757. * - VertexBuffer.UV4Kind
  25758. * - VertexBuffer.UV5Kind
  25759. * - VertexBuffer.UV6Kind
  25760. * - VertexBuffer.ColorKind
  25761. * - VertexBuffer.MatricesIndicesKind
  25762. * - VertexBuffer.MatricesIndicesExtraKind
  25763. * - VertexBuffer.MatricesWeightsKind
  25764. * - VertexBuffer.MatricesWeightsExtraKind
  25765. * @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
  25766. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25767. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25768. */
  25769. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25770. /**
  25771. * Returns the mesh VertexBuffer object from the requested `kind`
  25772. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25773. * - VertexBuffer.PositionKind
  25774. * - VertexBuffer.NormalKind
  25775. * - VertexBuffer.UVKind
  25776. * - VertexBuffer.UV2Kind
  25777. * - VertexBuffer.UV3Kind
  25778. * - VertexBuffer.UV4Kind
  25779. * - VertexBuffer.UV5Kind
  25780. * - VertexBuffer.UV6Kind
  25781. * - VertexBuffer.ColorKind
  25782. * - VertexBuffer.MatricesIndicesKind
  25783. * - VertexBuffer.MatricesIndicesExtraKind
  25784. * - VertexBuffer.MatricesWeightsKind
  25785. * - VertexBuffer.MatricesWeightsExtraKind
  25786. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25787. */
  25788. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25789. /**
  25790. * Tests if a specific vertex buffer is associated with this mesh
  25791. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25792. * - VertexBuffer.PositionKind
  25793. * - VertexBuffer.NormalKind
  25794. * - VertexBuffer.UVKind
  25795. * - VertexBuffer.UV2Kind
  25796. * - VertexBuffer.UV3Kind
  25797. * - VertexBuffer.UV4Kind
  25798. * - VertexBuffer.UV5Kind
  25799. * - VertexBuffer.UV6Kind
  25800. * - VertexBuffer.ColorKind
  25801. * - VertexBuffer.MatricesIndicesKind
  25802. * - VertexBuffer.MatricesIndicesExtraKind
  25803. * - VertexBuffer.MatricesWeightsKind
  25804. * - VertexBuffer.MatricesWeightsExtraKind
  25805. * @returns a boolean
  25806. */
  25807. isVerticesDataPresent(kind: string): boolean;
  25808. /**
  25809. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25810. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25811. * - VertexBuffer.PositionKind
  25812. * - VertexBuffer.UVKind
  25813. * - VertexBuffer.UV2Kind
  25814. * - VertexBuffer.UV3Kind
  25815. * - VertexBuffer.UV4Kind
  25816. * - VertexBuffer.UV5Kind
  25817. * - VertexBuffer.UV6Kind
  25818. * - VertexBuffer.ColorKind
  25819. * - VertexBuffer.MatricesIndicesKind
  25820. * - VertexBuffer.MatricesIndicesExtraKind
  25821. * - VertexBuffer.MatricesWeightsKind
  25822. * - VertexBuffer.MatricesWeightsExtraKind
  25823. * @returns a boolean
  25824. */
  25825. isVertexBufferUpdatable(kind: string): boolean;
  25826. /**
  25827. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25828. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25829. * - VertexBuffer.PositionKind
  25830. * - VertexBuffer.NormalKind
  25831. * - VertexBuffer.UVKind
  25832. * - VertexBuffer.UV2Kind
  25833. * - VertexBuffer.UV3Kind
  25834. * - VertexBuffer.UV4Kind
  25835. * - VertexBuffer.UV5Kind
  25836. * - VertexBuffer.UV6Kind
  25837. * - VertexBuffer.ColorKind
  25838. * - VertexBuffer.MatricesIndicesKind
  25839. * - VertexBuffer.MatricesIndicesExtraKind
  25840. * - VertexBuffer.MatricesWeightsKind
  25841. * - VertexBuffer.MatricesWeightsExtraKind
  25842. * @returns an array of strings
  25843. */
  25844. getVerticesDataKinds(): string[];
  25845. /**
  25846. * Returns a positive integer : the total number of indices in this mesh geometry.
  25847. * @returns the numner of indices or zero if the mesh has no geometry.
  25848. */
  25849. getTotalIndices(): number;
  25850. /**
  25851. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25852. * @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.
  25853. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25854. * @returns the indices array or an empty array if the mesh has no geometry
  25855. */
  25856. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25857. get isBlocked(): boolean;
  25858. /**
  25859. * Determine if the current mesh is ready to be rendered
  25860. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25861. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25862. * @returns true if all associated assets are ready (material, textures, shaders)
  25863. */
  25864. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25865. /**
  25866. * 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.
  25867. */
  25868. get areNormalsFrozen(): boolean;
  25869. /**
  25870. * 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.
  25871. * @returns the current mesh
  25872. */
  25873. freezeNormals(): Mesh;
  25874. /**
  25875. * 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
  25876. * @returns the current mesh
  25877. */
  25878. unfreezeNormals(): Mesh;
  25879. /**
  25880. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25881. */
  25882. set overridenInstanceCount(count: number);
  25883. /** @hidden */
  25884. _preActivate(): Mesh;
  25885. /** @hidden */
  25886. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25887. /** @hidden */
  25888. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25889. /**
  25890. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25891. * This means the mesh underlying bounding box and sphere are recomputed.
  25892. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25893. * @returns the current mesh
  25894. */
  25895. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25896. /** @hidden */
  25897. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25898. /**
  25899. * This function will subdivide the mesh into multiple submeshes
  25900. * @param count defines the expected number of submeshes
  25901. */
  25902. subdivide(count: number): void;
  25903. /**
  25904. * Copy a FloatArray into a specific associated vertex buffer
  25905. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25906. * - VertexBuffer.PositionKind
  25907. * - VertexBuffer.UVKind
  25908. * - VertexBuffer.UV2Kind
  25909. * - VertexBuffer.UV3Kind
  25910. * - VertexBuffer.UV4Kind
  25911. * - VertexBuffer.UV5Kind
  25912. * - VertexBuffer.UV6Kind
  25913. * - VertexBuffer.ColorKind
  25914. * - VertexBuffer.MatricesIndicesKind
  25915. * - VertexBuffer.MatricesIndicesExtraKind
  25916. * - VertexBuffer.MatricesWeightsKind
  25917. * - VertexBuffer.MatricesWeightsExtraKind
  25918. * @param data defines the data source
  25919. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25920. * @param stride defines the data stride size (can be null)
  25921. * @returns the current mesh
  25922. */
  25923. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25924. /**
  25925. * Delete a vertex buffer associated with this mesh
  25926. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25927. * - VertexBuffer.PositionKind
  25928. * - VertexBuffer.UVKind
  25929. * - VertexBuffer.UV2Kind
  25930. * - VertexBuffer.UV3Kind
  25931. * - VertexBuffer.UV4Kind
  25932. * - VertexBuffer.UV5Kind
  25933. * - VertexBuffer.UV6Kind
  25934. * - VertexBuffer.ColorKind
  25935. * - VertexBuffer.MatricesIndicesKind
  25936. * - VertexBuffer.MatricesIndicesExtraKind
  25937. * - VertexBuffer.MatricesWeightsKind
  25938. * - VertexBuffer.MatricesWeightsExtraKind
  25939. */
  25940. removeVerticesData(kind: string): void;
  25941. /**
  25942. * Flags an associated vertex buffer as updatable
  25943. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25944. * - VertexBuffer.PositionKind
  25945. * - VertexBuffer.UVKind
  25946. * - VertexBuffer.UV2Kind
  25947. * - VertexBuffer.UV3Kind
  25948. * - VertexBuffer.UV4Kind
  25949. * - VertexBuffer.UV5Kind
  25950. * - VertexBuffer.UV6Kind
  25951. * - VertexBuffer.ColorKind
  25952. * - VertexBuffer.MatricesIndicesKind
  25953. * - VertexBuffer.MatricesIndicesExtraKind
  25954. * - VertexBuffer.MatricesWeightsKind
  25955. * - VertexBuffer.MatricesWeightsExtraKind
  25956. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25957. */
  25958. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25959. /**
  25960. * Sets the mesh global Vertex Buffer
  25961. * @param buffer defines the buffer to use
  25962. * @returns the current mesh
  25963. */
  25964. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25965. /**
  25966. * Update a specific associated vertex buffer
  25967. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25968. * - VertexBuffer.PositionKind
  25969. * - VertexBuffer.UVKind
  25970. * - VertexBuffer.UV2Kind
  25971. * - VertexBuffer.UV3Kind
  25972. * - VertexBuffer.UV4Kind
  25973. * - VertexBuffer.UV5Kind
  25974. * - VertexBuffer.UV6Kind
  25975. * - VertexBuffer.ColorKind
  25976. * - VertexBuffer.MatricesIndicesKind
  25977. * - VertexBuffer.MatricesIndicesExtraKind
  25978. * - VertexBuffer.MatricesWeightsKind
  25979. * - VertexBuffer.MatricesWeightsExtraKind
  25980. * @param data defines the data source
  25981. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25982. * @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)
  25983. * @returns the current mesh
  25984. */
  25985. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25986. /**
  25987. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25988. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25989. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25990. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25991. * @returns the current mesh
  25992. */
  25993. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25994. /**
  25995. * Creates a un-shared specific occurence of the geometry for the mesh.
  25996. * @returns the current mesh
  25997. */
  25998. makeGeometryUnique(): Mesh;
  25999. /**
  26000. * Set the index buffer of this mesh
  26001. * @param indices defines the source data
  26002. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26003. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26004. * @returns the current mesh
  26005. */
  26006. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  26007. /**
  26008. * Update the current index buffer
  26009. * @param indices defines the source data
  26010. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26011. * @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)
  26012. * @returns the current mesh
  26013. */
  26014. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26015. /**
  26016. * Invert the geometry to move from a right handed system to a left handed one.
  26017. * @returns the current mesh
  26018. */
  26019. toLeftHanded(): Mesh;
  26020. /** @hidden */
  26021. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26022. /** @hidden */
  26023. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  26024. /**
  26025. * Registers for this mesh a javascript function called just before the rendering process
  26026. * @param func defines the function to call before rendering this mesh
  26027. * @returns the current mesh
  26028. */
  26029. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26030. /**
  26031. * Disposes a previously registered javascript function called before the rendering
  26032. * @param func defines the function to remove
  26033. * @returns the current mesh
  26034. */
  26035. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26036. /**
  26037. * Registers for this mesh a javascript function called just after the rendering is complete
  26038. * @param func defines the function to call after rendering this mesh
  26039. * @returns the current mesh
  26040. */
  26041. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26042. /**
  26043. * Disposes a previously registered javascript function called after the rendering.
  26044. * @param func defines the function to remove
  26045. * @returns the current mesh
  26046. */
  26047. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26048. /** @hidden */
  26049. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  26050. /** @hidden */
  26051. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26052. /** @hidden */
  26053. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  26054. /** @hidden */
  26055. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26056. /** @hidden */
  26057. _rebuild(): void;
  26058. /** @hidden */
  26059. _freeze(): void;
  26060. /** @hidden */
  26061. _unFreeze(): void;
  26062. /**
  26063. * 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
  26064. * @param subMesh defines the subMesh to render
  26065. * @param enableAlphaMode defines if alpha mode can be changed
  26066. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  26067. * @returns the current mesh
  26068. */
  26069. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  26070. private _onBeforeDraw;
  26071. /**
  26072. * Renormalize the mesh and patch it up if there are no weights
  26073. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26074. * However in the case of zero weights then we set just a single influence to 1.
  26075. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26076. */
  26077. cleanMatrixWeights(): void;
  26078. private normalizeSkinFourWeights;
  26079. private normalizeSkinWeightsAndExtra;
  26080. /**
  26081. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26082. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26083. * the user know there was an issue with importing the mesh
  26084. * @returns a validation object with skinned, valid and report string
  26085. */
  26086. validateSkinning(): {
  26087. skinned: boolean;
  26088. valid: boolean;
  26089. report: string;
  26090. };
  26091. /** @hidden */
  26092. _checkDelayState(): Mesh;
  26093. private _queueLoad;
  26094. /**
  26095. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26096. * A mesh is in the frustum if its bounding box intersects the frustum
  26097. * @param frustumPlanes defines the frustum to test
  26098. * @returns true if the mesh is in the frustum planes
  26099. */
  26100. isInFrustum(frustumPlanes: Plane[]): boolean;
  26101. /**
  26102. * Sets the mesh material by the material or multiMaterial `id` property
  26103. * @param id is a string identifying the material or the multiMaterial
  26104. * @returns the current mesh
  26105. */
  26106. setMaterialByID(id: string): Mesh;
  26107. /**
  26108. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26109. * @returns an array of IAnimatable
  26110. */
  26111. getAnimatables(): IAnimatable[];
  26112. /**
  26113. * Modifies the mesh geometry according to the passed transformation matrix.
  26114. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26115. * The mesh normals are modified using the same transformation.
  26116. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26117. * @param transform defines the transform matrix to use
  26118. * @see http://doc.babylonjs.com/resources/baking_transformations
  26119. * @returns the current mesh
  26120. */
  26121. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26122. /**
  26123. * Modifies the mesh geometry according to its own current World Matrix.
  26124. * The mesh World Matrix is then reset.
  26125. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26126. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26127. * @see http://doc.babylonjs.com/resources/baking_transformations
  26128. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  26129. * @returns the current mesh
  26130. */
  26131. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  26132. /** @hidden */
  26133. get _positions(): Nullable<Vector3[]>;
  26134. /** @hidden */
  26135. _resetPointsArrayCache(): Mesh;
  26136. /** @hidden */
  26137. _generatePointsArray(): boolean;
  26138. /**
  26139. * Returns a new Mesh object generated from the current mesh properties.
  26140. * This method must not get confused with createInstance()
  26141. * @param name is a string, the name given to the new mesh
  26142. * @param newParent can be any Node object (default `null`)
  26143. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26144. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26145. * @returns a new mesh
  26146. */
  26147. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26148. /**
  26149. * Releases resources associated with this mesh.
  26150. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26151. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26152. */
  26153. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26154. /** @hidden */
  26155. _disposeInstanceSpecificData(): void;
  26156. /**
  26157. * Modifies the mesh geometry according to a displacement map.
  26158. * 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.
  26159. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26160. * @param url is a string, the URL from the image file is to be downloaded.
  26161. * @param minHeight is the lower limit of the displacement.
  26162. * @param maxHeight is the upper limit of the displacement.
  26163. * @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.
  26164. * @param uvOffset is an optional vector2 used to offset UV.
  26165. * @param uvScale is an optional vector2 used to scale UV.
  26166. * @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.
  26167. * @returns the Mesh.
  26168. */
  26169. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26170. /**
  26171. * Modifies the mesh geometry according to a displacementMap buffer.
  26172. * 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.
  26173. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26174. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26175. * @param heightMapWidth is the width of the buffer image.
  26176. * @param heightMapHeight is the height of the buffer image.
  26177. * @param minHeight is the lower limit of the displacement.
  26178. * @param maxHeight is the upper limit of the displacement.
  26179. * @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.
  26180. * @param uvOffset is an optional vector2 used to offset UV.
  26181. * @param uvScale is an optional vector2 used to scale UV.
  26182. * @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.
  26183. * @returns the Mesh.
  26184. */
  26185. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26186. /**
  26187. * Modify the mesh to get a flat shading rendering.
  26188. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26189. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26190. * @returns current mesh
  26191. */
  26192. convertToFlatShadedMesh(): Mesh;
  26193. /**
  26194. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26195. * In other words, more vertices, no more indices and a single bigger VBO.
  26196. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26197. * @returns current mesh
  26198. */
  26199. convertToUnIndexedMesh(): Mesh;
  26200. /**
  26201. * Inverses facet orientations.
  26202. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26203. * @param flipNormals will also inverts the normals
  26204. * @returns current mesh
  26205. */
  26206. flipFaces(flipNormals?: boolean): Mesh;
  26207. /**
  26208. * Increase the number of facets and hence vertices in a mesh
  26209. * Vertex normals are interpolated from existing vertex normals
  26210. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26211. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  26212. */
  26213. increaseVertices(numberPerEdge: number): void;
  26214. /**
  26215. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  26216. * This will undo any application of covertToFlatShadedMesh
  26217. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26218. */
  26219. forceSharedVertices(): void;
  26220. /** @hidden */
  26221. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  26222. /** @hidden */
  26223. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  26224. /**
  26225. * Creates a new InstancedMesh object from the mesh model.
  26226. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26227. * @param name defines the name of the new instance
  26228. * @returns a new InstancedMesh
  26229. */
  26230. createInstance(name: string): InstancedMesh;
  26231. /**
  26232. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26233. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26234. * @returns the current mesh
  26235. */
  26236. synchronizeInstances(): Mesh;
  26237. /**
  26238. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26239. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26240. * This should be used together with the simplification to avoid disappearing triangles.
  26241. * @param successCallback an optional success callback to be called after the optimization finished.
  26242. * @returns the current mesh
  26243. */
  26244. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26245. /**
  26246. * Serialize current mesh
  26247. * @param serializationObject defines the object which will receive the serialization data
  26248. */
  26249. serialize(serializationObject: any): void;
  26250. /** @hidden */
  26251. _syncGeometryWithMorphTargetManager(): void;
  26252. /** @hidden */
  26253. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26254. /**
  26255. * Returns a new Mesh object parsed from the source provided.
  26256. * @param parsedMesh is the source
  26257. * @param scene defines the hosting scene
  26258. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26259. * @returns a new Mesh
  26260. */
  26261. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26262. /**
  26263. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26264. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26265. * @param name defines the name of the mesh to create
  26266. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26267. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26268. * @param closePath creates a seam between the first and the last points of each path of the path array
  26269. * @param offset is taken in account only if the `pathArray` is containing a single path
  26270. * @param scene defines the hosting scene
  26271. * @param updatable defines if the mesh must be flagged as updatable
  26272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26273. * @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)
  26274. * @returns a new Mesh
  26275. */
  26276. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26277. /**
  26278. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26279. * @param name defines the name of the mesh to create
  26280. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26281. * @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
  26282. * @param scene defines the hosting scene
  26283. * @param updatable defines if the mesh must be flagged as updatable
  26284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26285. * @returns a new Mesh
  26286. */
  26287. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26288. /**
  26289. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26290. * @param name defines the name of the mesh to create
  26291. * @param size sets the size (float) of each box side (default 1)
  26292. * @param scene defines the hosting scene
  26293. * @param updatable defines if the mesh must be flagged as updatable
  26294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26295. * @returns a new Mesh
  26296. */
  26297. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26298. /**
  26299. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26300. * @param name defines the name of the mesh to create
  26301. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26302. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26303. * @param scene defines the hosting scene
  26304. * @param updatable defines if the mesh must be flagged as updatable
  26305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26306. * @returns a new Mesh
  26307. */
  26308. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26309. /**
  26310. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26311. * @param name defines the name of the mesh to create
  26312. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26313. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26314. * @param scene defines the hosting scene
  26315. * @returns a new Mesh
  26316. */
  26317. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26318. /**
  26319. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26320. * @param name defines the name of the mesh to create
  26321. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26322. * @param diameterTop set the top cap diameter (floats, default 1)
  26323. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26324. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26325. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26326. * @param scene defines the hosting scene
  26327. * @param updatable defines if the mesh must be flagged as updatable
  26328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26329. * @returns a new Mesh
  26330. */
  26331. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26332. /**
  26333. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26334. * @param name defines the name of the mesh to create
  26335. * @param diameter sets the diameter size (float) of the torus (default 1)
  26336. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26337. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26338. * @param scene defines the hosting scene
  26339. * @param updatable defines if the mesh must be flagged as updatable
  26340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26341. * @returns a new Mesh
  26342. */
  26343. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26344. /**
  26345. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26346. * @param name defines the name of the mesh to create
  26347. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26348. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26349. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26350. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26351. * @param p the number of windings on X axis (positive integers, default 2)
  26352. * @param q the number of windings on Y axis (positive integers, default 3)
  26353. * @param scene defines the hosting scene
  26354. * @param updatable defines if the mesh must be flagged as updatable
  26355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26356. * @returns a new Mesh
  26357. */
  26358. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26359. /**
  26360. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26361. * @param name defines the name of the mesh to create
  26362. * @param points is an array successive Vector3
  26363. * @param scene defines the hosting scene
  26364. * @param updatable defines if the mesh must be flagged as updatable
  26365. * @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).
  26366. * @returns a new Mesh
  26367. */
  26368. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26369. /**
  26370. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26371. * @param name defines the name of the mesh to create
  26372. * @param points is an array successive Vector3
  26373. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26374. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26375. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26376. * @param scene defines the hosting scene
  26377. * @param updatable defines if the mesh must be flagged as updatable
  26378. * @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)
  26379. * @returns a new Mesh
  26380. */
  26381. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26382. /**
  26383. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26384. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26385. * 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.
  26386. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26387. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26388. * Remember you can only change the shape positions, not their number when updating a polygon.
  26389. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26390. * @param name defines the name of the mesh to create
  26391. * @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
  26392. * @param scene defines the hosting scene
  26393. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26394. * @param updatable defines if the mesh must be flagged as updatable
  26395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26396. * @param earcutInjection can be used to inject your own earcut reference
  26397. * @returns a new Mesh
  26398. */
  26399. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26400. /**
  26401. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26402. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26403. * @param name defines the name of the mesh to create
  26404. * @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
  26405. * @param depth defines the height of extrusion
  26406. * @param scene defines the hosting scene
  26407. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26408. * @param updatable defines if the mesh must be flagged as updatable
  26409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26410. * @param earcutInjection can be used to inject your own earcut reference
  26411. * @returns a new Mesh
  26412. */
  26413. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26414. /**
  26415. * Creates an extruded shape mesh.
  26416. * 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
  26417. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26418. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26419. * @param name defines the name of the mesh to create
  26420. * @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
  26421. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26422. * @param scale is the value to scale the shape
  26423. * @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
  26424. * @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
  26425. * @param scene defines the hosting scene
  26426. * @param updatable defines if the mesh must be flagged as updatable
  26427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26428. * @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)
  26429. * @returns a new Mesh
  26430. */
  26431. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26432. /**
  26433. * Creates an custom extruded shape mesh.
  26434. * The custom extrusion is a parametric shape.
  26435. * It has no predefined shape. Its final shape will depend on the input parameters.
  26436. * Please consider using the same method from the MeshBuilder class instead
  26437. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26438. * @param name defines the name of the mesh to create
  26439. * @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
  26440. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26441. * @param scaleFunction is a custom Javascript function called on each path point
  26442. * @param rotationFunction is a custom Javascript function called on each path point
  26443. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26444. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26445. * @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
  26446. * @param scene defines the hosting scene
  26447. * @param updatable defines if the mesh must be flagged as updatable
  26448. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26449. * @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)
  26450. * @returns a new Mesh
  26451. */
  26452. 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;
  26453. /**
  26454. * Creates lathe mesh.
  26455. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26456. * Please consider using the same method from the MeshBuilder class instead
  26457. * @param name defines the name of the mesh to create
  26458. * @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
  26459. * @param radius is the radius value of the lathe
  26460. * @param tessellation is the side number of the lathe.
  26461. * @param scene defines the hosting scene
  26462. * @param updatable defines if the mesh must be flagged as updatable
  26463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26464. * @returns a new Mesh
  26465. */
  26466. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26467. /**
  26468. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26469. * @param name defines the name of the mesh to create
  26470. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26471. * @param scene defines the hosting scene
  26472. * @param updatable defines if the mesh must be flagged as updatable
  26473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26474. * @returns a new Mesh
  26475. */
  26476. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26477. /**
  26478. * Creates a ground mesh.
  26479. * Please consider using the same method from the MeshBuilder class instead
  26480. * @param name defines the name of the mesh to create
  26481. * @param width set the width of the ground
  26482. * @param height set the height of the ground
  26483. * @param subdivisions sets the number of subdivisions per side
  26484. * @param scene defines the hosting scene
  26485. * @param updatable defines if the mesh must be flagged as updatable
  26486. * @returns a new Mesh
  26487. */
  26488. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26489. /**
  26490. * Creates a tiled ground mesh.
  26491. * Please consider using the same method from the MeshBuilder class instead
  26492. * @param name defines the name of the mesh to create
  26493. * @param xmin set the ground minimum X coordinate
  26494. * @param zmin set the ground minimum Y coordinate
  26495. * @param xmax set the ground maximum X coordinate
  26496. * @param zmax set the ground maximum Z coordinate
  26497. * @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
  26498. * @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
  26499. * @param scene defines the hosting scene
  26500. * @param updatable defines if the mesh must be flagged as updatable
  26501. * @returns a new Mesh
  26502. */
  26503. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26504. w: number;
  26505. h: number;
  26506. }, precision: {
  26507. w: number;
  26508. h: number;
  26509. }, scene: Scene, updatable?: boolean): Mesh;
  26510. /**
  26511. * Creates a ground mesh from a height map.
  26512. * Please consider using the same method from the MeshBuilder class instead
  26513. * @see http://doc.babylonjs.com/babylon101/height_map
  26514. * @param name defines the name of the mesh to create
  26515. * @param url sets the URL of the height map image resource
  26516. * @param width set the ground width size
  26517. * @param height set the ground height size
  26518. * @param subdivisions sets the number of subdivision per side
  26519. * @param minHeight is the minimum altitude on the ground
  26520. * @param maxHeight is the maximum altitude on the ground
  26521. * @param scene defines the hosting scene
  26522. * @param updatable defines if the mesh must be flagged as updatable
  26523. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26524. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26525. * @returns a new Mesh
  26526. */
  26527. 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;
  26528. /**
  26529. * Creates a tube mesh.
  26530. * The tube is a parametric shape.
  26531. * It has no predefined shape. Its final shape will depend on the input parameters.
  26532. * Please consider using the same method from the MeshBuilder class instead
  26533. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26534. * @param name defines the name of the mesh to create
  26535. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26536. * @param radius sets the tube radius size
  26537. * @param tessellation is the number of sides on the tubular surface
  26538. * @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
  26539. * @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
  26540. * @param scene defines the hosting scene
  26541. * @param updatable defines if the mesh must be flagged as updatable
  26542. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26543. * @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)
  26544. * @returns a new Mesh
  26545. */
  26546. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26547. (i: number, distance: number): number;
  26548. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26549. /**
  26550. * Creates a polyhedron mesh.
  26551. * Please consider using the same method from the MeshBuilder class instead.
  26552. * * 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
  26553. * * The parameter `size` (positive float, default 1) sets the polygon size
  26554. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26555. * * 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`
  26556. * * 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
  26557. * * 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)`)
  26558. * * 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
  26559. * * 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
  26560. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26561. * * 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
  26562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26563. * @param name defines the name of the mesh to create
  26564. * @param options defines the options used to create the mesh
  26565. * @param scene defines the hosting scene
  26566. * @returns a new Mesh
  26567. */
  26568. static CreatePolyhedron(name: string, options: {
  26569. type?: number;
  26570. size?: number;
  26571. sizeX?: number;
  26572. sizeY?: number;
  26573. sizeZ?: number;
  26574. custom?: any;
  26575. faceUV?: Vector4[];
  26576. faceColors?: Color4[];
  26577. updatable?: boolean;
  26578. sideOrientation?: number;
  26579. }, scene: Scene): Mesh;
  26580. /**
  26581. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26582. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26583. * * 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`)
  26584. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26585. * * 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
  26586. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26587. * * 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
  26588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26589. * @param name defines the name of the mesh
  26590. * @param options defines the options used to create the mesh
  26591. * @param scene defines the hosting scene
  26592. * @returns a new Mesh
  26593. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26594. */
  26595. static CreateIcoSphere(name: string, options: {
  26596. radius?: number;
  26597. flat?: boolean;
  26598. subdivisions?: number;
  26599. sideOrientation?: number;
  26600. updatable?: boolean;
  26601. }, scene: Scene): Mesh;
  26602. /**
  26603. * Creates a decal mesh.
  26604. * Please consider using the same method from the MeshBuilder class instead.
  26605. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26606. * @param name defines the name of the mesh
  26607. * @param sourceMesh defines the mesh receiving the decal
  26608. * @param position sets the position of the decal in world coordinates
  26609. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26610. * @param size sets the decal scaling
  26611. * @param angle sets the angle to rotate the decal
  26612. * @returns a new Mesh
  26613. */
  26614. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26615. /**
  26616. * Prepare internal position array for software CPU skinning
  26617. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26618. */
  26619. setPositionsForCPUSkinning(): Float32Array;
  26620. /**
  26621. * Prepare internal normal array for software CPU skinning
  26622. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26623. */
  26624. setNormalsForCPUSkinning(): Float32Array;
  26625. /**
  26626. * Updates the vertex buffer by applying transformation from the bones
  26627. * @param skeleton defines the skeleton to apply to current mesh
  26628. * @returns the current mesh
  26629. */
  26630. applySkeleton(skeleton: Skeleton): Mesh;
  26631. /**
  26632. * 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
  26633. * @param meshes defines the list of meshes to scan
  26634. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26635. */
  26636. static MinMax(meshes: AbstractMesh[]): {
  26637. min: Vector3;
  26638. max: Vector3;
  26639. };
  26640. /**
  26641. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26642. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26643. * @returns a vector3
  26644. */
  26645. static Center(meshesOrMinMaxVector: {
  26646. min: Vector3;
  26647. max: Vector3;
  26648. } | AbstractMesh[]): Vector3;
  26649. /**
  26650. * Merge the array of meshes into a single mesh for performance reasons.
  26651. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26652. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26653. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26654. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26655. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26656. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26657. * @returns a new mesh
  26658. */
  26659. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26660. /** @hidden */
  26661. addInstance(instance: InstancedMesh): void;
  26662. /** @hidden */
  26663. removeInstance(instance: InstancedMesh): void;
  26664. }
  26665. }
  26666. declare module "babylonjs/Cameras/camera" {
  26667. import { SmartArray } from "babylonjs/Misc/smartArray";
  26668. import { Observable } from "babylonjs/Misc/observable";
  26669. import { Nullable } from "babylonjs/types";
  26670. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26671. import { Scene } from "babylonjs/scene";
  26672. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26673. import { Node } from "babylonjs/node";
  26674. import { Mesh } from "babylonjs/Meshes/mesh";
  26675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26676. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26677. import { Viewport } from "babylonjs/Maths/math.viewport";
  26678. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26679. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26680. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26681. import { Ray } from "babylonjs/Culling/ray";
  26682. /**
  26683. * This is the base class of all the camera used in the application.
  26684. * @see http://doc.babylonjs.com/features/cameras
  26685. */
  26686. export class Camera extends Node {
  26687. /** @hidden */
  26688. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26689. /**
  26690. * This is the default projection mode used by the cameras.
  26691. * It helps recreating a feeling of perspective and better appreciate depth.
  26692. * This is the best way to simulate real life cameras.
  26693. */
  26694. static readonly PERSPECTIVE_CAMERA: number;
  26695. /**
  26696. * This helps creating camera with an orthographic mode.
  26697. * 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.
  26698. */
  26699. static readonly ORTHOGRAPHIC_CAMERA: number;
  26700. /**
  26701. * This is the default FOV mode for perspective cameras.
  26702. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26703. */
  26704. static readonly FOVMODE_VERTICAL_FIXED: number;
  26705. /**
  26706. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26707. */
  26708. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26709. /**
  26710. * This specifies ther is no need for a camera rig.
  26711. * Basically only one eye is rendered corresponding to the camera.
  26712. */
  26713. static readonly RIG_MODE_NONE: number;
  26714. /**
  26715. * Simulates a camera Rig with one blue eye and one red eye.
  26716. * This can be use with 3d blue and red glasses.
  26717. */
  26718. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26719. /**
  26720. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26721. */
  26722. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26723. /**
  26724. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26725. */
  26726. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26727. /**
  26728. * Defines that both eyes of the camera will be rendered over under each other.
  26729. */
  26730. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26731. /**
  26732. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26733. */
  26734. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26735. /**
  26736. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26737. */
  26738. static readonly RIG_MODE_VR: number;
  26739. /**
  26740. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26741. */
  26742. static readonly RIG_MODE_WEBVR: number;
  26743. /**
  26744. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26745. */
  26746. static readonly RIG_MODE_CUSTOM: number;
  26747. /**
  26748. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26749. */
  26750. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26751. /**
  26752. * Define the input manager associated with the camera.
  26753. */
  26754. inputs: CameraInputsManager<Camera>;
  26755. /** @hidden */
  26756. _position: Vector3;
  26757. /**
  26758. * Define the current local position of the camera in the scene
  26759. */
  26760. get position(): Vector3;
  26761. set position(newPosition: Vector3);
  26762. /**
  26763. * The vector the camera should consider as up.
  26764. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26765. */
  26766. upVector: Vector3;
  26767. /**
  26768. * Define the current limit on the left side for an orthographic camera
  26769. * In scene unit
  26770. */
  26771. orthoLeft: Nullable<number>;
  26772. /**
  26773. * Define the current limit on the right side for an orthographic camera
  26774. * In scene unit
  26775. */
  26776. orthoRight: Nullable<number>;
  26777. /**
  26778. * Define the current limit on the bottom side for an orthographic camera
  26779. * In scene unit
  26780. */
  26781. orthoBottom: Nullable<number>;
  26782. /**
  26783. * Define the current limit on the top side for an orthographic camera
  26784. * In scene unit
  26785. */
  26786. orthoTop: Nullable<number>;
  26787. /**
  26788. * Field Of View is set in Radians. (default is 0.8)
  26789. */
  26790. fov: number;
  26791. /**
  26792. * Define the minimum distance the camera can see from.
  26793. * This is important to note that the depth buffer are not infinite and the closer it starts
  26794. * the more your scene might encounter depth fighting issue.
  26795. */
  26796. minZ: number;
  26797. /**
  26798. * Define the maximum distance the camera can see to.
  26799. * This is important to note that the depth buffer are not infinite and the further it end
  26800. * the more your scene might encounter depth fighting issue.
  26801. */
  26802. maxZ: number;
  26803. /**
  26804. * Define the default inertia of the camera.
  26805. * This helps giving a smooth feeling to the camera movement.
  26806. */
  26807. inertia: number;
  26808. /**
  26809. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26810. */
  26811. mode: number;
  26812. /**
  26813. * Define whether the camera is intermediate.
  26814. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26815. */
  26816. isIntermediate: boolean;
  26817. /**
  26818. * Define the viewport of the camera.
  26819. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26820. */
  26821. viewport: Viewport;
  26822. /**
  26823. * Restricts the camera to viewing objects with the same layerMask.
  26824. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26825. */
  26826. layerMask: number;
  26827. /**
  26828. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26829. */
  26830. fovMode: number;
  26831. /**
  26832. * Rig mode of the camera.
  26833. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26834. * This is normally controlled byt the camera themselves as internal use.
  26835. */
  26836. cameraRigMode: number;
  26837. /**
  26838. * Defines the distance between both "eyes" in case of a RIG
  26839. */
  26840. interaxialDistance: number;
  26841. /**
  26842. * Defines if stereoscopic rendering is done side by side or over under.
  26843. */
  26844. isStereoscopicSideBySide: boolean;
  26845. /**
  26846. * 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
  26847. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26848. * else in the scene. (Eg. security camera)
  26849. *
  26850. * 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)
  26851. */
  26852. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26853. /**
  26854. * When set, the camera will render to this render target instead of the default canvas
  26855. *
  26856. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26857. */
  26858. outputRenderTarget: Nullable<RenderTargetTexture>;
  26859. /**
  26860. * Observable triggered when the camera view matrix has changed.
  26861. */
  26862. onViewMatrixChangedObservable: Observable<Camera>;
  26863. /**
  26864. * Observable triggered when the camera Projection matrix has changed.
  26865. */
  26866. onProjectionMatrixChangedObservable: Observable<Camera>;
  26867. /**
  26868. * Observable triggered when the inputs have been processed.
  26869. */
  26870. onAfterCheckInputsObservable: Observable<Camera>;
  26871. /**
  26872. * Observable triggered when reset has been called and applied to the camera.
  26873. */
  26874. onRestoreStateObservable: Observable<Camera>;
  26875. /**
  26876. * Is this camera a part of a rig system?
  26877. */
  26878. isRigCamera: boolean;
  26879. /**
  26880. * If isRigCamera set to true this will be set with the parent camera.
  26881. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26882. */
  26883. rigParent?: Camera;
  26884. /** @hidden */
  26885. _cameraRigParams: any;
  26886. /** @hidden */
  26887. _rigCameras: Camera[];
  26888. /** @hidden */
  26889. _rigPostProcess: Nullable<PostProcess>;
  26890. protected _webvrViewMatrix: Matrix;
  26891. /** @hidden */
  26892. _skipRendering: boolean;
  26893. /** @hidden */
  26894. _projectionMatrix: Matrix;
  26895. /** @hidden */
  26896. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26897. /** @hidden */
  26898. _activeMeshes: SmartArray<AbstractMesh>;
  26899. protected _globalPosition: Vector3;
  26900. /** @hidden */
  26901. _computedViewMatrix: Matrix;
  26902. private _doNotComputeProjectionMatrix;
  26903. private _transformMatrix;
  26904. private _frustumPlanes;
  26905. private _refreshFrustumPlanes;
  26906. private _storedFov;
  26907. private _stateStored;
  26908. /**
  26909. * Instantiates a new camera object.
  26910. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26911. * @see http://doc.babylonjs.com/features/cameras
  26912. * @param name Defines the name of the camera in the scene
  26913. * @param position Defines the position of the camera
  26914. * @param scene Defines the scene the camera belongs too
  26915. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26916. */
  26917. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26918. /**
  26919. * Store current camera state (fov, position, etc..)
  26920. * @returns the camera
  26921. */
  26922. storeState(): Camera;
  26923. /**
  26924. * Restores the camera state values if it has been stored. You must call storeState() first
  26925. */
  26926. protected _restoreStateValues(): boolean;
  26927. /**
  26928. * Restored camera state. You must call storeState() first.
  26929. * @returns true if restored and false otherwise
  26930. */
  26931. restoreState(): boolean;
  26932. /**
  26933. * Gets the class name of the camera.
  26934. * @returns the class name
  26935. */
  26936. getClassName(): string;
  26937. /** @hidden */
  26938. readonly _isCamera: boolean;
  26939. /**
  26940. * Gets a string representation of the camera useful for debug purpose.
  26941. * @param fullDetails Defines that a more verboe level of logging is required
  26942. * @returns the string representation
  26943. */
  26944. toString(fullDetails?: boolean): string;
  26945. /**
  26946. * Gets the current world space position of the camera.
  26947. */
  26948. get globalPosition(): Vector3;
  26949. /**
  26950. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26951. * @returns the active meshe list
  26952. */
  26953. getActiveMeshes(): SmartArray<AbstractMesh>;
  26954. /**
  26955. * Check whether a mesh is part of the current active mesh list of the camera
  26956. * @param mesh Defines the mesh to check
  26957. * @returns true if active, false otherwise
  26958. */
  26959. isActiveMesh(mesh: Mesh): boolean;
  26960. /**
  26961. * Is this camera ready to be used/rendered
  26962. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26963. * @return true if the camera is ready
  26964. */
  26965. isReady(completeCheck?: boolean): boolean;
  26966. /** @hidden */
  26967. _initCache(): void;
  26968. /** @hidden */
  26969. _updateCache(ignoreParentClass?: boolean): void;
  26970. /** @hidden */
  26971. _isSynchronized(): boolean;
  26972. /** @hidden */
  26973. _isSynchronizedViewMatrix(): boolean;
  26974. /** @hidden */
  26975. _isSynchronizedProjectionMatrix(): boolean;
  26976. /**
  26977. * Attach the input controls to a specific dom element to get the input from.
  26978. * @param element Defines the element the controls should be listened from
  26979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26980. */
  26981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26982. /**
  26983. * Detach the current controls from the specified dom element.
  26984. * @param element Defines the element to stop listening the inputs from
  26985. */
  26986. detachControl(element: HTMLElement): void;
  26987. /**
  26988. * Update the camera state according to the different inputs gathered during the frame.
  26989. */
  26990. update(): void;
  26991. /** @hidden */
  26992. _checkInputs(): void;
  26993. /** @hidden */
  26994. get rigCameras(): Camera[];
  26995. /**
  26996. * Gets the post process used by the rig cameras
  26997. */
  26998. get rigPostProcess(): Nullable<PostProcess>;
  26999. /**
  27000. * Internal, gets the first post proces.
  27001. * @returns the first post process to be run on this camera.
  27002. */
  27003. _getFirstPostProcess(): Nullable<PostProcess>;
  27004. private _cascadePostProcessesToRigCams;
  27005. /**
  27006. * Attach a post process to the camera.
  27007. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  27008. * @param postProcess The post process to attach to the camera
  27009. * @param insertAt The position of the post process in case several of them are in use in the scene
  27010. * @returns the position the post process has been inserted at
  27011. */
  27012. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  27013. /**
  27014. * Detach a post process to the camera.
  27015. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  27016. * @param postProcess The post process to detach from the camera
  27017. */
  27018. detachPostProcess(postProcess: PostProcess): void;
  27019. /**
  27020. * Gets the current world matrix of the camera
  27021. */
  27022. getWorldMatrix(): Matrix;
  27023. /** @hidden */
  27024. _getViewMatrix(): Matrix;
  27025. /**
  27026. * Gets the current view matrix of the camera.
  27027. * @param force forces the camera to recompute the matrix without looking at the cached state
  27028. * @returns the view matrix
  27029. */
  27030. getViewMatrix(force?: boolean): Matrix;
  27031. /**
  27032. * Freeze the projection matrix.
  27033. * It will prevent the cache check of the camera projection compute and can speed up perf
  27034. * if no parameter of the camera are meant to change
  27035. * @param projection Defines manually a projection if necessary
  27036. */
  27037. freezeProjectionMatrix(projection?: Matrix): void;
  27038. /**
  27039. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  27040. */
  27041. unfreezeProjectionMatrix(): void;
  27042. /**
  27043. * Gets the current projection matrix of the camera.
  27044. * @param force forces the camera to recompute the matrix without looking at the cached state
  27045. * @returns the projection matrix
  27046. */
  27047. getProjectionMatrix(force?: boolean): Matrix;
  27048. /**
  27049. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  27050. * @returns a Matrix
  27051. */
  27052. getTransformationMatrix(): Matrix;
  27053. private _updateFrustumPlanes;
  27054. /**
  27055. * Checks if a cullable object (mesh...) is in the camera frustum
  27056. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  27057. * @param target The object to check
  27058. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  27059. * @returns true if the object is in frustum otherwise false
  27060. */
  27061. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  27062. /**
  27063. * Checks if a cullable object (mesh...) is in the camera frustum
  27064. * Unlike isInFrustum this cheks the full bounding box
  27065. * @param target The object to check
  27066. * @returns true if the object is in frustum otherwise false
  27067. */
  27068. isCompletelyInFrustum(target: ICullable): boolean;
  27069. /**
  27070. * Gets a ray in the forward direction from the camera.
  27071. * @param length Defines the length of the ray to create
  27072. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  27073. * @param origin Defines the start point of the ray which defaults to the camera position
  27074. * @returns the forward ray
  27075. */
  27076. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  27077. /**
  27078. * Releases resources associated with this node.
  27079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27081. */
  27082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27083. /** @hidden */
  27084. _isLeftCamera: boolean;
  27085. /**
  27086. * Gets the left camera of a rig setup in case of Rigged Camera
  27087. */
  27088. get isLeftCamera(): boolean;
  27089. /** @hidden */
  27090. _isRightCamera: boolean;
  27091. /**
  27092. * Gets the right camera of a rig setup in case of Rigged Camera
  27093. */
  27094. get isRightCamera(): boolean;
  27095. /**
  27096. * Gets the left camera of a rig setup in case of Rigged Camera
  27097. */
  27098. get leftCamera(): Nullable<FreeCamera>;
  27099. /**
  27100. * Gets the right camera of a rig setup in case of Rigged Camera
  27101. */
  27102. get rightCamera(): Nullable<FreeCamera>;
  27103. /**
  27104. * Gets the left camera target of a rig setup in case of Rigged Camera
  27105. * @returns the target position
  27106. */
  27107. getLeftTarget(): Nullable<Vector3>;
  27108. /**
  27109. * Gets the right camera target of a rig setup in case of Rigged Camera
  27110. * @returns the target position
  27111. */
  27112. getRightTarget(): Nullable<Vector3>;
  27113. /**
  27114. * @hidden
  27115. */
  27116. setCameraRigMode(mode: number, rigParams: any): void;
  27117. /** @hidden */
  27118. static _setStereoscopicRigMode(camera: Camera): void;
  27119. /** @hidden */
  27120. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  27121. /** @hidden */
  27122. static _setVRRigMode(camera: Camera, rigParams: any): void;
  27123. /** @hidden */
  27124. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  27125. /** @hidden */
  27126. _getVRProjectionMatrix(): Matrix;
  27127. protected _updateCameraRotationMatrix(): void;
  27128. protected _updateWebVRCameraRotationMatrix(): void;
  27129. /**
  27130. * This function MUST be overwritten by the different WebVR cameras available.
  27131. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27132. * @hidden
  27133. */
  27134. _getWebVRProjectionMatrix(): Matrix;
  27135. /**
  27136. * This function MUST be overwritten by the different WebVR cameras available.
  27137. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27138. * @hidden
  27139. */
  27140. _getWebVRViewMatrix(): Matrix;
  27141. /** @hidden */
  27142. setCameraRigParameter(name: string, value: any): void;
  27143. /**
  27144. * needs to be overridden by children so sub has required properties to be copied
  27145. * @hidden
  27146. */
  27147. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27148. /**
  27149. * May need to be overridden by children
  27150. * @hidden
  27151. */
  27152. _updateRigCameras(): void;
  27153. /** @hidden */
  27154. _setupInputs(): void;
  27155. /**
  27156. * Serialiaze the camera setup to a json represention
  27157. * @returns the JSON representation
  27158. */
  27159. serialize(): any;
  27160. /**
  27161. * Clones the current camera.
  27162. * @param name The cloned camera name
  27163. * @returns the cloned camera
  27164. */
  27165. clone(name: string): Camera;
  27166. /**
  27167. * Gets the direction of the camera relative to a given local axis.
  27168. * @param localAxis Defines the reference axis to provide a relative direction.
  27169. * @return the direction
  27170. */
  27171. getDirection(localAxis: Vector3): Vector3;
  27172. /**
  27173. * Returns the current camera absolute rotation
  27174. */
  27175. get absoluteRotation(): Quaternion;
  27176. /**
  27177. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27178. * @param localAxis Defines the reference axis to provide a relative direction.
  27179. * @param result Defines the vector to store the result in
  27180. */
  27181. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27182. /**
  27183. * Gets a camera constructor for a given camera type
  27184. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27185. * @param name The name of the camera the result will be able to instantiate
  27186. * @param scene The scene the result will construct the camera in
  27187. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27188. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27189. * @returns a factory method to construc the camera
  27190. */
  27191. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27192. /**
  27193. * Compute the world matrix of the camera.
  27194. * @returns the camera world matrix
  27195. */
  27196. computeWorldMatrix(): Matrix;
  27197. /**
  27198. * Parse a JSON and creates the camera from the parsed information
  27199. * @param parsedCamera The JSON to parse
  27200. * @param scene The scene to instantiate the camera in
  27201. * @returns the newly constructed camera
  27202. */
  27203. static Parse(parsedCamera: any, scene: Scene): Camera;
  27204. }
  27205. }
  27206. declare module "babylonjs/Meshes/Builders/discBuilder" {
  27207. import { Nullable } from "babylonjs/types";
  27208. import { Scene } from "babylonjs/scene";
  27209. import { Vector4 } from "babylonjs/Maths/math.vector";
  27210. import { Mesh } from "babylonjs/Meshes/mesh";
  27211. /**
  27212. * Class containing static functions to help procedurally build meshes
  27213. */
  27214. export class DiscBuilder {
  27215. /**
  27216. * Creates a plane polygonal mesh. By default, this is a disc
  27217. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27218. * * 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
  27219. * * 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
  27220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27221. * * 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
  27222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27223. * @param name defines the name of the mesh
  27224. * @param options defines the options used to create the mesh
  27225. * @param scene defines the hosting scene
  27226. * @returns the plane polygonal mesh
  27227. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27228. */
  27229. static CreateDisc(name: string, options: {
  27230. radius?: number;
  27231. tessellation?: number;
  27232. arc?: number;
  27233. updatable?: boolean;
  27234. sideOrientation?: number;
  27235. frontUVs?: Vector4;
  27236. backUVs?: Vector4;
  27237. }, scene?: Nullable<Scene>): Mesh;
  27238. }
  27239. }
  27240. declare module "babylonjs/Materials/fresnelParameters" {
  27241. import { DeepImmutable } from "babylonjs/types";
  27242. import { Color3 } from "babylonjs/Maths/math.color";
  27243. /**
  27244. * Options to be used when creating a FresnelParameters.
  27245. */
  27246. export type IFresnelParametersCreationOptions = {
  27247. /**
  27248. * Define the color used on edges (grazing angle)
  27249. */
  27250. leftColor?: Color3;
  27251. /**
  27252. * Define the color used on center
  27253. */
  27254. rightColor?: Color3;
  27255. /**
  27256. * Define bias applied to computed fresnel term
  27257. */
  27258. bias?: number;
  27259. /**
  27260. * Defined the power exponent applied to fresnel term
  27261. */
  27262. power?: number;
  27263. /**
  27264. * Define if the fresnel effect is enable or not.
  27265. */
  27266. isEnabled?: boolean;
  27267. };
  27268. /**
  27269. * Serialized format for FresnelParameters.
  27270. */
  27271. export type IFresnelParametersSerialized = {
  27272. /**
  27273. * Define the color used on edges (grazing angle) [as an array]
  27274. */
  27275. leftColor: number[];
  27276. /**
  27277. * Define the color used on center [as an array]
  27278. */
  27279. rightColor: number[];
  27280. /**
  27281. * Define bias applied to computed fresnel term
  27282. */
  27283. bias: number;
  27284. /**
  27285. * Defined the power exponent applied to fresnel term
  27286. */
  27287. power?: number;
  27288. /**
  27289. * Define if the fresnel effect is enable or not.
  27290. */
  27291. isEnabled: boolean;
  27292. };
  27293. /**
  27294. * This represents all the required information to add a fresnel effect on a material:
  27295. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27296. */
  27297. export class FresnelParameters {
  27298. private _isEnabled;
  27299. /**
  27300. * Define if the fresnel effect is enable or not.
  27301. */
  27302. get isEnabled(): boolean;
  27303. set isEnabled(value: boolean);
  27304. /**
  27305. * Define the color used on edges (grazing angle)
  27306. */
  27307. leftColor: Color3;
  27308. /**
  27309. * Define the color used on center
  27310. */
  27311. rightColor: Color3;
  27312. /**
  27313. * Define bias applied to computed fresnel term
  27314. */
  27315. bias: number;
  27316. /**
  27317. * Defined the power exponent applied to fresnel term
  27318. */
  27319. power: number;
  27320. /**
  27321. * Creates a new FresnelParameters object.
  27322. *
  27323. * @param options provide your own settings to optionally to override defaults
  27324. */
  27325. constructor(options?: IFresnelParametersCreationOptions);
  27326. /**
  27327. * Clones the current fresnel and its valuues
  27328. * @returns a clone fresnel configuration
  27329. */
  27330. clone(): FresnelParameters;
  27331. /**
  27332. * Determines equality between FresnelParameters objects
  27333. * @param otherFresnelParameters defines the second operand
  27334. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27335. */
  27336. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27337. /**
  27338. * Serializes the current fresnel parameters to a JSON representation.
  27339. * @return the JSON serialization
  27340. */
  27341. serialize(): IFresnelParametersSerialized;
  27342. /**
  27343. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27344. * @param parsedFresnelParameters Define the JSON representation
  27345. * @returns the parsed parameters
  27346. */
  27347. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27348. }
  27349. }
  27350. declare module "babylonjs/Materials/pushMaterial" {
  27351. import { Nullable } from "babylonjs/types";
  27352. import { Scene } from "babylonjs/scene";
  27353. import { Matrix } from "babylonjs/Maths/math.vector";
  27354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27355. import { Mesh } from "babylonjs/Meshes/mesh";
  27356. import { Material } from "babylonjs/Materials/material";
  27357. import { Effect } from "babylonjs/Materials/effect";
  27358. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27359. /**
  27360. * Base class of materials working in push mode in babylon JS
  27361. * @hidden
  27362. */
  27363. export class PushMaterial extends Material {
  27364. protected _activeEffect: Effect;
  27365. protected _normalMatrix: Matrix;
  27366. /**
  27367. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27368. * This means that the material can keep using a previous shader while a new one is being compiled.
  27369. * This is mostly used when shader parallel compilation is supported (true by default)
  27370. */
  27371. allowShaderHotSwapping: boolean;
  27372. constructor(name: string, scene: Scene);
  27373. getEffect(): Effect;
  27374. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27375. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27376. /**
  27377. * Binds the given world matrix to the active effect
  27378. *
  27379. * @param world the matrix to bind
  27380. */
  27381. bindOnlyWorldMatrix(world: Matrix): void;
  27382. /**
  27383. * Binds the given normal matrix to the active effect
  27384. *
  27385. * @param normalMatrix the matrix to bind
  27386. */
  27387. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27388. bind(world: Matrix, mesh?: Mesh): void;
  27389. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27390. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27391. }
  27392. }
  27393. declare module "babylonjs/Materials/materialFlags" {
  27394. /**
  27395. * This groups all the flags used to control the materials channel.
  27396. */
  27397. export class MaterialFlags {
  27398. private static _DiffuseTextureEnabled;
  27399. /**
  27400. * Are diffuse textures enabled in the application.
  27401. */
  27402. static get DiffuseTextureEnabled(): boolean;
  27403. static set DiffuseTextureEnabled(value: boolean);
  27404. private static _AmbientTextureEnabled;
  27405. /**
  27406. * Are ambient textures enabled in the application.
  27407. */
  27408. static get AmbientTextureEnabled(): boolean;
  27409. static set AmbientTextureEnabled(value: boolean);
  27410. private static _OpacityTextureEnabled;
  27411. /**
  27412. * Are opacity textures enabled in the application.
  27413. */
  27414. static get OpacityTextureEnabled(): boolean;
  27415. static set OpacityTextureEnabled(value: boolean);
  27416. private static _ReflectionTextureEnabled;
  27417. /**
  27418. * Are reflection textures enabled in the application.
  27419. */
  27420. static get ReflectionTextureEnabled(): boolean;
  27421. static set ReflectionTextureEnabled(value: boolean);
  27422. private static _EmissiveTextureEnabled;
  27423. /**
  27424. * Are emissive textures enabled in the application.
  27425. */
  27426. static get EmissiveTextureEnabled(): boolean;
  27427. static set EmissiveTextureEnabled(value: boolean);
  27428. private static _SpecularTextureEnabled;
  27429. /**
  27430. * Are specular textures enabled in the application.
  27431. */
  27432. static get SpecularTextureEnabled(): boolean;
  27433. static set SpecularTextureEnabled(value: boolean);
  27434. private static _BumpTextureEnabled;
  27435. /**
  27436. * Are bump textures enabled in the application.
  27437. */
  27438. static get BumpTextureEnabled(): boolean;
  27439. static set BumpTextureEnabled(value: boolean);
  27440. private static _LightmapTextureEnabled;
  27441. /**
  27442. * Are lightmap textures enabled in the application.
  27443. */
  27444. static get LightmapTextureEnabled(): boolean;
  27445. static set LightmapTextureEnabled(value: boolean);
  27446. private static _RefractionTextureEnabled;
  27447. /**
  27448. * Are refraction textures enabled in the application.
  27449. */
  27450. static get RefractionTextureEnabled(): boolean;
  27451. static set RefractionTextureEnabled(value: boolean);
  27452. private static _ColorGradingTextureEnabled;
  27453. /**
  27454. * Are color grading textures enabled in the application.
  27455. */
  27456. static get ColorGradingTextureEnabled(): boolean;
  27457. static set ColorGradingTextureEnabled(value: boolean);
  27458. private static _FresnelEnabled;
  27459. /**
  27460. * Are fresnels enabled in the application.
  27461. */
  27462. static get FresnelEnabled(): boolean;
  27463. static set FresnelEnabled(value: boolean);
  27464. private static _ClearCoatTextureEnabled;
  27465. /**
  27466. * Are clear coat textures enabled in the application.
  27467. */
  27468. static get ClearCoatTextureEnabled(): boolean;
  27469. static set ClearCoatTextureEnabled(value: boolean);
  27470. private static _ClearCoatBumpTextureEnabled;
  27471. /**
  27472. * Are clear coat bump textures enabled in the application.
  27473. */
  27474. static get ClearCoatBumpTextureEnabled(): boolean;
  27475. static set ClearCoatBumpTextureEnabled(value: boolean);
  27476. private static _ClearCoatTintTextureEnabled;
  27477. /**
  27478. * Are clear coat tint textures enabled in the application.
  27479. */
  27480. static get ClearCoatTintTextureEnabled(): boolean;
  27481. static set ClearCoatTintTextureEnabled(value: boolean);
  27482. private static _SheenTextureEnabled;
  27483. /**
  27484. * Are sheen textures enabled in the application.
  27485. */
  27486. static get SheenTextureEnabled(): boolean;
  27487. static set SheenTextureEnabled(value: boolean);
  27488. private static _AnisotropicTextureEnabled;
  27489. /**
  27490. * Are anisotropic textures enabled in the application.
  27491. */
  27492. static get AnisotropicTextureEnabled(): boolean;
  27493. static set AnisotropicTextureEnabled(value: boolean);
  27494. private static _ThicknessTextureEnabled;
  27495. /**
  27496. * Are thickness textures enabled in the application.
  27497. */
  27498. static get ThicknessTextureEnabled(): boolean;
  27499. static set ThicknessTextureEnabled(value: boolean);
  27500. }
  27501. }
  27502. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27503. /** @hidden */
  27504. export var defaultFragmentDeclaration: {
  27505. name: string;
  27506. shader: string;
  27507. };
  27508. }
  27509. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27510. /** @hidden */
  27511. export var defaultUboDeclaration: {
  27512. name: string;
  27513. shader: string;
  27514. };
  27515. }
  27516. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27517. /** @hidden */
  27518. export var lightFragmentDeclaration: {
  27519. name: string;
  27520. shader: string;
  27521. };
  27522. }
  27523. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27524. /** @hidden */
  27525. export var lightUboDeclaration: {
  27526. name: string;
  27527. shader: string;
  27528. };
  27529. }
  27530. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27531. /** @hidden */
  27532. export var lightsFragmentFunctions: {
  27533. name: string;
  27534. shader: string;
  27535. };
  27536. }
  27537. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27538. /** @hidden */
  27539. export var shadowsFragmentFunctions: {
  27540. name: string;
  27541. shader: string;
  27542. };
  27543. }
  27544. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27545. /** @hidden */
  27546. export var fresnelFunction: {
  27547. name: string;
  27548. shader: string;
  27549. };
  27550. }
  27551. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27552. /** @hidden */
  27553. export var reflectionFunction: {
  27554. name: string;
  27555. shader: string;
  27556. };
  27557. }
  27558. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  27559. /** @hidden */
  27560. export var bumpFragmentMainFunctions: {
  27561. name: string;
  27562. shader: string;
  27563. };
  27564. }
  27565. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27566. /** @hidden */
  27567. export var bumpFragmentFunctions: {
  27568. name: string;
  27569. shader: string;
  27570. };
  27571. }
  27572. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27573. /** @hidden */
  27574. export var logDepthDeclaration: {
  27575. name: string;
  27576. shader: string;
  27577. };
  27578. }
  27579. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27580. /** @hidden */
  27581. export var bumpFragment: {
  27582. name: string;
  27583. shader: string;
  27584. };
  27585. }
  27586. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27587. /** @hidden */
  27588. export var depthPrePass: {
  27589. name: string;
  27590. shader: string;
  27591. };
  27592. }
  27593. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27594. /** @hidden */
  27595. export var lightFragment: {
  27596. name: string;
  27597. shader: string;
  27598. };
  27599. }
  27600. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27601. /** @hidden */
  27602. export var logDepthFragment: {
  27603. name: string;
  27604. shader: string;
  27605. };
  27606. }
  27607. declare module "babylonjs/Shaders/default.fragment" {
  27608. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27609. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27611. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27612. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27613. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27614. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27615. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27616. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27617. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27618. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27619. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27620. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27621. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27622. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27623. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27624. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27625. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27626. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27627. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27628. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27629. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27630. /** @hidden */
  27631. export var defaultPixelShader: {
  27632. name: string;
  27633. shader: string;
  27634. };
  27635. }
  27636. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27637. /** @hidden */
  27638. export var defaultVertexDeclaration: {
  27639. name: string;
  27640. shader: string;
  27641. };
  27642. }
  27643. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27644. /** @hidden */
  27645. export var bumpVertexDeclaration: {
  27646. name: string;
  27647. shader: string;
  27648. };
  27649. }
  27650. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27651. /** @hidden */
  27652. export var bumpVertex: {
  27653. name: string;
  27654. shader: string;
  27655. };
  27656. }
  27657. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27658. /** @hidden */
  27659. export var fogVertex: {
  27660. name: string;
  27661. shader: string;
  27662. };
  27663. }
  27664. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27665. /** @hidden */
  27666. export var shadowsVertex: {
  27667. name: string;
  27668. shader: string;
  27669. };
  27670. }
  27671. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27672. /** @hidden */
  27673. export var pointCloudVertex: {
  27674. name: string;
  27675. shader: string;
  27676. };
  27677. }
  27678. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27679. /** @hidden */
  27680. export var logDepthVertex: {
  27681. name: string;
  27682. shader: string;
  27683. };
  27684. }
  27685. declare module "babylonjs/Shaders/default.vertex" {
  27686. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27687. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27689. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27690. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27691. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27692. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27693. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27694. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27695. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27696. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27698. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27699. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27700. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27701. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27702. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27703. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27704. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27705. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27706. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27707. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27708. /** @hidden */
  27709. export var defaultVertexShader: {
  27710. name: string;
  27711. shader: string;
  27712. };
  27713. }
  27714. declare module "babylonjs/Materials/standardMaterial" {
  27715. import { SmartArray } from "babylonjs/Misc/smartArray";
  27716. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27717. import { Nullable } from "babylonjs/types";
  27718. import { Scene } from "babylonjs/scene";
  27719. import { Matrix } from "babylonjs/Maths/math.vector";
  27720. import { Color3 } from "babylonjs/Maths/math.color";
  27721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27723. import { Mesh } from "babylonjs/Meshes/mesh";
  27724. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27725. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27726. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27727. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27728. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27729. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27730. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27731. import "babylonjs/Shaders/default.fragment";
  27732. import "babylonjs/Shaders/default.vertex";
  27733. /** @hidden */
  27734. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27735. MAINUV1: boolean;
  27736. MAINUV2: boolean;
  27737. DIFFUSE: boolean;
  27738. DIFFUSEDIRECTUV: number;
  27739. AMBIENT: boolean;
  27740. AMBIENTDIRECTUV: number;
  27741. OPACITY: boolean;
  27742. OPACITYDIRECTUV: number;
  27743. OPACITYRGB: boolean;
  27744. REFLECTION: boolean;
  27745. EMISSIVE: boolean;
  27746. EMISSIVEDIRECTUV: number;
  27747. SPECULAR: boolean;
  27748. SPECULARDIRECTUV: number;
  27749. BUMP: boolean;
  27750. BUMPDIRECTUV: number;
  27751. PARALLAX: boolean;
  27752. PARALLAXOCCLUSION: boolean;
  27753. SPECULAROVERALPHA: boolean;
  27754. CLIPPLANE: boolean;
  27755. CLIPPLANE2: boolean;
  27756. CLIPPLANE3: boolean;
  27757. CLIPPLANE4: boolean;
  27758. CLIPPLANE5: boolean;
  27759. CLIPPLANE6: boolean;
  27760. ALPHATEST: boolean;
  27761. DEPTHPREPASS: boolean;
  27762. ALPHAFROMDIFFUSE: boolean;
  27763. POINTSIZE: boolean;
  27764. FOG: boolean;
  27765. SPECULARTERM: boolean;
  27766. DIFFUSEFRESNEL: boolean;
  27767. OPACITYFRESNEL: boolean;
  27768. REFLECTIONFRESNEL: boolean;
  27769. REFRACTIONFRESNEL: boolean;
  27770. EMISSIVEFRESNEL: boolean;
  27771. FRESNEL: boolean;
  27772. NORMAL: boolean;
  27773. UV1: boolean;
  27774. UV2: boolean;
  27775. VERTEXCOLOR: boolean;
  27776. VERTEXALPHA: boolean;
  27777. NUM_BONE_INFLUENCERS: number;
  27778. BonesPerMesh: number;
  27779. BONETEXTURE: boolean;
  27780. INSTANCES: boolean;
  27781. GLOSSINESS: boolean;
  27782. ROUGHNESS: boolean;
  27783. EMISSIVEASILLUMINATION: boolean;
  27784. LINKEMISSIVEWITHDIFFUSE: boolean;
  27785. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27786. LIGHTMAP: boolean;
  27787. LIGHTMAPDIRECTUV: number;
  27788. OBJECTSPACE_NORMALMAP: boolean;
  27789. USELIGHTMAPASSHADOWMAP: boolean;
  27790. REFLECTIONMAP_3D: boolean;
  27791. REFLECTIONMAP_SPHERICAL: boolean;
  27792. REFLECTIONMAP_PLANAR: boolean;
  27793. REFLECTIONMAP_CUBIC: boolean;
  27794. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27795. REFLECTIONMAP_PROJECTION: boolean;
  27796. REFLECTIONMAP_SKYBOX: boolean;
  27797. REFLECTIONMAP_EXPLICIT: boolean;
  27798. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27799. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27800. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27801. INVERTCUBICMAP: boolean;
  27802. LOGARITHMICDEPTH: boolean;
  27803. REFRACTION: boolean;
  27804. REFRACTIONMAP_3D: boolean;
  27805. REFLECTIONOVERALPHA: boolean;
  27806. TWOSIDEDLIGHTING: boolean;
  27807. SHADOWFLOAT: boolean;
  27808. MORPHTARGETS: boolean;
  27809. MORPHTARGETS_NORMAL: boolean;
  27810. MORPHTARGETS_TANGENT: boolean;
  27811. MORPHTARGETS_UV: boolean;
  27812. NUM_MORPH_INFLUENCERS: number;
  27813. NONUNIFORMSCALING: boolean;
  27814. PREMULTIPLYALPHA: boolean;
  27815. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27816. ALPHABLEND: boolean;
  27817. RGBDLIGHTMAP: boolean;
  27818. RGBDREFLECTION: boolean;
  27819. RGBDREFRACTION: boolean;
  27820. IMAGEPROCESSING: boolean;
  27821. VIGNETTE: boolean;
  27822. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27823. VIGNETTEBLENDMODEOPAQUE: boolean;
  27824. TONEMAPPING: boolean;
  27825. TONEMAPPING_ACES: boolean;
  27826. CONTRAST: boolean;
  27827. COLORCURVES: boolean;
  27828. COLORGRADING: boolean;
  27829. COLORGRADING3D: boolean;
  27830. SAMPLER3DGREENDEPTH: boolean;
  27831. SAMPLER3DBGRMAP: boolean;
  27832. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27833. MULTIVIEW: boolean;
  27834. /**
  27835. * If the reflection texture on this material is in linear color space
  27836. * @hidden
  27837. */
  27838. IS_REFLECTION_LINEAR: boolean;
  27839. /**
  27840. * If the refraction texture on this material is in linear color space
  27841. * @hidden
  27842. */
  27843. IS_REFRACTION_LINEAR: boolean;
  27844. EXPOSURE: boolean;
  27845. constructor();
  27846. setReflectionMode(modeToEnable: string): void;
  27847. }
  27848. /**
  27849. * This is the default material used in Babylon. It is the best trade off between quality
  27850. * and performances.
  27851. * @see http://doc.babylonjs.com/babylon101/materials
  27852. */
  27853. export class StandardMaterial extends PushMaterial {
  27854. private _diffuseTexture;
  27855. /**
  27856. * The basic texture of the material as viewed under a light.
  27857. */
  27858. diffuseTexture: Nullable<BaseTexture>;
  27859. private _ambientTexture;
  27860. /**
  27861. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27862. */
  27863. ambientTexture: Nullable<BaseTexture>;
  27864. private _opacityTexture;
  27865. /**
  27866. * Define the transparency of the material from a texture.
  27867. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27868. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27869. */
  27870. opacityTexture: Nullable<BaseTexture>;
  27871. private _reflectionTexture;
  27872. /**
  27873. * Define the texture used to display the reflection.
  27874. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27875. */
  27876. reflectionTexture: Nullable<BaseTexture>;
  27877. private _emissiveTexture;
  27878. /**
  27879. * Define texture of the material as if self lit.
  27880. * This will be mixed in the final result even in the absence of light.
  27881. */
  27882. emissiveTexture: Nullable<BaseTexture>;
  27883. private _specularTexture;
  27884. /**
  27885. * Define how the color and intensity of the highlight given by the light in the material.
  27886. */
  27887. specularTexture: Nullable<BaseTexture>;
  27888. private _bumpTexture;
  27889. /**
  27890. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27891. * 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.
  27892. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27893. */
  27894. bumpTexture: Nullable<BaseTexture>;
  27895. private _lightmapTexture;
  27896. /**
  27897. * Complex lighting can be computationally expensive to compute at runtime.
  27898. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27899. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27900. */
  27901. lightmapTexture: Nullable<BaseTexture>;
  27902. private _refractionTexture;
  27903. /**
  27904. * Define the texture used to display the refraction.
  27905. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27906. */
  27907. refractionTexture: Nullable<BaseTexture>;
  27908. /**
  27909. * The color of the material lit by the environmental background lighting.
  27910. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27911. */
  27912. ambientColor: Color3;
  27913. /**
  27914. * The basic color of the material as viewed under a light.
  27915. */
  27916. diffuseColor: Color3;
  27917. /**
  27918. * Define how the color and intensity of the highlight given by the light in the material.
  27919. */
  27920. specularColor: Color3;
  27921. /**
  27922. * Define the color of the material as if self lit.
  27923. * This will be mixed in the final result even in the absence of light.
  27924. */
  27925. emissiveColor: Color3;
  27926. /**
  27927. * Defines how sharp are the highlights in the material.
  27928. * The bigger the value the sharper giving a more glossy feeling to the result.
  27929. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27930. */
  27931. specularPower: number;
  27932. private _useAlphaFromDiffuseTexture;
  27933. /**
  27934. * Does the transparency come from the diffuse texture alpha channel.
  27935. */
  27936. useAlphaFromDiffuseTexture: boolean;
  27937. private _useEmissiveAsIllumination;
  27938. /**
  27939. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27940. */
  27941. useEmissiveAsIllumination: boolean;
  27942. private _linkEmissiveWithDiffuse;
  27943. /**
  27944. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27945. * the emissive level when the final color is close to one.
  27946. */
  27947. linkEmissiveWithDiffuse: boolean;
  27948. private _useSpecularOverAlpha;
  27949. /**
  27950. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27951. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27952. */
  27953. useSpecularOverAlpha: boolean;
  27954. private _useReflectionOverAlpha;
  27955. /**
  27956. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27957. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27958. */
  27959. useReflectionOverAlpha: boolean;
  27960. private _disableLighting;
  27961. /**
  27962. * Does lights from the scene impacts this material.
  27963. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27964. */
  27965. disableLighting: boolean;
  27966. private _useObjectSpaceNormalMap;
  27967. /**
  27968. * Allows using an object space normal map (instead of tangent space).
  27969. */
  27970. useObjectSpaceNormalMap: boolean;
  27971. private _useParallax;
  27972. /**
  27973. * Is parallax enabled or not.
  27974. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27975. */
  27976. useParallax: boolean;
  27977. private _useParallaxOcclusion;
  27978. /**
  27979. * Is parallax occlusion enabled or not.
  27980. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27981. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27982. */
  27983. useParallaxOcclusion: boolean;
  27984. /**
  27985. * 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.
  27986. */
  27987. parallaxScaleBias: number;
  27988. private _roughness;
  27989. /**
  27990. * Helps to define how blurry the reflections should appears in the material.
  27991. */
  27992. roughness: number;
  27993. /**
  27994. * In case of refraction, define the value of the index of refraction.
  27995. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27996. */
  27997. indexOfRefraction: number;
  27998. /**
  27999. * Invert the refraction texture alongside the y axis.
  28000. * It can be useful with procedural textures or probe for instance.
  28001. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  28002. */
  28003. invertRefractionY: boolean;
  28004. /**
  28005. * Defines the alpha limits in alpha test mode.
  28006. */
  28007. alphaCutOff: number;
  28008. private _useLightmapAsShadowmap;
  28009. /**
  28010. * In case of light mapping, define whether the map contains light or shadow informations.
  28011. */
  28012. useLightmapAsShadowmap: boolean;
  28013. private _diffuseFresnelParameters;
  28014. /**
  28015. * Define the diffuse fresnel parameters of the material.
  28016. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28017. */
  28018. diffuseFresnelParameters: FresnelParameters;
  28019. private _opacityFresnelParameters;
  28020. /**
  28021. * Define the opacity fresnel parameters of the material.
  28022. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28023. */
  28024. opacityFresnelParameters: FresnelParameters;
  28025. private _reflectionFresnelParameters;
  28026. /**
  28027. * Define the reflection fresnel parameters of the material.
  28028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28029. */
  28030. reflectionFresnelParameters: FresnelParameters;
  28031. private _refractionFresnelParameters;
  28032. /**
  28033. * Define the refraction fresnel parameters of the material.
  28034. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28035. */
  28036. refractionFresnelParameters: FresnelParameters;
  28037. private _emissiveFresnelParameters;
  28038. /**
  28039. * Define the emissive fresnel parameters of the material.
  28040. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28041. */
  28042. emissiveFresnelParameters: FresnelParameters;
  28043. private _useReflectionFresnelFromSpecular;
  28044. /**
  28045. * If true automatically deducts the fresnels values from the material specularity.
  28046. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28047. */
  28048. useReflectionFresnelFromSpecular: boolean;
  28049. private _useGlossinessFromSpecularMapAlpha;
  28050. /**
  28051. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  28052. */
  28053. useGlossinessFromSpecularMapAlpha: boolean;
  28054. private _maxSimultaneousLights;
  28055. /**
  28056. * Defines the maximum number of lights that can be used in the material
  28057. */
  28058. maxSimultaneousLights: number;
  28059. private _invertNormalMapX;
  28060. /**
  28061. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28062. */
  28063. invertNormalMapX: boolean;
  28064. private _invertNormalMapY;
  28065. /**
  28066. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28067. */
  28068. invertNormalMapY: boolean;
  28069. private _twoSidedLighting;
  28070. /**
  28071. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28072. */
  28073. twoSidedLighting: boolean;
  28074. /**
  28075. * Default configuration related to image processing available in the standard Material.
  28076. */
  28077. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28078. /**
  28079. * Gets the image processing configuration used either in this material.
  28080. */
  28081. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28082. /**
  28083. * Sets the Default image processing configuration used either in the this material.
  28084. *
  28085. * If sets to null, the scene one is in use.
  28086. */
  28087. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28088. /**
  28089. * Keep track of the image processing observer to allow dispose and replace.
  28090. */
  28091. private _imageProcessingObserver;
  28092. /**
  28093. * Attaches a new image processing configuration to the Standard Material.
  28094. * @param configuration
  28095. */
  28096. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  28097. /**
  28098. * Gets wether the color curves effect is enabled.
  28099. */
  28100. get cameraColorCurvesEnabled(): boolean;
  28101. /**
  28102. * Sets wether the color curves effect is enabled.
  28103. */
  28104. set cameraColorCurvesEnabled(value: boolean);
  28105. /**
  28106. * Gets wether the color grading effect is enabled.
  28107. */
  28108. get cameraColorGradingEnabled(): boolean;
  28109. /**
  28110. * Gets wether the color grading effect is enabled.
  28111. */
  28112. set cameraColorGradingEnabled(value: boolean);
  28113. /**
  28114. * Gets wether tonemapping is enabled or not.
  28115. */
  28116. get cameraToneMappingEnabled(): boolean;
  28117. /**
  28118. * Sets wether tonemapping is enabled or not
  28119. */
  28120. set cameraToneMappingEnabled(value: boolean);
  28121. /**
  28122. * The camera exposure used on this material.
  28123. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28124. * This corresponds to a photographic exposure.
  28125. */
  28126. get cameraExposure(): number;
  28127. /**
  28128. * The camera exposure used on this material.
  28129. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28130. * This corresponds to a photographic exposure.
  28131. */
  28132. set cameraExposure(value: number);
  28133. /**
  28134. * Gets The camera contrast used on this material.
  28135. */
  28136. get cameraContrast(): number;
  28137. /**
  28138. * Sets The camera contrast used on this material.
  28139. */
  28140. set cameraContrast(value: number);
  28141. /**
  28142. * Gets the Color Grading 2D Lookup Texture.
  28143. */
  28144. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28145. /**
  28146. * Sets the Color Grading 2D Lookup Texture.
  28147. */
  28148. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28149. /**
  28150. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28151. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28152. * 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;
  28153. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28154. */
  28155. get cameraColorCurves(): Nullable<ColorCurves>;
  28156. /**
  28157. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28158. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28159. * 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;
  28160. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28161. */
  28162. set cameraColorCurves(value: Nullable<ColorCurves>);
  28163. protected _renderTargets: SmartArray<RenderTargetTexture>;
  28164. protected _worldViewProjectionMatrix: Matrix;
  28165. protected _globalAmbientColor: Color3;
  28166. protected _useLogarithmicDepth: boolean;
  28167. protected _rebuildInParallel: boolean;
  28168. /**
  28169. * Instantiates a new standard material.
  28170. * This is the default material used in Babylon. It is the best trade off between quality
  28171. * and performances.
  28172. * @see http://doc.babylonjs.com/babylon101/materials
  28173. * @param name Define the name of the material in the scene
  28174. * @param scene Define the scene the material belong to
  28175. */
  28176. constructor(name: string, scene: Scene);
  28177. /**
  28178. * Gets a boolean indicating that current material needs to register RTT
  28179. */
  28180. get hasRenderTargetTextures(): boolean;
  28181. /**
  28182. * Gets the current class name of the material e.g. "StandardMaterial"
  28183. * Mainly use in serialization.
  28184. * @returns the class name
  28185. */
  28186. getClassName(): string;
  28187. /**
  28188. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  28189. * You can try switching to logarithmic depth.
  28190. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  28191. */
  28192. get useLogarithmicDepth(): boolean;
  28193. set useLogarithmicDepth(value: boolean);
  28194. /**
  28195. * Specifies if the material will require alpha blending
  28196. * @returns a boolean specifying if alpha blending is needed
  28197. */
  28198. needAlphaBlending(): boolean;
  28199. /**
  28200. * Specifies if this material should be rendered in alpha test mode
  28201. * @returns a boolean specifying if an alpha test is needed.
  28202. */
  28203. needAlphaTesting(): boolean;
  28204. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  28205. /**
  28206. * Get the texture used for alpha test purpose.
  28207. * @returns the diffuse texture in case of the standard material.
  28208. */
  28209. getAlphaTestTexture(): Nullable<BaseTexture>;
  28210. /**
  28211. * Get if the submesh is ready to be used and all its information available.
  28212. * Child classes can use it to update shaders
  28213. * @param mesh defines the mesh to check
  28214. * @param subMesh defines which submesh to check
  28215. * @param useInstances specifies that instances should be used
  28216. * @returns a boolean indicating that the submesh is ready or not
  28217. */
  28218. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28219. /**
  28220. * Builds the material UBO layouts.
  28221. * Used internally during the effect preparation.
  28222. */
  28223. buildUniformLayout(): void;
  28224. /**
  28225. * Unbinds the material from the mesh
  28226. */
  28227. unbind(): void;
  28228. /**
  28229. * Binds the submesh to this material by preparing the effect and shader to draw
  28230. * @param world defines the world transformation matrix
  28231. * @param mesh defines the mesh containing the submesh
  28232. * @param subMesh defines the submesh to bind the material to
  28233. */
  28234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28235. /**
  28236. * Get the list of animatables in the material.
  28237. * @returns the list of animatables object used in the material
  28238. */
  28239. getAnimatables(): IAnimatable[];
  28240. /**
  28241. * Gets the active textures from the material
  28242. * @returns an array of textures
  28243. */
  28244. getActiveTextures(): BaseTexture[];
  28245. /**
  28246. * Specifies if the material uses a texture
  28247. * @param texture defines the texture to check against the material
  28248. * @returns a boolean specifying if the material uses the texture
  28249. */
  28250. hasTexture(texture: BaseTexture): boolean;
  28251. /**
  28252. * Disposes the material
  28253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28254. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28255. */
  28256. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28257. /**
  28258. * Makes a duplicate of the material, and gives it a new name
  28259. * @param name defines the new name for the duplicated material
  28260. * @returns the cloned material
  28261. */
  28262. clone(name: string): StandardMaterial;
  28263. /**
  28264. * Serializes this material in a JSON representation
  28265. * @returns the serialized material object
  28266. */
  28267. serialize(): any;
  28268. /**
  28269. * Creates a standard material from parsed material data
  28270. * @param source defines the JSON representation of the material
  28271. * @param scene defines the hosting scene
  28272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28273. * @returns a new standard material
  28274. */
  28275. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  28276. /**
  28277. * Are diffuse textures enabled in the application.
  28278. */
  28279. static get DiffuseTextureEnabled(): boolean;
  28280. static set DiffuseTextureEnabled(value: boolean);
  28281. /**
  28282. * Are ambient textures enabled in the application.
  28283. */
  28284. static get AmbientTextureEnabled(): boolean;
  28285. static set AmbientTextureEnabled(value: boolean);
  28286. /**
  28287. * Are opacity textures enabled in the application.
  28288. */
  28289. static get OpacityTextureEnabled(): boolean;
  28290. static set OpacityTextureEnabled(value: boolean);
  28291. /**
  28292. * Are reflection textures enabled in the application.
  28293. */
  28294. static get ReflectionTextureEnabled(): boolean;
  28295. static set ReflectionTextureEnabled(value: boolean);
  28296. /**
  28297. * Are emissive textures enabled in the application.
  28298. */
  28299. static get EmissiveTextureEnabled(): boolean;
  28300. static set EmissiveTextureEnabled(value: boolean);
  28301. /**
  28302. * Are specular textures enabled in the application.
  28303. */
  28304. static get SpecularTextureEnabled(): boolean;
  28305. static set SpecularTextureEnabled(value: boolean);
  28306. /**
  28307. * Are bump textures enabled in the application.
  28308. */
  28309. static get BumpTextureEnabled(): boolean;
  28310. static set BumpTextureEnabled(value: boolean);
  28311. /**
  28312. * Are lightmap textures enabled in the application.
  28313. */
  28314. static get LightmapTextureEnabled(): boolean;
  28315. static set LightmapTextureEnabled(value: boolean);
  28316. /**
  28317. * Are refraction textures enabled in the application.
  28318. */
  28319. static get RefractionTextureEnabled(): boolean;
  28320. static set RefractionTextureEnabled(value: boolean);
  28321. /**
  28322. * Are color grading textures enabled in the application.
  28323. */
  28324. static get ColorGradingTextureEnabled(): boolean;
  28325. static set ColorGradingTextureEnabled(value: boolean);
  28326. /**
  28327. * Are fresnels enabled in the application.
  28328. */
  28329. static get FresnelEnabled(): boolean;
  28330. static set FresnelEnabled(value: boolean);
  28331. }
  28332. }
  28333. declare module "babylonjs/Particles/solidParticleSystem" {
  28334. import { Nullable } from "babylonjs/types";
  28335. import { Mesh } from "babylonjs/Meshes/mesh";
  28336. import { Scene, IDisposable } from "babylonjs/scene";
  28337. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  28338. import { Material } from "babylonjs/Materials/material";
  28339. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28340. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28341. /**
  28342. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28343. *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.
  28344. * The SPS is also a particle system. It provides some methods to manage the particles.
  28345. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28346. *
  28347. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28348. */
  28349. export class SolidParticleSystem implements IDisposable {
  28350. /**
  28351. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28352. * Example : var p = SPS.particles[i];
  28353. */
  28354. particles: SolidParticle[];
  28355. /**
  28356. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28357. */
  28358. nbParticles: number;
  28359. /**
  28360. * If the particles must ever face the camera (default false). Useful for planar particles.
  28361. */
  28362. billboard: boolean;
  28363. /**
  28364. * Recompute normals when adding a shape
  28365. */
  28366. recomputeNormals: boolean;
  28367. /**
  28368. * This a counter ofr your own usage. It's not set by any SPS functions.
  28369. */
  28370. counter: number;
  28371. /**
  28372. * The SPS name. This name is also given to the underlying mesh.
  28373. */
  28374. name: string;
  28375. /**
  28376. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28377. */
  28378. mesh: Mesh;
  28379. /**
  28380. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28381. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28382. */
  28383. vars: any;
  28384. /**
  28385. * This array is populated when the SPS is set as 'pickable'.
  28386. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28387. * Each element of this array is an object `{idx: int, faceId: int}`.
  28388. * `idx` is the picked particle index in the `SPS.particles` array
  28389. * `faceId` is the picked face index counted within this particle.
  28390. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28391. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28392. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28393. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28394. */
  28395. pickedParticles: {
  28396. idx: number;
  28397. faceId: number;
  28398. }[];
  28399. /**
  28400. * This array is populated when the SPS is set as 'pickable'
  28401. * Each key of this array is a submesh index.
  28402. * Each element of this array is a second array defined like this :
  28403. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28404. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28405. * `idx` is the picked particle index in the `SPS.particles` array
  28406. * `faceId` is the picked face index counted within this particle.
  28407. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28408. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28409. */
  28410. pickedBySubMesh: {
  28411. idx: number;
  28412. faceId: number;
  28413. }[][];
  28414. /**
  28415. * This array is populated when `enableDepthSort` is set to true.
  28416. * Each element of this array is an instance of the class DepthSortedParticle.
  28417. */
  28418. depthSortedParticles: DepthSortedParticle[];
  28419. /**
  28420. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28421. * @hidden
  28422. */
  28423. _bSphereOnly: boolean;
  28424. /**
  28425. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28426. * @hidden
  28427. */
  28428. _bSphereRadiusFactor: number;
  28429. private _scene;
  28430. private _positions;
  28431. private _indices;
  28432. private _normals;
  28433. private _colors;
  28434. private _uvs;
  28435. private _indices32;
  28436. private _positions32;
  28437. private _normals32;
  28438. private _fixedNormal32;
  28439. private _colors32;
  28440. private _uvs32;
  28441. private _index;
  28442. private _updatable;
  28443. private _pickable;
  28444. private _isVisibilityBoxLocked;
  28445. private _alwaysVisible;
  28446. private _depthSort;
  28447. private _expandable;
  28448. private _shapeCounter;
  28449. private _copy;
  28450. private _color;
  28451. private _computeParticleColor;
  28452. private _computeParticleTexture;
  28453. private _computeParticleRotation;
  28454. private _computeParticleVertex;
  28455. private _computeBoundingBox;
  28456. private _depthSortParticles;
  28457. private _camera;
  28458. private _mustUnrotateFixedNormals;
  28459. private _particlesIntersect;
  28460. private _needs32Bits;
  28461. private _isNotBuilt;
  28462. private _lastParticleId;
  28463. private _idxOfId;
  28464. private _multimaterialEnabled;
  28465. private _useModelMaterial;
  28466. private _indicesByMaterial;
  28467. private _materialIndexes;
  28468. private _depthSortFunction;
  28469. private _materialSortFunction;
  28470. private _materials;
  28471. private _multimaterial;
  28472. private _materialIndexesById;
  28473. private _defaultMaterial;
  28474. private _autoUpdateSubMeshes;
  28475. private _tmpVertex;
  28476. /**
  28477. * Creates a SPS (Solid Particle System) object.
  28478. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28479. * @param scene (Scene) is the scene in which the SPS is added.
  28480. * @param options defines the options of the sps e.g.
  28481. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28482. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28483. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28484. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  28485. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28486. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28487. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28488. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28489. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28490. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28491. */
  28492. constructor(name: string, scene: Scene, options?: {
  28493. updatable?: boolean;
  28494. isPickable?: boolean;
  28495. enableDepthSort?: boolean;
  28496. particleIntersection?: boolean;
  28497. boundingSphereOnly?: boolean;
  28498. bSphereRadiusFactor?: number;
  28499. expandable?: boolean;
  28500. useModelMaterial?: boolean;
  28501. enableMultiMaterial?: boolean;
  28502. });
  28503. /**
  28504. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28505. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28506. * @returns the created mesh
  28507. */
  28508. buildMesh(): Mesh;
  28509. /**
  28510. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28511. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28512. * Thus the particles generated from `digest()` have their property `position` set yet.
  28513. * @param mesh ( Mesh ) is the mesh to be digested
  28514. * @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
  28515. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28516. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28517. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28518. * @returns the current SPS
  28519. */
  28520. digest(mesh: Mesh, options?: {
  28521. facetNb?: number;
  28522. number?: number;
  28523. delta?: number;
  28524. storage?: [];
  28525. }): SolidParticleSystem;
  28526. /**
  28527. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28528. * @hidden
  28529. */
  28530. private _unrotateFixedNormals;
  28531. /**
  28532. * Resets the temporary working copy particle
  28533. * @hidden
  28534. */
  28535. private _resetCopy;
  28536. /**
  28537. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28538. * @param p the current index in the positions array to be updated
  28539. * @param ind the current index in the indices array
  28540. * @param shape a Vector3 array, the shape geometry
  28541. * @param positions the positions array to be updated
  28542. * @param meshInd the shape indices array
  28543. * @param indices the indices array to be updated
  28544. * @param meshUV the shape uv array
  28545. * @param uvs the uv array to be updated
  28546. * @param meshCol the shape color array
  28547. * @param colors the color array to be updated
  28548. * @param meshNor the shape normals array
  28549. * @param normals the normals array to be updated
  28550. * @param idx the particle index
  28551. * @param idxInShape the particle index in its shape
  28552. * @param options the addShape() method passed options
  28553. * @model the particle model
  28554. * @hidden
  28555. */
  28556. private _meshBuilder;
  28557. /**
  28558. * Returns a shape Vector3 array from positions float array
  28559. * @param positions float array
  28560. * @returns a vector3 array
  28561. * @hidden
  28562. */
  28563. private _posToShape;
  28564. /**
  28565. * Returns a shapeUV array from a float uvs (array deep copy)
  28566. * @param uvs as a float array
  28567. * @returns a shapeUV array
  28568. * @hidden
  28569. */
  28570. private _uvsToShapeUV;
  28571. /**
  28572. * Adds a new particle object in the particles array
  28573. * @param idx particle index in particles array
  28574. * @param id particle id
  28575. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28576. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28577. * @param model particle ModelShape object
  28578. * @param shapeId model shape identifier
  28579. * @param idxInShape index of the particle in the current model
  28580. * @param bInfo model bounding info object
  28581. * @param storage target storage array, if any
  28582. * @hidden
  28583. */
  28584. private _addParticle;
  28585. /**
  28586. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28587. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28588. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28589. * @param nb (positive integer) the number of particles to be created from this model
  28590. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28591. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28592. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28593. * @returns the number of shapes in the system
  28594. */
  28595. addShape(mesh: Mesh, nb: number, options?: {
  28596. positionFunction?: any;
  28597. vertexFunction?: any;
  28598. storage?: [];
  28599. }): number;
  28600. /**
  28601. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28602. * @hidden
  28603. */
  28604. private _rebuildParticle;
  28605. /**
  28606. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28607. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  28608. * @returns the SPS.
  28609. */
  28610. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28611. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28612. * Returns an array with the removed particles.
  28613. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  28614. * The SPS can't be empty so at least one particle needs to remain in place.
  28615. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28616. * @param start index of the first particle to remove
  28617. * @param end index of the last particle to remove (included)
  28618. * @returns an array populated with the removed particles
  28619. */
  28620. removeParticles(start: number, end: number): SolidParticle[];
  28621. /**
  28622. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28623. * @param solidParticleArray an array populated with Solid Particles objects
  28624. * @returns the SPS
  28625. */
  28626. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28627. /**
  28628. * Creates a new particle and modifies the SPS mesh geometry :
  28629. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28630. * - calls _addParticle() to populate the particle array
  28631. * factorized code from addShape() and insertParticlesFromArray()
  28632. * @param idx particle index in the particles array
  28633. * @param i particle index in its shape
  28634. * @param modelShape particle ModelShape object
  28635. * @param shape shape vertex array
  28636. * @param meshInd shape indices array
  28637. * @param meshUV shape uv array
  28638. * @param meshCol shape color array
  28639. * @param meshNor shape normals array
  28640. * @param bbInfo shape bounding info
  28641. * @param storage target particle storage
  28642. * @options addShape() passed options
  28643. * @hidden
  28644. */
  28645. private _insertNewParticle;
  28646. /**
  28647. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28648. * This method calls `updateParticle()` for each particle of the SPS.
  28649. * For an animated SPS, it is usually called within the render loop.
  28650. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28651. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28652. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28653. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28654. * @returns the SPS.
  28655. */
  28656. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28657. /**
  28658. * Disposes the SPS.
  28659. */
  28660. dispose(): void;
  28661. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28662. * idx is the particle index in the SPS
  28663. * faceId is the picked face index counted within this particle.
  28664. * Returns null if the pickInfo can't identify a picked particle.
  28665. * @param pickingInfo (PickingInfo object)
  28666. * @returns {idx: number, faceId: number} or null
  28667. */
  28668. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28669. idx: number;
  28670. faceId: number;
  28671. }>;
  28672. /**
  28673. * Returns a SolidParticle object from its identifier : particle.id
  28674. * @param id (integer) the particle Id
  28675. * @returns the searched particle or null if not found in the SPS.
  28676. */
  28677. getParticleById(id: number): Nullable<SolidParticle>;
  28678. /**
  28679. * Returns a new array populated with the particles having the passed shapeId.
  28680. * @param shapeId (integer) the shape identifier
  28681. * @returns a new solid particle array
  28682. */
  28683. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28684. /**
  28685. * Populates the passed array "ref" with the particles having the passed shapeId.
  28686. * @param shapeId the shape identifier
  28687. * @returns the SPS
  28688. * @param ref
  28689. */
  28690. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28691. /**
  28692. * Computes the required SubMeshes according the materials assigned to the particles.
  28693. * @returns the solid particle system.
  28694. * Does nothing if called before the SPS mesh is built.
  28695. */
  28696. computeSubMeshes(): SolidParticleSystem;
  28697. /**
  28698. * Sorts the solid particles by material when MultiMaterial is enabled.
  28699. * Updates the indices32 array.
  28700. * Updates the indicesByMaterial array.
  28701. * Updates the mesh indices array.
  28702. * @returns the SPS
  28703. * @hidden
  28704. */
  28705. private _sortParticlesByMaterial;
  28706. /**
  28707. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28708. * @hidden
  28709. */
  28710. private _setMaterialIndexesById;
  28711. /**
  28712. * Returns an array with unique values of Materials from the passed array
  28713. * @param array the material array to be checked and filtered
  28714. * @hidden
  28715. */
  28716. private _filterUniqueMaterialId;
  28717. /**
  28718. * Sets a new Standard Material as _defaultMaterial if not already set.
  28719. * @hidden
  28720. */
  28721. private _setDefaultMaterial;
  28722. /**
  28723. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28724. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28725. * @returns the SPS.
  28726. */
  28727. refreshVisibleSize(): SolidParticleSystem;
  28728. /**
  28729. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28730. * @param size the size (float) of the visibility box
  28731. * note : this doesn't lock the SPS mesh bounding box.
  28732. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28733. */
  28734. setVisibilityBox(size: number): void;
  28735. /**
  28736. * Gets whether the SPS as always visible or not
  28737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28738. */
  28739. get isAlwaysVisible(): boolean;
  28740. /**
  28741. * Sets the SPS as always visible or not
  28742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28743. */
  28744. set isAlwaysVisible(val: boolean);
  28745. /**
  28746. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28747. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28748. */
  28749. set isVisibilityBoxLocked(val: boolean);
  28750. /**
  28751. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28752. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28753. */
  28754. get isVisibilityBoxLocked(): boolean;
  28755. /**
  28756. * Tells to `setParticles()` to compute the particle rotations or not.
  28757. * Default value : true. The SPS is faster when it's set to false.
  28758. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28759. */
  28760. set computeParticleRotation(val: boolean);
  28761. /**
  28762. * Tells to `setParticles()` to compute the particle colors or not.
  28763. * Default value : true. The SPS is faster when it's set to false.
  28764. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28765. */
  28766. set computeParticleColor(val: boolean);
  28767. set computeParticleTexture(val: boolean);
  28768. /**
  28769. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28770. * Default value : false. The SPS is faster when it's set to false.
  28771. * Note : the particle custom vertex positions aren't stored values.
  28772. */
  28773. set computeParticleVertex(val: boolean);
  28774. /**
  28775. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28776. */
  28777. set computeBoundingBox(val: boolean);
  28778. /**
  28779. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28780. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28781. * Default : `true`
  28782. */
  28783. set depthSortParticles(val: boolean);
  28784. /**
  28785. * Gets if `setParticles()` computes the particle rotations or not.
  28786. * Default value : true. The SPS is faster when it's set to false.
  28787. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28788. */
  28789. get computeParticleRotation(): boolean;
  28790. /**
  28791. * Gets if `setParticles()` computes the particle colors or not.
  28792. * Default value : true. The SPS is faster when it's set to false.
  28793. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28794. */
  28795. get computeParticleColor(): boolean;
  28796. /**
  28797. * Gets if `setParticles()` computes the particle textures or not.
  28798. * Default value : true. The SPS is faster when it's set to false.
  28799. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28800. */
  28801. get computeParticleTexture(): boolean;
  28802. /**
  28803. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28804. * Default value : false. The SPS is faster when it's set to false.
  28805. * Note : the particle custom vertex positions aren't stored values.
  28806. */
  28807. get computeParticleVertex(): boolean;
  28808. /**
  28809. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28810. */
  28811. get computeBoundingBox(): boolean;
  28812. /**
  28813. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28814. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28815. * Default : `true`
  28816. */
  28817. get depthSortParticles(): boolean;
  28818. /**
  28819. * Gets if the SPS is created as expandable at construction time.
  28820. * Default : `false`
  28821. */
  28822. get expandable(): boolean;
  28823. /**
  28824. * Gets if the SPS supports the Multi Materials
  28825. */
  28826. get multimaterialEnabled(): boolean;
  28827. /**
  28828. * Gets if the SPS uses the model materials for its own multimaterial.
  28829. */
  28830. get useModelMaterial(): boolean;
  28831. /**
  28832. * The SPS used material array.
  28833. */
  28834. get materials(): Material[];
  28835. /**
  28836. * Sets the SPS MultiMaterial from the passed materials.
  28837. * Note : the passed array is internally copied and not used then by reference.
  28838. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28839. */
  28840. setMultiMaterial(materials: Material[]): void;
  28841. /**
  28842. * The SPS computed multimaterial object
  28843. */
  28844. get multimaterial(): MultiMaterial;
  28845. set multimaterial(mm: MultiMaterial);
  28846. /**
  28847. * If the subMeshes must be updated on the next call to setParticles()
  28848. */
  28849. get autoUpdateSubMeshes(): boolean;
  28850. set autoUpdateSubMeshes(val: boolean);
  28851. /**
  28852. * This function does nothing. It may be overwritten to set all the particle first values.
  28853. * The SPS doesn't call this function, you may have to call it by your own.
  28854. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28855. */
  28856. initParticles(): void;
  28857. /**
  28858. * This function does nothing. It may be overwritten to recycle a particle.
  28859. * The SPS doesn't call this function, you may have to call it by your own.
  28860. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28861. * @param particle The particle to recycle
  28862. * @returns the recycled particle
  28863. */
  28864. recycleParticle(particle: SolidParticle): SolidParticle;
  28865. /**
  28866. * Updates a particle : this function should be overwritten by the user.
  28867. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28868. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28869. * @example : just set a particle position or velocity and recycle conditions
  28870. * @param particle The particle to update
  28871. * @returns the updated particle
  28872. */
  28873. updateParticle(particle: SolidParticle): SolidParticle;
  28874. /**
  28875. * Updates a vertex of a particle : it can be overwritten by the user.
  28876. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28877. * @param particle the current particle
  28878. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  28879. * @param pt the index of the current vertex in the particle shape
  28880. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28881. * @example : just set a vertex particle position or color
  28882. * @returns the sps
  28883. */
  28884. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  28885. /**
  28886. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28887. * This does nothing and may be overwritten by the user.
  28888. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28889. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28890. * @param update the boolean update value actually passed to setParticles()
  28891. */
  28892. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28893. /**
  28894. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28895. * This will be passed three parameters.
  28896. * This does nothing and may be overwritten by the user.
  28897. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28898. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28899. * @param update the boolean update value actually passed to setParticles()
  28900. */
  28901. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28902. }
  28903. }
  28904. declare module "babylonjs/Particles/solidParticle" {
  28905. import { Nullable } from "babylonjs/types";
  28906. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  28907. import { Color4 } from "babylonjs/Maths/math.color";
  28908. import { Mesh } from "babylonjs/Meshes/mesh";
  28909. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28910. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28911. import { Plane } from "babylonjs/Maths/math.plane";
  28912. import { Material } from "babylonjs/Materials/material";
  28913. /**
  28914. * Represents one particle of a solid particle system.
  28915. */
  28916. export class SolidParticle {
  28917. /**
  28918. * particle global index
  28919. */
  28920. idx: number;
  28921. /**
  28922. * particle identifier
  28923. */
  28924. id: number;
  28925. /**
  28926. * The color of the particle
  28927. */
  28928. color: Nullable<Color4>;
  28929. /**
  28930. * The world space position of the particle.
  28931. */
  28932. position: Vector3;
  28933. /**
  28934. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28935. */
  28936. rotation: Vector3;
  28937. /**
  28938. * The world space rotation quaternion of the particle.
  28939. */
  28940. rotationQuaternion: Nullable<Quaternion>;
  28941. /**
  28942. * The scaling of the particle.
  28943. */
  28944. scaling: Vector3;
  28945. /**
  28946. * The uvs of the particle.
  28947. */
  28948. uvs: Vector4;
  28949. /**
  28950. * The current speed of the particle.
  28951. */
  28952. velocity: Vector3;
  28953. /**
  28954. * The pivot point in the particle local space.
  28955. */
  28956. pivot: Vector3;
  28957. /**
  28958. * Must the particle be translated from its pivot point in its local space ?
  28959. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28960. * Default : false
  28961. */
  28962. translateFromPivot: boolean;
  28963. /**
  28964. * Is the particle active or not ?
  28965. */
  28966. alive: boolean;
  28967. /**
  28968. * Is the particle visible or not ?
  28969. */
  28970. isVisible: boolean;
  28971. /**
  28972. * Index of this particle in the global "positions" array (Internal use)
  28973. * @hidden
  28974. */
  28975. _pos: number;
  28976. /**
  28977. * @hidden Index of this particle in the global "indices" array (Internal use)
  28978. */
  28979. _ind: number;
  28980. /**
  28981. * @hidden ModelShape of this particle (Internal use)
  28982. */
  28983. _model: ModelShape;
  28984. /**
  28985. * ModelShape id of this particle
  28986. */
  28987. shapeId: number;
  28988. /**
  28989. * Index of the particle in its shape id
  28990. */
  28991. idxInShape: number;
  28992. /**
  28993. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28994. */
  28995. _modelBoundingInfo: BoundingInfo;
  28996. /**
  28997. * @hidden Particle BoundingInfo object (Internal use)
  28998. */
  28999. _boundingInfo: BoundingInfo;
  29000. /**
  29001. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  29002. */
  29003. _sps: SolidParticleSystem;
  29004. /**
  29005. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  29006. */
  29007. _stillInvisible: boolean;
  29008. /**
  29009. * @hidden Last computed particle rotation matrix
  29010. */
  29011. _rotationMatrix: number[];
  29012. /**
  29013. * Parent particle Id, if any.
  29014. * Default null.
  29015. */
  29016. parentId: Nullable<number>;
  29017. /**
  29018. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  29019. */
  29020. materialIndex: Nullable<number>;
  29021. /**
  29022. * Custom object or properties.
  29023. */
  29024. props: Nullable<any>;
  29025. /**
  29026. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  29027. * The possible values are :
  29028. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29029. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29032. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29033. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  29034. * */
  29035. cullingStrategy: number;
  29036. /**
  29037. * @hidden Internal global position in the SPS.
  29038. */
  29039. _globalPosition: Vector3;
  29040. /**
  29041. * Creates a Solid Particle object.
  29042. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  29043. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  29044. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  29045. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  29046. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  29047. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  29048. * @param shapeId (integer) is the model shape identifier in the SPS.
  29049. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  29050. * @param sps defines the sps it is associated to
  29051. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  29052. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  29053. */
  29054. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  29055. /**
  29056. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  29057. * @param target the particle target
  29058. * @returns the current particle
  29059. */
  29060. copyToRef(target: SolidParticle): SolidParticle;
  29061. /**
  29062. * Legacy support, changed scale to scaling
  29063. */
  29064. get scale(): Vector3;
  29065. /**
  29066. * Legacy support, changed scale to scaling
  29067. */
  29068. set scale(scale: Vector3);
  29069. /**
  29070. * Legacy support, changed quaternion to rotationQuaternion
  29071. */
  29072. get quaternion(): Nullable<Quaternion>;
  29073. /**
  29074. * Legacy support, changed quaternion to rotationQuaternion
  29075. */
  29076. set quaternion(q: Nullable<Quaternion>);
  29077. /**
  29078. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  29079. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  29080. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  29081. * @returns true if it intersects
  29082. */
  29083. intersectsMesh(target: Mesh | SolidParticle): boolean;
  29084. /**
  29085. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  29086. * A particle is in the frustum if its bounding box intersects the frustum
  29087. * @param frustumPlanes defines the frustum to test
  29088. * @returns true if the particle is in the frustum planes
  29089. */
  29090. isInFrustum(frustumPlanes: Plane[]): boolean;
  29091. /**
  29092. * get the rotation matrix of the particle
  29093. * @hidden
  29094. */
  29095. getRotationMatrix(m: Matrix): void;
  29096. }
  29097. /**
  29098. * Represents the shape of the model used by one particle of a solid particle system.
  29099. * SPS internal tool, don't use it manually.
  29100. */
  29101. export class ModelShape {
  29102. /**
  29103. * The shape id
  29104. * @hidden
  29105. */
  29106. shapeID: number;
  29107. /**
  29108. * flat array of model positions (internal use)
  29109. * @hidden
  29110. */
  29111. _shape: Vector3[];
  29112. /**
  29113. * flat array of model UVs (internal use)
  29114. * @hidden
  29115. */
  29116. _shapeUV: number[];
  29117. /**
  29118. * color array of the model
  29119. * @hidden
  29120. */
  29121. _shapeColors: number[];
  29122. /**
  29123. * indices array of the model
  29124. * @hidden
  29125. */
  29126. _indices: number[];
  29127. /**
  29128. * normals array of the model
  29129. * @hidden
  29130. */
  29131. _normals: number[];
  29132. /**
  29133. * length of the shape in the model indices array (internal use)
  29134. * @hidden
  29135. */
  29136. _indicesLength: number;
  29137. /**
  29138. * Custom position function (internal use)
  29139. * @hidden
  29140. */
  29141. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29142. /**
  29143. * Custom vertex function (internal use)
  29144. * @hidden
  29145. */
  29146. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29147. /**
  29148. * Model material (internal use)
  29149. * @hidden
  29150. */
  29151. _material: Nullable<Material>;
  29152. /**
  29153. * 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.
  29154. * SPS internal tool, don't use it manually.
  29155. * @hidden
  29156. */
  29157. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  29158. }
  29159. /**
  29160. * Represents a Depth Sorted Particle in the solid particle system.
  29161. * @hidden
  29162. */
  29163. export class DepthSortedParticle {
  29164. /**
  29165. * Particle index
  29166. */
  29167. idx: number;
  29168. /**
  29169. * Index of the particle in the "indices" array
  29170. */
  29171. ind: number;
  29172. /**
  29173. * Length of the particle shape in the "indices" array
  29174. */
  29175. indicesLength: number;
  29176. /**
  29177. * Squared distance from the particle to the camera
  29178. */
  29179. sqDistance: number;
  29180. /**
  29181. * Material index when used with MultiMaterials
  29182. */
  29183. materialIndex: number;
  29184. /**
  29185. * Creates a new sorted particle
  29186. * @param materialIndex
  29187. */
  29188. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  29189. }
  29190. /**
  29191. * Represents a solid particle vertex
  29192. */
  29193. export class SolidParticleVertex {
  29194. /**
  29195. * Vertex position
  29196. */
  29197. position: Vector3;
  29198. /**
  29199. * Vertex color
  29200. */
  29201. color: Color4;
  29202. /**
  29203. * Vertex UV
  29204. */
  29205. uv: Vector2;
  29206. /**
  29207. * Creates a new solid particle vertex
  29208. */
  29209. constructor();
  29210. /** Vertex x coordinate */
  29211. get x(): number;
  29212. set x(val: number);
  29213. /** Vertex y coordinate */
  29214. get y(): number;
  29215. set y(val: number);
  29216. /** Vertex z coordinate */
  29217. get z(): number;
  29218. set z(val: number);
  29219. }
  29220. }
  29221. declare module "babylonjs/Collisions/meshCollisionData" {
  29222. import { Collider } from "babylonjs/Collisions/collider";
  29223. import { Vector3 } from "babylonjs/Maths/math.vector";
  29224. import { Nullable } from "babylonjs/types";
  29225. import { Observer } from "babylonjs/Misc/observable";
  29226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29227. /**
  29228. * @hidden
  29229. */
  29230. export class _MeshCollisionData {
  29231. _checkCollisions: boolean;
  29232. _collisionMask: number;
  29233. _collisionGroup: number;
  29234. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29235. _collider: Nullable<Collider>;
  29236. _oldPositionForCollisions: Vector3;
  29237. _diffPositionForCollisions: Vector3;
  29238. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29239. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29240. }
  29241. }
  29242. declare module "babylonjs/Meshes/abstractMesh" {
  29243. import { Observable } from "babylonjs/Misc/observable";
  29244. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29245. import { Camera } from "babylonjs/Cameras/camera";
  29246. import { Scene, IDisposable } from "babylonjs/scene";
  29247. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29248. import { Node } from "babylonjs/node";
  29249. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29251. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29252. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29253. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29254. import { Material } from "babylonjs/Materials/material";
  29255. import { Light } from "babylonjs/Lights/light";
  29256. import { Skeleton } from "babylonjs/Bones/skeleton";
  29257. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29258. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29259. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29260. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29261. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29262. import { Plane } from "babylonjs/Maths/math.plane";
  29263. import { Ray } from "babylonjs/Culling/ray";
  29264. import { Collider } from "babylonjs/Collisions/collider";
  29265. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29266. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29267. /** @hidden */
  29268. class _FacetDataStorage {
  29269. facetPositions: Vector3[];
  29270. facetNormals: Vector3[];
  29271. facetPartitioning: number[][];
  29272. facetNb: number;
  29273. partitioningSubdivisions: number;
  29274. partitioningBBoxRatio: number;
  29275. facetDataEnabled: boolean;
  29276. facetParameters: any;
  29277. bbSize: Vector3;
  29278. subDiv: {
  29279. max: number;
  29280. X: number;
  29281. Y: number;
  29282. Z: number;
  29283. };
  29284. facetDepthSort: boolean;
  29285. facetDepthSortEnabled: boolean;
  29286. depthSortedIndices: IndicesArray;
  29287. depthSortedFacets: {
  29288. ind: number;
  29289. sqDistance: number;
  29290. }[];
  29291. facetDepthSortFunction: (f1: {
  29292. ind: number;
  29293. sqDistance: number;
  29294. }, f2: {
  29295. ind: number;
  29296. sqDistance: number;
  29297. }) => number;
  29298. facetDepthSortFrom: Vector3;
  29299. facetDepthSortOrigin: Vector3;
  29300. invertedMatrix: Matrix;
  29301. }
  29302. /**
  29303. * @hidden
  29304. **/
  29305. class _InternalAbstractMeshDataInfo {
  29306. _hasVertexAlpha: boolean;
  29307. _useVertexColors: boolean;
  29308. _numBoneInfluencers: number;
  29309. _applyFog: boolean;
  29310. _receiveShadows: boolean;
  29311. _facetData: _FacetDataStorage;
  29312. _visibility: number;
  29313. _skeleton: Nullable<Skeleton>;
  29314. _layerMask: number;
  29315. _computeBonesUsingShaders: boolean;
  29316. _isActive: boolean;
  29317. _onlyForInstances: boolean;
  29318. _isActiveIntermediate: boolean;
  29319. _onlyForInstancesIntermediate: boolean;
  29320. _actAsRegularMesh: boolean;
  29321. }
  29322. /**
  29323. * Class used to store all common mesh properties
  29324. */
  29325. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29326. /** No occlusion */
  29327. static OCCLUSION_TYPE_NONE: number;
  29328. /** Occlusion set to optimisitic */
  29329. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29330. /** Occlusion set to strict */
  29331. static OCCLUSION_TYPE_STRICT: number;
  29332. /** Use an accurante occlusion algorithm */
  29333. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29334. /** Use a conservative occlusion algorithm */
  29335. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29336. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29337. * Test order :
  29338. * Is the bounding sphere outside the frustum ?
  29339. * If not, are the bounding box vertices outside the frustum ?
  29340. * It not, then the cullable object is in the frustum.
  29341. */
  29342. static readonly CULLINGSTRATEGY_STANDARD: number;
  29343. /** Culling strategy : Bounding Sphere Only.
  29344. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29345. * It's also less accurate than the standard because some not visible objects can still be selected.
  29346. * Test : is the bounding sphere outside the frustum ?
  29347. * If not, then the cullable object is in the frustum.
  29348. */
  29349. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29350. /** Culling strategy : Optimistic Inclusion.
  29351. * This in an inclusion test first, then the standard exclusion test.
  29352. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29353. * 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.
  29354. * Anyway, it's as accurate as the standard strategy.
  29355. * Test :
  29356. * Is the cullable object bounding sphere center in the frustum ?
  29357. * If not, apply the default culling strategy.
  29358. */
  29359. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29360. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29361. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29362. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29363. * 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.
  29364. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29365. * Test :
  29366. * Is the cullable object bounding sphere center in the frustum ?
  29367. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29368. */
  29369. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29370. /**
  29371. * No billboard
  29372. */
  29373. static get BILLBOARDMODE_NONE(): number;
  29374. /** Billboard on X axis */
  29375. static get BILLBOARDMODE_X(): number;
  29376. /** Billboard on Y axis */
  29377. static get BILLBOARDMODE_Y(): number;
  29378. /** Billboard on Z axis */
  29379. static get BILLBOARDMODE_Z(): number;
  29380. /** Billboard on all axes */
  29381. static get BILLBOARDMODE_ALL(): number;
  29382. /** Billboard on using position instead of orientation */
  29383. static get BILLBOARDMODE_USE_POSITION(): number;
  29384. /** @hidden */
  29385. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29386. /**
  29387. * The culling strategy to use to check whether the mesh must be rendered or not.
  29388. * This value can be changed at any time and will be used on the next render mesh selection.
  29389. * The possible values are :
  29390. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29391. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29392. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29393. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29394. * Please read each static variable documentation to get details about the culling process.
  29395. * */
  29396. cullingStrategy: number;
  29397. /**
  29398. * Gets the number of facets in the mesh
  29399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29400. */
  29401. get facetNb(): number;
  29402. /**
  29403. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29405. */
  29406. get partitioningSubdivisions(): number;
  29407. set partitioningSubdivisions(nb: number);
  29408. /**
  29409. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29410. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29412. */
  29413. get partitioningBBoxRatio(): number;
  29414. set partitioningBBoxRatio(ratio: number);
  29415. /**
  29416. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29417. * Works only for updatable meshes.
  29418. * Doesn't work with multi-materials
  29419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29420. */
  29421. get mustDepthSortFacets(): boolean;
  29422. set mustDepthSortFacets(sort: boolean);
  29423. /**
  29424. * The location (Vector3) where the facet depth sort must be computed from.
  29425. * By default, the active camera position.
  29426. * Used only when facet depth sort is enabled
  29427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29428. */
  29429. get facetDepthSortFrom(): Vector3;
  29430. set facetDepthSortFrom(location: Vector3);
  29431. /**
  29432. * gets a boolean indicating if facetData is enabled
  29433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29434. */
  29435. get isFacetDataEnabled(): boolean;
  29436. /** @hidden */
  29437. _updateNonUniformScalingState(value: boolean): boolean;
  29438. /**
  29439. * An event triggered when this mesh collides with another one
  29440. */
  29441. onCollideObservable: Observable<AbstractMesh>;
  29442. /** Set a function to call when this mesh collides with another one */
  29443. set onCollide(callback: () => void);
  29444. /**
  29445. * An event triggered when the collision's position changes
  29446. */
  29447. onCollisionPositionChangeObservable: Observable<Vector3>;
  29448. /** Set a function to call when the collision's position changes */
  29449. set onCollisionPositionChange(callback: () => void);
  29450. /**
  29451. * An event triggered when material is changed
  29452. */
  29453. onMaterialChangedObservable: Observable<AbstractMesh>;
  29454. /**
  29455. * Gets or sets the orientation for POV movement & rotation
  29456. */
  29457. definedFacingForward: boolean;
  29458. /** @hidden */
  29459. _occlusionQuery: Nullable<WebGLQuery>;
  29460. /** @hidden */
  29461. _renderingGroup: Nullable<RenderingGroup>;
  29462. /**
  29463. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29464. */
  29465. get visibility(): number;
  29466. /**
  29467. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29468. */
  29469. set visibility(value: number);
  29470. /** Gets or sets the alpha index used to sort transparent meshes
  29471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29472. */
  29473. alphaIndex: number;
  29474. /**
  29475. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29476. */
  29477. isVisible: boolean;
  29478. /**
  29479. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29480. */
  29481. isPickable: boolean;
  29482. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29483. showSubMeshesBoundingBox: boolean;
  29484. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29485. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29486. */
  29487. isBlocker: boolean;
  29488. /**
  29489. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29490. */
  29491. enablePointerMoveEvents: boolean;
  29492. /**
  29493. * Specifies the rendering group id for this mesh (0 by default)
  29494. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29495. */
  29496. renderingGroupId: number;
  29497. private _material;
  29498. /** Gets or sets current material */
  29499. get material(): Nullable<Material>;
  29500. set material(value: Nullable<Material>);
  29501. /**
  29502. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29503. * @see http://doc.babylonjs.com/babylon101/shadows
  29504. */
  29505. get receiveShadows(): boolean;
  29506. set receiveShadows(value: boolean);
  29507. /** Defines color to use when rendering outline */
  29508. outlineColor: Color3;
  29509. /** Define width to use when rendering outline */
  29510. outlineWidth: number;
  29511. /** Defines color to use when rendering overlay */
  29512. overlayColor: Color3;
  29513. /** Defines alpha to use when rendering overlay */
  29514. overlayAlpha: number;
  29515. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29516. get hasVertexAlpha(): boolean;
  29517. set hasVertexAlpha(value: boolean);
  29518. /** 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) */
  29519. get useVertexColors(): boolean;
  29520. set useVertexColors(value: boolean);
  29521. /**
  29522. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29523. */
  29524. get computeBonesUsingShaders(): boolean;
  29525. set computeBonesUsingShaders(value: boolean);
  29526. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29527. get numBoneInfluencers(): number;
  29528. set numBoneInfluencers(value: number);
  29529. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29530. get applyFog(): boolean;
  29531. set applyFog(value: boolean);
  29532. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29533. useOctreeForRenderingSelection: boolean;
  29534. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29535. useOctreeForPicking: boolean;
  29536. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29537. useOctreeForCollisions: boolean;
  29538. /**
  29539. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29540. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29541. */
  29542. get layerMask(): number;
  29543. set layerMask(value: number);
  29544. /**
  29545. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29546. */
  29547. alwaysSelectAsActiveMesh: boolean;
  29548. /**
  29549. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29550. */
  29551. doNotSyncBoundingInfo: boolean;
  29552. /**
  29553. * Gets or sets the current action manager
  29554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29555. */
  29556. actionManager: Nullable<AbstractActionManager>;
  29557. private _meshCollisionData;
  29558. /**
  29559. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29560. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29561. */
  29562. ellipsoid: Vector3;
  29563. /**
  29564. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29566. */
  29567. ellipsoidOffset: Vector3;
  29568. /**
  29569. * Gets or sets a collision mask used to mask collisions (default is -1).
  29570. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29571. */
  29572. get collisionMask(): number;
  29573. set collisionMask(mask: number);
  29574. /**
  29575. * Gets or sets the current collision group mask (-1 by default).
  29576. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29577. */
  29578. get collisionGroup(): number;
  29579. set collisionGroup(mask: number);
  29580. /**
  29581. * Gets or sets current surrounding meshes (null by default).
  29582. *
  29583. * By default collision detection is tested against every mesh in the scene.
  29584. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29585. * meshes will be tested for the collision.
  29586. *
  29587. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29588. */
  29589. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29590. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29591. /**
  29592. * Defines edge width used when edgesRenderer is enabled
  29593. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29594. */
  29595. edgesWidth: number;
  29596. /**
  29597. * Defines edge color used when edgesRenderer is enabled
  29598. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29599. */
  29600. edgesColor: Color4;
  29601. /** @hidden */
  29602. _edgesRenderer: Nullable<IEdgesRenderer>;
  29603. /** @hidden */
  29604. _masterMesh: Nullable<AbstractMesh>;
  29605. /** @hidden */
  29606. _boundingInfo: Nullable<BoundingInfo>;
  29607. /** @hidden */
  29608. _renderId: number;
  29609. /**
  29610. * Gets or sets the list of subMeshes
  29611. * @see http://doc.babylonjs.com/how_to/multi_materials
  29612. */
  29613. subMeshes: SubMesh[];
  29614. /** @hidden */
  29615. _intersectionsInProgress: AbstractMesh[];
  29616. /** @hidden */
  29617. _unIndexed: boolean;
  29618. /** @hidden */
  29619. _lightSources: Light[];
  29620. /** Gets the list of lights affecting that mesh */
  29621. get lightSources(): Light[];
  29622. /** @hidden */
  29623. get _positions(): Nullable<Vector3[]>;
  29624. /** @hidden */
  29625. _waitingData: {
  29626. lods: Nullable<any>;
  29627. actions: Nullable<any>;
  29628. freezeWorldMatrix: Nullable<boolean>;
  29629. };
  29630. /** @hidden */
  29631. _bonesTransformMatrices: Nullable<Float32Array>;
  29632. /** @hidden */
  29633. _transformMatrixTexture: Nullable<RawTexture>;
  29634. /**
  29635. * Gets or sets a skeleton to apply skining transformations
  29636. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29637. */
  29638. set skeleton(value: Nullable<Skeleton>);
  29639. get skeleton(): Nullable<Skeleton>;
  29640. /**
  29641. * An event triggered when the mesh is rebuilt.
  29642. */
  29643. onRebuildObservable: Observable<AbstractMesh>;
  29644. /**
  29645. * Creates a new AbstractMesh
  29646. * @param name defines the name of the mesh
  29647. * @param scene defines the hosting scene
  29648. */
  29649. constructor(name: string, scene?: Nullable<Scene>);
  29650. /**
  29651. * Returns the string "AbstractMesh"
  29652. * @returns "AbstractMesh"
  29653. */
  29654. getClassName(): string;
  29655. /**
  29656. * Gets a string representation of the current mesh
  29657. * @param fullDetails defines a boolean indicating if full details must be included
  29658. * @returns a string representation of the current mesh
  29659. */
  29660. toString(fullDetails?: boolean): string;
  29661. /**
  29662. * @hidden
  29663. */
  29664. protected _getEffectiveParent(): Nullable<Node>;
  29665. /** @hidden */
  29666. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29667. /** @hidden */
  29668. _rebuild(): void;
  29669. /** @hidden */
  29670. _resyncLightSources(): void;
  29671. /** @hidden */
  29672. _resyncLightSource(light: Light): void;
  29673. /** @hidden */
  29674. _unBindEffect(): void;
  29675. /** @hidden */
  29676. _removeLightSource(light: Light, dispose: boolean): void;
  29677. private _markSubMeshesAsDirty;
  29678. /** @hidden */
  29679. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29680. /** @hidden */
  29681. _markSubMeshesAsAttributesDirty(): void;
  29682. /** @hidden */
  29683. _markSubMeshesAsMiscDirty(): void;
  29684. /**
  29685. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29686. */
  29687. get scaling(): Vector3;
  29688. set scaling(newScaling: Vector3);
  29689. /**
  29690. * Returns true if the mesh is blocked. Implemented by child classes
  29691. */
  29692. get isBlocked(): boolean;
  29693. /**
  29694. * Returns the mesh itself by default. Implemented by child classes
  29695. * @param camera defines the camera to use to pick the right LOD level
  29696. * @returns the currentAbstractMesh
  29697. */
  29698. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29699. /**
  29700. * Returns 0 by default. Implemented by child classes
  29701. * @returns an integer
  29702. */
  29703. getTotalVertices(): number;
  29704. /**
  29705. * Returns a positive integer : the total number of indices in this mesh geometry.
  29706. * @returns the numner of indices or zero if the mesh has no geometry.
  29707. */
  29708. getTotalIndices(): number;
  29709. /**
  29710. * Returns null by default. Implemented by child classes
  29711. * @returns null
  29712. */
  29713. getIndices(): Nullable<IndicesArray>;
  29714. /**
  29715. * Returns the array of the requested vertex data kind. Implemented by child classes
  29716. * @param kind defines the vertex data kind to use
  29717. * @returns null
  29718. */
  29719. getVerticesData(kind: string): Nullable<FloatArray>;
  29720. /**
  29721. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29722. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29723. * Note that a new underlying VertexBuffer object is created each call.
  29724. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29725. * @param kind defines vertex data kind:
  29726. * * VertexBuffer.PositionKind
  29727. * * VertexBuffer.UVKind
  29728. * * VertexBuffer.UV2Kind
  29729. * * VertexBuffer.UV3Kind
  29730. * * VertexBuffer.UV4Kind
  29731. * * VertexBuffer.UV5Kind
  29732. * * VertexBuffer.UV6Kind
  29733. * * VertexBuffer.ColorKind
  29734. * * VertexBuffer.MatricesIndicesKind
  29735. * * VertexBuffer.MatricesIndicesExtraKind
  29736. * * VertexBuffer.MatricesWeightsKind
  29737. * * VertexBuffer.MatricesWeightsExtraKind
  29738. * @param data defines the data source
  29739. * @param updatable defines if the data must be flagged as updatable (or static)
  29740. * @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
  29741. * @returns the current mesh
  29742. */
  29743. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29744. /**
  29745. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29746. * If the mesh has no geometry, it is simply returned as it is.
  29747. * @param kind defines vertex data kind:
  29748. * * VertexBuffer.PositionKind
  29749. * * VertexBuffer.UVKind
  29750. * * VertexBuffer.UV2Kind
  29751. * * VertexBuffer.UV3Kind
  29752. * * VertexBuffer.UV4Kind
  29753. * * VertexBuffer.UV5Kind
  29754. * * VertexBuffer.UV6Kind
  29755. * * VertexBuffer.ColorKind
  29756. * * VertexBuffer.MatricesIndicesKind
  29757. * * VertexBuffer.MatricesIndicesExtraKind
  29758. * * VertexBuffer.MatricesWeightsKind
  29759. * * VertexBuffer.MatricesWeightsExtraKind
  29760. * @param data defines the data source
  29761. * @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
  29762. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29763. * @returns the current mesh
  29764. */
  29765. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29766. /**
  29767. * Sets the mesh indices,
  29768. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29769. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29770. * @param totalVertices Defines the total number of vertices
  29771. * @returns the current mesh
  29772. */
  29773. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29774. /**
  29775. * Gets a boolean indicating if specific vertex data is present
  29776. * @param kind defines the vertex data kind to use
  29777. * @returns true is data kind is present
  29778. */
  29779. isVerticesDataPresent(kind: string): boolean;
  29780. /**
  29781. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29782. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29783. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29784. * @returns a BoundingInfo
  29785. */
  29786. getBoundingInfo(): BoundingInfo;
  29787. /**
  29788. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29789. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29790. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29791. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29792. * @returns the current mesh
  29793. */
  29794. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29795. /**
  29796. * Overwrite the current bounding info
  29797. * @param boundingInfo defines the new bounding info
  29798. * @returns the current mesh
  29799. */
  29800. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29801. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29802. get useBones(): boolean;
  29803. /** @hidden */
  29804. _preActivate(): void;
  29805. /** @hidden */
  29806. _preActivateForIntermediateRendering(renderId: number): void;
  29807. /** @hidden */
  29808. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29809. /** @hidden */
  29810. _postActivate(): void;
  29811. /** @hidden */
  29812. _freeze(): void;
  29813. /** @hidden */
  29814. _unFreeze(): void;
  29815. /**
  29816. * Gets the current world matrix
  29817. * @returns a Matrix
  29818. */
  29819. getWorldMatrix(): Matrix;
  29820. /** @hidden */
  29821. _getWorldMatrixDeterminant(): number;
  29822. /**
  29823. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29824. */
  29825. get isAnInstance(): boolean;
  29826. /**
  29827. * Gets a boolean indicating if this mesh has instances
  29828. */
  29829. get hasInstances(): boolean;
  29830. /**
  29831. * Perform relative position change from the point of view of behind the front of the mesh.
  29832. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29833. * Supports definition of mesh facing forward or backward
  29834. * @param amountRight defines the distance on the right axis
  29835. * @param amountUp defines the distance on the up axis
  29836. * @param amountForward defines the distance on the forward axis
  29837. * @returns the current mesh
  29838. */
  29839. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29840. /**
  29841. * Calculate relative position change from the point of view of behind the front of the mesh.
  29842. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29843. * Supports definition of mesh facing forward or backward
  29844. * @param amountRight defines the distance on the right axis
  29845. * @param amountUp defines the distance on the up axis
  29846. * @param amountForward defines the distance on the forward axis
  29847. * @returns the new displacement vector
  29848. */
  29849. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29850. /**
  29851. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29852. * Supports definition of mesh facing forward or backward
  29853. * @param flipBack defines the flip
  29854. * @param twirlClockwise defines the twirl
  29855. * @param tiltRight defines the tilt
  29856. * @returns the current mesh
  29857. */
  29858. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29859. /**
  29860. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29861. * Supports definition of mesh facing forward or backward.
  29862. * @param flipBack defines the flip
  29863. * @param twirlClockwise defines the twirl
  29864. * @param tiltRight defines the tilt
  29865. * @returns the new rotation vector
  29866. */
  29867. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29868. /**
  29869. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29870. * This means the mesh underlying bounding box and sphere are recomputed.
  29871. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29872. * @returns the current mesh
  29873. */
  29874. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29875. /** @hidden */
  29876. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29877. /** @hidden */
  29878. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29879. /** @hidden */
  29880. _updateBoundingInfo(): AbstractMesh;
  29881. /** @hidden */
  29882. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29883. /** @hidden */
  29884. protected _afterComputeWorldMatrix(): void;
  29885. /** @hidden */
  29886. get _effectiveMesh(): AbstractMesh;
  29887. /**
  29888. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29889. * A mesh is in the frustum if its bounding box intersects the frustum
  29890. * @param frustumPlanes defines the frustum to test
  29891. * @returns true if the mesh is in the frustum planes
  29892. */
  29893. isInFrustum(frustumPlanes: Plane[]): boolean;
  29894. /**
  29895. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29896. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29897. * @param frustumPlanes defines the frustum to test
  29898. * @returns true if the mesh is completely in the frustum planes
  29899. */
  29900. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29901. /**
  29902. * True if the mesh intersects another mesh or a SolidParticle object
  29903. * @param mesh defines a target mesh or SolidParticle to test
  29904. * @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)
  29905. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29906. * @returns true if there is an intersection
  29907. */
  29908. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29909. /**
  29910. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29911. * @param point defines the point to test
  29912. * @returns true if there is an intersection
  29913. */
  29914. intersectsPoint(point: Vector3): boolean;
  29915. /**
  29916. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29918. */
  29919. get checkCollisions(): boolean;
  29920. set checkCollisions(collisionEnabled: boolean);
  29921. /**
  29922. * Gets Collider object used to compute collisions (not physics)
  29923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29924. */
  29925. get collider(): Nullable<Collider>;
  29926. /**
  29927. * Move the mesh using collision engine
  29928. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29929. * @param displacement defines the requested displacement vector
  29930. * @returns the current mesh
  29931. */
  29932. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29933. private _onCollisionPositionChange;
  29934. /** @hidden */
  29935. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29936. /** @hidden */
  29937. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29938. /** @hidden */
  29939. _checkCollision(collider: Collider): AbstractMesh;
  29940. /** @hidden */
  29941. _generatePointsArray(): boolean;
  29942. /**
  29943. * Checks if the passed Ray intersects with the mesh
  29944. * @param ray defines the ray to use
  29945. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29946. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29947. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29948. * @returns the picking info
  29949. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29950. */
  29951. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29952. /**
  29953. * Clones the current mesh
  29954. * @param name defines the mesh name
  29955. * @param newParent defines the new mesh parent
  29956. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29957. * @returns the new mesh
  29958. */
  29959. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29960. /**
  29961. * Disposes all the submeshes of the current meshnp
  29962. * @returns the current mesh
  29963. */
  29964. releaseSubMeshes(): AbstractMesh;
  29965. /**
  29966. * Releases resources associated with this abstract mesh.
  29967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29969. */
  29970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29971. /**
  29972. * Adds the passed mesh as a child to the current mesh
  29973. * @param mesh defines the child mesh
  29974. * @returns the current mesh
  29975. */
  29976. addChild(mesh: AbstractMesh): AbstractMesh;
  29977. /**
  29978. * Removes the passed mesh from the current mesh children list
  29979. * @param mesh defines the child mesh
  29980. * @returns the current mesh
  29981. */
  29982. removeChild(mesh: AbstractMesh): AbstractMesh;
  29983. /** @hidden */
  29984. private _initFacetData;
  29985. /**
  29986. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29987. * This method can be called within the render loop.
  29988. * 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
  29989. * @returns the current mesh
  29990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29991. */
  29992. updateFacetData(): AbstractMesh;
  29993. /**
  29994. * Returns the facetLocalNormals array.
  29995. * The normals are expressed in the mesh local spac
  29996. * @returns an array of Vector3
  29997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29998. */
  29999. getFacetLocalNormals(): Vector3[];
  30000. /**
  30001. * Returns the facetLocalPositions array.
  30002. * The facet positions are expressed in the mesh local space
  30003. * @returns an array of Vector3
  30004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30005. */
  30006. getFacetLocalPositions(): Vector3[];
  30007. /**
  30008. * Returns the facetLocalPartioning array
  30009. * @returns an array of array of numbers
  30010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30011. */
  30012. getFacetLocalPartitioning(): number[][];
  30013. /**
  30014. * Returns the i-th facet position in the world system.
  30015. * This method allocates a new Vector3 per call
  30016. * @param i defines the facet index
  30017. * @returns a new Vector3
  30018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30019. */
  30020. getFacetPosition(i: number): Vector3;
  30021. /**
  30022. * Sets the reference Vector3 with the i-th facet position in the world system
  30023. * @param i defines the facet index
  30024. * @param ref defines the target vector
  30025. * @returns the current mesh
  30026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30027. */
  30028. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  30029. /**
  30030. * Returns the i-th facet normal in the world system.
  30031. * This method allocates a new Vector3 per call
  30032. * @param i defines the facet index
  30033. * @returns a new Vector3
  30034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30035. */
  30036. getFacetNormal(i: number): Vector3;
  30037. /**
  30038. * Sets the reference Vector3 with the i-th facet normal in the world system
  30039. * @param i defines the facet index
  30040. * @param ref defines the target vector
  30041. * @returns the current mesh
  30042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30043. */
  30044. getFacetNormalToRef(i: number, ref: Vector3): this;
  30045. /**
  30046. * 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)
  30047. * @param x defines x coordinate
  30048. * @param y defines y coordinate
  30049. * @param z defines z coordinate
  30050. * @returns the array of facet indexes
  30051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30052. */
  30053. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  30054. /**
  30055. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  30056. * @param projected sets as the (x,y,z) world projection on the facet
  30057. * @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
  30058. * @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
  30059. * @param x defines x coordinate
  30060. * @param y defines y coordinate
  30061. * @param z defines z coordinate
  30062. * @returns the face index if found (or null instead)
  30063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30064. */
  30065. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  30066. /**
  30067. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  30068. * @param projected sets as the (x,y,z) local projection on the facet
  30069. * @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
  30070. * @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
  30071. * @param x defines x coordinate
  30072. * @param y defines y coordinate
  30073. * @param z defines z coordinate
  30074. * @returns the face index if found (or null instead)
  30075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30076. */
  30077. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  30078. /**
  30079. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  30080. * @returns the parameters
  30081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30082. */
  30083. getFacetDataParameters(): any;
  30084. /**
  30085. * Disables the feature FacetData and frees the related memory
  30086. * @returns the current mesh
  30087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30088. */
  30089. disableFacetData(): AbstractMesh;
  30090. /**
  30091. * Updates the AbstractMesh indices array
  30092. * @param indices defines the data source
  30093. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  30094. * @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)
  30095. * @returns the current mesh
  30096. */
  30097. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  30098. /**
  30099. * Creates new normals data for the mesh
  30100. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  30101. * @returns the current mesh
  30102. */
  30103. createNormals(updatable: boolean): AbstractMesh;
  30104. /**
  30105. * Align the mesh with a normal
  30106. * @param normal defines the normal to use
  30107. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  30108. * @returns the current mesh
  30109. */
  30110. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  30111. /** @hidden */
  30112. _checkOcclusionQuery(): boolean;
  30113. /**
  30114. * Disables the mesh edge rendering mode
  30115. * @returns the currentAbstractMesh
  30116. */
  30117. disableEdgesRendering(): AbstractMesh;
  30118. /**
  30119. * Enables the edge rendering mode on the mesh.
  30120. * This mode makes the mesh edges visible
  30121. * @param epsilon defines the maximal distance between two angles to detect a face
  30122. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30123. * @returns the currentAbstractMesh
  30124. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30125. */
  30126. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30127. }
  30128. }
  30129. declare module "babylonjs/Actions/actionEvent" {
  30130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30131. import { Nullable } from "babylonjs/types";
  30132. import { Sprite } from "babylonjs/Sprites/sprite";
  30133. import { Scene } from "babylonjs/scene";
  30134. import { Vector2 } from "babylonjs/Maths/math.vector";
  30135. /**
  30136. * Interface used to define ActionEvent
  30137. */
  30138. export interface IActionEvent {
  30139. /** The mesh or sprite that triggered the action */
  30140. source: any;
  30141. /** The X mouse cursor position at the time of the event */
  30142. pointerX: number;
  30143. /** The Y mouse cursor position at the time of the event */
  30144. pointerY: number;
  30145. /** The mesh that is currently pointed at (can be null) */
  30146. meshUnderPointer: Nullable<AbstractMesh>;
  30147. /** the original (browser) event that triggered the ActionEvent */
  30148. sourceEvent?: any;
  30149. /** additional data for the event */
  30150. additionalData?: any;
  30151. }
  30152. /**
  30153. * ActionEvent is the event being sent when an action is triggered.
  30154. */
  30155. export class ActionEvent implements IActionEvent {
  30156. /** The mesh or sprite that triggered the action */
  30157. source: any;
  30158. /** The X mouse cursor position at the time of the event */
  30159. pointerX: number;
  30160. /** The Y mouse cursor position at the time of the event */
  30161. pointerY: number;
  30162. /** The mesh that is currently pointed at (can be null) */
  30163. meshUnderPointer: Nullable<AbstractMesh>;
  30164. /** the original (browser) event that triggered the ActionEvent */
  30165. sourceEvent?: any;
  30166. /** additional data for the event */
  30167. additionalData?: any;
  30168. /**
  30169. * Creates a new ActionEvent
  30170. * @param source The mesh or sprite that triggered the action
  30171. * @param pointerX The X mouse cursor position at the time of the event
  30172. * @param pointerY The Y mouse cursor position at the time of the event
  30173. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30174. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30175. * @param additionalData additional data for the event
  30176. */
  30177. constructor(
  30178. /** The mesh or sprite that triggered the action */
  30179. source: any,
  30180. /** The X mouse cursor position at the time of the event */
  30181. pointerX: number,
  30182. /** The Y mouse cursor position at the time of the event */
  30183. pointerY: number,
  30184. /** The mesh that is currently pointed at (can be null) */
  30185. meshUnderPointer: Nullable<AbstractMesh>,
  30186. /** the original (browser) event that triggered the ActionEvent */
  30187. sourceEvent?: any,
  30188. /** additional data for the event */
  30189. additionalData?: any);
  30190. /**
  30191. * Helper function to auto-create an ActionEvent from a source mesh.
  30192. * @param source The source mesh that triggered the event
  30193. * @param evt The original (browser) event
  30194. * @param additionalData additional data for the event
  30195. * @returns the new ActionEvent
  30196. */
  30197. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30198. /**
  30199. * Helper function to auto-create an ActionEvent from a source sprite
  30200. * @param source The source sprite that triggered the event
  30201. * @param scene Scene associated with the sprite
  30202. * @param evt The original (browser) event
  30203. * @param additionalData additional data for the event
  30204. * @returns the new ActionEvent
  30205. */
  30206. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30207. /**
  30208. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30209. * @param scene the scene where the event occurred
  30210. * @param evt The original (browser) event
  30211. * @returns the new ActionEvent
  30212. */
  30213. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30214. /**
  30215. * Helper function to auto-create an ActionEvent from a primitive
  30216. * @param prim defines the target primitive
  30217. * @param pointerPos defines the pointer position
  30218. * @param evt The original (browser) event
  30219. * @param additionalData additional data for the event
  30220. * @returns the new ActionEvent
  30221. */
  30222. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30223. }
  30224. }
  30225. declare module "babylonjs/Actions/abstractActionManager" {
  30226. import { IDisposable } from "babylonjs/scene";
  30227. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30228. import { IAction } from "babylonjs/Actions/action";
  30229. import { Nullable } from "babylonjs/types";
  30230. /**
  30231. * Abstract class used to decouple action Manager from scene and meshes.
  30232. * Do not instantiate.
  30233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30234. */
  30235. export abstract class AbstractActionManager implements IDisposable {
  30236. /** Gets the list of active triggers */
  30237. static Triggers: {
  30238. [key: string]: number;
  30239. };
  30240. /** Gets the cursor to use when hovering items */
  30241. hoverCursor: string;
  30242. /** Gets the list of actions */
  30243. actions: IAction[];
  30244. /**
  30245. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30246. */
  30247. isRecursive: boolean;
  30248. /**
  30249. * Releases all associated resources
  30250. */
  30251. abstract dispose(): void;
  30252. /**
  30253. * Does this action manager has pointer triggers
  30254. */
  30255. abstract get hasPointerTriggers(): boolean;
  30256. /**
  30257. * Does this action manager has pick triggers
  30258. */
  30259. abstract get hasPickTriggers(): boolean;
  30260. /**
  30261. * Process a specific trigger
  30262. * @param trigger defines the trigger to process
  30263. * @param evt defines the event details to be processed
  30264. */
  30265. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30266. /**
  30267. * Does this action manager handles actions of any of the given triggers
  30268. * @param triggers defines the triggers to be tested
  30269. * @return a boolean indicating whether one (or more) of the triggers is handled
  30270. */
  30271. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30272. /**
  30273. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30274. * speed.
  30275. * @param triggerA defines the trigger to be tested
  30276. * @param triggerB defines the trigger to be tested
  30277. * @return a boolean indicating whether one (or more) of the triggers is handled
  30278. */
  30279. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30280. /**
  30281. * Does this action manager handles actions of a given trigger
  30282. * @param trigger defines the trigger to be tested
  30283. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30284. * @return whether the trigger is handled
  30285. */
  30286. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30287. /**
  30288. * Serialize this manager to a JSON object
  30289. * @param name defines the property name to store this manager
  30290. * @returns a JSON representation of this manager
  30291. */
  30292. abstract serialize(name: string): any;
  30293. /**
  30294. * Registers an action to this action manager
  30295. * @param action defines the action to be registered
  30296. * @return the action amended (prepared) after registration
  30297. */
  30298. abstract registerAction(action: IAction): Nullable<IAction>;
  30299. /**
  30300. * Unregisters an action to this action manager
  30301. * @param action defines the action to be unregistered
  30302. * @return a boolean indicating whether the action has been unregistered
  30303. */
  30304. abstract unregisterAction(action: IAction): Boolean;
  30305. /**
  30306. * Does exist one action manager with at least one trigger
  30307. **/
  30308. static get HasTriggers(): boolean;
  30309. /**
  30310. * Does exist one action manager with at least one pick trigger
  30311. **/
  30312. static get HasPickTriggers(): boolean;
  30313. /**
  30314. * Does exist one action manager that handles actions of a given trigger
  30315. * @param trigger defines the trigger to be tested
  30316. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30317. **/
  30318. static HasSpecificTrigger(trigger: number): boolean;
  30319. }
  30320. }
  30321. declare module "babylonjs/node" {
  30322. import { Scene } from "babylonjs/scene";
  30323. import { Nullable } from "babylonjs/types";
  30324. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30325. import { Engine } from "babylonjs/Engines/engine";
  30326. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30327. import { Observable } from "babylonjs/Misc/observable";
  30328. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30329. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30330. import { Animatable } from "babylonjs/Animations/animatable";
  30331. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30332. import { Animation } from "babylonjs/Animations/animation";
  30333. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30335. /**
  30336. * Defines how a node can be built from a string name.
  30337. */
  30338. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30339. /**
  30340. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30341. */
  30342. export class Node implements IBehaviorAware<Node> {
  30343. /** @hidden */
  30344. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30345. private static _NodeConstructors;
  30346. /**
  30347. * Add a new node constructor
  30348. * @param type defines the type name of the node to construct
  30349. * @param constructorFunc defines the constructor function
  30350. */
  30351. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30352. /**
  30353. * Returns a node constructor based on type name
  30354. * @param type defines the type name
  30355. * @param name defines the new node name
  30356. * @param scene defines the hosting scene
  30357. * @param options defines optional options to transmit to constructors
  30358. * @returns the new constructor or null
  30359. */
  30360. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30361. /**
  30362. * Gets or sets the name of the node
  30363. */
  30364. name: string;
  30365. /**
  30366. * Gets or sets the id of the node
  30367. */
  30368. id: string;
  30369. /**
  30370. * Gets or sets the unique id of the node
  30371. */
  30372. uniqueId: number;
  30373. /**
  30374. * Gets or sets a string used to store user defined state for the node
  30375. */
  30376. state: string;
  30377. /**
  30378. * Gets or sets an object used to store user defined information for the node
  30379. */
  30380. metadata: any;
  30381. /**
  30382. * For internal use only. Please do not use.
  30383. */
  30384. reservedDataStore: any;
  30385. /**
  30386. * List of inspectable custom properties (used by the Inspector)
  30387. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30388. */
  30389. inspectableCustomProperties: IInspectable[];
  30390. private _doNotSerialize;
  30391. /**
  30392. * Gets or sets a boolean used to define if the node must be serialized
  30393. */
  30394. get doNotSerialize(): boolean;
  30395. set doNotSerialize(value: boolean);
  30396. /** @hidden */
  30397. _isDisposed: boolean;
  30398. /**
  30399. * Gets a list of Animations associated with the node
  30400. */
  30401. animations: import("babylonjs/Animations/animation").Animation[];
  30402. protected _ranges: {
  30403. [name: string]: Nullable<AnimationRange>;
  30404. };
  30405. /**
  30406. * Callback raised when the node is ready to be used
  30407. */
  30408. onReady: Nullable<(node: Node) => void>;
  30409. private _isEnabled;
  30410. private _isParentEnabled;
  30411. private _isReady;
  30412. /** @hidden */
  30413. _currentRenderId: number;
  30414. private _parentUpdateId;
  30415. /** @hidden */
  30416. _childUpdateId: number;
  30417. /** @hidden */
  30418. _waitingParentId: Nullable<string>;
  30419. /** @hidden */
  30420. _scene: Scene;
  30421. /** @hidden */
  30422. _cache: any;
  30423. private _parentNode;
  30424. private _children;
  30425. /** @hidden */
  30426. _worldMatrix: Matrix;
  30427. /** @hidden */
  30428. _worldMatrixDeterminant: number;
  30429. /** @hidden */
  30430. _worldMatrixDeterminantIsDirty: boolean;
  30431. /** @hidden */
  30432. private _sceneRootNodesIndex;
  30433. /**
  30434. * Gets a boolean indicating if the node has been disposed
  30435. * @returns true if the node was disposed
  30436. */
  30437. isDisposed(): boolean;
  30438. /**
  30439. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30440. * @see https://doc.babylonjs.com/how_to/parenting
  30441. */
  30442. set parent(parent: Nullable<Node>);
  30443. get parent(): Nullable<Node>;
  30444. /** @hidden */
  30445. _addToSceneRootNodes(): void;
  30446. /** @hidden */
  30447. _removeFromSceneRootNodes(): void;
  30448. private _animationPropertiesOverride;
  30449. /**
  30450. * Gets or sets the animation properties override
  30451. */
  30452. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30453. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30454. /**
  30455. * Gets a string idenfifying the name of the class
  30456. * @returns "Node" string
  30457. */
  30458. getClassName(): string;
  30459. /** @hidden */
  30460. readonly _isNode: boolean;
  30461. /**
  30462. * An event triggered when the mesh is disposed
  30463. */
  30464. onDisposeObservable: Observable<Node>;
  30465. private _onDisposeObserver;
  30466. /**
  30467. * Sets a callback that will be raised when the node will be disposed
  30468. */
  30469. set onDispose(callback: () => void);
  30470. /**
  30471. * Creates a new Node
  30472. * @param name the name and id to be given to this node
  30473. * @param scene the scene this node will be added to
  30474. */
  30475. constructor(name: string, scene?: Nullable<Scene>);
  30476. /**
  30477. * Gets the scene of the node
  30478. * @returns a scene
  30479. */
  30480. getScene(): Scene;
  30481. /**
  30482. * Gets the engine of the node
  30483. * @returns a Engine
  30484. */
  30485. getEngine(): Engine;
  30486. private _behaviors;
  30487. /**
  30488. * Attach a behavior to the node
  30489. * @see http://doc.babylonjs.com/features/behaviour
  30490. * @param behavior defines the behavior to attach
  30491. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30492. * @returns the current Node
  30493. */
  30494. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30495. /**
  30496. * Remove an attached behavior
  30497. * @see http://doc.babylonjs.com/features/behaviour
  30498. * @param behavior defines the behavior to attach
  30499. * @returns the current Node
  30500. */
  30501. removeBehavior(behavior: Behavior<Node>): Node;
  30502. /**
  30503. * Gets the list of attached behaviors
  30504. * @see http://doc.babylonjs.com/features/behaviour
  30505. */
  30506. get behaviors(): Behavior<Node>[];
  30507. /**
  30508. * Gets an attached behavior by name
  30509. * @param name defines the name of the behavior to look for
  30510. * @see http://doc.babylonjs.com/features/behaviour
  30511. * @returns null if behavior was not found else the requested behavior
  30512. */
  30513. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30514. /**
  30515. * Returns the latest update of the World matrix
  30516. * @returns a Matrix
  30517. */
  30518. getWorldMatrix(): Matrix;
  30519. /** @hidden */
  30520. _getWorldMatrixDeterminant(): number;
  30521. /**
  30522. * Returns directly the latest state of the mesh World matrix.
  30523. * A Matrix is returned.
  30524. */
  30525. get worldMatrixFromCache(): Matrix;
  30526. /** @hidden */
  30527. _initCache(): void;
  30528. /** @hidden */
  30529. updateCache(force?: boolean): void;
  30530. /** @hidden */
  30531. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30532. /** @hidden */
  30533. _updateCache(ignoreParentClass?: boolean): void;
  30534. /** @hidden */
  30535. _isSynchronized(): boolean;
  30536. /** @hidden */
  30537. _markSyncedWithParent(): void;
  30538. /** @hidden */
  30539. isSynchronizedWithParent(): boolean;
  30540. /** @hidden */
  30541. isSynchronized(): boolean;
  30542. /**
  30543. * Is this node ready to be used/rendered
  30544. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30545. * @return true if the node is ready
  30546. */
  30547. isReady(completeCheck?: boolean): boolean;
  30548. /**
  30549. * Is this node enabled?
  30550. * 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
  30551. * @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
  30552. * @return whether this node (and its parent) is enabled
  30553. */
  30554. isEnabled(checkAncestors?: boolean): boolean;
  30555. /** @hidden */
  30556. protected _syncParentEnabledState(): void;
  30557. /**
  30558. * Set the enabled state of this node
  30559. * @param value defines the new enabled state
  30560. */
  30561. setEnabled(value: boolean): void;
  30562. /**
  30563. * Is this node a descendant of the given node?
  30564. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30565. * @param ancestor defines the parent node to inspect
  30566. * @returns a boolean indicating if this node is a descendant of the given node
  30567. */
  30568. isDescendantOf(ancestor: Node): boolean;
  30569. /** @hidden */
  30570. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30571. /**
  30572. * Will return all nodes that have this node as ascendant
  30573. * @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
  30574. * @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
  30575. * @return all children nodes of all types
  30576. */
  30577. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30578. /**
  30579. * Get all child-meshes of this node
  30580. * @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)
  30581. * @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
  30582. * @returns an array of AbstractMesh
  30583. */
  30584. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30585. /**
  30586. * Get all direct children of this node
  30587. * @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
  30588. * @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)
  30589. * @returns an array of Node
  30590. */
  30591. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30592. /** @hidden */
  30593. _setReady(state: boolean): void;
  30594. /**
  30595. * Get an animation by name
  30596. * @param name defines the name of the animation to look for
  30597. * @returns null if not found else the requested animation
  30598. */
  30599. getAnimationByName(name: string): Nullable<Animation>;
  30600. /**
  30601. * Creates an animation range for this node
  30602. * @param name defines the name of the range
  30603. * @param from defines the starting key
  30604. * @param to defines the end key
  30605. */
  30606. createAnimationRange(name: string, from: number, to: number): void;
  30607. /**
  30608. * Delete a specific animation range
  30609. * @param name defines the name of the range to delete
  30610. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30611. */
  30612. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30613. /**
  30614. * Get an animation range by name
  30615. * @param name defines the name of the animation range to look for
  30616. * @returns null if not found else the requested animation range
  30617. */
  30618. getAnimationRange(name: string): Nullable<AnimationRange>;
  30619. /**
  30620. * Gets the list of all animation ranges defined on this node
  30621. * @returns an array
  30622. */
  30623. getAnimationRanges(): Nullable<AnimationRange>[];
  30624. /**
  30625. * Will start the animation sequence
  30626. * @param name defines the range frames for animation sequence
  30627. * @param loop defines if the animation should loop (false by default)
  30628. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30629. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30630. * @returns the object created for this animation. If range does not exist, it will return null
  30631. */
  30632. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30633. /**
  30634. * Serialize animation ranges into a JSON compatible object
  30635. * @returns serialization object
  30636. */
  30637. serializeAnimationRanges(): any;
  30638. /**
  30639. * Computes the world matrix of the node
  30640. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30641. * @returns the world matrix
  30642. */
  30643. computeWorldMatrix(force?: boolean): Matrix;
  30644. /**
  30645. * Releases resources associated with this node.
  30646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30648. */
  30649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30650. /**
  30651. * Parse animation range data from a serialization object and store them into a given node
  30652. * @param node defines where to store the animation ranges
  30653. * @param parsedNode defines the serialization object to read data from
  30654. * @param scene defines the hosting scene
  30655. */
  30656. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30657. /**
  30658. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30659. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30660. * @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
  30661. * @returns the new bounding vectors
  30662. */
  30663. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30664. min: Vector3;
  30665. max: Vector3;
  30666. };
  30667. }
  30668. }
  30669. declare module "babylonjs/Animations/animation" {
  30670. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30671. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30672. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30673. import { Nullable } from "babylonjs/types";
  30674. import { Scene } from "babylonjs/scene";
  30675. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30676. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30677. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30678. import { Node } from "babylonjs/node";
  30679. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30680. import { Size } from "babylonjs/Maths/math.size";
  30681. import { Animatable } from "babylonjs/Animations/animatable";
  30682. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30683. /**
  30684. * @hidden
  30685. */
  30686. export class _IAnimationState {
  30687. key: number;
  30688. repeatCount: number;
  30689. workValue?: any;
  30690. loopMode?: number;
  30691. offsetValue?: any;
  30692. highLimitValue?: any;
  30693. }
  30694. /**
  30695. * Class used to store any kind of animation
  30696. */
  30697. export class Animation {
  30698. /**Name of the animation */
  30699. name: string;
  30700. /**Property to animate */
  30701. targetProperty: string;
  30702. /**The frames per second of the animation */
  30703. framePerSecond: number;
  30704. /**The data type of the animation */
  30705. dataType: number;
  30706. /**The loop mode of the animation */
  30707. loopMode?: number | undefined;
  30708. /**Specifies if blending should be enabled */
  30709. enableBlending?: boolean | undefined;
  30710. /**
  30711. * Use matrix interpolation instead of using direct key value when animating matrices
  30712. */
  30713. static AllowMatricesInterpolation: boolean;
  30714. /**
  30715. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30716. */
  30717. static AllowMatrixDecomposeForInterpolation: boolean;
  30718. /**
  30719. * Stores the key frames of the animation
  30720. */
  30721. private _keys;
  30722. /**
  30723. * Stores the easing function of the animation
  30724. */
  30725. private _easingFunction;
  30726. /**
  30727. * @hidden Internal use only
  30728. */
  30729. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30730. /**
  30731. * The set of event that will be linked to this animation
  30732. */
  30733. private _events;
  30734. /**
  30735. * Stores an array of target property paths
  30736. */
  30737. targetPropertyPath: string[];
  30738. /**
  30739. * Stores the blending speed of the animation
  30740. */
  30741. blendingSpeed: number;
  30742. /**
  30743. * Stores the animation ranges for the animation
  30744. */
  30745. private _ranges;
  30746. /**
  30747. * @hidden Internal use
  30748. */
  30749. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30750. /**
  30751. * Sets up an animation
  30752. * @param property The property to animate
  30753. * @param animationType The animation type to apply
  30754. * @param framePerSecond The frames per second of the animation
  30755. * @param easingFunction The easing function used in the animation
  30756. * @returns The created animation
  30757. */
  30758. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30759. /**
  30760. * Create and start an animation on a node
  30761. * @param name defines the name of the global animation that will be run on all nodes
  30762. * @param node defines the root node where the animation will take place
  30763. * @param targetProperty defines property to animate
  30764. * @param framePerSecond defines the number of frame per second yo use
  30765. * @param totalFrame defines the number of frames in total
  30766. * @param from defines the initial value
  30767. * @param to defines the final value
  30768. * @param loopMode defines which loop mode you want to use (off by default)
  30769. * @param easingFunction defines the easing function to use (linear by default)
  30770. * @param onAnimationEnd defines the callback to call when animation end
  30771. * @returns the animatable created for this animation
  30772. */
  30773. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30774. /**
  30775. * Create and start an animation on a node and its descendants
  30776. * @param name defines the name of the global animation that will be run on all nodes
  30777. * @param node defines the root node where the animation will take place
  30778. * @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
  30779. * @param targetProperty defines property to animate
  30780. * @param framePerSecond defines the number of frame per second to use
  30781. * @param totalFrame defines the number of frames in total
  30782. * @param from defines the initial value
  30783. * @param to defines the final value
  30784. * @param loopMode defines which loop mode you want to use (off by default)
  30785. * @param easingFunction defines the easing function to use (linear by default)
  30786. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30787. * @returns the list of animatables created for all nodes
  30788. * @example https://www.babylonjs-playground.com/#MH0VLI
  30789. */
  30790. 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[]>;
  30791. /**
  30792. * Creates a new animation, merges it with the existing animations and starts it
  30793. * @param name Name of the animation
  30794. * @param node Node which contains the scene that begins the animations
  30795. * @param targetProperty Specifies which property to animate
  30796. * @param framePerSecond The frames per second of the animation
  30797. * @param totalFrame The total number of frames
  30798. * @param from The frame at the beginning of the animation
  30799. * @param to The frame at the end of the animation
  30800. * @param loopMode Specifies the loop mode of the animation
  30801. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30802. * @param onAnimationEnd Callback to run once the animation is complete
  30803. * @returns Nullable animation
  30804. */
  30805. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30806. /**
  30807. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30808. * @param sourceAnimation defines the Animation containing keyframes to convert
  30809. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30810. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30811. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30812. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30813. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30814. */
  30815. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30816. /**
  30817. * Transition property of an host to the target Value
  30818. * @param property The property to transition
  30819. * @param targetValue The target Value of the property
  30820. * @param host The object where the property to animate belongs
  30821. * @param scene Scene used to run the animation
  30822. * @param frameRate Framerate (in frame/s) to use
  30823. * @param transition The transition type we want to use
  30824. * @param duration The duration of the animation, in milliseconds
  30825. * @param onAnimationEnd Callback trigger at the end of the animation
  30826. * @returns Nullable animation
  30827. */
  30828. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30829. /**
  30830. * Return the array of runtime animations currently using this animation
  30831. */
  30832. get runtimeAnimations(): RuntimeAnimation[];
  30833. /**
  30834. * Specifies if any of the runtime animations are currently running
  30835. */
  30836. get hasRunningRuntimeAnimations(): boolean;
  30837. /**
  30838. * Initializes the animation
  30839. * @param name Name of the animation
  30840. * @param targetProperty Property to animate
  30841. * @param framePerSecond The frames per second of the animation
  30842. * @param dataType The data type of the animation
  30843. * @param loopMode The loop mode of the animation
  30844. * @param enableBlending Specifies if blending should be enabled
  30845. */
  30846. constructor(
  30847. /**Name of the animation */
  30848. name: string,
  30849. /**Property to animate */
  30850. targetProperty: string,
  30851. /**The frames per second of the animation */
  30852. framePerSecond: number,
  30853. /**The data type of the animation */
  30854. dataType: number,
  30855. /**The loop mode of the animation */
  30856. loopMode?: number | undefined,
  30857. /**Specifies if blending should be enabled */
  30858. enableBlending?: boolean | undefined);
  30859. /**
  30860. * Converts the animation to a string
  30861. * @param fullDetails support for multiple levels of logging within scene loading
  30862. * @returns String form of the animation
  30863. */
  30864. toString(fullDetails?: boolean): string;
  30865. /**
  30866. * Add an event to this animation
  30867. * @param event Event to add
  30868. */
  30869. addEvent(event: AnimationEvent): void;
  30870. /**
  30871. * Remove all events found at the given frame
  30872. * @param frame The frame to remove events from
  30873. */
  30874. removeEvents(frame: number): void;
  30875. /**
  30876. * Retrieves all the events from the animation
  30877. * @returns Events from the animation
  30878. */
  30879. getEvents(): AnimationEvent[];
  30880. /**
  30881. * Creates an animation range
  30882. * @param name Name of the animation range
  30883. * @param from Starting frame of the animation range
  30884. * @param to Ending frame of the animation
  30885. */
  30886. createRange(name: string, from: number, to: number): void;
  30887. /**
  30888. * Deletes an animation range by name
  30889. * @param name Name of the animation range to delete
  30890. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30891. */
  30892. deleteRange(name: string, deleteFrames?: boolean): void;
  30893. /**
  30894. * Gets the animation range by name, or null if not defined
  30895. * @param name Name of the animation range
  30896. * @returns Nullable animation range
  30897. */
  30898. getRange(name: string): Nullable<AnimationRange>;
  30899. /**
  30900. * Gets the key frames from the animation
  30901. * @returns The key frames of the animation
  30902. */
  30903. getKeys(): Array<IAnimationKey>;
  30904. /**
  30905. * Gets the highest frame rate of the animation
  30906. * @returns Highest frame rate of the animation
  30907. */
  30908. getHighestFrame(): number;
  30909. /**
  30910. * Gets the easing function of the animation
  30911. * @returns Easing function of the animation
  30912. */
  30913. getEasingFunction(): IEasingFunction;
  30914. /**
  30915. * Sets the easing function of the animation
  30916. * @param easingFunction A custom mathematical formula for animation
  30917. */
  30918. setEasingFunction(easingFunction: EasingFunction): void;
  30919. /**
  30920. * Interpolates a scalar linearly
  30921. * @param startValue Start value of the animation curve
  30922. * @param endValue End value of the animation curve
  30923. * @param gradient Scalar amount to interpolate
  30924. * @returns Interpolated scalar value
  30925. */
  30926. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30927. /**
  30928. * Interpolates a scalar cubically
  30929. * @param startValue Start value of the animation curve
  30930. * @param outTangent End tangent of the animation
  30931. * @param endValue End value of the animation curve
  30932. * @param inTangent Start tangent of the animation curve
  30933. * @param gradient Scalar amount to interpolate
  30934. * @returns Interpolated scalar value
  30935. */
  30936. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30937. /**
  30938. * Interpolates a quaternion using a spherical linear interpolation
  30939. * @param startValue Start value of the animation curve
  30940. * @param endValue End value of the animation curve
  30941. * @param gradient Scalar amount to interpolate
  30942. * @returns Interpolated quaternion value
  30943. */
  30944. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30945. /**
  30946. * Interpolates a quaternion cubically
  30947. * @param startValue Start value of the animation curve
  30948. * @param outTangent End tangent of the animation curve
  30949. * @param endValue End value of the animation curve
  30950. * @param inTangent Start tangent of the animation curve
  30951. * @param gradient Scalar amount to interpolate
  30952. * @returns Interpolated quaternion value
  30953. */
  30954. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30955. /**
  30956. * Interpolates a Vector3 linearl
  30957. * @param startValue Start value of the animation curve
  30958. * @param endValue End value of the animation curve
  30959. * @param gradient Scalar amount to interpolate
  30960. * @returns Interpolated scalar value
  30961. */
  30962. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30963. /**
  30964. * Interpolates a Vector3 cubically
  30965. * @param startValue Start value of the animation curve
  30966. * @param outTangent End tangent of the animation
  30967. * @param endValue End value of the animation curve
  30968. * @param inTangent Start tangent of the animation curve
  30969. * @param gradient Scalar amount to interpolate
  30970. * @returns InterpolatedVector3 value
  30971. */
  30972. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30973. /**
  30974. * Interpolates a Vector2 linearly
  30975. * @param startValue Start value of the animation curve
  30976. * @param endValue End value of the animation curve
  30977. * @param gradient Scalar amount to interpolate
  30978. * @returns Interpolated Vector2 value
  30979. */
  30980. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30981. /**
  30982. * Interpolates a Vector2 cubically
  30983. * @param startValue Start value of the animation curve
  30984. * @param outTangent End tangent of the animation
  30985. * @param endValue End value of the animation curve
  30986. * @param inTangent Start tangent of the animation curve
  30987. * @param gradient Scalar amount to interpolate
  30988. * @returns Interpolated Vector2 value
  30989. */
  30990. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30991. /**
  30992. * Interpolates a size linearly
  30993. * @param startValue Start value of the animation curve
  30994. * @param endValue End value of the animation curve
  30995. * @param gradient Scalar amount to interpolate
  30996. * @returns Interpolated Size value
  30997. */
  30998. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30999. /**
  31000. * Interpolates a Color3 linearly
  31001. * @param startValue Start value of the animation curve
  31002. * @param endValue End value of the animation curve
  31003. * @param gradient Scalar amount to interpolate
  31004. * @returns Interpolated Color3 value
  31005. */
  31006. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  31007. /**
  31008. * Interpolates a Color4 linearly
  31009. * @param startValue Start value of the animation curve
  31010. * @param endValue End value of the animation curve
  31011. * @param gradient Scalar amount to interpolate
  31012. * @returns Interpolated Color3 value
  31013. */
  31014. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  31015. /**
  31016. * @hidden Internal use only
  31017. */
  31018. _getKeyValue(value: any): any;
  31019. /**
  31020. * @hidden Internal use only
  31021. */
  31022. _interpolate(currentFrame: number, state: _IAnimationState): any;
  31023. /**
  31024. * Defines the function to use to interpolate matrices
  31025. * @param startValue defines the start matrix
  31026. * @param endValue defines the end matrix
  31027. * @param gradient defines the gradient between both matrices
  31028. * @param result defines an optional target matrix where to store the interpolation
  31029. * @returns the interpolated matrix
  31030. */
  31031. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  31032. /**
  31033. * Makes a copy of the animation
  31034. * @returns Cloned animation
  31035. */
  31036. clone(): Animation;
  31037. /**
  31038. * Sets the key frames of the animation
  31039. * @param values The animation key frames to set
  31040. */
  31041. setKeys(values: Array<IAnimationKey>): void;
  31042. /**
  31043. * Serializes the animation to an object
  31044. * @returns Serialized object
  31045. */
  31046. serialize(): any;
  31047. /**
  31048. * Float animation type
  31049. */
  31050. static readonly ANIMATIONTYPE_FLOAT: number;
  31051. /**
  31052. * Vector3 animation type
  31053. */
  31054. static readonly ANIMATIONTYPE_VECTOR3: number;
  31055. /**
  31056. * Quaternion animation type
  31057. */
  31058. static readonly ANIMATIONTYPE_QUATERNION: number;
  31059. /**
  31060. * Matrix animation type
  31061. */
  31062. static readonly ANIMATIONTYPE_MATRIX: number;
  31063. /**
  31064. * Color3 animation type
  31065. */
  31066. static readonly ANIMATIONTYPE_COLOR3: number;
  31067. /**
  31068. * Color3 animation type
  31069. */
  31070. static readonly ANIMATIONTYPE_COLOR4: number;
  31071. /**
  31072. * Vector2 animation type
  31073. */
  31074. static readonly ANIMATIONTYPE_VECTOR2: number;
  31075. /**
  31076. * Size animation type
  31077. */
  31078. static readonly ANIMATIONTYPE_SIZE: number;
  31079. /**
  31080. * Relative Loop Mode
  31081. */
  31082. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  31083. /**
  31084. * Cycle Loop Mode
  31085. */
  31086. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  31087. /**
  31088. * Constant Loop Mode
  31089. */
  31090. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  31091. /** @hidden */
  31092. static _UniversalLerp(left: any, right: any, amount: number): any;
  31093. /**
  31094. * Parses an animation object and creates an animation
  31095. * @param parsedAnimation Parsed animation object
  31096. * @returns Animation object
  31097. */
  31098. static Parse(parsedAnimation: any): Animation;
  31099. /**
  31100. * Appends the serialized animations from the source animations
  31101. * @param source Source containing the animations
  31102. * @param destination Target to store the animations
  31103. */
  31104. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31105. }
  31106. }
  31107. declare module "babylonjs/Animations/animatable.interface" {
  31108. import { Nullable } from "babylonjs/types";
  31109. import { Animation } from "babylonjs/Animations/animation";
  31110. /**
  31111. * Interface containing an array of animations
  31112. */
  31113. export interface IAnimatable {
  31114. /**
  31115. * Array of animations
  31116. */
  31117. animations: Nullable<Array<Animation>>;
  31118. }
  31119. }
  31120. declare module "babylonjs/Misc/decorators" {
  31121. import { Nullable } from "babylonjs/types";
  31122. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31123. import { Scene } from "babylonjs/scene";
  31124. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31125. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31126. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31127. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31128. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31129. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31130. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31131. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31132. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31133. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31134. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31135. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31136. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31137. /**
  31138. * Decorator used to define property that can be serialized as reference to a camera
  31139. * @param sourceName defines the name of the property to decorate
  31140. */
  31141. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31142. /**
  31143. * Class used to help serialization objects
  31144. */
  31145. export class SerializationHelper {
  31146. /** @hidden */
  31147. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31148. /** @hidden */
  31149. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31150. /** @hidden */
  31151. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31152. /** @hidden */
  31153. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31154. /**
  31155. * Appends the serialized animations from the source animations
  31156. * @param source Source containing the animations
  31157. * @param destination Target to store the animations
  31158. */
  31159. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31160. /**
  31161. * Static function used to serialized a specific entity
  31162. * @param entity defines the entity to serialize
  31163. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31164. * @returns a JSON compatible object representing the serialization of the entity
  31165. */
  31166. static Serialize<T>(entity: T, serializationObject?: any): any;
  31167. /**
  31168. * Creates a new entity from a serialization data object
  31169. * @param creationFunction defines a function used to instanciated the new entity
  31170. * @param source defines the source serialization data
  31171. * @param scene defines the hosting scene
  31172. * @param rootUrl defines the root url for resources
  31173. * @returns a new entity
  31174. */
  31175. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31176. /**
  31177. * Clones an object
  31178. * @param creationFunction defines the function used to instanciate the new object
  31179. * @param source defines the source object
  31180. * @returns the cloned object
  31181. */
  31182. static Clone<T>(creationFunction: () => T, source: T): T;
  31183. /**
  31184. * Instanciates a new object based on a source one (some data will be shared between both object)
  31185. * @param creationFunction defines the function used to instanciate the new object
  31186. * @param source defines the source object
  31187. * @returns the new object
  31188. */
  31189. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31190. }
  31191. }
  31192. declare module "babylonjs/Materials/Textures/baseTexture" {
  31193. import { Observable } from "babylonjs/Misc/observable";
  31194. import { Nullable } from "babylonjs/types";
  31195. import { Scene } from "babylonjs/scene";
  31196. import { Matrix } from "babylonjs/Maths/math.vector";
  31197. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31198. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31199. import { ISize } from "babylonjs/Maths/math.size";
  31200. import "babylonjs/Misc/fileTools";
  31201. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31202. /**
  31203. * Base class of all the textures in babylon.
  31204. * It groups all the common properties the materials, post process, lights... might need
  31205. * in order to make a correct use of the texture.
  31206. */
  31207. export class BaseTexture implements IAnimatable {
  31208. /**
  31209. * Default anisotropic filtering level for the application.
  31210. * It is set to 4 as a good tradeoff between perf and quality.
  31211. */
  31212. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31213. /**
  31214. * Gets or sets the unique id of the texture
  31215. */
  31216. uniqueId: number;
  31217. /**
  31218. * Define the name of the texture.
  31219. */
  31220. name: string;
  31221. /**
  31222. * Gets or sets an object used to store user defined information.
  31223. */
  31224. metadata: any;
  31225. /**
  31226. * For internal use only. Please do not use.
  31227. */
  31228. reservedDataStore: any;
  31229. private _hasAlpha;
  31230. /**
  31231. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31232. */
  31233. set hasAlpha(value: boolean);
  31234. get hasAlpha(): boolean;
  31235. /**
  31236. * Defines if the alpha value should be determined via the rgb values.
  31237. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31238. */
  31239. getAlphaFromRGB: boolean;
  31240. /**
  31241. * Intensity or strength of the texture.
  31242. * It is commonly used by materials to fine tune the intensity of the texture
  31243. */
  31244. level: number;
  31245. /**
  31246. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31247. * This is part of the texture as textures usually maps to one uv set.
  31248. */
  31249. coordinatesIndex: number;
  31250. private _coordinatesMode;
  31251. /**
  31252. * How a texture is mapped.
  31253. *
  31254. * | Value | Type | Description |
  31255. * | ----- | ----------------------------------- | ----------- |
  31256. * | 0 | EXPLICIT_MODE | |
  31257. * | 1 | SPHERICAL_MODE | |
  31258. * | 2 | PLANAR_MODE | |
  31259. * | 3 | CUBIC_MODE | |
  31260. * | 4 | PROJECTION_MODE | |
  31261. * | 5 | SKYBOX_MODE | |
  31262. * | 6 | INVCUBIC_MODE | |
  31263. * | 7 | EQUIRECTANGULAR_MODE | |
  31264. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31265. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31266. */
  31267. set coordinatesMode(value: number);
  31268. get coordinatesMode(): number;
  31269. /**
  31270. * | Value | Type | Description |
  31271. * | ----- | ------------------ | ----------- |
  31272. * | 0 | CLAMP_ADDRESSMODE | |
  31273. * | 1 | WRAP_ADDRESSMODE | |
  31274. * | 2 | MIRROR_ADDRESSMODE | |
  31275. */
  31276. wrapU: number;
  31277. /**
  31278. * | Value | Type | Description |
  31279. * | ----- | ------------------ | ----------- |
  31280. * | 0 | CLAMP_ADDRESSMODE | |
  31281. * | 1 | WRAP_ADDRESSMODE | |
  31282. * | 2 | MIRROR_ADDRESSMODE | |
  31283. */
  31284. wrapV: number;
  31285. /**
  31286. * | Value | Type | Description |
  31287. * | ----- | ------------------ | ----------- |
  31288. * | 0 | CLAMP_ADDRESSMODE | |
  31289. * | 1 | WRAP_ADDRESSMODE | |
  31290. * | 2 | MIRROR_ADDRESSMODE | |
  31291. */
  31292. wrapR: number;
  31293. /**
  31294. * With compliant hardware and browser (supporting anisotropic filtering)
  31295. * this defines the level of anisotropic filtering in the texture.
  31296. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31297. */
  31298. anisotropicFilteringLevel: number;
  31299. /**
  31300. * Define if the texture is a cube texture or if false a 2d texture.
  31301. */
  31302. get isCube(): boolean;
  31303. set isCube(value: boolean);
  31304. /**
  31305. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31306. */
  31307. get is3D(): boolean;
  31308. set is3D(value: boolean);
  31309. /**
  31310. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31311. */
  31312. get is2DArray(): boolean;
  31313. set is2DArray(value: boolean);
  31314. /**
  31315. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31316. * HDR texture are usually stored in linear space.
  31317. * This only impacts the PBR and Background materials
  31318. */
  31319. gammaSpace: boolean;
  31320. /**
  31321. * Gets or sets whether or not the texture contains RGBD data.
  31322. */
  31323. get isRGBD(): boolean;
  31324. set isRGBD(value: boolean);
  31325. /**
  31326. * Is Z inverted in the texture (useful in a cube texture).
  31327. */
  31328. invertZ: boolean;
  31329. /**
  31330. * Are mip maps generated for this texture or not.
  31331. */
  31332. get noMipmap(): boolean;
  31333. /**
  31334. * @hidden
  31335. */
  31336. lodLevelInAlpha: boolean;
  31337. /**
  31338. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31339. */
  31340. get lodGenerationOffset(): number;
  31341. set lodGenerationOffset(value: number);
  31342. /**
  31343. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31344. */
  31345. get lodGenerationScale(): number;
  31346. set lodGenerationScale(value: number);
  31347. /**
  31348. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31349. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31350. * average roughness values.
  31351. */
  31352. get linearSpecularLOD(): boolean;
  31353. set linearSpecularLOD(value: boolean);
  31354. /**
  31355. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31356. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31357. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31358. */
  31359. get irradianceTexture(): Nullable<BaseTexture>;
  31360. set irradianceTexture(value: Nullable<BaseTexture>);
  31361. /**
  31362. * Define if the texture is a render target.
  31363. */
  31364. isRenderTarget: boolean;
  31365. /**
  31366. * Define the unique id of the texture in the scene.
  31367. */
  31368. get uid(): string;
  31369. /**
  31370. * Return a string representation of the texture.
  31371. * @returns the texture as a string
  31372. */
  31373. toString(): string;
  31374. /**
  31375. * Get the class name of the texture.
  31376. * @returns "BaseTexture"
  31377. */
  31378. getClassName(): string;
  31379. /**
  31380. * Define the list of animation attached to the texture.
  31381. */
  31382. animations: import("babylonjs/Animations/animation").Animation[];
  31383. /**
  31384. * An event triggered when the texture is disposed.
  31385. */
  31386. onDisposeObservable: Observable<BaseTexture>;
  31387. private _onDisposeObserver;
  31388. /**
  31389. * Callback triggered when the texture has been disposed.
  31390. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31391. */
  31392. set onDispose(callback: () => void);
  31393. /**
  31394. * Define the current state of the loading sequence when in delayed load mode.
  31395. */
  31396. delayLoadState: number;
  31397. private _scene;
  31398. private _engine;
  31399. /** @hidden */
  31400. _texture: Nullable<InternalTexture>;
  31401. private _uid;
  31402. /**
  31403. * Define if the texture is preventinga material to render or not.
  31404. * If not and the texture is not ready, the engine will use a default black texture instead.
  31405. */
  31406. get isBlocking(): boolean;
  31407. /**
  31408. * Instantiates a new BaseTexture.
  31409. * Base class of all the textures in babylon.
  31410. * It groups all the common properties the materials, post process, lights... might need
  31411. * in order to make a correct use of the texture.
  31412. * @param sceneOrEngine Define the scene or engine the texture blongs to
  31413. */
  31414. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  31415. /**
  31416. * Get the scene the texture belongs to.
  31417. * @returns the scene or null if undefined
  31418. */
  31419. getScene(): Nullable<Scene>;
  31420. /** @hidden */
  31421. protected _getEngine(): Nullable<ThinEngine>;
  31422. /**
  31423. * Get the texture transform matrix used to offset tile the texture for istance.
  31424. * @returns the transformation matrix
  31425. */
  31426. getTextureMatrix(): Matrix;
  31427. /**
  31428. * Get the texture reflection matrix used to rotate/transform the reflection.
  31429. * @returns the reflection matrix
  31430. */
  31431. getReflectionTextureMatrix(): Matrix;
  31432. /**
  31433. * Get the underlying lower level texture from Babylon.
  31434. * @returns the insternal texture
  31435. */
  31436. getInternalTexture(): Nullable<InternalTexture>;
  31437. /**
  31438. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31439. * @returns true if ready or not blocking
  31440. */
  31441. isReadyOrNotBlocking(): boolean;
  31442. /**
  31443. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31444. * @returns true if fully ready
  31445. */
  31446. isReady(): boolean;
  31447. private _cachedSize;
  31448. /**
  31449. * Get the size of the texture.
  31450. * @returns the texture size.
  31451. */
  31452. getSize(): ISize;
  31453. /**
  31454. * Get the base size of the texture.
  31455. * It can be different from the size if the texture has been resized for POT for instance
  31456. * @returns the base size
  31457. */
  31458. getBaseSize(): ISize;
  31459. /**
  31460. * Update the sampling mode of the texture.
  31461. * Default is Trilinear mode.
  31462. *
  31463. * | Value | Type | Description |
  31464. * | ----- | ------------------ | ----------- |
  31465. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31466. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31467. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31468. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31469. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31470. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31471. * | 7 | NEAREST_LINEAR | |
  31472. * | 8 | NEAREST_NEAREST | |
  31473. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31474. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31475. * | 11 | LINEAR_LINEAR | |
  31476. * | 12 | LINEAR_NEAREST | |
  31477. *
  31478. * > _mag_: magnification filter (close to the viewer)
  31479. * > _min_: minification filter (far from the viewer)
  31480. * > _mip_: filter used between mip map levels
  31481. *@param samplingMode Define the new sampling mode of the texture
  31482. */
  31483. updateSamplingMode(samplingMode: number): void;
  31484. /**
  31485. * Scales the texture if is `canRescale()`
  31486. * @param ratio the resize factor we want to use to rescale
  31487. */
  31488. scale(ratio: number): void;
  31489. /**
  31490. * Get if the texture can rescale.
  31491. */
  31492. get canRescale(): boolean;
  31493. /** @hidden */
  31494. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31495. /** @hidden */
  31496. _rebuild(): void;
  31497. /**
  31498. * Triggers the load sequence in delayed load mode.
  31499. */
  31500. delayLoad(): void;
  31501. /**
  31502. * Clones the texture.
  31503. * @returns the cloned texture
  31504. */
  31505. clone(): Nullable<BaseTexture>;
  31506. /**
  31507. * Get the texture underlying type (INT, FLOAT...)
  31508. */
  31509. get textureType(): number;
  31510. /**
  31511. * Get the texture underlying format (RGB, RGBA...)
  31512. */
  31513. get textureFormat(): number;
  31514. /**
  31515. * Indicates that textures need to be re-calculated for all materials
  31516. */
  31517. protected _markAllSubMeshesAsTexturesDirty(): void;
  31518. /**
  31519. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31520. * This will returns an RGBA array buffer containing either in values (0-255) or
  31521. * float values (0-1) depending of the underlying buffer type.
  31522. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31523. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31524. * @param buffer defines a user defined buffer to fill with data (can be null)
  31525. * @returns The Array buffer containing the pixels data.
  31526. */
  31527. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31528. /**
  31529. * Release and destroy the underlying lower level texture aka internalTexture.
  31530. */
  31531. releaseInternalTexture(): void;
  31532. /** @hidden */
  31533. get _lodTextureHigh(): Nullable<BaseTexture>;
  31534. /** @hidden */
  31535. get _lodTextureMid(): Nullable<BaseTexture>;
  31536. /** @hidden */
  31537. get _lodTextureLow(): Nullable<BaseTexture>;
  31538. /**
  31539. * Dispose the texture and release its associated resources.
  31540. */
  31541. dispose(): void;
  31542. /**
  31543. * Serialize the texture into a JSON representation that can be parsed later on.
  31544. * @returns the JSON representation of the texture
  31545. */
  31546. serialize(): any;
  31547. /**
  31548. * Helper function to be called back once a list of texture contains only ready textures.
  31549. * @param textures Define the list of textures to wait for
  31550. * @param callback Define the callback triggered once the entire list will be ready
  31551. */
  31552. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31553. private static _isScene;
  31554. }
  31555. }
  31556. declare module "babylonjs/Materials/effect" {
  31557. import { Observable } from "babylonjs/Misc/observable";
  31558. import { Nullable } from "babylonjs/types";
  31559. import { IDisposable } from "babylonjs/scene";
  31560. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31561. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31562. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31563. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31564. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31565. import { Engine } from "babylonjs/Engines/engine";
  31566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31569. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31570. /**
  31571. * Options to be used when creating an effect.
  31572. */
  31573. export interface IEffectCreationOptions {
  31574. /**
  31575. * Atrributes that will be used in the shader.
  31576. */
  31577. attributes: string[];
  31578. /**
  31579. * Uniform varible names that will be set in the shader.
  31580. */
  31581. uniformsNames: string[];
  31582. /**
  31583. * Uniform buffer variable names that will be set in the shader.
  31584. */
  31585. uniformBuffersNames: string[];
  31586. /**
  31587. * Sampler texture variable names that will be set in the shader.
  31588. */
  31589. samplers: string[];
  31590. /**
  31591. * Define statements that will be set in the shader.
  31592. */
  31593. defines: any;
  31594. /**
  31595. * Possible fallbacks for this effect to improve performance when needed.
  31596. */
  31597. fallbacks: Nullable<IEffectFallbacks>;
  31598. /**
  31599. * Callback that will be called when the shader is compiled.
  31600. */
  31601. onCompiled: Nullable<(effect: Effect) => void>;
  31602. /**
  31603. * Callback that will be called if an error occurs during shader compilation.
  31604. */
  31605. onError: Nullable<(effect: Effect, errors: string) => void>;
  31606. /**
  31607. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31608. */
  31609. indexParameters?: any;
  31610. /**
  31611. * Max number of lights that can be used in the shader.
  31612. */
  31613. maxSimultaneousLights?: number;
  31614. /**
  31615. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31616. */
  31617. transformFeedbackVaryings?: Nullable<string[]>;
  31618. }
  31619. /**
  31620. * Effect containing vertex and fragment shader that can be executed on an object.
  31621. */
  31622. export class Effect implements IDisposable {
  31623. /**
  31624. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31625. */
  31626. static ShadersRepository: string;
  31627. /**
  31628. * Enable logging of the shader code when a compilation error occurs
  31629. */
  31630. static LogShaderCodeOnCompilationError: boolean;
  31631. /**
  31632. * Name of the effect.
  31633. */
  31634. name: any;
  31635. /**
  31636. * String container all the define statements that should be set on the shader.
  31637. */
  31638. defines: string;
  31639. /**
  31640. * Callback that will be called when the shader is compiled.
  31641. */
  31642. onCompiled: Nullable<(effect: Effect) => void>;
  31643. /**
  31644. * Callback that will be called if an error occurs during shader compilation.
  31645. */
  31646. onError: Nullable<(effect: Effect, errors: string) => void>;
  31647. /**
  31648. * Callback that will be called when effect is bound.
  31649. */
  31650. onBind: Nullable<(effect: Effect) => void>;
  31651. /**
  31652. * Unique ID of the effect.
  31653. */
  31654. uniqueId: number;
  31655. /**
  31656. * Observable that will be called when the shader is compiled.
  31657. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31658. */
  31659. onCompileObservable: Observable<Effect>;
  31660. /**
  31661. * Observable that will be called if an error occurs during shader compilation.
  31662. */
  31663. onErrorObservable: Observable<Effect>;
  31664. /** @hidden */
  31665. _onBindObservable: Nullable<Observable<Effect>>;
  31666. /**
  31667. * @hidden
  31668. * Specifies if the effect was previously ready
  31669. */
  31670. _wasPreviouslyReady: boolean;
  31671. /**
  31672. * Observable that will be called when effect is bound.
  31673. */
  31674. get onBindObservable(): Observable<Effect>;
  31675. /** @hidden */
  31676. _bonesComputationForcedToCPU: boolean;
  31677. private static _uniqueIdSeed;
  31678. private _engine;
  31679. private _uniformBuffersNames;
  31680. private _uniformBuffersNamesList;
  31681. private _uniformsNames;
  31682. private _samplerList;
  31683. private _samplers;
  31684. private _isReady;
  31685. private _compilationError;
  31686. private _allFallbacksProcessed;
  31687. private _attributesNames;
  31688. private _attributes;
  31689. private _attributeLocationByName;
  31690. private _uniforms;
  31691. /**
  31692. * Key for the effect.
  31693. * @hidden
  31694. */
  31695. _key: string;
  31696. private _indexParameters;
  31697. private _fallbacks;
  31698. private _vertexSourceCode;
  31699. private _fragmentSourceCode;
  31700. private _vertexSourceCodeOverride;
  31701. private _fragmentSourceCodeOverride;
  31702. private _transformFeedbackVaryings;
  31703. /**
  31704. * Compiled shader to webGL program.
  31705. * @hidden
  31706. */
  31707. _pipelineContext: Nullable<IPipelineContext>;
  31708. private _valueCache;
  31709. private static _baseCache;
  31710. /**
  31711. * Instantiates an effect.
  31712. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31713. * @param baseName Name of the effect.
  31714. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31715. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31716. * @param samplers List of sampler variables that will be passed to the shader.
  31717. * @param engine Engine to be used to render the effect
  31718. * @param defines Define statements to be added to the shader.
  31719. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31720. * @param onCompiled Callback that will be called when the shader is compiled.
  31721. * @param onError Callback that will be called if an error occurs during shader compilation.
  31722. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31723. */
  31724. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  31725. private _useFinalCode;
  31726. /**
  31727. * Unique key for this effect
  31728. */
  31729. get key(): string;
  31730. /**
  31731. * If the effect has been compiled and prepared.
  31732. * @returns if the effect is compiled and prepared.
  31733. */
  31734. isReady(): boolean;
  31735. private _isReadyInternal;
  31736. /**
  31737. * The engine the effect was initialized with.
  31738. * @returns the engine.
  31739. */
  31740. getEngine(): Engine;
  31741. /**
  31742. * The pipeline context for this effect
  31743. * @returns the associated pipeline context
  31744. */
  31745. getPipelineContext(): Nullable<IPipelineContext>;
  31746. /**
  31747. * The set of names of attribute variables for the shader.
  31748. * @returns An array of attribute names.
  31749. */
  31750. getAttributesNames(): string[];
  31751. /**
  31752. * Returns the attribute at the given index.
  31753. * @param index The index of the attribute.
  31754. * @returns The location of the attribute.
  31755. */
  31756. getAttributeLocation(index: number): number;
  31757. /**
  31758. * Returns the attribute based on the name of the variable.
  31759. * @param name of the attribute to look up.
  31760. * @returns the attribute location.
  31761. */
  31762. getAttributeLocationByName(name: string): number;
  31763. /**
  31764. * The number of attributes.
  31765. * @returns the numnber of attributes.
  31766. */
  31767. getAttributesCount(): number;
  31768. /**
  31769. * Gets the index of a uniform variable.
  31770. * @param uniformName of the uniform to look up.
  31771. * @returns the index.
  31772. */
  31773. getUniformIndex(uniformName: string): number;
  31774. /**
  31775. * Returns the attribute based on the name of the variable.
  31776. * @param uniformName of the uniform to look up.
  31777. * @returns the location of the uniform.
  31778. */
  31779. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31780. /**
  31781. * Returns an array of sampler variable names
  31782. * @returns The array of sampler variable names.
  31783. */
  31784. getSamplers(): string[];
  31785. /**
  31786. * Returns an array of uniform variable names
  31787. * @returns The array of uniform variable names.
  31788. */
  31789. getUniformNames(): string[];
  31790. /**
  31791. * Returns an array of uniform buffer variable names
  31792. * @returns The array of uniform buffer variable names.
  31793. */
  31794. getUniformBuffersNames(): string[];
  31795. /**
  31796. * Returns the index parameters used to create the effect
  31797. * @returns The index parameters object
  31798. */
  31799. getIndexParameters(): any;
  31800. /**
  31801. * The error from the last compilation.
  31802. * @returns the error string.
  31803. */
  31804. getCompilationError(): string;
  31805. /**
  31806. * Gets a boolean indicating that all fallbacks were used during compilation
  31807. * @returns true if all fallbacks were used
  31808. */
  31809. allFallbacksProcessed(): boolean;
  31810. /**
  31811. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31812. * @param func The callback to be used.
  31813. */
  31814. executeWhenCompiled(func: (effect: Effect) => void): void;
  31815. private _checkIsReady;
  31816. private _loadShader;
  31817. /**
  31818. * Gets the vertex shader source code of this effect
  31819. */
  31820. get vertexSourceCode(): string;
  31821. /**
  31822. * Gets the fragment shader source code of this effect
  31823. */
  31824. get fragmentSourceCode(): string;
  31825. /**
  31826. * Recompiles the webGL program
  31827. * @param vertexSourceCode The source code for the vertex shader.
  31828. * @param fragmentSourceCode The source code for the fragment shader.
  31829. * @param onCompiled Callback called when completed.
  31830. * @param onError Callback called on error.
  31831. * @hidden
  31832. */
  31833. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31834. /**
  31835. * Prepares the effect
  31836. * @hidden
  31837. */
  31838. _prepareEffect(): void;
  31839. private _getShaderCodeAndErrorLine;
  31840. private _processCompilationErrors;
  31841. /**
  31842. * Checks if the effect is supported. (Must be called after compilation)
  31843. */
  31844. get isSupported(): boolean;
  31845. /**
  31846. * Binds a texture to the engine to be used as output of the shader.
  31847. * @param channel Name of the output variable.
  31848. * @param texture Texture to bind.
  31849. * @hidden
  31850. */
  31851. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31852. /**
  31853. * Sets a texture on the engine to be used in the shader.
  31854. * @param channel Name of the sampler variable.
  31855. * @param texture Texture to set.
  31856. */
  31857. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31858. /**
  31859. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31860. * @param channel Name of the sampler variable.
  31861. * @param texture Texture to set.
  31862. */
  31863. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31864. /**
  31865. * Sets an array of textures on the engine to be used in the shader.
  31866. * @param channel Name of the variable.
  31867. * @param textures Textures to set.
  31868. */
  31869. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31870. /**
  31871. * 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)
  31872. * @param channel Name of the sampler variable.
  31873. * @param postProcess Post process to get the input texture from.
  31874. */
  31875. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31876. /**
  31877. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31878. * 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)
  31879. * @param channel Name of the sampler variable.
  31880. * @param postProcess Post process to get the output texture from.
  31881. */
  31882. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31883. /** @hidden */
  31884. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31885. /** @hidden */
  31886. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31887. /** @hidden */
  31888. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31889. /** @hidden */
  31890. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31891. /**
  31892. * Binds a buffer to a uniform.
  31893. * @param buffer Buffer to bind.
  31894. * @param name Name of the uniform variable to bind to.
  31895. */
  31896. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31897. /**
  31898. * Binds block to a uniform.
  31899. * @param blockName Name of the block to bind.
  31900. * @param index Index to bind.
  31901. */
  31902. bindUniformBlock(blockName: string, index: number): void;
  31903. /**
  31904. * Sets an interger value on a uniform variable.
  31905. * @param uniformName Name of the variable.
  31906. * @param value Value to be set.
  31907. * @returns this effect.
  31908. */
  31909. setInt(uniformName: string, value: number): Effect;
  31910. /**
  31911. * Sets an int array on a uniform variable.
  31912. * @param uniformName Name of the variable.
  31913. * @param array array to be set.
  31914. * @returns this effect.
  31915. */
  31916. setIntArray(uniformName: string, array: Int32Array): Effect;
  31917. /**
  31918. * 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)
  31919. * @param uniformName Name of the variable.
  31920. * @param array array to be set.
  31921. * @returns this effect.
  31922. */
  31923. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31924. /**
  31925. * 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)
  31926. * @param uniformName Name of the variable.
  31927. * @param array array to be set.
  31928. * @returns this effect.
  31929. */
  31930. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31931. /**
  31932. * 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)
  31933. * @param uniformName Name of the variable.
  31934. * @param array array to be set.
  31935. * @returns this effect.
  31936. */
  31937. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31938. /**
  31939. * Sets an float array on a uniform variable.
  31940. * @param uniformName Name of the variable.
  31941. * @param array array to be set.
  31942. * @returns this effect.
  31943. */
  31944. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31945. /**
  31946. * 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)
  31947. * @param uniformName Name of the variable.
  31948. * @param array array to be set.
  31949. * @returns this effect.
  31950. */
  31951. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31952. /**
  31953. * 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)
  31954. * @param uniformName Name of the variable.
  31955. * @param array array to be set.
  31956. * @returns this effect.
  31957. */
  31958. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31959. /**
  31960. * 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)
  31961. * @param uniformName Name of the variable.
  31962. * @param array array to be set.
  31963. * @returns this effect.
  31964. */
  31965. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31966. /**
  31967. * Sets an array on a uniform variable.
  31968. * @param uniformName Name of the variable.
  31969. * @param array array to be set.
  31970. * @returns this effect.
  31971. */
  31972. setArray(uniformName: string, array: number[]): Effect;
  31973. /**
  31974. * 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)
  31975. * @param uniformName Name of the variable.
  31976. * @param array array to be set.
  31977. * @returns this effect.
  31978. */
  31979. setArray2(uniformName: string, array: number[]): Effect;
  31980. /**
  31981. * 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)
  31982. * @param uniformName Name of the variable.
  31983. * @param array array to be set.
  31984. * @returns this effect.
  31985. */
  31986. setArray3(uniformName: string, array: number[]): Effect;
  31987. /**
  31988. * 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)
  31989. * @param uniformName Name of the variable.
  31990. * @param array array to be set.
  31991. * @returns this effect.
  31992. */
  31993. setArray4(uniformName: string, array: number[]): Effect;
  31994. /**
  31995. * Sets matrices on a uniform variable.
  31996. * @param uniformName Name of the variable.
  31997. * @param matrices matrices to be set.
  31998. * @returns this effect.
  31999. */
  32000. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  32001. /**
  32002. * Sets matrix on a uniform variable.
  32003. * @param uniformName Name of the variable.
  32004. * @param matrix matrix to be set.
  32005. * @returns this effect.
  32006. */
  32007. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  32008. /**
  32009. * 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)
  32010. * @param uniformName Name of the variable.
  32011. * @param matrix matrix to be set.
  32012. * @returns this effect.
  32013. */
  32014. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  32015. /**
  32016. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  32017. * @param uniformName Name of the variable.
  32018. * @param matrix matrix to be set.
  32019. * @returns this effect.
  32020. */
  32021. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  32022. /**
  32023. * Sets a float on a uniform variable.
  32024. * @param uniformName Name of the variable.
  32025. * @param value value to be set.
  32026. * @returns this effect.
  32027. */
  32028. setFloat(uniformName: string, value: number): Effect;
  32029. /**
  32030. * Sets a boolean on a uniform variable.
  32031. * @param uniformName Name of the variable.
  32032. * @param bool value to be set.
  32033. * @returns this effect.
  32034. */
  32035. setBool(uniformName: string, bool: boolean): Effect;
  32036. /**
  32037. * Sets a Vector2 on a uniform variable.
  32038. * @param uniformName Name of the variable.
  32039. * @param vector2 vector2 to be set.
  32040. * @returns this effect.
  32041. */
  32042. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  32043. /**
  32044. * Sets a float2 on a uniform variable.
  32045. * @param uniformName Name of the variable.
  32046. * @param x First float in float2.
  32047. * @param y Second float in float2.
  32048. * @returns this effect.
  32049. */
  32050. setFloat2(uniformName: string, x: number, y: number): Effect;
  32051. /**
  32052. * Sets a Vector3 on a uniform variable.
  32053. * @param uniformName Name of the variable.
  32054. * @param vector3 Value to be set.
  32055. * @returns this effect.
  32056. */
  32057. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  32058. /**
  32059. * Sets a float3 on a uniform variable.
  32060. * @param uniformName Name of the variable.
  32061. * @param x First float in float3.
  32062. * @param y Second float in float3.
  32063. * @param z Third float in float3.
  32064. * @returns this effect.
  32065. */
  32066. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  32067. /**
  32068. * Sets a Vector4 on a uniform variable.
  32069. * @param uniformName Name of the variable.
  32070. * @param vector4 Value to be set.
  32071. * @returns this effect.
  32072. */
  32073. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  32074. /**
  32075. * Sets a float4 on a uniform variable.
  32076. * @param uniformName Name of the variable.
  32077. * @param x First float in float4.
  32078. * @param y Second float in float4.
  32079. * @param z Third float in float4.
  32080. * @param w Fourth float in float4.
  32081. * @returns this effect.
  32082. */
  32083. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  32084. /**
  32085. * Sets a Color3 on a uniform variable.
  32086. * @param uniformName Name of the variable.
  32087. * @param color3 Value to be set.
  32088. * @returns this effect.
  32089. */
  32090. setColor3(uniformName: string, color3: IColor3Like): Effect;
  32091. /**
  32092. * Sets a Color4 on a uniform variable.
  32093. * @param uniformName Name of the variable.
  32094. * @param color3 Value to be set.
  32095. * @param alpha Alpha value to be set.
  32096. * @returns this effect.
  32097. */
  32098. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  32099. /**
  32100. * Sets a Color4 on a uniform variable
  32101. * @param uniformName defines the name of the variable
  32102. * @param color4 defines the value to be set
  32103. * @returns this effect.
  32104. */
  32105. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  32106. /** Release all associated resources */
  32107. dispose(): void;
  32108. /**
  32109. * This function will add a new shader to the shader store
  32110. * @param name the name of the shader
  32111. * @param pixelShader optional pixel shader content
  32112. * @param vertexShader optional vertex shader content
  32113. */
  32114. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  32115. /**
  32116. * Store of each shader (The can be looked up using effect.key)
  32117. */
  32118. static ShadersStore: {
  32119. [key: string]: string;
  32120. };
  32121. /**
  32122. * Store of each included file for a shader (The can be looked up using effect.key)
  32123. */
  32124. static IncludesShadersStore: {
  32125. [key: string]: string;
  32126. };
  32127. /**
  32128. * Resets the cache of effects.
  32129. */
  32130. static ResetCache(): void;
  32131. }
  32132. }
  32133. declare module "babylonjs/Engines/engineCapabilities" {
  32134. /**
  32135. * Interface used to describe the capabilities of the engine relatively to the current browser
  32136. */
  32137. export interface EngineCapabilities {
  32138. /** Maximum textures units per fragment shader */
  32139. maxTexturesImageUnits: number;
  32140. /** Maximum texture units per vertex shader */
  32141. maxVertexTextureImageUnits: number;
  32142. /** Maximum textures units in the entire pipeline */
  32143. maxCombinedTexturesImageUnits: number;
  32144. /** Maximum texture size */
  32145. maxTextureSize: number;
  32146. /** Maximum texture samples */
  32147. maxSamples?: number;
  32148. /** Maximum cube texture size */
  32149. maxCubemapTextureSize: number;
  32150. /** Maximum render texture size */
  32151. maxRenderTextureSize: number;
  32152. /** Maximum number of vertex attributes */
  32153. maxVertexAttribs: number;
  32154. /** Maximum number of varyings */
  32155. maxVaryingVectors: number;
  32156. /** Maximum number of uniforms per vertex shader */
  32157. maxVertexUniformVectors: number;
  32158. /** Maximum number of uniforms per fragment shader */
  32159. maxFragmentUniformVectors: number;
  32160. /** Defines if standard derivates (dx/dy) are supported */
  32161. standardDerivatives: boolean;
  32162. /** Defines if s3tc texture compression is supported */
  32163. s3tc?: WEBGL_compressed_texture_s3tc;
  32164. /** Defines if pvrtc texture compression is supported */
  32165. pvrtc: any;
  32166. /** Defines if etc1 texture compression is supported */
  32167. etc1: any;
  32168. /** Defines if etc2 texture compression is supported */
  32169. etc2: any;
  32170. /** Defines if astc texture compression is supported */
  32171. astc: any;
  32172. /** Defines if float textures are supported */
  32173. textureFloat: boolean;
  32174. /** Defines if vertex array objects are supported */
  32175. vertexArrayObject: boolean;
  32176. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32177. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32178. /** Gets the maximum level of anisotropy supported */
  32179. maxAnisotropy: number;
  32180. /** Defines if instancing is supported */
  32181. instancedArrays: boolean;
  32182. /** Defines if 32 bits indices are supported */
  32183. uintIndices: boolean;
  32184. /** Defines if high precision shaders are supported */
  32185. highPrecisionShaderSupported: boolean;
  32186. /** Defines if depth reading in the fragment shader is supported */
  32187. fragmentDepthSupported: boolean;
  32188. /** Defines if float texture linear filtering is supported*/
  32189. textureFloatLinearFiltering: boolean;
  32190. /** Defines if rendering to float textures is supported */
  32191. textureFloatRender: boolean;
  32192. /** Defines if half float textures are supported*/
  32193. textureHalfFloat: boolean;
  32194. /** Defines if half float texture linear filtering is supported*/
  32195. textureHalfFloatLinearFiltering: boolean;
  32196. /** Defines if rendering to half float textures is supported */
  32197. textureHalfFloatRender: boolean;
  32198. /** Defines if textureLOD shader command is supported */
  32199. textureLOD: boolean;
  32200. /** Defines if draw buffers extension is supported */
  32201. drawBuffersExtension: boolean;
  32202. /** Defines if depth textures are supported */
  32203. depthTextureExtension: boolean;
  32204. /** Defines if float color buffer are supported */
  32205. colorBufferFloat: boolean;
  32206. /** Gets disjoint timer query extension (null if not supported) */
  32207. timerQuery?: EXT_disjoint_timer_query;
  32208. /** Defines if timestamp can be used with timer query */
  32209. canUseTimestampForTimerQuery: boolean;
  32210. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32211. multiview?: any;
  32212. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32213. oculusMultiview?: any;
  32214. /** Function used to let the system compiles shaders in background */
  32215. parallelShaderCompile?: {
  32216. COMPLETION_STATUS_KHR: number;
  32217. };
  32218. /** Max number of texture samples for MSAA */
  32219. maxMSAASamples: number;
  32220. /** Defines if the blend min max extension is supported */
  32221. blendMinMax: boolean;
  32222. }
  32223. }
  32224. declare module "babylonjs/States/depthCullingState" {
  32225. import { Nullable } from "babylonjs/types";
  32226. /**
  32227. * @hidden
  32228. **/
  32229. export class DepthCullingState {
  32230. private _isDepthTestDirty;
  32231. private _isDepthMaskDirty;
  32232. private _isDepthFuncDirty;
  32233. private _isCullFaceDirty;
  32234. private _isCullDirty;
  32235. private _isZOffsetDirty;
  32236. private _isFrontFaceDirty;
  32237. private _depthTest;
  32238. private _depthMask;
  32239. private _depthFunc;
  32240. private _cull;
  32241. private _cullFace;
  32242. private _zOffset;
  32243. private _frontFace;
  32244. /**
  32245. * Initializes the state.
  32246. */
  32247. constructor();
  32248. get isDirty(): boolean;
  32249. get zOffset(): number;
  32250. set zOffset(value: number);
  32251. get cullFace(): Nullable<number>;
  32252. set cullFace(value: Nullable<number>);
  32253. get cull(): Nullable<boolean>;
  32254. set cull(value: Nullable<boolean>);
  32255. get depthFunc(): Nullable<number>;
  32256. set depthFunc(value: Nullable<number>);
  32257. get depthMask(): boolean;
  32258. set depthMask(value: boolean);
  32259. get depthTest(): boolean;
  32260. set depthTest(value: boolean);
  32261. get frontFace(): Nullable<number>;
  32262. set frontFace(value: Nullable<number>);
  32263. reset(): void;
  32264. apply(gl: WebGLRenderingContext): void;
  32265. }
  32266. }
  32267. declare module "babylonjs/States/stencilState" {
  32268. /**
  32269. * @hidden
  32270. **/
  32271. export class StencilState {
  32272. /** 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 */
  32273. static readonly ALWAYS: number;
  32274. /** Passed to stencilOperation to specify that stencil value must be kept */
  32275. static readonly KEEP: number;
  32276. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32277. static readonly REPLACE: number;
  32278. private _isStencilTestDirty;
  32279. private _isStencilMaskDirty;
  32280. private _isStencilFuncDirty;
  32281. private _isStencilOpDirty;
  32282. private _stencilTest;
  32283. private _stencilMask;
  32284. private _stencilFunc;
  32285. private _stencilFuncRef;
  32286. private _stencilFuncMask;
  32287. private _stencilOpStencilFail;
  32288. private _stencilOpDepthFail;
  32289. private _stencilOpStencilDepthPass;
  32290. get isDirty(): boolean;
  32291. get stencilFunc(): number;
  32292. set stencilFunc(value: number);
  32293. get stencilFuncRef(): number;
  32294. set stencilFuncRef(value: number);
  32295. get stencilFuncMask(): number;
  32296. set stencilFuncMask(value: number);
  32297. get stencilOpStencilFail(): number;
  32298. set stencilOpStencilFail(value: number);
  32299. get stencilOpDepthFail(): number;
  32300. set stencilOpDepthFail(value: number);
  32301. get stencilOpStencilDepthPass(): number;
  32302. set stencilOpStencilDepthPass(value: number);
  32303. get stencilMask(): number;
  32304. set stencilMask(value: number);
  32305. get stencilTest(): boolean;
  32306. set stencilTest(value: boolean);
  32307. constructor();
  32308. reset(): void;
  32309. apply(gl: WebGLRenderingContext): void;
  32310. }
  32311. }
  32312. declare module "babylonjs/States/alphaCullingState" {
  32313. /**
  32314. * @hidden
  32315. **/
  32316. export class AlphaState {
  32317. private _isAlphaBlendDirty;
  32318. private _isBlendFunctionParametersDirty;
  32319. private _isBlendEquationParametersDirty;
  32320. private _isBlendConstantsDirty;
  32321. private _alphaBlend;
  32322. private _blendFunctionParameters;
  32323. private _blendEquationParameters;
  32324. private _blendConstants;
  32325. /**
  32326. * Initializes the state.
  32327. */
  32328. constructor();
  32329. get isDirty(): boolean;
  32330. get alphaBlend(): boolean;
  32331. set alphaBlend(value: boolean);
  32332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32335. reset(): void;
  32336. apply(gl: WebGLRenderingContext): void;
  32337. }
  32338. }
  32339. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32340. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32341. /** @hidden */
  32342. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32343. attributeProcessor(attribute: string): string;
  32344. varyingProcessor(varying: string, isFragment: boolean): string;
  32345. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32346. }
  32347. }
  32348. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32349. /**
  32350. * Interface for attribute information associated with buffer instanciation
  32351. */
  32352. export interface InstancingAttributeInfo {
  32353. /**
  32354. * Name of the GLSL attribute
  32355. * if attribute index is not specified, this is used to retrieve the index from the effect
  32356. */
  32357. attributeName: string;
  32358. /**
  32359. * Index/offset of the attribute in the vertex shader
  32360. * if not specified, this will be computes from the name.
  32361. */
  32362. index?: number;
  32363. /**
  32364. * size of the attribute, 1, 2, 3 or 4
  32365. */
  32366. attributeSize: number;
  32367. /**
  32368. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32369. */
  32370. offset: number;
  32371. /**
  32372. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32373. * default to 1
  32374. */
  32375. divisor?: number;
  32376. /**
  32377. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32378. * default is FLOAT
  32379. */
  32380. attributeType?: number;
  32381. /**
  32382. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32383. */
  32384. normalized?: boolean;
  32385. }
  32386. }
  32387. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32389. import { Nullable } from "babylonjs/types";
  32390. module "babylonjs/Engines/thinEngine" {
  32391. interface ThinEngine {
  32392. /**
  32393. * Update a video texture
  32394. * @param texture defines the texture to update
  32395. * @param video defines the video element to use
  32396. * @param invertY defines if data must be stored with Y axis inverted
  32397. */
  32398. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32399. }
  32400. }
  32401. }
  32402. declare module "babylonjs/Materials/Textures/videoTexture" {
  32403. import { Observable } from "babylonjs/Misc/observable";
  32404. import { Nullable } from "babylonjs/types";
  32405. import { Scene } from "babylonjs/scene";
  32406. import { Texture } from "babylonjs/Materials/Textures/texture";
  32407. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32408. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32409. /**
  32410. * Settings for finer control over video usage
  32411. */
  32412. export interface VideoTextureSettings {
  32413. /**
  32414. * Applies `autoplay` to video, if specified
  32415. */
  32416. autoPlay?: boolean;
  32417. /**
  32418. * Applies `loop` to video, if specified
  32419. */
  32420. loop?: boolean;
  32421. /**
  32422. * Automatically updates internal texture from video at every frame in the render loop
  32423. */
  32424. autoUpdateTexture: boolean;
  32425. /**
  32426. * Image src displayed during the video loading or until the user interacts with the video.
  32427. */
  32428. poster?: string;
  32429. }
  32430. /**
  32431. * If you want to display a video in your scene, this is the special texture for that.
  32432. * This special texture works similar to other textures, with the exception of a few parameters.
  32433. * @see https://doc.babylonjs.com/how_to/video_texture
  32434. */
  32435. export class VideoTexture extends Texture {
  32436. /**
  32437. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32438. */
  32439. readonly autoUpdateTexture: boolean;
  32440. /**
  32441. * The video instance used by the texture internally
  32442. */
  32443. readonly video: HTMLVideoElement;
  32444. private _onUserActionRequestedObservable;
  32445. /**
  32446. * Event triggerd when a dom action is required by the user to play the video.
  32447. * This happens due to recent changes in browser policies preventing video to auto start.
  32448. */
  32449. get onUserActionRequestedObservable(): Observable<Texture>;
  32450. private _generateMipMaps;
  32451. private _stillImageCaptured;
  32452. private _displayingPosterTexture;
  32453. private _settings;
  32454. private _createInternalTextureOnEvent;
  32455. private _frameId;
  32456. private _currentSrc;
  32457. /**
  32458. * Creates a video texture.
  32459. * If you want to display a video in your scene, this is the special texture for that.
  32460. * This special texture works similar to other textures, with the exception of a few parameters.
  32461. * @see https://doc.babylonjs.com/how_to/video_texture
  32462. * @param name optional name, will detect from video source, if not defined
  32463. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32464. * @param scene is obviously the current scene.
  32465. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32466. * @param invertY is false by default but can be used to invert video on Y axis
  32467. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32468. * @param settings allows finer control over video usage
  32469. */
  32470. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32471. private _getName;
  32472. private _getVideo;
  32473. private _createInternalTexture;
  32474. private reset;
  32475. /**
  32476. * @hidden Internal method to initiate `update`.
  32477. */
  32478. _rebuild(): void;
  32479. /**
  32480. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32481. */
  32482. update(): void;
  32483. /**
  32484. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32485. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32486. */
  32487. updateTexture(isVisible: boolean): void;
  32488. protected _updateInternalTexture: () => void;
  32489. /**
  32490. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32491. * @param url New url.
  32492. */
  32493. updateURL(url: string): void;
  32494. /**
  32495. * Clones the texture.
  32496. * @returns the cloned texture
  32497. */
  32498. clone(): VideoTexture;
  32499. /**
  32500. * Dispose the texture and release its associated resources.
  32501. */
  32502. dispose(): void;
  32503. /**
  32504. * Creates a video texture straight from a stream.
  32505. * @param scene Define the scene the texture should be created in
  32506. * @param stream Define the stream the texture should be created from
  32507. * @returns The created video texture as a promise
  32508. */
  32509. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32510. /**
  32511. * Creates a video texture straight from your WebCam video feed.
  32512. * @param scene Define the scene the texture should be created in
  32513. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32514. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32515. * @returns The created video texture as a promise
  32516. */
  32517. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32518. minWidth: number;
  32519. maxWidth: number;
  32520. minHeight: number;
  32521. maxHeight: number;
  32522. deviceId: string;
  32523. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32524. /**
  32525. * Creates a video texture straight from your WebCam video feed.
  32526. * @param scene Define the scene the texture should be created in
  32527. * @param onReady Define a callback to triggered once the texture will be ready
  32528. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32529. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32530. */
  32531. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32532. minWidth: number;
  32533. maxWidth: number;
  32534. minHeight: number;
  32535. maxHeight: number;
  32536. deviceId: string;
  32537. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32538. }
  32539. }
  32540. declare module "babylonjs/Engines/thinEngine" {
  32541. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32542. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32543. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32544. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32545. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32546. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32547. import { Observable } from "babylonjs/Misc/observable";
  32548. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32549. import { StencilState } from "babylonjs/States/stencilState";
  32550. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32552. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32554. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32555. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32556. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32557. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32558. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32560. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32561. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32562. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32563. import { WebRequest } from "babylonjs/Misc/webRequest";
  32564. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32565. /**
  32566. * Defines the interface used by objects working like Scene
  32567. * @hidden
  32568. */
  32569. export interface ISceneLike {
  32570. _addPendingData(data: any): void;
  32571. _removePendingData(data: any): void;
  32572. offlineProvider: IOfflineProvider;
  32573. }
  32574. /** Interface defining initialization parameters for Engine class */
  32575. export interface EngineOptions extends WebGLContextAttributes {
  32576. /**
  32577. * Defines if the engine should no exceed a specified device ratio
  32578. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32579. */
  32580. limitDeviceRatio?: number;
  32581. /**
  32582. * Defines if webvr should be enabled automatically
  32583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32584. */
  32585. autoEnableWebVR?: boolean;
  32586. /**
  32587. * Defines if webgl2 should be turned off even if supported
  32588. * @see http://doc.babylonjs.com/features/webgl2
  32589. */
  32590. disableWebGL2Support?: boolean;
  32591. /**
  32592. * Defines if webaudio should be initialized as well
  32593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32594. */
  32595. audioEngine?: boolean;
  32596. /**
  32597. * Defines if animations should run using a deterministic lock step
  32598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32599. */
  32600. deterministicLockstep?: boolean;
  32601. /** Defines the maximum steps to use with deterministic lock step mode */
  32602. lockstepMaxSteps?: number;
  32603. /** Defines the seconds between each deterministic lock step */
  32604. timeStep?: number;
  32605. /**
  32606. * Defines that engine should ignore context lost events
  32607. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32608. */
  32609. doNotHandleContextLost?: boolean;
  32610. /**
  32611. * Defines that engine should ignore modifying touch action attribute and style
  32612. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32613. */
  32614. doNotHandleTouchAction?: boolean;
  32615. /**
  32616. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32617. */
  32618. useHighPrecisionFloats?: boolean;
  32619. }
  32620. /**
  32621. * The base engine class (root of all engines)
  32622. */
  32623. export class ThinEngine {
  32624. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32625. static ExceptionList: ({
  32626. key: string;
  32627. capture: string;
  32628. captureConstraint: number;
  32629. targets: string[];
  32630. } | {
  32631. key: string;
  32632. capture: null;
  32633. captureConstraint: null;
  32634. targets: string[];
  32635. })[];
  32636. /** @hidden */
  32637. static _TextureLoaders: IInternalTextureLoader[];
  32638. /**
  32639. * Returns the current npm package of the sdk
  32640. */
  32641. static get NpmPackage(): string;
  32642. /**
  32643. * Returns the current version of the framework
  32644. */
  32645. static get Version(): string;
  32646. /**
  32647. * Returns a string describing the current engine
  32648. */
  32649. get description(): string;
  32650. /**
  32651. * Gets or sets the epsilon value used by collision engine
  32652. */
  32653. static CollisionsEpsilon: number;
  32654. /**
  32655. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32656. */
  32657. static get ShadersRepository(): string;
  32658. static set ShadersRepository(value: string);
  32659. /** @hidden */
  32660. _shaderProcessor: IShaderProcessor;
  32661. /**
  32662. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32663. */
  32664. forcePOTTextures: boolean;
  32665. /**
  32666. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32667. */
  32668. isFullscreen: boolean;
  32669. /**
  32670. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32671. */
  32672. cullBackFaces: boolean;
  32673. /**
  32674. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32675. */
  32676. renderEvenInBackground: boolean;
  32677. /**
  32678. * Gets or sets a boolean indicating that cache can be kept between frames
  32679. */
  32680. preventCacheWipeBetweenFrames: boolean;
  32681. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32682. validateShaderPrograms: boolean;
  32683. /**
  32684. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32685. * This can provide greater z depth for distant objects.
  32686. */
  32687. useReverseDepthBuffer: boolean;
  32688. /**
  32689. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32690. */
  32691. disableUniformBuffers: boolean;
  32692. /** @hidden */
  32693. _uniformBuffers: UniformBuffer[];
  32694. /**
  32695. * Gets a boolean indicating that the engine supports uniform buffers
  32696. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32697. */
  32698. get supportsUniformBuffers(): boolean;
  32699. /** @hidden */
  32700. _gl: WebGLRenderingContext;
  32701. /** @hidden */
  32702. _webGLVersion: number;
  32703. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32704. protected _windowIsBackground: boolean;
  32705. protected _creationOptions: EngineOptions;
  32706. protected _highPrecisionShadersAllowed: boolean;
  32707. /** @hidden */
  32708. get _shouldUseHighPrecisionShader(): boolean;
  32709. /**
  32710. * Gets a boolean indicating that only power of 2 textures are supported
  32711. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32712. */
  32713. get needPOTTextures(): boolean;
  32714. /** @hidden */
  32715. _badOS: boolean;
  32716. /** @hidden */
  32717. _badDesktopOS: boolean;
  32718. private _hardwareScalingLevel;
  32719. /** @hidden */
  32720. _caps: EngineCapabilities;
  32721. private _isStencilEnable;
  32722. private _glVersion;
  32723. private _glRenderer;
  32724. private _glVendor;
  32725. /** @hidden */
  32726. _videoTextureSupported: boolean;
  32727. protected _renderingQueueLaunched: boolean;
  32728. protected _activeRenderLoops: (() => void)[];
  32729. /**
  32730. * Observable signaled when a context lost event is raised
  32731. */
  32732. onContextLostObservable: Observable<ThinEngine>;
  32733. /**
  32734. * Observable signaled when a context restored event is raised
  32735. */
  32736. onContextRestoredObservable: Observable<ThinEngine>;
  32737. private _onContextLost;
  32738. private _onContextRestored;
  32739. protected _contextWasLost: boolean;
  32740. /** @hidden */
  32741. _doNotHandleContextLost: boolean;
  32742. /**
  32743. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32744. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32745. */
  32746. get doNotHandleContextLost(): boolean;
  32747. set doNotHandleContextLost(value: boolean);
  32748. /**
  32749. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32750. */
  32751. disableVertexArrayObjects: boolean;
  32752. /** @hidden */
  32753. protected _colorWrite: boolean;
  32754. /** @hidden */
  32755. protected _colorWriteChanged: boolean;
  32756. /** @hidden */
  32757. protected _depthCullingState: DepthCullingState;
  32758. /** @hidden */
  32759. protected _stencilState: StencilState;
  32760. /** @hidden */
  32761. _alphaState: AlphaState;
  32762. /** @hidden */
  32763. _alphaMode: number;
  32764. /** @hidden */
  32765. _alphaEquation: number;
  32766. /** @hidden */
  32767. _internalTexturesCache: InternalTexture[];
  32768. /** @hidden */
  32769. protected _activeChannel: number;
  32770. private _currentTextureChannel;
  32771. /** @hidden */
  32772. protected _boundTexturesCache: {
  32773. [key: string]: Nullable<InternalTexture>;
  32774. };
  32775. /** @hidden */
  32776. protected _currentEffect: Nullable<Effect>;
  32777. /** @hidden */
  32778. protected _currentProgram: Nullable<WebGLProgram>;
  32779. private _compiledEffects;
  32780. private _vertexAttribArraysEnabled;
  32781. /** @hidden */
  32782. protected _cachedViewport: Nullable<IViewportLike>;
  32783. private _cachedVertexArrayObject;
  32784. /** @hidden */
  32785. protected _cachedVertexBuffers: any;
  32786. /** @hidden */
  32787. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32788. /** @hidden */
  32789. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32790. /** @hidden */
  32791. _currentRenderTarget: Nullable<InternalTexture>;
  32792. private _uintIndicesCurrentlySet;
  32793. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32794. /** @hidden */
  32795. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32796. /** @hidden */
  32797. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  32798. private _currentBufferPointers;
  32799. private _currentInstanceLocations;
  32800. private _currentInstanceBuffers;
  32801. private _textureUnits;
  32802. /** @hidden */
  32803. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32804. /** @hidden */
  32805. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32806. /** @hidden */
  32807. _boundRenderFunction: any;
  32808. private _vaoRecordInProgress;
  32809. private _mustWipeVertexAttributes;
  32810. private _emptyTexture;
  32811. private _emptyCubeTexture;
  32812. private _emptyTexture3D;
  32813. private _emptyTexture2DArray;
  32814. /** @hidden */
  32815. _frameHandler: number;
  32816. private _nextFreeTextureSlots;
  32817. private _maxSimultaneousTextures;
  32818. private _activeRequests;
  32819. /** @hidden */
  32820. _transformTextureUrl: Nullable<(url: string) => string>;
  32821. protected get _supportsHardwareTextureRescaling(): boolean;
  32822. private _framebufferDimensionsObject;
  32823. /**
  32824. * sets the object from which width and height will be taken from when getting render width and height
  32825. * Will fallback to the gl object
  32826. * @param dimensions the framebuffer width and height that will be used.
  32827. */
  32828. set framebufferDimensionsObject(dimensions: Nullable<{
  32829. framebufferWidth: number;
  32830. framebufferHeight: number;
  32831. }>);
  32832. /**
  32833. * Gets the current viewport
  32834. */
  32835. get currentViewport(): Nullable<IViewportLike>;
  32836. /**
  32837. * Gets the default empty texture
  32838. */
  32839. get emptyTexture(): InternalTexture;
  32840. /**
  32841. * Gets the default empty 3D texture
  32842. */
  32843. get emptyTexture3D(): InternalTexture;
  32844. /**
  32845. * Gets the default empty 2D array texture
  32846. */
  32847. get emptyTexture2DArray(): InternalTexture;
  32848. /**
  32849. * Gets the default empty cube texture
  32850. */
  32851. get emptyCubeTexture(): InternalTexture;
  32852. /**
  32853. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32854. */
  32855. readonly premultipliedAlpha: boolean;
  32856. /**
  32857. * Observable event triggered before each texture is initialized
  32858. */
  32859. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32860. /**
  32861. * Creates a new engine
  32862. * @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
  32863. * @param antialias defines enable antialiasing (default: false)
  32864. * @param options defines further options to be sent to the getContext() function
  32865. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32866. */
  32867. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32868. private _rebuildInternalTextures;
  32869. private _rebuildEffects;
  32870. /**
  32871. * Gets a boolean indicating if all created effects are ready
  32872. * @returns true if all effects are ready
  32873. */
  32874. areAllEffectsReady(): boolean;
  32875. protected _rebuildBuffers(): void;
  32876. protected _initGLContext(): void;
  32877. /**
  32878. * Gets version of the current webGL context
  32879. */
  32880. get webGLVersion(): number;
  32881. /**
  32882. * Gets a string idenfifying the name of the class
  32883. * @returns "Engine" string
  32884. */
  32885. getClassName(): string;
  32886. /**
  32887. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32888. */
  32889. get isStencilEnable(): boolean;
  32890. /** @hidden */
  32891. _prepareWorkingCanvas(): void;
  32892. /**
  32893. * Reset the texture cache to empty state
  32894. */
  32895. resetTextureCache(): void;
  32896. /**
  32897. * Gets an object containing information about the current webGL context
  32898. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32899. */
  32900. getGlInfo(): {
  32901. vendor: string;
  32902. renderer: string;
  32903. version: string;
  32904. };
  32905. /**
  32906. * Defines the hardware scaling level.
  32907. * By default the hardware scaling level is computed from the window device ratio.
  32908. * 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.
  32909. * @param level defines the level to use
  32910. */
  32911. setHardwareScalingLevel(level: number): void;
  32912. /**
  32913. * Gets the current hardware scaling level.
  32914. * By default the hardware scaling level is computed from the window device ratio.
  32915. * 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.
  32916. * @returns a number indicating the current hardware scaling level
  32917. */
  32918. getHardwareScalingLevel(): number;
  32919. /**
  32920. * Gets the list of loaded textures
  32921. * @returns an array containing all loaded textures
  32922. */
  32923. getLoadedTexturesCache(): InternalTexture[];
  32924. /**
  32925. * Gets the object containing all engine capabilities
  32926. * @returns the EngineCapabilities object
  32927. */
  32928. getCaps(): EngineCapabilities;
  32929. /**
  32930. * stop executing a render loop function and remove it from the execution array
  32931. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32932. */
  32933. stopRenderLoop(renderFunction?: () => void): void;
  32934. /** @hidden */
  32935. _renderLoop(): void;
  32936. /**
  32937. * Gets the HTML canvas attached with the current webGL context
  32938. * @returns a HTML canvas
  32939. */
  32940. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32941. /**
  32942. * Gets host window
  32943. * @returns the host window object
  32944. */
  32945. getHostWindow(): Nullable<Window>;
  32946. /**
  32947. * Gets the current render width
  32948. * @param useScreen defines if screen size must be used (or the current render target if any)
  32949. * @returns a number defining the current render width
  32950. */
  32951. getRenderWidth(useScreen?: boolean): number;
  32952. /**
  32953. * Gets the current render height
  32954. * @param useScreen defines if screen size must be used (or the current render target if any)
  32955. * @returns a number defining the current render height
  32956. */
  32957. getRenderHeight(useScreen?: boolean): number;
  32958. /**
  32959. * Can be used to override the current requestAnimationFrame requester.
  32960. * @hidden
  32961. */
  32962. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32963. /**
  32964. * Register and execute a render loop. The engine can have more than one render function
  32965. * @param renderFunction defines the function to continuously execute
  32966. */
  32967. runRenderLoop(renderFunction: () => void): void;
  32968. /**
  32969. * Clear the current render buffer or the current render target (if any is set up)
  32970. * @param color defines the color to use
  32971. * @param backBuffer defines if the back buffer must be cleared
  32972. * @param depth defines if the depth buffer must be cleared
  32973. * @param stencil defines if the stencil buffer must be cleared
  32974. */
  32975. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32976. private _viewportCached;
  32977. /** @hidden */
  32978. _viewport(x: number, y: number, width: number, height: number): void;
  32979. /**
  32980. * Set the WebGL's viewport
  32981. * @param viewport defines the viewport element to be used
  32982. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32983. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32984. */
  32985. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32986. /**
  32987. * Begin a new frame
  32988. */
  32989. beginFrame(): void;
  32990. /**
  32991. * Enf the current frame
  32992. */
  32993. endFrame(): void;
  32994. /**
  32995. * Resize the view according to the canvas' size
  32996. */
  32997. resize(): void;
  32998. /**
  32999. * Force a specific size of the canvas
  33000. * @param width defines the new canvas' width
  33001. * @param height defines the new canvas' height
  33002. */
  33003. setSize(width: number, height: number): void;
  33004. /**
  33005. * Binds the frame buffer to the specified texture.
  33006. * @param texture The texture to render to or null for the default canvas
  33007. * @param faceIndex The face of the texture to render to in case of cube texture
  33008. * @param requiredWidth The width of the target to render to
  33009. * @param requiredHeight The height of the target to render to
  33010. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  33011. * @param lodLevel defines the lod level to bind to the frame buffer
  33012. * @param layer defines the 2d array index to bind to frame buffer to
  33013. */
  33014. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  33015. /** @hidden */
  33016. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  33017. /**
  33018. * Unbind the current render target texture from the webGL context
  33019. * @param texture defines the render target texture to unbind
  33020. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  33021. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  33022. */
  33023. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  33024. /**
  33025. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  33026. */
  33027. flushFramebuffer(): void;
  33028. /**
  33029. * Unbind the current render target and bind the default framebuffer
  33030. */
  33031. restoreDefaultFramebuffer(): void;
  33032. /** @hidden */
  33033. protected _resetVertexBufferBinding(): void;
  33034. /**
  33035. * Creates a vertex buffer
  33036. * @param data the data for the vertex buffer
  33037. * @returns the new WebGL static buffer
  33038. */
  33039. createVertexBuffer(data: DataArray): DataBuffer;
  33040. private _createVertexBuffer;
  33041. /**
  33042. * Creates a dynamic vertex buffer
  33043. * @param data the data for the dynamic vertex buffer
  33044. * @returns the new WebGL dynamic buffer
  33045. */
  33046. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  33047. protected _resetIndexBufferBinding(): void;
  33048. /**
  33049. * Creates a new index buffer
  33050. * @param indices defines the content of the index buffer
  33051. * @param updatable defines if the index buffer must be updatable
  33052. * @returns a new webGL buffer
  33053. */
  33054. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  33055. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  33056. /**
  33057. * Bind a webGL buffer to the webGL context
  33058. * @param buffer defines the buffer to bind
  33059. */
  33060. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  33061. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  33062. private bindBuffer;
  33063. /**
  33064. * update the bound buffer with the given data
  33065. * @param data defines the data to update
  33066. */
  33067. updateArrayBuffer(data: Float32Array): void;
  33068. private _vertexAttribPointer;
  33069. /** @hidden */
  33070. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  33071. private _bindVertexBuffersAttributes;
  33072. /**
  33073. * Records a vertex array object
  33074. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33075. * @param vertexBuffers defines the list of vertex buffers to store
  33076. * @param indexBuffer defines the index buffer to store
  33077. * @param effect defines the effect to store
  33078. * @returns the new vertex array object
  33079. */
  33080. recordVertexArrayObject(vertexBuffers: {
  33081. [key: string]: VertexBuffer;
  33082. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  33083. /**
  33084. * Bind a specific vertex array object
  33085. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33086. * @param vertexArrayObject defines the vertex array object to bind
  33087. * @param indexBuffer defines the index buffer to bind
  33088. */
  33089. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  33090. /**
  33091. * Bind webGl buffers directly to the webGL context
  33092. * @param vertexBuffer defines the vertex buffer to bind
  33093. * @param indexBuffer defines the index buffer to bind
  33094. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  33095. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  33096. * @param effect defines the effect associated with the vertex buffer
  33097. */
  33098. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  33099. private _unbindVertexArrayObject;
  33100. /**
  33101. * Bind a list of vertex buffers to the webGL context
  33102. * @param vertexBuffers defines the list of vertex buffers to bind
  33103. * @param indexBuffer defines the index buffer to bind
  33104. * @param effect defines the effect associated with the vertex buffers
  33105. */
  33106. bindBuffers(vertexBuffers: {
  33107. [key: string]: Nullable<VertexBuffer>;
  33108. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  33109. /**
  33110. * Unbind all instance attributes
  33111. */
  33112. unbindInstanceAttributes(): void;
  33113. /**
  33114. * Release and free the memory of a vertex array object
  33115. * @param vao defines the vertex array object to delete
  33116. */
  33117. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  33118. /** @hidden */
  33119. _releaseBuffer(buffer: DataBuffer): boolean;
  33120. protected _deleteBuffer(buffer: DataBuffer): void;
  33121. /**
  33122. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  33123. * @param instancesBuffer defines the webGL buffer to update and bind
  33124. * @param data defines the data to store in the buffer
  33125. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  33126. */
  33127. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  33128. /**
  33129. * Bind the content of a webGL buffer used with instantiation
  33130. * @param instancesBuffer defines the webGL buffer to bind
  33131. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  33132. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  33133. */
  33134. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  33135. /**
  33136. * Disable the instance attribute corresponding to the name in parameter
  33137. * @param name defines the name of the attribute to disable
  33138. */
  33139. disableInstanceAttributeByName(name: string): void;
  33140. /**
  33141. * Disable the instance attribute corresponding to the location in parameter
  33142. * @param attributeLocation defines the attribute location of the attribute to disable
  33143. */
  33144. disableInstanceAttribute(attributeLocation: number): void;
  33145. /**
  33146. * Disable the attribute corresponding to the location in parameter
  33147. * @param attributeLocation defines the attribute location of the attribute to disable
  33148. */
  33149. disableAttributeByIndex(attributeLocation: number): void;
  33150. /**
  33151. * Send a draw order
  33152. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33153. * @param indexStart defines the starting index
  33154. * @param indexCount defines the number of index to draw
  33155. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33156. */
  33157. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  33158. /**
  33159. * Draw a list of points
  33160. * @param verticesStart defines the index of first vertex to draw
  33161. * @param verticesCount defines the count of vertices to draw
  33162. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33163. */
  33164. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33165. /**
  33166. * Draw a list of unindexed primitives
  33167. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33168. * @param verticesStart defines the index of first vertex to draw
  33169. * @param verticesCount defines the count of vertices to draw
  33170. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33171. */
  33172. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33173. /**
  33174. * Draw a list of indexed primitives
  33175. * @param fillMode defines the primitive to use
  33176. * @param indexStart defines the starting index
  33177. * @param indexCount defines the number of index to draw
  33178. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33179. */
  33180. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33181. /**
  33182. * Draw a list of unindexed primitives
  33183. * @param fillMode defines the primitive to use
  33184. * @param verticesStart defines the index of first vertex to draw
  33185. * @param verticesCount defines the count of vertices to draw
  33186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33187. */
  33188. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33189. private _drawMode;
  33190. /** @hidden */
  33191. protected _reportDrawCall(): void;
  33192. /** @hidden */
  33193. _releaseEffect(effect: Effect): void;
  33194. /** @hidden */
  33195. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33196. /**
  33197. * Create a new effect (used to store vertex/fragment shaders)
  33198. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33199. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33200. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33201. * @param samplers defines an array of string used to represent textures
  33202. * @param defines defines the string containing the defines to use to compile the shaders
  33203. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33204. * @param onCompiled defines a function to call when the effect creation is successful
  33205. * @param onError defines a function to call when the effect creation has failed
  33206. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33207. * @returns the new Effect
  33208. */
  33209. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  33210. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33211. private _compileShader;
  33212. private _compileRawShader;
  33213. /** @hidden */
  33214. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33215. /**
  33216. * Directly creates a webGL program
  33217. * @param pipelineContext defines the pipeline context to attach to
  33218. * @param vertexCode defines the vertex shader code to use
  33219. * @param fragmentCode defines the fragment shader code to use
  33220. * @param context defines the webGL context to use (if not set, the current one will be used)
  33221. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33222. * @returns the new webGL program
  33223. */
  33224. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33225. /**
  33226. * Creates a webGL program
  33227. * @param pipelineContext defines the pipeline context to attach to
  33228. * @param vertexCode defines the vertex shader code to use
  33229. * @param fragmentCode defines the fragment shader code to use
  33230. * @param defines defines the string containing the defines to use to compile the shaders
  33231. * @param context defines the webGL context to use (if not set, the current one will be used)
  33232. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33233. * @returns the new webGL program
  33234. */
  33235. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33236. /**
  33237. * Creates a new pipeline context
  33238. * @returns the new pipeline
  33239. */
  33240. createPipelineContext(): IPipelineContext;
  33241. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33242. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33243. /** @hidden */
  33244. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33245. /** @hidden */
  33246. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33247. /** @hidden */
  33248. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33249. /**
  33250. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33251. * @param pipelineContext defines the pipeline context to use
  33252. * @param uniformsNames defines the list of uniform names
  33253. * @returns an array of webGL uniform locations
  33254. */
  33255. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33256. /**
  33257. * Gets the lsit of active attributes for a given webGL program
  33258. * @param pipelineContext defines the pipeline context to use
  33259. * @param attributesNames defines the list of attribute names to get
  33260. * @returns an array of indices indicating the offset of each attribute
  33261. */
  33262. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33263. /**
  33264. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33265. * @param effect defines the effect to activate
  33266. */
  33267. enableEffect(effect: Nullable<Effect>): void;
  33268. /**
  33269. * Set the value of an uniform to a number (int)
  33270. * @param uniform defines the webGL uniform location where to store the value
  33271. * @param value defines the int number to store
  33272. */
  33273. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33274. /**
  33275. * Set the value of an uniform to an array of int32
  33276. * @param uniform defines the webGL uniform location where to store the value
  33277. * @param array defines the array of int32 to store
  33278. */
  33279. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33280. /**
  33281. * Set the value of an uniform to an array of int32 (stored as vec2)
  33282. * @param uniform defines the webGL uniform location where to store the value
  33283. * @param array defines the array of int32 to store
  33284. */
  33285. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33286. /**
  33287. * Set the value of an uniform to an array of int32 (stored as vec3)
  33288. * @param uniform defines the webGL uniform location where to store the value
  33289. * @param array defines the array of int32 to store
  33290. */
  33291. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33292. /**
  33293. * Set the value of an uniform to an array of int32 (stored as vec4)
  33294. * @param uniform defines the webGL uniform location where to store the value
  33295. * @param array defines the array of int32 to store
  33296. */
  33297. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33298. /**
  33299. * Set the value of an uniform to an array of number
  33300. * @param uniform defines the webGL uniform location where to store the value
  33301. * @param array defines the array of number to store
  33302. */
  33303. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33304. /**
  33305. * Set the value of an uniform to an array of number (stored as vec2)
  33306. * @param uniform defines the webGL uniform location where to store the value
  33307. * @param array defines the array of number to store
  33308. */
  33309. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33310. /**
  33311. * Set the value of an uniform to an array of number (stored as vec3)
  33312. * @param uniform defines the webGL uniform location where to store the value
  33313. * @param array defines the array of number to store
  33314. */
  33315. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33316. /**
  33317. * Set the value of an uniform to an array of number (stored as vec4)
  33318. * @param uniform defines the webGL uniform location where to store the value
  33319. * @param array defines the array of number to store
  33320. */
  33321. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33322. /**
  33323. * Set the value of an uniform to an array of float32 (stored as matrices)
  33324. * @param uniform defines the webGL uniform location where to store the value
  33325. * @param matrices defines the array of float32 to store
  33326. */
  33327. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33328. /**
  33329. * Set the value of an uniform to a matrix (3x3)
  33330. * @param uniform defines the webGL uniform location where to store the value
  33331. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33332. */
  33333. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33334. /**
  33335. * Set the value of an uniform to a matrix (2x2)
  33336. * @param uniform defines the webGL uniform location where to store the value
  33337. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33338. */
  33339. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33340. /**
  33341. * Set the value of an uniform to a number (float)
  33342. * @param uniform defines the webGL uniform location where to store the value
  33343. * @param value defines the float number to store
  33344. */
  33345. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33346. /**
  33347. * Set the value of an uniform to a vec2
  33348. * @param uniform defines the webGL uniform location where to store the value
  33349. * @param x defines the 1st component of the value
  33350. * @param y defines the 2nd component of the value
  33351. */
  33352. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33353. /**
  33354. * Set the value of an uniform to a vec3
  33355. * @param uniform defines the webGL uniform location where to store the value
  33356. * @param x defines the 1st component of the value
  33357. * @param y defines the 2nd component of the value
  33358. * @param z defines the 3rd component of the value
  33359. */
  33360. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33361. /**
  33362. * Set the value of an uniform to a vec4
  33363. * @param uniform defines the webGL uniform location where to store the value
  33364. * @param x defines the 1st component of the value
  33365. * @param y defines the 2nd component of the value
  33366. * @param z defines the 3rd component of the value
  33367. * @param w defines the 4th component of the value
  33368. */
  33369. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33370. /**
  33371. * Apply all cached states (depth, culling, stencil and alpha)
  33372. */
  33373. applyStates(): void;
  33374. /**
  33375. * Enable or disable color writing
  33376. * @param enable defines the state to set
  33377. */
  33378. setColorWrite(enable: boolean): void;
  33379. /**
  33380. * Gets a boolean indicating if color writing is enabled
  33381. * @returns the current color writing state
  33382. */
  33383. getColorWrite(): boolean;
  33384. /**
  33385. * Gets the depth culling state manager
  33386. */
  33387. get depthCullingState(): DepthCullingState;
  33388. /**
  33389. * Gets the alpha state manager
  33390. */
  33391. get alphaState(): AlphaState;
  33392. /**
  33393. * Gets the stencil state manager
  33394. */
  33395. get stencilState(): StencilState;
  33396. /**
  33397. * Clears the list of texture accessible through engine.
  33398. * This can help preventing texture load conflict due to name collision.
  33399. */
  33400. clearInternalTexturesCache(): void;
  33401. /**
  33402. * Force the entire cache to be cleared
  33403. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33404. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33405. */
  33406. wipeCaches(bruteForce?: boolean): void;
  33407. /** @hidden */
  33408. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33409. min: number;
  33410. mag: number;
  33411. };
  33412. /** @hidden */
  33413. _createTexture(): WebGLTexture;
  33414. /**
  33415. * Usually called from Texture.ts.
  33416. * Passed information to create a WebGLTexture
  33417. * @param url defines a value which contains one of the following:
  33418. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33419. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33420. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33421. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33422. * @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)
  33423. * @param scene needed for loading to the correct scene
  33424. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33425. * @param onLoad optional callback to be called upon successful completion
  33426. * @param onError optional callback to be called upon failure
  33427. * @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
  33428. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33429. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33430. * @param forcedExtension defines the extension to use to pick the right loader
  33431. * @param mimeType defines an optional mime type
  33432. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33433. */
  33434. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  33435. /**
  33436. * Loads an image as an HTMLImageElement.
  33437. * @param input url string, ArrayBuffer, or Blob to load
  33438. * @param onLoad callback called when the image successfully loads
  33439. * @param onError callback called when the image fails to load
  33440. * @param offlineProvider offline provider for caching
  33441. * @param mimeType optional mime type
  33442. * @returns the HTMLImageElement of the loaded image
  33443. * @hidden
  33444. */
  33445. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33446. /**
  33447. * @hidden
  33448. */
  33449. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33450. private _unpackFlipYCached;
  33451. /**
  33452. * In case you are sharing the context with other applications, it might
  33453. * be interested to not cache the unpack flip y state to ensure a consistent
  33454. * value would be set.
  33455. */
  33456. enableUnpackFlipYCached: boolean;
  33457. /** @hidden */
  33458. _unpackFlipY(value: boolean): void;
  33459. /** @hidden */
  33460. _getUnpackAlignement(): number;
  33461. private _getTextureTarget;
  33462. /**
  33463. * Update the sampling mode of a given texture
  33464. * @param samplingMode defines the required sampling mode
  33465. * @param texture defines the texture to update
  33466. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33467. */
  33468. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33469. /**
  33470. * Update the sampling mode of a given texture
  33471. * @param texture defines the texture to update
  33472. * @param wrapU defines the texture wrap mode of the u coordinates
  33473. * @param wrapV defines the texture wrap mode of the v coordinates
  33474. * @param wrapR defines the texture wrap mode of the r coordinates
  33475. */
  33476. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33477. /** @hidden */
  33478. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33479. width: number;
  33480. height: number;
  33481. layers?: number;
  33482. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33483. /** @hidden */
  33484. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33485. /** @hidden */
  33486. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33487. /**
  33488. * Update a portion of an internal texture
  33489. * @param texture defines the texture to update
  33490. * @param imageData defines the data to store into the texture
  33491. * @param xOffset defines the x coordinates of the update rectangle
  33492. * @param yOffset defines the y coordinates of the update rectangle
  33493. * @param width defines the width of the update rectangle
  33494. * @param height defines the height of the update rectangle
  33495. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33496. * @param lod defines the lod level to update (0 by default)
  33497. */
  33498. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33499. /** @hidden */
  33500. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33501. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33502. private _prepareWebGLTexture;
  33503. /** @hidden */
  33504. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33505. private _getDepthStencilBuffer;
  33506. /** @hidden */
  33507. _releaseFramebufferObjects(texture: InternalTexture): void;
  33508. /** @hidden */
  33509. _releaseTexture(texture: InternalTexture): void;
  33510. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33511. protected _setProgram(program: WebGLProgram): void;
  33512. protected _boundUniforms: {
  33513. [key: number]: WebGLUniformLocation;
  33514. };
  33515. /**
  33516. * Binds an effect to the webGL context
  33517. * @param effect defines the effect to bind
  33518. */
  33519. bindSamplers(effect: Effect): void;
  33520. private _activateCurrentTexture;
  33521. /** @hidden */
  33522. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33523. /** @hidden */
  33524. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33525. /**
  33526. * Unbind all textures from the webGL context
  33527. */
  33528. unbindAllTextures(): void;
  33529. /**
  33530. * Sets a texture to the according uniform.
  33531. * @param channel The texture channel
  33532. * @param uniform The uniform to set
  33533. * @param texture The texture to apply
  33534. */
  33535. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33536. private _bindSamplerUniformToChannel;
  33537. private _getTextureWrapMode;
  33538. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33539. /**
  33540. * Sets an array of texture to the webGL context
  33541. * @param channel defines the channel where the texture array must be set
  33542. * @param uniform defines the associated uniform location
  33543. * @param textures defines the array of textures to bind
  33544. */
  33545. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33546. /** @hidden */
  33547. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33548. private _setTextureParameterFloat;
  33549. private _setTextureParameterInteger;
  33550. /**
  33551. * Unbind all vertex attributes from the webGL context
  33552. */
  33553. unbindAllAttributes(): void;
  33554. /**
  33555. * 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
  33556. */
  33557. releaseEffects(): void;
  33558. /**
  33559. * Dispose and release all associated resources
  33560. */
  33561. dispose(): void;
  33562. /**
  33563. * Attach a new callback raised when context lost event is fired
  33564. * @param callback defines the callback to call
  33565. */
  33566. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33567. /**
  33568. * Attach a new callback raised when context restored event is fired
  33569. * @param callback defines the callback to call
  33570. */
  33571. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33572. /**
  33573. * Get the current error code of the webGL context
  33574. * @returns the error code
  33575. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33576. */
  33577. getError(): number;
  33578. private _canRenderToFloatFramebuffer;
  33579. private _canRenderToHalfFloatFramebuffer;
  33580. private _canRenderToFramebuffer;
  33581. /** @hidden */
  33582. _getWebGLTextureType(type: number): number;
  33583. /** @hidden */
  33584. _getInternalFormat(format: number): number;
  33585. /** @hidden */
  33586. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33587. /** @hidden */
  33588. _getRGBAMultiSampleBufferFormat(type: number): number;
  33589. /** @hidden */
  33590. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  33591. /**
  33592. * Loads a file from a url
  33593. * @param url url to load
  33594. * @param onSuccess callback called when the file successfully loads
  33595. * @param onProgress callback called while file is loading (if the server supports this mode)
  33596. * @param offlineProvider defines the offline provider for caching
  33597. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33598. * @param onError callback called when the file fails to load
  33599. * @returns a file request object
  33600. * @hidden
  33601. */
  33602. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  33603. /**
  33604. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33605. * @param x defines the x coordinate of the rectangle where pixels must be read
  33606. * @param y defines the y coordinate of the rectangle where pixels must be read
  33607. * @param width defines the width of the rectangle where pixels must be read
  33608. * @param height defines the height of the rectangle where pixels must be read
  33609. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33610. * @returns a Uint8Array containing RGBA colors
  33611. */
  33612. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33613. private static _isSupported;
  33614. /**
  33615. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33616. * @returns true if the engine can be created
  33617. * @ignorenaming
  33618. */
  33619. static isSupported(): boolean;
  33620. /**
  33621. * Find the next highest power of two.
  33622. * @param x Number to start search from.
  33623. * @return Next highest power of two.
  33624. */
  33625. static CeilingPOT(x: number): number;
  33626. /**
  33627. * Find the next lowest power of two.
  33628. * @param x Number to start search from.
  33629. * @return Next lowest power of two.
  33630. */
  33631. static FloorPOT(x: number): number;
  33632. /**
  33633. * Find the nearest power of two.
  33634. * @param x Number to start search from.
  33635. * @return Next nearest power of two.
  33636. */
  33637. static NearestPOT(x: number): number;
  33638. /**
  33639. * Get the closest exponent of two
  33640. * @param value defines the value to approximate
  33641. * @param max defines the maximum value to return
  33642. * @param mode defines how to define the closest value
  33643. * @returns closest exponent of two of the given value
  33644. */
  33645. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33646. /**
  33647. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33648. * @param func - the function to be called
  33649. * @param requester - the object that will request the next frame. Falls back to window.
  33650. * @returns frame number
  33651. */
  33652. static QueueNewFrame(func: () => void, requester?: any): number;
  33653. /**
  33654. * Gets host document
  33655. * @returns the host document object
  33656. */
  33657. getHostDocument(): Nullable<Document>;
  33658. }
  33659. }
  33660. declare module "babylonjs/Maths/sphericalPolynomial" {
  33661. import { Vector3 } from "babylonjs/Maths/math.vector";
  33662. import { Color3 } from "babylonjs/Maths/math.color";
  33663. /**
  33664. * Class representing spherical harmonics coefficients to the 3rd degree
  33665. */
  33666. export class SphericalHarmonics {
  33667. /**
  33668. * Defines whether or not the harmonics have been prescaled for rendering.
  33669. */
  33670. preScaled: boolean;
  33671. /**
  33672. * The l0,0 coefficients of the spherical harmonics
  33673. */
  33674. l00: Vector3;
  33675. /**
  33676. * The l1,-1 coefficients of the spherical harmonics
  33677. */
  33678. l1_1: Vector3;
  33679. /**
  33680. * The l1,0 coefficients of the spherical harmonics
  33681. */
  33682. l10: Vector3;
  33683. /**
  33684. * The l1,1 coefficients of the spherical harmonics
  33685. */
  33686. l11: Vector3;
  33687. /**
  33688. * The l2,-2 coefficients of the spherical harmonics
  33689. */
  33690. l2_2: Vector3;
  33691. /**
  33692. * The l2,-1 coefficients of the spherical harmonics
  33693. */
  33694. l2_1: Vector3;
  33695. /**
  33696. * The l2,0 coefficients of the spherical harmonics
  33697. */
  33698. l20: Vector3;
  33699. /**
  33700. * The l2,1 coefficients of the spherical harmonics
  33701. */
  33702. l21: Vector3;
  33703. /**
  33704. * The l2,2 coefficients of the spherical harmonics
  33705. */
  33706. l22: Vector3;
  33707. /**
  33708. * Adds a light to the spherical harmonics
  33709. * @param direction the direction of the light
  33710. * @param color the color of the light
  33711. * @param deltaSolidAngle the delta solid angle of the light
  33712. */
  33713. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33714. /**
  33715. * Scales the spherical harmonics by the given amount
  33716. * @param scale the amount to scale
  33717. */
  33718. scaleInPlace(scale: number): void;
  33719. /**
  33720. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33721. *
  33722. * ```
  33723. * E_lm = A_l * L_lm
  33724. * ```
  33725. *
  33726. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33727. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33728. * the scaling factors are given in equation 9.
  33729. */
  33730. convertIncidentRadianceToIrradiance(): void;
  33731. /**
  33732. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33733. *
  33734. * ```
  33735. * L = (1/pi) * E * rho
  33736. * ```
  33737. *
  33738. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33739. */
  33740. convertIrradianceToLambertianRadiance(): void;
  33741. /**
  33742. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33743. * required operations at run time.
  33744. *
  33745. * This is simply done by scaling back the SH with Ylm constants parameter.
  33746. * The trigonometric part being applied by the shader at run time.
  33747. */
  33748. preScaleForRendering(): void;
  33749. /**
  33750. * Constructs a spherical harmonics from an array.
  33751. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33752. * @returns the spherical harmonics
  33753. */
  33754. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33755. /**
  33756. * Gets the spherical harmonics from polynomial
  33757. * @param polynomial the spherical polynomial
  33758. * @returns the spherical harmonics
  33759. */
  33760. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33761. }
  33762. /**
  33763. * Class representing spherical polynomial coefficients to the 3rd degree
  33764. */
  33765. export class SphericalPolynomial {
  33766. private _harmonics;
  33767. /**
  33768. * The spherical harmonics used to create the polynomials.
  33769. */
  33770. get preScaledHarmonics(): SphericalHarmonics;
  33771. /**
  33772. * The x coefficients of the spherical polynomial
  33773. */
  33774. x: Vector3;
  33775. /**
  33776. * The y coefficients of the spherical polynomial
  33777. */
  33778. y: Vector3;
  33779. /**
  33780. * The z coefficients of the spherical polynomial
  33781. */
  33782. z: Vector3;
  33783. /**
  33784. * The xx coefficients of the spherical polynomial
  33785. */
  33786. xx: Vector3;
  33787. /**
  33788. * The yy coefficients of the spherical polynomial
  33789. */
  33790. yy: Vector3;
  33791. /**
  33792. * The zz coefficients of the spherical polynomial
  33793. */
  33794. zz: Vector3;
  33795. /**
  33796. * The xy coefficients of the spherical polynomial
  33797. */
  33798. xy: Vector3;
  33799. /**
  33800. * The yz coefficients of the spherical polynomial
  33801. */
  33802. yz: Vector3;
  33803. /**
  33804. * The zx coefficients of the spherical polynomial
  33805. */
  33806. zx: Vector3;
  33807. /**
  33808. * Adds an ambient color to the spherical polynomial
  33809. * @param color the color to add
  33810. */
  33811. addAmbient(color: Color3): void;
  33812. /**
  33813. * Scales the spherical polynomial by the given amount
  33814. * @param scale the amount to scale
  33815. */
  33816. scaleInPlace(scale: number): void;
  33817. /**
  33818. * Gets the spherical polynomial from harmonics
  33819. * @param harmonics the spherical harmonics
  33820. * @returns the spherical polynomial
  33821. */
  33822. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33823. /**
  33824. * Constructs a spherical polynomial from an array.
  33825. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33826. * @returns the spherical polynomial
  33827. */
  33828. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33829. }
  33830. }
  33831. declare module "babylonjs/Materials/Textures/internalTexture" {
  33832. import { Observable } from "babylonjs/Misc/observable";
  33833. import { Nullable, int } from "babylonjs/types";
  33834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33835. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33836. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33837. /**
  33838. * Defines the source of the internal texture
  33839. */
  33840. export enum InternalTextureSource {
  33841. /**
  33842. * The source of the texture data is unknown
  33843. */
  33844. Unknown = 0,
  33845. /**
  33846. * Texture data comes from an URL
  33847. */
  33848. Url = 1,
  33849. /**
  33850. * Texture data is only used for temporary storage
  33851. */
  33852. Temp = 2,
  33853. /**
  33854. * Texture data comes from raw data (ArrayBuffer)
  33855. */
  33856. Raw = 3,
  33857. /**
  33858. * Texture content is dynamic (video or dynamic texture)
  33859. */
  33860. Dynamic = 4,
  33861. /**
  33862. * Texture content is generated by rendering to it
  33863. */
  33864. RenderTarget = 5,
  33865. /**
  33866. * Texture content is part of a multi render target process
  33867. */
  33868. MultiRenderTarget = 6,
  33869. /**
  33870. * Texture data comes from a cube data file
  33871. */
  33872. Cube = 7,
  33873. /**
  33874. * Texture data comes from a raw cube data
  33875. */
  33876. CubeRaw = 8,
  33877. /**
  33878. * Texture data come from a prefiltered cube data file
  33879. */
  33880. CubePrefiltered = 9,
  33881. /**
  33882. * Texture content is raw 3D data
  33883. */
  33884. Raw3D = 10,
  33885. /**
  33886. * Texture content is raw 2D array data
  33887. */
  33888. Raw2DArray = 11,
  33889. /**
  33890. * Texture content is a depth texture
  33891. */
  33892. Depth = 12,
  33893. /**
  33894. * Texture data comes from a raw cube data encoded with RGBD
  33895. */
  33896. CubeRawRGBD = 13
  33897. }
  33898. /**
  33899. * Class used to store data associated with WebGL texture data for the engine
  33900. * This class should not be used directly
  33901. */
  33902. export class InternalTexture {
  33903. /** @hidden */
  33904. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33905. /**
  33906. * Defines if the texture is ready
  33907. */
  33908. isReady: boolean;
  33909. /**
  33910. * Defines if the texture is a cube texture
  33911. */
  33912. isCube: boolean;
  33913. /**
  33914. * Defines if the texture contains 3D data
  33915. */
  33916. is3D: boolean;
  33917. /**
  33918. * Defines if the texture contains 2D array data
  33919. */
  33920. is2DArray: boolean;
  33921. /**
  33922. * Defines if the texture contains multiview data
  33923. */
  33924. isMultiview: boolean;
  33925. /**
  33926. * Gets the URL used to load this texture
  33927. */
  33928. url: string;
  33929. /**
  33930. * Gets the sampling mode of the texture
  33931. */
  33932. samplingMode: number;
  33933. /**
  33934. * Gets a boolean indicating if the texture needs mipmaps generation
  33935. */
  33936. generateMipMaps: boolean;
  33937. /**
  33938. * Gets the number of samples used by the texture (WebGL2+ only)
  33939. */
  33940. samples: number;
  33941. /**
  33942. * Gets the type of the texture (int, float...)
  33943. */
  33944. type: number;
  33945. /**
  33946. * Gets the format of the texture (RGB, RGBA...)
  33947. */
  33948. format: number;
  33949. /**
  33950. * Observable called when the texture is loaded
  33951. */
  33952. onLoadedObservable: Observable<InternalTexture>;
  33953. /**
  33954. * Gets the width of the texture
  33955. */
  33956. width: number;
  33957. /**
  33958. * Gets the height of the texture
  33959. */
  33960. height: number;
  33961. /**
  33962. * Gets the depth of the texture
  33963. */
  33964. depth: number;
  33965. /**
  33966. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33967. */
  33968. baseWidth: number;
  33969. /**
  33970. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33971. */
  33972. baseHeight: number;
  33973. /**
  33974. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33975. */
  33976. baseDepth: number;
  33977. /**
  33978. * Gets a boolean indicating if the texture is inverted on Y axis
  33979. */
  33980. invertY: boolean;
  33981. /** @hidden */
  33982. _invertVScale: boolean;
  33983. /** @hidden */
  33984. _associatedChannel: number;
  33985. /** @hidden */
  33986. _source: InternalTextureSource;
  33987. /** @hidden */
  33988. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33989. /** @hidden */
  33990. _bufferView: Nullable<ArrayBufferView>;
  33991. /** @hidden */
  33992. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33993. /** @hidden */
  33994. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33995. /** @hidden */
  33996. _size: number;
  33997. /** @hidden */
  33998. _extension: string;
  33999. /** @hidden */
  34000. _files: Nullable<string[]>;
  34001. /** @hidden */
  34002. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34003. /** @hidden */
  34004. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34005. /** @hidden */
  34006. _framebuffer: Nullable<WebGLFramebuffer>;
  34007. /** @hidden */
  34008. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  34009. /** @hidden */
  34010. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  34011. /** @hidden */
  34012. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  34013. /** @hidden */
  34014. _attachments: Nullable<number[]>;
  34015. /** @hidden */
  34016. _cachedCoordinatesMode: Nullable<number>;
  34017. /** @hidden */
  34018. _cachedWrapU: Nullable<number>;
  34019. /** @hidden */
  34020. _cachedWrapV: Nullable<number>;
  34021. /** @hidden */
  34022. _cachedWrapR: Nullable<number>;
  34023. /** @hidden */
  34024. _cachedAnisotropicFilteringLevel: Nullable<number>;
  34025. /** @hidden */
  34026. _isDisabled: boolean;
  34027. /** @hidden */
  34028. _compression: Nullable<string>;
  34029. /** @hidden */
  34030. _generateStencilBuffer: boolean;
  34031. /** @hidden */
  34032. _generateDepthBuffer: boolean;
  34033. /** @hidden */
  34034. _comparisonFunction: number;
  34035. /** @hidden */
  34036. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  34037. /** @hidden */
  34038. _lodGenerationScale: number;
  34039. /** @hidden */
  34040. _lodGenerationOffset: number;
  34041. /** @hidden */
  34042. _depthStencilTexture: Nullable<InternalTexture>;
  34043. /** @hidden */
  34044. _colorTextureArray: Nullable<WebGLTexture>;
  34045. /** @hidden */
  34046. _depthStencilTextureArray: Nullable<WebGLTexture>;
  34047. /** @hidden */
  34048. _lodTextureHigh: Nullable<BaseTexture>;
  34049. /** @hidden */
  34050. _lodTextureMid: Nullable<BaseTexture>;
  34051. /** @hidden */
  34052. _lodTextureLow: Nullable<BaseTexture>;
  34053. /** @hidden */
  34054. _isRGBD: boolean;
  34055. /** @hidden */
  34056. _linearSpecularLOD: boolean;
  34057. /** @hidden */
  34058. _irradianceTexture: Nullable<BaseTexture>;
  34059. /** @hidden */
  34060. _webGLTexture: Nullable<WebGLTexture>;
  34061. /** @hidden */
  34062. _references: number;
  34063. private _engine;
  34064. /**
  34065. * Gets the Engine the texture belongs to.
  34066. * @returns The babylon engine
  34067. */
  34068. getEngine(): ThinEngine;
  34069. /**
  34070. * Gets the data source type of the texture
  34071. */
  34072. get source(): InternalTextureSource;
  34073. /**
  34074. * Creates a new InternalTexture
  34075. * @param engine defines the engine to use
  34076. * @param source defines the type of data that will be used
  34077. * @param delayAllocation if the texture allocation should be delayed (default: false)
  34078. */
  34079. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  34080. /**
  34081. * Increments the number of references (ie. the number of Texture that point to it)
  34082. */
  34083. incrementReferences(): void;
  34084. /**
  34085. * Change the size of the texture (not the size of the content)
  34086. * @param width defines the new width
  34087. * @param height defines the new height
  34088. * @param depth defines the new depth (1 by default)
  34089. */
  34090. updateSize(width: int, height: int, depth?: int): void;
  34091. /** @hidden */
  34092. _rebuild(): void;
  34093. /** @hidden */
  34094. _swapAndDie(target: InternalTexture): void;
  34095. /**
  34096. * Dispose the current allocated resources
  34097. */
  34098. dispose(): void;
  34099. }
  34100. }
  34101. declare module "babylonjs/Audio/analyser" {
  34102. import { Scene } from "babylonjs/scene";
  34103. /**
  34104. * Class used to work with sound analyzer using fast fourier transform (FFT)
  34105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34106. */
  34107. export class Analyser {
  34108. /**
  34109. * Gets or sets the smoothing
  34110. * @ignorenaming
  34111. */
  34112. SMOOTHING: number;
  34113. /**
  34114. * Gets or sets the FFT table size
  34115. * @ignorenaming
  34116. */
  34117. FFT_SIZE: number;
  34118. /**
  34119. * Gets or sets the bar graph amplitude
  34120. * @ignorenaming
  34121. */
  34122. BARGRAPHAMPLITUDE: number;
  34123. /**
  34124. * Gets or sets the position of the debug canvas
  34125. * @ignorenaming
  34126. */
  34127. DEBUGCANVASPOS: {
  34128. x: number;
  34129. y: number;
  34130. };
  34131. /**
  34132. * Gets or sets the debug canvas size
  34133. * @ignorenaming
  34134. */
  34135. DEBUGCANVASSIZE: {
  34136. width: number;
  34137. height: number;
  34138. };
  34139. private _byteFreqs;
  34140. private _byteTime;
  34141. private _floatFreqs;
  34142. private _webAudioAnalyser;
  34143. private _debugCanvas;
  34144. private _debugCanvasContext;
  34145. private _scene;
  34146. private _registerFunc;
  34147. private _audioEngine;
  34148. /**
  34149. * Creates a new analyser
  34150. * @param scene defines hosting scene
  34151. */
  34152. constructor(scene: Scene);
  34153. /**
  34154. * Get the number of data values you will have to play with for the visualization
  34155. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  34156. * @returns a number
  34157. */
  34158. getFrequencyBinCount(): number;
  34159. /**
  34160. * Gets the current frequency data as a byte array
  34161. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34162. * @returns a Uint8Array
  34163. */
  34164. getByteFrequencyData(): Uint8Array;
  34165. /**
  34166. * Gets the current waveform as a byte array
  34167. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34168. * @returns a Uint8Array
  34169. */
  34170. getByteTimeDomainData(): Uint8Array;
  34171. /**
  34172. * Gets the current frequency data as a float array
  34173. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34174. * @returns a Float32Array
  34175. */
  34176. getFloatFrequencyData(): Float32Array;
  34177. /**
  34178. * Renders the debug canvas
  34179. */
  34180. drawDebugCanvas(): void;
  34181. /**
  34182. * Stops rendering the debug canvas and removes it
  34183. */
  34184. stopDebugCanvas(): void;
  34185. /**
  34186. * Connects two audio nodes
  34187. * @param inputAudioNode defines first node to connect
  34188. * @param outputAudioNode defines second node to connect
  34189. */
  34190. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34191. /**
  34192. * Releases all associated resources
  34193. */
  34194. dispose(): void;
  34195. }
  34196. }
  34197. declare module "babylonjs/Audio/audioEngine" {
  34198. import { IDisposable } from "babylonjs/scene";
  34199. import { Analyser } from "babylonjs/Audio/analyser";
  34200. import { Nullable } from "babylonjs/types";
  34201. import { Observable } from "babylonjs/Misc/observable";
  34202. /**
  34203. * This represents an audio engine and it is responsible
  34204. * to play, synchronize and analyse sounds throughout the application.
  34205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34206. */
  34207. export interface IAudioEngine extends IDisposable {
  34208. /**
  34209. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34210. */
  34211. readonly canUseWebAudio: boolean;
  34212. /**
  34213. * Gets the current AudioContext if available.
  34214. */
  34215. readonly audioContext: Nullable<AudioContext>;
  34216. /**
  34217. * The master gain node defines the global audio volume of your audio engine.
  34218. */
  34219. readonly masterGain: GainNode;
  34220. /**
  34221. * Gets whether or not mp3 are supported by your browser.
  34222. */
  34223. readonly isMP3supported: boolean;
  34224. /**
  34225. * Gets whether or not ogg are supported by your browser.
  34226. */
  34227. readonly isOGGsupported: boolean;
  34228. /**
  34229. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34230. * @ignoreNaming
  34231. */
  34232. WarnedWebAudioUnsupported: boolean;
  34233. /**
  34234. * Defines if the audio engine relies on a custom unlocked button.
  34235. * In this case, the embedded button will not be displayed.
  34236. */
  34237. useCustomUnlockedButton: boolean;
  34238. /**
  34239. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34240. */
  34241. readonly unlocked: boolean;
  34242. /**
  34243. * Event raised when audio has been unlocked on the browser.
  34244. */
  34245. onAudioUnlockedObservable: Observable<AudioEngine>;
  34246. /**
  34247. * Event raised when audio has been locked on the browser.
  34248. */
  34249. onAudioLockedObservable: Observable<AudioEngine>;
  34250. /**
  34251. * Flags the audio engine in Locked state.
  34252. * This happens due to new browser policies preventing audio to autoplay.
  34253. */
  34254. lock(): void;
  34255. /**
  34256. * Unlocks the audio engine once a user action has been done on the dom.
  34257. * This is helpful to resume play once browser policies have been satisfied.
  34258. */
  34259. unlock(): void;
  34260. /**
  34261. * Gets the global volume sets on the master gain.
  34262. * @returns the global volume if set or -1 otherwise
  34263. */
  34264. getGlobalVolume(): number;
  34265. /**
  34266. * Sets the global volume of your experience (sets on the master gain).
  34267. * @param newVolume Defines the new global volume of the application
  34268. */
  34269. setGlobalVolume(newVolume: number): void;
  34270. /**
  34271. * Connect the audio engine to an audio analyser allowing some amazing
  34272. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34274. * @param analyser The analyser to connect to the engine
  34275. */
  34276. connectToAnalyser(analyser: Analyser): void;
  34277. }
  34278. /**
  34279. * This represents the default audio engine used in babylon.
  34280. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34282. */
  34283. export class AudioEngine implements IAudioEngine {
  34284. private _audioContext;
  34285. private _audioContextInitialized;
  34286. private _muteButton;
  34287. private _hostElement;
  34288. /**
  34289. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34290. */
  34291. canUseWebAudio: boolean;
  34292. /**
  34293. * The master gain node defines the global audio volume of your audio engine.
  34294. */
  34295. masterGain: GainNode;
  34296. /**
  34297. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34298. * @ignoreNaming
  34299. */
  34300. WarnedWebAudioUnsupported: boolean;
  34301. /**
  34302. * Gets whether or not mp3 are supported by your browser.
  34303. */
  34304. isMP3supported: boolean;
  34305. /**
  34306. * Gets whether or not ogg are supported by your browser.
  34307. */
  34308. isOGGsupported: boolean;
  34309. /**
  34310. * Gets whether audio has been unlocked on the device.
  34311. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34312. * a user interaction has happened.
  34313. */
  34314. unlocked: boolean;
  34315. /**
  34316. * Defines if the audio engine relies on a custom unlocked button.
  34317. * In this case, the embedded button will not be displayed.
  34318. */
  34319. useCustomUnlockedButton: boolean;
  34320. /**
  34321. * Event raised when audio has been unlocked on the browser.
  34322. */
  34323. onAudioUnlockedObservable: Observable<AudioEngine>;
  34324. /**
  34325. * Event raised when audio has been locked on the browser.
  34326. */
  34327. onAudioLockedObservable: Observable<AudioEngine>;
  34328. /**
  34329. * Gets the current AudioContext if available.
  34330. */
  34331. get audioContext(): Nullable<AudioContext>;
  34332. private _connectedAnalyser;
  34333. /**
  34334. * Instantiates a new audio engine.
  34335. *
  34336. * There should be only one per page as some browsers restrict the number
  34337. * of audio contexts you can create.
  34338. * @param hostElement defines the host element where to display the mute icon if necessary
  34339. */
  34340. constructor(hostElement?: Nullable<HTMLElement>);
  34341. /**
  34342. * Flags the audio engine in Locked state.
  34343. * This happens due to new browser policies preventing audio to autoplay.
  34344. */
  34345. lock(): void;
  34346. /**
  34347. * Unlocks the audio engine once a user action has been done on the dom.
  34348. * This is helpful to resume play once browser policies have been satisfied.
  34349. */
  34350. unlock(): void;
  34351. private _resumeAudioContext;
  34352. private _initializeAudioContext;
  34353. private _tryToRun;
  34354. private _triggerRunningState;
  34355. private _triggerSuspendedState;
  34356. private _displayMuteButton;
  34357. private _moveButtonToTopLeft;
  34358. private _onResize;
  34359. private _hideMuteButton;
  34360. /**
  34361. * Destroy and release the resources associated with the audio ccontext.
  34362. */
  34363. dispose(): void;
  34364. /**
  34365. * Gets the global volume sets on the master gain.
  34366. * @returns the global volume if set or -1 otherwise
  34367. */
  34368. getGlobalVolume(): number;
  34369. /**
  34370. * Sets the global volume of your experience (sets on the master gain).
  34371. * @param newVolume Defines the new global volume of the application
  34372. */
  34373. setGlobalVolume(newVolume: number): void;
  34374. /**
  34375. * Connect the audio engine to an audio analyser allowing some amazing
  34376. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34378. * @param analyser The analyser to connect to the engine
  34379. */
  34380. connectToAnalyser(analyser: Analyser): void;
  34381. }
  34382. }
  34383. declare module "babylonjs/Loading/loadingScreen" {
  34384. /**
  34385. * Interface used to present a loading screen while loading a scene
  34386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34387. */
  34388. export interface ILoadingScreen {
  34389. /**
  34390. * Function called to display the loading screen
  34391. */
  34392. displayLoadingUI: () => void;
  34393. /**
  34394. * Function called to hide the loading screen
  34395. */
  34396. hideLoadingUI: () => void;
  34397. /**
  34398. * Gets or sets the color to use for the background
  34399. */
  34400. loadingUIBackgroundColor: string;
  34401. /**
  34402. * Gets or sets the text to display while loading
  34403. */
  34404. loadingUIText: string;
  34405. }
  34406. /**
  34407. * Class used for the default loading screen
  34408. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34409. */
  34410. export class DefaultLoadingScreen implements ILoadingScreen {
  34411. private _renderingCanvas;
  34412. private _loadingText;
  34413. private _loadingDivBackgroundColor;
  34414. private _loadingDiv;
  34415. private _loadingTextDiv;
  34416. /** Gets or sets the logo url to use for the default loading screen */
  34417. static DefaultLogoUrl: string;
  34418. /** Gets or sets the spinner url to use for the default loading screen */
  34419. static DefaultSpinnerUrl: string;
  34420. /**
  34421. * Creates a new default loading screen
  34422. * @param _renderingCanvas defines the canvas used to render the scene
  34423. * @param _loadingText defines the default text to display
  34424. * @param _loadingDivBackgroundColor defines the default background color
  34425. */
  34426. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34427. /**
  34428. * Function called to display the loading screen
  34429. */
  34430. displayLoadingUI(): void;
  34431. /**
  34432. * Function called to hide the loading screen
  34433. */
  34434. hideLoadingUI(): void;
  34435. /**
  34436. * Gets or sets the text to display while loading
  34437. */
  34438. set loadingUIText(text: string);
  34439. get loadingUIText(): string;
  34440. /**
  34441. * Gets or sets the color to use for the background
  34442. */
  34443. get loadingUIBackgroundColor(): string;
  34444. set loadingUIBackgroundColor(color: string);
  34445. private _resizeLoadingUI;
  34446. }
  34447. }
  34448. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34449. /**
  34450. * Interface for any object that can request an animation frame
  34451. */
  34452. export interface ICustomAnimationFrameRequester {
  34453. /**
  34454. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34455. */
  34456. renderFunction?: Function;
  34457. /**
  34458. * Called to request the next frame to render to
  34459. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34460. */
  34461. requestAnimationFrame: Function;
  34462. /**
  34463. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34464. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34465. */
  34466. requestID?: number;
  34467. }
  34468. }
  34469. declare module "babylonjs/Misc/performanceMonitor" {
  34470. /**
  34471. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34472. */
  34473. export class PerformanceMonitor {
  34474. private _enabled;
  34475. private _rollingFrameTime;
  34476. private _lastFrameTimeMs;
  34477. /**
  34478. * constructor
  34479. * @param frameSampleSize The number of samples required to saturate the sliding window
  34480. */
  34481. constructor(frameSampleSize?: number);
  34482. /**
  34483. * Samples current frame
  34484. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34485. */
  34486. sampleFrame(timeMs?: number): void;
  34487. /**
  34488. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34489. */
  34490. get averageFrameTime(): number;
  34491. /**
  34492. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34493. */
  34494. get averageFrameTimeVariance(): number;
  34495. /**
  34496. * Returns the frame time of the most recent frame
  34497. */
  34498. get instantaneousFrameTime(): number;
  34499. /**
  34500. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34501. */
  34502. get averageFPS(): number;
  34503. /**
  34504. * Returns the average framerate in frames per second using the most recent frame time
  34505. */
  34506. get instantaneousFPS(): number;
  34507. /**
  34508. * Returns true if enough samples have been taken to completely fill the sliding window
  34509. */
  34510. get isSaturated(): boolean;
  34511. /**
  34512. * Enables contributions to the sliding window sample set
  34513. */
  34514. enable(): void;
  34515. /**
  34516. * Disables contributions to the sliding window sample set
  34517. * Samples will not be interpolated over the disabled period
  34518. */
  34519. disable(): void;
  34520. /**
  34521. * Returns true if sampling is enabled
  34522. */
  34523. get isEnabled(): boolean;
  34524. /**
  34525. * Resets performance monitor
  34526. */
  34527. reset(): void;
  34528. }
  34529. /**
  34530. * RollingAverage
  34531. *
  34532. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34533. */
  34534. export class RollingAverage {
  34535. /**
  34536. * Current average
  34537. */
  34538. average: number;
  34539. /**
  34540. * Current variance
  34541. */
  34542. variance: number;
  34543. protected _samples: Array<number>;
  34544. protected _sampleCount: number;
  34545. protected _pos: number;
  34546. protected _m2: number;
  34547. /**
  34548. * constructor
  34549. * @param length The number of samples required to saturate the sliding window
  34550. */
  34551. constructor(length: number);
  34552. /**
  34553. * Adds a sample to the sample set
  34554. * @param v The sample value
  34555. */
  34556. add(v: number): void;
  34557. /**
  34558. * Returns previously added values or null if outside of history or outside the sliding window domain
  34559. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34560. * @return Value previously recorded with add() or null if outside of range
  34561. */
  34562. history(i: number): number;
  34563. /**
  34564. * Returns true if enough samples have been taken to completely fill the sliding window
  34565. * @return true if sample-set saturated
  34566. */
  34567. isSaturated(): boolean;
  34568. /**
  34569. * Resets the rolling average (equivalent to 0 samples taken so far)
  34570. */
  34571. reset(): void;
  34572. /**
  34573. * Wraps a value around the sample range boundaries
  34574. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34575. * @return Wrapped position in sample range
  34576. */
  34577. protected _wrapPosition(i: number): number;
  34578. }
  34579. }
  34580. declare module "babylonjs/Misc/perfCounter" {
  34581. /**
  34582. * This class is used to track a performance counter which is number based.
  34583. * The user has access to many properties which give statistics of different nature.
  34584. *
  34585. * The implementer can track two kinds of Performance Counter: time and count.
  34586. * 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.
  34587. * 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.
  34588. */
  34589. export class PerfCounter {
  34590. /**
  34591. * Gets or sets a global boolean to turn on and off all the counters
  34592. */
  34593. static Enabled: boolean;
  34594. /**
  34595. * Returns the smallest value ever
  34596. */
  34597. get min(): number;
  34598. /**
  34599. * Returns the biggest value ever
  34600. */
  34601. get max(): number;
  34602. /**
  34603. * Returns the average value since the performance counter is running
  34604. */
  34605. get average(): number;
  34606. /**
  34607. * Returns the average value of the last second the counter was monitored
  34608. */
  34609. get lastSecAverage(): number;
  34610. /**
  34611. * Returns the current value
  34612. */
  34613. get current(): number;
  34614. /**
  34615. * Gets the accumulated total
  34616. */
  34617. get total(): number;
  34618. /**
  34619. * Gets the total value count
  34620. */
  34621. get count(): number;
  34622. /**
  34623. * Creates a new counter
  34624. */
  34625. constructor();
  34626. /**
  34627. * Call this method to start monitoring a new frame.
  34628. * 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.
  34629. */
  34630. fetchNewFrame(): void;
  34631. /**
  34632. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34633. * @param newCount the count value to add to the monitored count
  34634. * @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.
  34635. */
  34636. addCount(newCount: number, fetchResult: boolean): void;
  34637. /**
  34638. * Start monitoring this performance counter
  34639. */
  34640. beginMonitoring(): void;
  34641. /**
  34642. * Compute the time lapsed since the previous beginMonitoring() call.
  34643. * @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
  34644. */
  34645. endMonitoring(newFrame?: boolean): void;
  34646. private _fetchResult;
  34647. private _startMonitoringTime;
  34648. private _min;
  34649. private _max;
  34650. private _average;
  34651. private _current;
  34652. private _totalValueCount;
  34653. private _totalAccumulated;
  34654. private _lastSecAverage;
  34655. private _lastSecAccumulated;
  34656. private _lastSecTime;
  34657. private _lastSecValueCount;
  34658. }
  34659. }
  34660. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34661. module "babylonjs/Engines/thinEngine" {
  34662. interface ThinEngine {
  34663. /**
  34664. * Sets alpha constants used by some alpha blending modes
  34665. * @param r defines the red component
  34666. * @param g defines the green component
  34667. * @param b defines the blue component
  34668. * @param a defines the alpha component
  34669. */
  34670. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34671. /**
  34672. * Sets the current alpha mode
  34673. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34674. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34675. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34676. */
  34677. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34678. /**
  34679. * Gets the current alpha mode
  34680. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34681. * @returns the current alpha mode
  34682. */
  34683. getAlphaMode(): number;
  34684. /**
  34685. * Sets the current alpha equation
  34686. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34687. */
  34688. setAlphaEquation(equation: number): void;
  34689. /**
  34690. * Gets the current alpha equation.
  34691. * @returns the current alpha equation
  34692. */
  34693. getAlphaEquation(): number;
  34694. }
  34695. }
  34696. }
  34697. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  34698. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34699. import { Nullable } from "babylonjs/types";
  34700. module "babylonjs/Engines/thinEngine" {
  34701. interface ThinEngine {
  34702. /** @hidden */
  34703. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34704. }
  34705. }
  34706. }
  34707. declare module "babylonjs/Engines/engine" {
  34708. import { Observable } from "babylonjs/Misc/observable";
  34709. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34710. import { Scene } from "babylonjs/scene";
  34711. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34712. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34713. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34714. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34715. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34716. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34717. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34718. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34719. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34720. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34721. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34722. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34723. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34724. import "babylonjs/Engines/Extensions/engine.alpha";
  34725. import "babylonjs/Engines/Extensions/engine.readTexture";
  34726. import { Material } from "babylonjs/Materials/material";
  34727. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34728. /**
  34729. * Defines the interface used by display changed events
  34730. */
  34731. export interface IDisplayChangedEventArgs {
  34732. /** Gets the vrDisplay object (if any) */
  34733. vrDisplay: Nullable<any>;
  34734. /** Gets a boolean indicating if webVR is supported */
  34735. vrSupported: boolean;
  34736. }
  34737. /**
  34738. * Defines the interface used by objects containing a viewport (like a camera)
  34739. */
  34740. interface IViewportOwnerLike {
  34741. /**
  34742. * Gets or sets the viewport
  34743. */
  34744. viewport: IViewportLike;
  34745. }
  34746. /**
  34747. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34748. */
  34749. export class Engine extends ThinEngine {
  34750. /** Defines that alpha blending is disabled */
  34751. static readonly ALPHA_DISABLE: number;
  34752. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34753. static readonly ALPHA_ADD: number;
  34754. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34755. static readonly ALPHA_COMBINE: number;
  34756. /** Defines that alpha blending to DEST - SRC * DEST */
  34757. static readonly ALPHA_SUBTRACT: number;
  34758. /** Defines that alpha blending to SRC * DEST */
  34759. static readonly ALPHA_MULTIPLY: number;
  34760. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34761. static readonly ALPHA_MAXIMIZED: number;
  34762. /** Defines that alpha blending to SRC + DEST */
  34763. static readonly ALPHA_ONEONE: number;
  34764. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34765. static readonly ALPHA_PREMULTIPLIED: number;
  34766. /**
  34767. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34768. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34769. */
  34770. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34771. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34772. static readonly ALPHA_INTERPOLATE: number;
  34773. /**
  34774. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34775. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34776. */
  34777. static readonly ALPHA_SCREENMODE: number;
  34778. /** Defines that the ressource is not delayed*/
  34779. static readonly DELAYLOADSTATE_NONE: number;
  34780. /** Defines that the ressource was successfully delay loaded */
  34781. static readonly DELAYLOADSTATE_LOADED: number;
  34782. /** Defines that the ressource is currently delay loading */
  34783. static readonly DELAYLOADSTATE_LOADING: number;
  34784. /** Defines that the ressource is delayed and has not started loading */
  34785. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34786. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34787. static readonly NEVER: number;
  34788. /** 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 */
  34789. static readonly ALWAYS: number;
  34790. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34791. static readonly LESS: number;
  34792. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34793. static readonly EQUAL: number;
  34794. /** 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 */
  34795. static readonly LEQUAL: number;
  34796. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34797. static readonly GREATER: number;
  34798. /** 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 */
  34799. static readonly GEQUAL: number;
  34800. /** 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 */
  34801. static readonly NOTEQUAL: number;
  34802. /** Passed to stencilOperation to specify that stencil value must be kept */
  34803. static readonly KEEP: number;
  34804. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34805. static readonly REPLACE: number;
  34806. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34807. static readonly INCR: number;
  34808. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34809. static readonly DECR: number;
  34810. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34811. static readonly INVERT: number;
  34812. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34813. static readonly INCR_WRAP: number;
  34814. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34815. static readonly DECR_WRAP: number;
  34816. /** Texture is not repeating outside of 0..1 UVs */
  34817. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34818. /** Texture is repeating outside of 0..1 UVs */
  34819. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34820. /** Texture is repeating and mirrored */
  34821. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34822. /** ALPHA */
  34823. static readonly TEXTUREFORMAT_ALPHA: number;
  34824. /** LUMINANCE */
  34825. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34826. /** LUMINANCE_ALPHA */
  34827. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34828. /** RGB */
  34829. static readonly TEXTUREFORMAT_RGB: number;
  34830. /** RGBA */
  34831. static readonly TEXTUREFORMAT_RGBA: number;
  34832. /** RED */
  34833. static readonly TEXTUREFORMAT_RED: number;
  34834. /** RED (2nd reference) */
  34835. static readonly TEXTUREFORMAT_R: number;
  34836. /** RG */
  34837. static readonly TEXTUREFORMAT_RG: number;
  34838. /** RED_INTEGER */
  34839. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34840. /** RED_INTEGER (2nd reference) */
  34841. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34842. /** RG_INTEGER */
  34843. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34844. /** RGB_INTEGER */
  34845. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34846. /** RGBA_INTEGER */
  34847. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34848. /** UNSIGNED_BYTE */
  34849. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34850. /** UNSIGNED_BYTE (2nd reference) */
  34851. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34852. /** FLOAT */
  34853. static readonly TEXTURETYPE_FLOAT: number;
  34854. /** HALF_FLOAT */
  34855. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34856. /** BYTE */
  34857. static readonly TEXTURETYPE_BYTE: number;
  34858. /** SHORT */
  34859. static readonly TEXTURETYPE_SHORT: number;
  34860. /** UNSIGNED_SHORT */
  34861. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34862. /** INT */
  34863. static readonly TEXTURETYPE_INT: number;
  34864. /** UNSIGNED_INT */
  34865. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34866. /** UNSIGNED_SHORT_4_4_4_4 */
  34867. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34868. /** UNSIGNED_SHORT_5_5_5_1 */
  34869. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34870. /** UNSIGNED_SHORT_5_6_5 */
  34871. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34872. /** UNSIGNED_INT_2_10_10_10_REV */
  34873. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34874. /** UNSIGNED_INT_24_8 */
  34875. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34876. /** UNSIGNED_INT_10F_11F_11F_REV */
  34877. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34878. /** UNSIGNED_INT_5_9_9_9_REV */
  34879. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34880. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34881. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34882. /** nearest is mag = nearest and min = nearest and mip = linear */
  34883. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34884. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34885. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34886. /** Trilinear is mag = linear and min = linear and mip = linear */
  34887. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34888. /** nearest is mag = nearest and min = nearest and mip = linear */
  34889. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34890. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34891. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34892. /** Trilinear is mag = linear and min = linear and mip = linear */
  34893. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34894. /** mag = nearest and min = nearest and mip = nearest */
  34895. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34896. /** mag = nearest and min = linear and mip = nearest */
  34897. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34898. /** mag = nearest and min = linear and mip = linear */
  34899. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34900. /** mag = nearest and min = linear and mip = none */
  34901. static readonly TEXTURE_NEAREST_LINEAR: number;
  34902. /** mag = nearest and min = nearest and mip = none */
  34903. static readonly TEXTURE_NEAREST_NEAREST: number;
  34904. /** mag = linear and min = nearest and mip = nearest */
  34905. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34906. /** mag = linear and min = nearest and mip = linear */
  34907. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34908. /** mag = linear and min = linear and mip = none */
  34909. static readonly TEXTURE_LINEAR_LINEAR: number;
  34910. /** mag = linear and min = nearest and mip = none */
  34911. static readonly TEXTURE_LINEAR_NEAREST: number;
  34912. /** Explicit coordinates mode */
  34913. static readonly TEXTURE_EXPLICIT_MODE: number;
  34914. /** Spherical coordinates mode */
  34915. static readonly TEXTURE_SPHERICAL_MODE: number;
  34916. /** Planar coordinates mode */
  34917. static readonly TEXTURE_PLANAR_MODE: number;
  34918. /** Cubic coordinates mode */
  34919. static readonly TEXTURE_CUBIC_MODE: number;
  34920. /** Projection coordinates mode */
  34921. static readonly TEXTURE_PROJECTION_MODE: number;
  34922. /** Skybox coordinates mode */
  34923. static readonly TEXTURE_SKYBOX_MODE: number;
  34924. /** Inverse Cubic coordinates mode */
  34925. static readonly TEXTURE_INVCUBIC_MODE: number;
  34926. /** Equirectangular coordinates mode */
  34927. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34928. /** Equirectangular Fixed coordinates mode */
  34929. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34930. /** Equirectangular Fixed Mirrored coordinates mode */
  34931. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34932. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34933. static readonly SCALEMODE_FLOOR: number;
  34934. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34935. static readonly SCALEMODE_NEAREST: number;
  34936. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34937. static readonly SCALEMODE_CEILING: number;
  34938. /**
  34939. * Returns the current npm package of the sdk
  34940. */
  34941. static get NpmPackage(): string;
  34942. /**
  34943. * Returns the current version of the framework
  34944. */
  34945. static get Version(): string;
  34946. /** Gets the list of created engines */
  34947. static get Instances(): Engine[];
  34948. /**
  34949. * Gets the latest created engine
  34950. */
  34951. static get LastCreatedEngine(): Nullable<Engine>;
  34952. /**
  34953. * Gets the latest created scene
  34954. */
  34955. static get LastCreatedScene(): Nullable<Scene>;
  34956. /**
  34957. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34958. * @param flag defines which part of the materials must be marked as dirty
  34959. * @param predicate defines a predicate used to filter which materials should be affected
  34960. */
  34961. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34962. /**
  34963. * Method called to create the default loading screen.
  34964. * This can be overriden in your own app.
  34965. * @param canvas The rendering canvas element
  34966. * @returns The loading screen
  34967. */
  34968. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34969. /**
  34970. * Method called to create the default rescale post process on each engine.
  34971. */
  34972. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34973. /**
  34974. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34975. **/
  34976. enableOfflineSupport: boolean;
  34977. /**
  34978. * 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)
  34979. **/
  34980. disableManifestCheck: boolean;
  34981. /**
  34982. * Gets the list of created scenes
  34983. */
  34984. scenes: Scene[];
  34985. /**
  34986. * Event raised when a new scene is created
  34987. */
  34988. onNewSceneAddedObservable: Observable<Scene>;
  34989. /**
  34990. * Gets the list of created postprocesses
  34991. */
  34992. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34993. /**
  34994. * Gets a boolean indicating if the pointer is currently locked
  34995. */
  34996. isPointerLock: boolean;
  34997. /**
  34998. * Observable event triggered each time the rendering canvas is resized
  34999. */
  35000. onResizeObservable: Observable<Engine>;
  35001. /**
  35002. * Observable event triggered each time the canvas loses focus
  35003. */
  35004. onCanvasBlurObservable: Observable<Engine>;
  35005. /**
  35006. * Observable event triggered each time the canvas gains focus
  35007. */
  35008. onCanvasFocusObservable: Observable<Engine>;
  35009. /**
  35010. * Observable event triggered each time the canvas receives pointerout event
  35011. */
  35012. onCanvasPointerOutObservable: Observable<PointerEvent>;
  35013. /**
  35014. * Observable raised when the engine begins a new frame
  35015. */
  35016. onBeginFrameObservable: Observable<Engine>;
  35017. /**
  35018. * If set, will be used to request the next animation frame for the render loop
  35019. */
  35020. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  35021. /**
  35022. * Observable raised when the engine ends the current frame
  35023. */
  35024. onEndFrameObservable: Observable<Engine>;
  35025. /**
  35026. * Observable raised when the engine is about to compile a shader
  35027. */
  35028. onBeforeShaderCompilationObservable: Observable<Engine>;
  35029. /**
  35030. * Observable raised when the engine has jsut compiled a shader
  35031. */
  35032. onAfterShaderCompilationObservable: Observable<Engine>;
  35033. /**
  35034. * Gets the audio engine
  35035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35036. * @ignorenaming
  35037. */
  35038. static audioEngine: IAudioEngine;
  35039. /**
  35040. * Default AudioEngine factory responsible of creating the Audio Engine.
  35041. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  35042. */
  35043. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  35044. /**
  35045. * Default offline support factory responsible of creating a tool used to store data locally.
  35046. * By default, this will create a Database object if the workload has been embedded.
  35047. */
  35048. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  35049. private _loadingScreen;
  35050. private _pointerLockRequested;
  35051. private _rescalePostProcess;
  35052. private _deterministicLockstep;
  35053. private _lockstepMaxSteps;
  35054. private _timeStep;
  35055. protected get _supportsHardwareTextureRescaling(): boolean;
  35056. private _fps;
  35057. private _deltaTime;
  35058. /** @hidden */
  35059. _drawCalls: PerfCounter;
  35060. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  35061. canvasTabIndex: number;
  35062. /**
  35063. * Turn this value on if you want to pause FPS computation when in background
  35064. */
  35065. disablePerformanceMonitorInBackground: boolean;
  35066. private _performanceMonitor;
  35067. /**
  35068. * Gets the performance monitor attached to this engine
  35069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  35070. */
  35071. get performanceMonitor(): PerformanceMonitor;
  35072. private _onFocus;
  35073. private _onBlur;
  35074. private _onCanvasPointerOut;
  35075. private _onCanvasBlur;
  35076. private _onCanvasFocus;
  35077. private _onFullscreenChange;
  35078. private _onPointerLockChange;
  35079. /**
  35080. * Gets the HTML element used to attach event listeners
  35081. * @returns a HTML element
  35082. */
  35083. getInputElement(): Nullable<HTMLElement>;
  35084. /**
  35085. * Creates a new engine
  35086. * @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
  35087. * @param antialias defines enable antialiasing (default: false)
  35088. * @param options defines further options to be sent to the getContext() function
  35089. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35090. */
  35091. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35092. /**
  35093. * Gets current aspect ratio
  35094. * @param viewportOwner defines the camera to use to get the aspect ratio
  35095. * @param useScreen defines if screen size must be used (or the current render target if any)
  35096. * @returns a number defining the aspect ratio
  35097. */
  35098. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  35099. /**
  35100. * Gets current screen aspect ratio
  35101. * @returns a number defining the aspect ratio
  35102. */
  35103. getScreenAspectRatio(): number;
  35104. /**
  35105. * Gets the client rect of the HTML canvas attached with the current webGL context
  35106. * @returns a client rectanglee
  35107. */
  35108. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  35109. /**
  35110. * Gets the client rect of the HTML element used for events
  35111. * @returns a client rectanglee
  35112. */
  35113. getInputElementClientRect(): Nullable<ClientRect>;
  35114. /**
  35115. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  35116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35117. * @returns true if engine is in deterministic lock step mode
  35118. */
  35119. isDeterministicLockStep(): boolean;
  35120. /**
  35121. * Gets the max steps when engine is running in deterministic lock step
  35122. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35123. * @returns the max steps
  35124. */
  35125. getLockstepMaxSteps(): number;
  35126. /**
  35127. * Returns the time in ms between steps when using deterministic lock step.
  35128. * @returns time step in (ms)
  35129. */
  35130. getTimeStep(): number;
  35131. /**
  35132. * Force the mipmap generation for the given render target texture
  35133. * @param texture defines the render target texture to use
  35134. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  35135. */
  35136. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  35137. /** States */
  35138. /**
  35139. * Set various states to the webGL context
  35140. * @param culling defines backface culling state
  35141. * @param zOffset defines the value to apply to zOffset (0 by default)
  35142. * @param force defines if states must be applied even if cache is up to date
  35143. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  35144. */
  35145. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  35146. /**
  35147. * Set the z offset to apply to current rendering
  35148. * @param value defines the offset to apply
  35149. */
  35150. setZOffset(value: number): void;
  35151. /**
  35152. * Gets the current value of the zOffset
  35153. * @returns the current zOffset state
  35154. */
  35155. getZOffset(): number;
  35156. /**
  35157. * Enable or disable depth buffering
  35158. * @param enable defines the state to set
  35159. */
  35160. setDepthBuffer(enable: boolean): void;
  35161. /**
  35162. * Gets a boolean indicating if depth writing is enabled
  35163. * @returns the current depth writing state
  35164. */
  35165. getDepthWrite(): boolean;
  35166. /**
  35167. * Enable or disable depth writing
  35168. * @param enable defines the state to set
  35169. */
  35170. setDepthWrite(enable: boolean): void;
  35171. /**
  35172. * Gets a boolean indicating if stencil buffer is enabled
  35173. * @returns the current stencil buffer state
  35174. */
  35175. getStencilBuffer(): boolean;
  35176. /**
  35177. * Enable or disable the stencil buffer
  35178. * @param enable defines if the stencil buffer must be enabled or disabled
  35179. */
  35180. setStencilBuffer(enable: boolean): void;
  35181. /**
  35182. * Gets the current stencil mask
  35183. * @returns a number defining the new stencil mask to use
  35184. */
  35185. getStencilMask(): number;
  35186. /**
  35187. * Sets the current stencil mask
  35188. * @param mask defines the new stencil mask to use
  35189. */
  35190. setStencilMask(mask: number): void;
  35191. /**
  35192. * Gets the current stencil function
  35193. * @returns a number defining the stencil function to use
  35194. */
  35195. getStencilFunction(): number;
  35196. /**
  35197. * Gets the current stencil reference value
  35198. * @returns a number defining the stencil reference value to use
  35199. */
  35200. getStencilFunctionReference(): number;
  35201. /**
  35202. * Gets the current stencil mask
  35203. * @returns a number defining the stencil mask to use
  35204. */
  35205. getStencilFunctionMask(): number;
  35206. /**
  35207. * Sets the current stencil function
  35208. * @param stencilFunc defines the new stencil function to use
  35209. */
  35210. setStencilFunction(stencilFunc: number): void;
  35211. /**
  35212. * Sets the current stencil reference
  35213. * @param reference defines the new stencil reference to use
  35214. */
  35215. setStencilFunctionReference(reference: number): void;
  35216. /**
  35217. * Sets the current stencil mask
  35218. * @param mask defines the new stencil mask to use
  35219. */
  35220. setStencilFunctionMask(mask: number): void;
  35221. /**
  35222. * Gets the current stencil operation when stencil fails
  35223. * @returns a number defining stencil operation to use when stencil fails
  35224. */
  35225. getStencilOperationFail(): number;
  35226. /**
  35227. * Gets the current stencil operation when depth fails
  35228. * @returns a number defining stencil operation to use when depth fails
  35229. */
  35230. getStencilOperationDepthFail(): number;
  35231. /**
  35232. * Gets the current stencil operation when stencil passes
  35233. * @returns a number defining stencil operation to use when stencil passes
  35234. */
  35235. getStencilOperationPass(): number;
  35236. /**
  35237. * Sets the stencil operation to use when stencil fails
  35238. * @param operation defines the stencil operation to use when stencil fails
  35239. */
  35240. setStencilOperationFail(operation: number): void;
  35241. /**
  35242. * Sets the stencil operation to use when depth fails
  35243. * @param operation defines the stencil operation to use when depth fails
  35244. */
  35245. setStencilOperationDepthFail(operation: number): void;
  35246. /**
  35247. * Sets the stencil operation to use when stencil passes
  35248. * @param operation defines the stencil operation to use when stencil passes
  35249. */
  35250. setStencilOperationPass(operation: number): void;
  35251. /**
  35252. * Sets a boolean indicating if the dithering state is enabled or disabled
  35253. * @param value defines the dithering state
  35254. */
  35255. setDitheringState(value: boolean): void;
  35256. /**
  35257. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35258. * @param value defines the rasterizer state
  35259. */
  35260. setRasterizerState(value: boolean): void;
  35261. /**
  35262. * Gets the current depth function
  35263. * @returns a number defining the depth function
  35264. */
  35265. getDepthFunction(): Nullable<number>;
  35266. /**
  35267. * Sets the current depth function
  35268. * @param depthFunc defines the function to use
  35269. */
  35270. setDepthFunction(depthFunc: number): void;
  35271. /**
  35272. * Sets the current depth function to GREATER
  35273. */
  35274. setDepthFunctionToGreater(): void;
  35275. /**
  35276. * Sets the current depth function to GEQUAL
  35277. */
  35278. setDepthFunctionToGreaterOrEqual(): void;
  35279. /**
  35280. * Sets the current depth function to LESS
  35281. */
  35282. setDepthFunctionToLess(): void;
  35283. /**
  35284. * Sets the current depth function to LEQUAL
  35285. */
  35286. setDepthFunctionToLessOrEqual(): void;
  35287. private _cachedStencilBuffer;
  35288. private _cachedStencilFunction;
  35289. private _cachedStencilMask;
  35290. private _cachedStencilOperationPass;
  35291. private _cachedStencilOperationFail;
  35292. private _cachedStencilOperationDepthFail;
  35293. private _cachedStencilReference;
  35294. /**
  35295. * Caches the the state of the stencil buffer
  35296. */
  35297. cacheStencilState(): void;
  35298. /**
  35299. * Restores the state of the stencil buffer
  35300. */
  35301. restoreStencilState(): void;
  35302. /**
  35303. * Directly set the WebGL Viewport
  35304. * @param x defines the x coordinate of the viewport (in screen space)
  35305. * @param y defines the y coordinate of the viewport (in screen space)
  35306. * @param width defines the width of the viewport (in screen space)
  35307. * @param height defines the height of the viewport (in screen space)
  35308. * @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
  35309. */
  35310. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35311. /**
  35312. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35313. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35314. * @param y defines the y-coordinate of the corner of the clear rectangle
  35315. * @param width defines the width of the clear rectangle
  35316. * @param height defines the height of the clear rectangle
  35317. * @param clearColor defines the clear color
  35318. */
  35319. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35320. /**
  35321. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35322. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35323. * @param y defines the y-coordinate of the corner of the clear rectangle
  35324. * @param width defines the width of the clear rectangle
  35325. * @param height defines the height of the clear rectangle
  35326. */
  35327. enableScissor(x: number, y: number, width: number, height: number): void;
  35328. /**
  35329. * Disable previously set scissor test rectangle
  35330. */
  35331. disableScissor(): void;
  35332. protected _reportDrawCall(): void;
  35333. /**
  35334. * Initializes a webVR display and starts listening to display change events
  35335. * The onVRDisplayChangedObservable will be notified upon these changes
  35336. * @returns The onVRDisplayChangedObservable
  35337. */
  35338. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35339. /** @hidden */
  35340. _prepareVRComponent(): void;
  35341. /** @hidden */
  35342. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35343. /** @hidden */
  35344. _submitVRFrame(): void;
  35345. /**
  35346. * Call this function to leave webVR mode
  35347. * Will do nothing if webVR is not supported or if there is no webVR device
  35348. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35349. */
  35350. disableVR(): void;
  35351. /**
  35352. * Gets a boolean indicating that the system is in VR mode and is presenting
  35353. * @returns true if VR mode is engaged
  35354. */
  35355. isVRPresenting(): boolean;
  35356. /** @hidden */
  35357. _requestVRFrame(): void;
  35358. /** @hidden */
  35359. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35360. /**
  35361. * Gets the source code of the vertex shader associated with a specific webGL program
  35362. * @param program defines the program to use
  35363. * @returns a string containing the source code of the vertex shader associated with the program
  35364. */
  35365. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35366. /**
  35367. * Gets the source code of the fragment shader associated with a specific webGL program
  35368. * @param program defines the program to use
  35369. * @returns a string containing the source code of the fragment shader associated with the program
  35370. */
  35371. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35372. /**
  35373. * Sets a depth stencil texture from a render target to the according uniform.
  35374. * @param channel The texture channel
  35375. * @param uniform The uniform to set
  35376. * @param texture The render target texture containing the depth stencil texture to apply
  35377. */
  35378. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35379. /**
  35380. * Sets a texture to the webGL context from a postprocess
  35381. * @param channel defines the channel to use
  35382. * @param postProcess defines the source postprocess
  35383. */
  35384. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35385. /**
  35386. * Binds the output of the passed in post process to the texture channel specified
  35387. * @param channel The channel the texture should be bound to
  35388. * @param postProcess The post process which's output should be bound
  35389. */
  35390. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35391. protected _rebuildBuffers(): void;
  35392. /** @hidden */
  35393. _renderFrame(): void;
  35394. _renderLoop(): void;
  35395. /** @hidden */
  35396. _renderViews(): boolean;
  35397. /**
  35398. * Toggle full screen mode
  35399. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35400. */
  35401. switchFullscreen(requestPointerLock: boolean): void;
  35402. /**
  35403. * Enters full screen mode
  35404. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35405. */
  35406. enterFullscreen(requestPointerLock: boolean): void;
  35407. /**
  35408. * Exits full screen mode
  35409. */
  35410. exitFullscreen(): void;
  35411. /**
  35412. * Enters Pointerlock mode
  35413. */
  35414. enterPointerlock(): void;
  35415. /**
  35416. * Exits Pointerlock mode
  35417. */
  35418. exitPointerlock(): void;
  35419. /**
  35420. * Begin a new frame
  35421. */
  35422. beginFrame(): void;
  35423. /**
  35424. * Enf the current frame
  35425. */
  35426. endFrame(): void;
  35427. resize(): void;
  35428. /**
  35429. * Force a specific size of the canvas
  35430. * @param width defines the new canvas' width
  35431. * @param height defines the new canvas' height
  35432. */
  35433. setSize(width: number, height: number): void;
  35434. /**
  35435. * Updates a dynamic vertex buffer.
  35436. * @param vertexBuffer the vertex buffer to update
  35437. * @param data the data used to update the vertex buffer
  35438. * @param byteOffset the byte offset of the data
  35439. * @param byteLength the byte length of the data
  35440. */
  35441. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35442. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35443. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35444. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35445. _releaseTexture(texture: InternalTexture): void;
  35446. /**
  35447. * @hidden
  35448. * Rescales a texture
  35449. * @param source input texutre
  35450. * @param destination destination texture
  35451. * @param scene scene to use to render the resize
  35452. * @param internalFormat format to use when resizing
  35453. * @param onComplete callback to be called when resize has completed
  35454. */
  35455. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35456. /**
  35457. * Gets the current framerate
  35458. * @returns a number representing the framerate
  35459. */
  35460. getFps(): number;
  35461. /**
  35462. * Gets the time spent between current and previous frame
  35463. * @returns a number representing the delta time in ms
  35464. */
  35465. getDeltaTime(): number;
  35466. private _measureFps;
  35467. /** @hidden */
  35468. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35469. /**
  35470. * Update a dynamic index buffer
  35471. * @param indexBuffer defines the target index buffer
  35472. * @param indices defines the data to update
  35473. * @param offset defines the offset in the target index buffer where update should start
  35474. */
  35475. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35476. /**
  35477. * Updates the sample count of a render target texture
  35478. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35479. * @param texture defines the texture to update
  35480. * @param samples defines the sample count to set
  35481. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35482. */
  35483. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35484. /**
  35485. * Updates a depth texture Comparison Mode and Function.
  35486. * If the comparison Function is equal to 0, the mode will be set to none.
  35487. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35488. * @param texture The texture to set the comparison function for
  35489. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35490. */
  35491. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35492. /**
  35493. * Creates a webGL buffer to use with instanciation
  35494. * @param capacity defines the size of the buffer
  35495. * @returns the webGL buffer
  35496. */
  35497. createInstancesBuffer(capacity: number): DataBuffer;
  35498. /**
  35499. * Delete a webGL buffer used with instanciation
  35500. * @param buffer defines the webGL buffer to delete
  35501. */
  35502. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35503. private _clientWaitAsync;
  35504. /** @hidden */
  35505. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35506. dispose(): void;
  35507. private _disableTouchAction;
  35508. /**
  35509. * Display the loading screen
  35510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35511. */
  35512. displayLoadingUI(): void;
  35513. /**
  35514. * Hide the loading screen
  35515. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35516. */
  35517. hideLoadingUI(): void;
  35518. /**
  35519. * Gets the current loading screen object
  35520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35521. */
  35522. get loadingScreen(): ILoadingScreen;
  35523. /**
  35524. * Sets the current loading screen object
  35525. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35526. */
  35527. set loadingScreen(loadingScreen: ILoadingScreen);
  35528. /**
  35529. * Sets the current loading screen text
  35530. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35531. */
  35532. set loadingUIText(text: string);
  35533. /**
  35534. * Sets the current loading screen background color
  35535. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35536. */
  35537. set loadingUIBackgroundColor(color: string);
  35538. /** Pointerlock and fullscreen */
  35539. /**
  35540. * Ask the browser to promote the current element to pointerlock mode
  35541. * @param element defines the DOM element to promote
  35542. */
  35543. static _RequestPointerlock(element: HTMLElement): void;
  35544. /**
  35545. * Asks the browser to exit pointerlock mode
  35546. */
  35547. static _ExitPointerlock(): void;
  35548. /**
  35549. * Ask the browser to promote the current element to fullscreen rendering mode
  35550. * @param element defines the DOM element to promote
  35551. */
  35552. static _RequestFullscreen(element: HTMLElement): void;
  35553. /**
  35554. * Asks the browser to exit fullscreen mode
  35555. */
  35556. static _ExitFullscreen(): void;
  35557. }
  35558. }
  35559. declare module "babylonjs/Engines/engineStore" {
  35560. import { Nullable } from "babylonjs/types";
  35561. import { Engine } from "babylonjs/Engines/engine";
  35562. import { Scene } from "babylonjs/scene";
  35563. /**
  35564. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35565. * during the life time of the application.
  35566. */
  35567. export class EngineStore {
  35568. /** Gets the list of created engines */
  35569. static Instances: import("babylonjs/Engines/engine").Engine[];
  35570. /** @hidden */
  35571. static _LastCreatedScene: Nullable<Scene>;
  35572. /**
  35573. * Gets the latest created engine
  35574. */
  35575. static get LastCreatedEngine(): Nullable<Engine>;
  35576. /**
  35577. * Gets the latest created scene
  35578. */
  35579. static get LastCreatedScene(): Nullable<Scene>;
  35580. /**
  35581. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35582. * @ignorenaming
  35583. */
  35584. static UseFallbackTexture: boolean;
  35585. /**
  35586. * Texture content used if a texture cannot loaded
  35587. * @ignorenaming
  35588. */
  35589. static FallbackTexture: string;
  35590. }
  35591. }
  35592. declare module "babylonjs/Misc/promise" {
  35593. /**
  35594. * Helper class that provides a small promise polyfill
  35595. */
  35596. export class PromisePolyfill {
  35597. /**
  35598. * Static function used to check if the polyfill is required
  35599. * If this is the case then the function will inject the polyfill to window.Promise
  35600. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35601. */
  35602. static Apply(force?: boolean): void;
  35603. }
  35604. }
  35605. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35606. /**
  35607. * Interface for screenshot methods with describe argument called `size` as object with options
  35608. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35609. */
  35610. export interface IScreenshotSize {
  35611. /**
  35612. * number in pixels for canvas height
  35613. */
  35614. height?: number;
  35615. /**
  35616. * multiplier allowing render at a higher or lower resolution
  35617. * If value is defined then height and width will be ignored and taken from camera
  35618. */
  35619. precision?: number;
  35620. /**
  35621. * number in pixels for canvas width
  35622. */
  35623. width?: number;
  35624. }
  35625. }
  35626. declare module "babylonjs/Misc/tools" {
  35627. import { Nullable, float } from "babylonjs/types";
  35628. import { DomManagement } from "babylonjs/Misc/domManagement";
  35629. import { WebRequest } from "babylonjs/Misc/webRequest";
  35630. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35631. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35632. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35633. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35634. import { Camera } from "babylonjs/Cameras/camera";
  35635. import { Engine } from "babylonjs/Engines/engine";
  35636. interface IColor4Like {
  35637. r: float;
  35638. g: float;
  35639. b: float;
  35640. a: float;
  35641. }
  35642. /**
  35643. * Class containing a set of static utilities functions
  35644. */
  35645. export class Tools {
  35646. /**
  35647. * Gets or sets the base URL to use to load assets
  35648. */
  35649. static get BaseUrl(): string;
  35650. static set BaseUrl(value: string);
  35651. /**
  35652. * Enable/Disable Custom HTTP Request Headers globally.
  35653. * default = false
  35654. * @see CustomRequestHeaders
  35655. */
  35656. static UseCustomRequestHeaders: boolean;
  35657. /**
  35658. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35659. * i.e. when loading files, where the server/service expects an Authorization header
  35660. */
  35661. static CustomRequestHeaders: {
  35662. [key: string]: string;
  35663. };
  35664. /**
  35665. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35666. */
  35667. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35668. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35669. /**
  35670. * Default behaviour for cors in the application.
  35671. * It can be a string if the expected behavior is identical in the entire app.
  35672. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35673. */
  35674. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35675. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35676. /**
  35677. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35678. * @ignorenaming
  35679. */
  35680. static get UseFallbackTexture(): boolean;
  35681. static set UseFallbackTexture(value: boolean);
  35682. /**
  35683. * Use this object to register external classes like custom textures or material
  35684. * to allow the laoders to instantiate them
  35685. */
  35686. static get RegisteredExternalClasses(): {
  35687. [key: string]: Object;
  35688. };
  35689. static set RegisteredExternalClasses(classes: {
  35690. [key: string]: Object;
  35691. });
  35692. /**
  35693. * Texture content used if a texture cannot loaded
  35694. * @ignorenaming
  35695. */
  35696. static get fallbackTexture(): string;
  35697. static set fallbackTexture(value: string);
  35698. /**
  35699. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35700. * @param u defines the coordinate on X axis
  35701. * @param v defines the coordinate on Y axis
  35702. * @param width defines the width of the source data
  35703. * @param height defines the height of the source data
  35704. * @param pixels defines the source byte array
  35705. * @param color defines the output color
  35706. */
  35707. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35708. /**
  35709. * Interpolates between a and b via alpha
  35710. * @param a The lower value (returned when alpha = 0)
  35711. * @param b The upper value (returned when alpha = 1)
  35712. * @param alpha The interpolation-factor
  35713. * @return The mixed value
  35714. */
  35715. static Mix(a: number, b: number, alpha: number): number;
  35716. /**
  35717. * Tries to instantiate a new object from a given class name
  35718. * @param className defines the class name to instantiate
  35719. * @returns the new object or null if the system was not able to do the instantiation
  35720. */
  35721. static Instantiate(className: string): any;
  35722. /**
  35723. * Provides a slice function that will work even on IE
  35724. * @param data defines the array to slice
  35725. * @param start defines the start of the data (optional)
  35726. * @param end defines the end of the data (optional)
  35727. * @returns the new sliced array
  35728. */
  35729. static Slice<T>(data: T, start?: number, end?: number): T;
  35730. /**
  35731. * Polyfill for setImmediate
  35732. * @param action defines the action to execute after the current execution block
  35733. */
  35734. static SetImmediate(action: () => void): void;
  35735. /**
  35736. * Function indicating if a number is an exponent of 2
  35737. * @param value defines the value to test
  35738. * @returns true if the value is an exponent of 2
  35739. */
  35740. static IsExponentOfTwo(value: number): boolean;
  35741. private static _tmpFloatArray;
  35742. /**
  35743. * Returns the nearest 32-bit single precision float representation of a Number
  35744. * @param value A Number. If the parameter is of a different type, it will get converted
  35745. * to a number or to NaN if it cannot be converted
  35746. * @returns number
  35747. */
  35748. static FloatRound(value: number): number;
  35749. /**
  35750. * Extracts the filename from a path
  35751. * @param path defines the path to use
  35752. * @returns the filename
  35753. */
  35754. static GetFilename(path: string): string;
  35755. /**
  35756. * Extracts the "folder" part of a path (everything before the filename).
  35757. * @param uri The URI to extract the info from
  35758. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35759. * @returns The "folder" part of the path
  35760. */
  35761. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35762. /**
  35763. * Extracts text content from a DOM element hierarchy
  35764. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35765. */
  35766. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35767. /**
  35768. * Convert an angle in radians to degrees
  35769. * @param angle defines the angle to convert
  35770. * @returns the angle in degrees
  35771. */
  35772. static ToDegrees(angle: number): number;
  35773. /**
  35774. * Convert an angle in degrees to radians
  35775. * @param angle defines the angle to convert
  35776. * @returns the angle in radians
  35777. */
  35778. static ToRadians(angle: number): number;
  35779. /**
  35780. * Returns an array if obj is not an array
  35781. * @param obj defines the object to evaluate as an array
  35782. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35783. * @returns either obj directly if obj is an array or a new array containing obj
  35784. */
  35785. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35786. /**
  35787. * Gets the pointer prefix to use
  35788. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35789. */
  35790. static GetPointerPrefix(): string;
  35791. /**
  35792. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35793. * @param url define the url we are trying
  35794. * @param element define the dom element where to configure the cors policy
  35795. */
  35796. static SetCorsBehavior(url: string | string[], element: {
  35797. crossOrigin: string | null;
  35798. }): void;
  35799. /**
  35800. * Removes unwanted characters from an url
  35801. * @param url defines the url to clean
  35802. * @returns the cleaned url
  35803. */
  35804. static CleanUrl(url: string): string;
  35805. /**
  35806. * Gets or sets a function used to pre-process url before using them to load assets
  35807. */
  35808. static get PreprocessUrl(): (url: string) => string;
  35809. static set PreprocessUrl(processor: (url: string) => string);
  35810. /**
  35811. * Loads an image as an HTMLImageElement.
  35812. * @param input url string, ArrayBuffer, or Blob to load
  35813. * @param onLoad callback called when the image successfully loads
  35814. * @param onError callback called when the image fails to load
  35815. * @param offlineProvider offline provider for caching
  35816. * @param mimeType optional mime type
  35817. * @returns the HTMLImageElement of the loaded image
  35818. */
  35819. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35820. /**
  35821. * Loads a file from a url
  35822. * @param url url string, ArrayBuffer, or Blob to load
  35823. * @param onSuccess callback called when the file successfully loads
  35824. * @param onProgress callback called while file is loading (if the server supports this mode)
  35825. * @param offlineProvider defines the offline provider for caching
  35826. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35827. * @param onError callback called when the file fails to load
  35828. * @returns a file request object
  35829. */
  35830. 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;
  35831. /**
  35832. * Loads a file from a url
  35833. * @param url the file url to load
  35834. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35835. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35836. */
  35837. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35838. /**
  35839. * Load a script (identified by an url). When the url returns, the
  35840. * content of this file is added into a new script element, attached to the DOM (body element)
  35841. * @param scriptUrl defines the url of the script to laod
  35842. * @param onSuccess defines the callback called when the script is loaded
  35843. * @param onError defines the callback to call if an error occurs
  35844. * @param scriptId defines the id of the script element
  35845. */
  35846. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35847. /**
  35848. * Load an asynchronous script (identified by an url). When the url returns, the
  35849. * content of this file is added into a new script element, attached to the DOM (body element)
  35850. * @param scriptUrl defines the url of the script to laod
  35851. * @param scriptId defines the id of the script element
  35852. * @returns a promise request object
  35853. */
  35854. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35855. /**
  35856. * Loads a file from a blob
  35857. * @param fileToLoad defines the blob to use
  35858. * @param callback defines the callback to call when data is loaded
  35859. * @param progressCallback defines the callback to call during loading process
  35860. * @returns a file request object
  35861. */
  35862. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35863. /**
  35864. * Reads a file from a File object
  35865. * @param file defines the file to load
  35866. * @param onSuccess defines the callback to call when data is loaded
  35867. * @param onProgress defines the callback to call during loading process
  35868. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35869. * @param onError defines the callback to call when an error occurs
  35870. * @returns a file request object
  35871. */
  35872. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35873. /**
  35874. * Creates a data url from a given string content
  35875. * @param content defines the content to convert
  35876. * @returns the new data url link
  35877. */
  35878. static FileAsURL(content: string): string;
  35879. /**
  35880. * Format the given number to a specific decimal format
  35881. * @param value defines the number to format
  35882. * @param decimals defines the number of decimals to use
  35883. * @returns the formatted string
  35884. */
  35885. static Format(value: number, decimals?: number): string;
  35886. /**
  35887. * Tries to copy an object by duplicating every property
  35888. * @param source defines the source object
  35889. * @param destination defines the target object
  35890. * @param doNotCopyList defines a list of properties to avoid
  35891. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35892. */
  35893. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35894. /**
  35895. * Gets a boolean indicating if the given object has no own property
  35896. * @param obj defines the object to test
  35897. * @returns true if object has no own property
  35898. */
  35899. static IsEmpty(obj: any): boolean;
  35900. /**
  35901. * Function used to register events at window level
  35902. * @param windowElement defines the Window object to use
  35903. * @param events defines the events to register
  35904. */
  35905. static RegisterTopRootEvents(windowElement: Window, events: {
  35906. name: string;
  35907. handler: Nullable<(e: FocusEvent) => any>;
  35908. }[]): void;
  35909. /**
  35910. * Function used to unregister events from window level
  35911. * @param windowElement defines the Window object to use
  35912. * @param events defines the events to unregister
  35913. */
  35914. static UnregisterTopRootEvents(windowElement: Window, events: {
  35915. name: string;
  35916. handler: Nullable<(e: FocusEvent) => any>;
  35917. }[]): void;
  35918. /**
  35919. * @ignore
  35920. */
  35921. static _ScreenshotCanvas: HTMLCanvasElement;
  35922. /**
  35923. * Dumps the current bound framebuffer
  35924. * @param width defines the rendering width
  35925. * @param height defines the rendering height
  35926. * @param engine defines the hosting engine
  35927. * @param successCallback defines the callback triggered once the data are available
  35928. * @param mimeType defines the mime type of the result
  35929. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35930. */
  35931. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35932. /**
  35933. * Converts the canvas data to blob.
  35934. * This acts as a polyfill for browsers not supporting the to blob function.
  35935. * @param canvas Defines the canvas to extract the data from
  35936. * @param successCallback Defines the callback triggered once the data are available
  35937. * @param mimeType Defines the mime type of the result
  35938. */
  35939. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35940. /**
  35941. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35942. * @param successCallback defines the callback triggered once the data are available
  35943. * @param mimeType defines the mime type of the result
  35944. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35945. */
  35946. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35947. /**
  35948. * Downloads a blob in the browser
  35949. * @param blob defines the blob to download
  35950. * @param fileName defines the name of the downloaded file
  35951. */
  35952. static Download(blob: Blob, fileName: string): void;
  35953. /**
  35954. * Captures a screenshot of the current rendering
  35955. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35956. * @param engine defines the rendering engine
  35957. * @param camera defines the source camera
  35958. * @param size This parameter can be set to a single number or to an object with the
  35959. * following (optional) properties: precision, width, height. If a single number is passed,
  35960. * it will be used for both width and height. If an object is passed, the screenshot size
  35961. * will be derived from the parameters. The precision property is a multiplier allowing
  35962. * rendering at a higher or lower resolution
  35963. * @param successCallback defines the callback receives a single parameter which contains the
  35964. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35965. * src parameter of an <img> to display it
  35966. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35967. * Check your browser for supported MIME types
  35968. */
  35969. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35970. /**
  35971. * Captures a screenshot of the current rendering
  35972. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35973. * @param engine defines the rendering engine
  35974. * @param camera defines the source camera
  35975. * @param size This parameter can be set to a single number or to an object with the
  35976. * following (optional) properties: precision, width, height. If a single number is passed,
  35977. * it will be used for both width and height. If an object is passed, the screenshot size
  35978. * will be derived from the parameters. The precision property is a multiplier allowing
  35979. * rendering at a higher or lower resolution
  35980. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35981. * Check your browser for supported MIME types
  35982. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35983. * to the src parameter of an <img> to display it
  35984. */
  35985. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35986. /**
  35987. * Generates an image screenshot from the specified camera.
  35988. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35989. * @param engine The engine to use for rendering
  35990. * @param camera The camera to use for rendering
  35991. * @param size This parameter can be set to a single number or to an object with the
  35992. * following (optional) properties: precision, width, height. If a single number is passed,
  35993. * it will be used for both width and height. If an object is passed, the screenshot size
  35994. * will be derived from the parameters. The precision property is a multiplier allowing
  35995. * rendering at a higher or lower resolution
  35996. * @param successCallback The callback receives a single parameter which contains the
  35997. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35998. * src parameter of an <img> to display it
  35999. * @param mimeType The MIME type of the screenshot image (default: image/png).
  36000. * Check your browser for supported MIME types
  36001. * @param samples Texture samples (default: 1)
  36002. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  36003. * @param fileName A name for for the downloaded file.
  36004. */
  36005. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  36006. /**
  36007. * Generates an image screenshot from the specified camera.
  36008. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  36009. * @param engine The engine to use for rendering
  36010. * @param camera The camera to use for rendering
  36011. * @param size This parameter can be set to a single number or to an object with the
  36012. * following (optional) properties: precision, width, height. If a single number is passed,
  36013. * it will be used for both width and height. If an object is passed, the screenshot size
  36014. * will be derived from the parameters. The precision property is a multiplier allowing
  36015. * rendering at a higher or lower resolution
  36016. * @param mimeType The MIME type of the screenshot image (default: image/png).
  36017. * Check your browser for supported MIME types
  36018. * @param samples Texture samples (default: 1)
  36019. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  36020. * @param fileName A name for for the downloaded file.
  36021. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  36022. * to the src parameter of an <img> to display it
  36023. */
  36024. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  36025. /**
  36026. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  36027. * Be aware Math.random() could cause collisions, but:
  36028. * "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"
  36029. * @returns a pseudo random id
  36030. */
  36031. static RandomId(): string;
  36032. /**
  36033. * Test if the given uri is a base64 string
  36034. * @param uri The uri to test
  36035. * @return True if the uri is a base64 string or false otherwise
  36036. */
  36037. static IsBase64(uri: string): boolean;
  36038. /**
  36039. * Decode the given base64 uri.
  36040. * @param uri The uri to decode
  36041. * @return The decoded base64 data.
  36042. */
  36043. static DecodeBase64(uri: string): ArrayBuffer;
  36044. /**
  36045. * Gets the absolute url.
  36046. * @param url the input url
  36047. * @return the absolute url
  36048. */
  36049. static GetAbsoluteUrl(url: string): string;
  36050. /**
  36051. * No log
  36052. */
  36053. static readonly NoneLogLevel: number;
  36054. /**
  36055. * Only message logs
  36056. */
  36057. static readonly MessageLogLevel: number;
  36058. /**
  36059. * Only warning logs
  36060. */
  36061. static readonly WarningLogLevel: number;
  36062. /**
  36063. * Only error logs
  36064. */
  36065. static readonly ErrorLogLevel: number;
  36066. /**
  36067. * All logs
  36068. */
  36069. static readonly AllLogLevel: number;
  36070. /**
  36071. * Gets a value indicating the number of loading errors
  36072. * @ignorenaming
  36073. */
  36074. static get errorsCount(): number;
  36075. /**
  36076. * Callback called when a new log is added
  36077. */
  36078. static OnNewCacheEntry: (entry: string) => void;
  36079. /**
  36080. * Log a message to the console
  36081. * @param message defines the message to log
  36082. */
  36083. static Log(message: string): void;
  36084. /**
  36085. * Write a warning message to the console
  36086. * @param message defines the message to log
  36087. */
  36088. static Warn(message: string): void;
  36089. /**
  36090. * Write an error message to the console
  36091. * @param message defines the message to log
  36092. */
  36093. static Error(message: string): void;
  36094. /**
  36095. * Gets current log cache (list of logs)
  36096. */
  36097. static get LogCache(): string;
  36098. /**
  36099. * Clears the log cache
  36100. */
  36101. static ClearLogCache(): void;
  36102. /**
  36103. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  36104. */
  36105. static set LogLevels(level: number);
  36106. /**
  36107. * Checks if the window object exists
  36108. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  36109. */
  36110. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  36111. /**
  36112. * No performance log
  36113. */
  36114. static readonly PerformanceNoneLogLevel: number;
  36115. /**
  36116. * Use user marks to log performance
  36117. */
  36118. static readonly PerformanceUserMarkLogLevel: number;
  36119. /**
  36120. * Log performance to the console
  36121. */
  36122. static readonly PerformanceConsoleLogLevel: number;
  36123. private static _performance;
  36124. /**
  36125. * Sets the current performance log level
  36126. */
  36127. static set PerformanceLogLevel(level: number);
  36128. private static _StartPerformanceCounterDisabled;
  36129. private static _EndPerformanceCounterDisabled;
  36130. private static _StartUserMark;
  36131. private static _EndUserMark;
  36132. private static _StartPerformanceConsole;
  36133. private static _EndPerformanceConsole;
  36134. /**
  36135. * Starts a performance counter
  36136. */
  36137. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36138. /**
  36139. * Ends a specific performance coutner
  36140. */
  36141. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36142. /**
  36143. * Gets either window.performance.now() if supported or Date.now() else
  36144. */
  36145. static get Now(): number;
  36146. /**
  36147. * This method will return the name of the class used to create the instance of the given object.
  36148. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  36149. * @param object the object to get the class name from
  36150. * @param isType defines if the object is actually a type
  36151. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  36152. */
  36153. static GetClassName(object: any, isType?: boolean): string;
  36154. /**
  36155. * Gets the first element of an array satisfying a given predicate
  36156. * @param array defines the array to browse
  36157. * @param predicate defines the predicate to use
  36158. * @returns null if not found or the element
  36159. */
  36160. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  36161. /**
  36162. * This method will return the name of the full name of the class, including its owning module (if any).
  36163. * 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).
  36164. * @param object the object to get the class name from
  36165. * @param isType defines if the object is actually a type
  36166. * @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.
  36167. * @ignorenaming
  36168. */
  36169. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36170. /**
  36171. * Returns a promise that resolves after the given amount of time.
  36172. * @param delay Number of milliseconds to delay
  36173. * @returns Promise that resolves after the given amount of time
  36174. */
  36175. static DelayAsync(delay: number): Promise<void>;
  36176. /**
  36177. * Utility function to detect if the current user agent is Safari
  36178. * @returns whether or not the current user agent is safari
  36179. */
  36180. static IsSafari(): boolean;
  36181. }
  36182. /**
  36183. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36184. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36185. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36186. * @param name The name of the class, case should be preserved
  36187. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36188. */
  36189. export function className(name: string, module?: string): (target: Object) => void;
  36190. /**
  36191. * An implementation of a loop for asynchronous functions.
  36192. */
  36193. export class AsyncLoop {
  36194. /**
  36195. * Defines the number of iterations for the loop
  36196. */
  36197. iterations: number;
  36198. /**
  36199. * Defines the current index of the loop.
  36200. */
  36201. index: number;
  36202. private _done;
  36203. private _fn;
  36204. private _successCallback;
  36205. /**
  36206. * Constructor.
  36207. * @param iterations the number of iterations.
  36208. * @param func the function to run each iteration
  36209. * @param successCallback the callback that will be called upon succesful execution
  36210. * @param offset starting offset.
  36211. */
  36212. constructor(
  36213. /**
  36214. * Defines the number of iterations for the loop
  36215. */
  36216. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36217. /**
  36218. * Execute the next iteration. Must be called after the last iteration was finished.
  36219. */
  36220. executeNext(): void;
  36221. /**
  36222. * Break the loop and run the success callback.
  36223. */
  36224. breakLoop(): void;
  36225. /**
  36226. * Create and run an async loop.
  36227. * @param iterations the number of iterations.
  36228. * @param fn the function to run each iteration
  36229. * @param successCallback the callback that will be called upon succesful execution
  36230. * @param offset starting offset.
  36231. * @returns the created async loop object
  36232. */
  36233. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36234. /**
  36235. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36236. * @param iterations total number of iterations
  36237. * @param syncedIterations number of synchronous iterations in each async iteration.
  36238. * @param fn the function to call each iteration.
  36239. * @param callback a success call back that will be called when iterating stops.
  36240. * @param breakFunction a break condition (optional)
  36241. * @param timeout timeout settings for the setTimeout function. default - 0.
  36242. * @returns the created async loop object
  36243. */
  36244. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36245. }
  36246. }
  36247. declare module "babylonjs/Misc/stringDictionary" {
  36248. import { Nullable } from "babylonjs/types";
  36249. /**
  36250. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36251. * The underlying implementation relies on an associative array to ensure the best performances.
  36252. * The value can be anything including 'null' but except 'undefined'
  36253. */
  36254. export class StringDictionary<T> {
  36255. /**
  36256. * This will clear this dictionary and copy the content from the 'source' one.
  36257. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36258. * @param source the dictionary to take the content from and copy to this dictionary
  36259. */
  36260. copyFrom(source: StringDictionary<T>): void;
  36261. /**
  36262. * Get a value based from its key
  36263. * @param key the given key to get the matching value from
  36264. * @return the value if found, otherwise undefined is returned
  36265. */
  36266. get(key: string): T | undefined;
  36267. /**
  36268. * Get a value from its key or add it if it doesn't exist.
  36269. * This method will ensure you that a given key/data will be present in the dictionary.
  36270. * @param key the given key to get the matching value from
  36271. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36272. * The factory will only be invoked if there's no data for the given key.
  36273. * @return the value corresponding to the key.
  36274. */
  36275. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36276. /**
  36277. * Get a value from its key if present in the dictionary otherwise add it
  36278. * @param key the key to get the value from
  36279. * @param val if there's no such key/value pair in the dictionary add it with this value
  36280. * @return the value corresponding to the key
  36281. */
  36282. getOrAdd(key: string, val: T): T;
  36283. /**
  36284. * Check if there's a given key in the dictionary
  36285. * @param key the key to check for
  36286. * @return true if the key is present, false otherwise
  36287. */
  36288. contains(key: string): boolean;
  36289. /**
  36290. * Add a new key and its corresponding value
  36291. * @param key the key to add
  36292. * @param value the value corresponding to the key
  36293. * @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
  36294. */
  36295. add(key: string, value: T): boolean;
  36296. /**
  36297. * Update a specific value associated to a key
  36298. * @param key defines the key to use
  36299. * @param value defines the value to store
  36300. * @returns true if the value was updated (or false if the key was not found)
  36301. */
  36302. set(key: string, value: T): boolean;
  36303. /**
  36304. * Get the element of the given key and remove it from the dictionary
  36305. * @param key defines the key to search
  36306. * @returns the value associated with the key or null if not found
  36307. */
  36308. getAndRemove(key: string): Nullable<T>;
  36309. /**
  36310. * Remove a key/value from the dictionary.
  36311. * @param key the key to remove
  36312. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36313. */
  36314. remove(key: string): boolean;
  36315. /**
  36316. * Clear the whole content of the dictionary
  36317. */
  36318. clear(): void;
  36319. /**
  36320. * Gets the current count
  36321. */
  36322. get count(): number;
  36323. /**
  36324. * Execute a callback on each key/val of the dictionary.
  36325. * Note that you can remove any element in this dictionary in the callback implementation
  36326. * @param callback the callback to execute on a given key/value pair
  36327. */
  36328. forEach(callback: (key: string, val: T) => void): void;
  36329. /**
  36330. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36331. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36332. * Note that you can remove any element in this dictionary in the callback implementation
  36333. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36334. * @returns the first item
  36335. */
  36336. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36337. private _count;
  36338. private _data;
  36339. }
  36340. }
  36341. declare module "babylonjs/Collisions/collisionCoordinator" {
  36342. import { Nullable } from "babylonjs/types";
  36343. import { Scene } from "babylonjs/scene";
  36344. import { Vector3 } from "babylonjs/Maths/math.vector";
  36345. import { Collider } from "babylonjs/Collisions/collider";
  36346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36347. /** @hidden */
  36348. export interface ICollisionCoordinator {
  36349. createCollider(): Collider;
  36350. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36351. init(scene: Scene): void;
  36352. }
  36353. /** @hidden */
  36354. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36355. private _scene;
  36356. private _scaledPosition;
  36357. private _scaledVelocity;
  36358. private _finalPosition;
  36359. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36360. createCollider(): Collider;
  36361. init(scene: Scene): void;
  36362. private _collideWithWorld;
  36363. }
  36364. }
  36365. declare module "babylonjs/Inputs/scene.inputManager" {
  36366. import { Nullable } from "babylonjs/types";
  36367. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36368. import { Vector2 } from "babylonjs/Maths/math.vector";
  36369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36370. import { Scene } from "babylonjs/scene";
  36371. /**
  36372. * Class used to manage all inputs for the scene.
  36373. */
  36374. export class InputManager {
  36375. /** The distance in pixel that you have to move to prevent some events */
  36376. static DragMovementThreshold: number;
  36377. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36378. static LongPressDelay: number;
  36379. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36380. static DoubleClickDelay: number;
  36381. /** If you need to check double click without raising a single click at first click, enable this flag */
  36382. static ExclusiveDoubleClickMode: boolean;
  36383. private _wheelEventName;
  36384. private _onPointerMove;
  36385. private _onPointerDown;
  36386. private _onPointerUp;
  36387. private _initClickEvent;
  36388. private _initActionManager;
  36389. private _delayedSimpleClick;
  36390. private _delayedSimpleClickTimeout;
  36391. private _previousDelayedSimpleClickTimeout;
  36392. private _meshPickProceed;
  36393. private _previousButtonPressed;
  36394. private _currentPickResult;
  36395. private _previousPickResult;
  36396. private _totalPointersPressed;
  36397. private _doubleClickOccured;
  36398. private _pointerOverMesh;
  36399. private _pickedDownMesh;
  36400. private _pickedUpMesh;
  36401. private _pointerX;
  36402. private _pointerY;
  36403. private _unTranslatedPointerX;
  36404. private _unTranslatedPointerY;
  36405. private _startingPointerPosition;
  36406. private _previousStartingPointerPosition;
  36407. private _startingPointerTime;
  36408. private _previousStartingPointerTime;
  36409. private _pointerCaptures;
  36410. private _onKeyDown;
  36411. private _onKeyUp;
  36412. private _onCanvasFocusObserver;
  36413. private _onCanvasBlurObserver;
  36414. private _scene;
  36415. /**
  36416. * Creates a new InputManager
  36417. * @param scene defines the hosting scene
  36418. */
  36419. constructor(scene: Scene);
  36420. /**
  36421. * Gets the mesh that is currently under the pointer
  36422. */
  36423. get meshUnderPointer(): Nullable<AbstractMesh>;
  36424. /**
  36425. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36426. */
  36427. get unTranslatedPointer(): Vector2;
  36428. /**
  36429. * Gets or sets the current on-screen X position of the pointer
  36430. */
  36431. get pointerX(): number;
  36432. set pointerX(value: number);
  36433. /**
  36434. * Gets or sets the current on-screen Y position of the pointer
  36435. */
  36436. get pointerY(): number;
  36437. set pointerY(value: number);
  36438. private _updatePointerPosition;
  36439. private _processPointerMove;
  36440. private _setRayOnPointerInfo;
  36441. private _checkPrePointerObservable;
  36442. /**
  36443. * Use this method to simulate a pointer move on a mesh
  36444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36447. */
  36448. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36449. /**
  36450. * Use this method to simulate a pointer down on a mesh
  36451. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36452. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36453. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36454. */
  36455. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36456. private _processPointerDown;
  36457. /** @hidden */
  36458. _isPointerSwiping(): boolean;
  36459. /**
  36460. * Use this method to simulate a pointer up on a mesh
  36461. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36462. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36463. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36464. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36465. */
  36466. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36467. private _processPointerUp;
  36468. /**
  36469. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36470. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36471. * @returns true if the pointer was captured
  36472. */
  36473. isPointerCaptured(pointerId?: number): boolean;
  36474. /**
  36475. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36476. * @param attachUp defines if you want to attach events to pointerup
  36477. * @param attachDown defines if you want to attach events to pointerdown
  36478. * @param attachMove defines if you want to attach events to pointermove
  36479. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36480. */
  36481. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36482. /**
  36483. * Detaches all event handlers
  36484. */
  36485. detachControl(): void;
  36486. /**
  36487. * Force the value of meshUnderPointer
  36488. * @param mesh defines the mesh to use
  36489. */
  36490. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36491. /**
  36492. * Gets the mesh under the pointer
  36493. * @returns a Mesh or null if no mesh is under the pointer
  36494. */
  36495. getPointerOverMesh(): Nullable<AbstractMesh>;
  36496. }
  36497. }
  36498. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36499. /**
  36500. * Helper class used to generate session unique ID
  36501. */
  36502. export class UniqueIdGenerator {
  36503. private static _UniqueIdCounter;
  36504. /**
  36505. * Gets an unique (relatively to the current scene) Id
  36506. */
  36507. static get UniqueId(): number;
  36508. }
  36509. }
  36510. declare module "babylonjs/Animations/animationGroup" {
  36511. import { Animatable } from "babylonjs/Animations/animatable";
  36512. import { Animation } from "babylonjs/Animations/animation";
  36513. import { Scene, IDisposable } from "babylonjs/scene";
  36514. import { Observable } from "babylonjs/Misc/observable";
  36515. import { Nullable } from "babylonjs/types";
  36516. import "babylonjs/Animations/animatable";
  36517. /**
  36518. * This class defines the direct association between an animation and a target
  36519. */
  36520. export class TargetedAnimation {
  36521. /**
  36522. * Animation to perform
  36523. */
  36524. animation: Animation;
  36525. /**
  36526. * Target to animate
  36527. */
  36528. target: any;
  36529. /**
  36530. * Serialize the object
  36531. * @returns the JSON object representing the current entity
  36532. */
  36533. serialize(): any;
  36534. }
  36535. /**
  36536. * Use this class to create coordinated animations on multiple targets
  36537. */
  36538. export class AnimationGroup implements IDisposable {
  36539. /** The name of the animation group */
  36540. name: string;
  36541. private _scene;
  36542. private _targetedAnimations;
  36543. private _animatables;
  36544. private _from;
  36545. private _to;
  36546. private _isStarted;
  36547. private _isPaused;
  36548. private _speedRatio;
  36549. private _loopAnimation;
  36550. private _isAdditive;
  36551. /**
  36552. * Gets or sets the unique id of the node
  36553. */
  36554. uniqueId: number;
  36555. /**
  36556. * This observable will notify when one animation have ended
  36557. */
  36558. onAnimationEndObservable: Observable<TargetedAnimation>;
  36559. /**
  36560. * Observer raised when one animation loops
  36561. */
  36562. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36563. /**
  36564. * Observer raised when all animations have looped
  36565. */
  36566. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36567. /**
  36568. * This observable will notify when all animations have ended.
  36569. */
  36570. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36571. /**
  36572. * This observable will notify when all animations have paused.
  36573. */
  36574. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36575. /**
  36576. * This observable will notify when all animations are playing.
  36577. */
  36578. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36579. /**
  36580. * Gets the first frame
  36581. */
  36582. get from(): number;
  36583. /**
  36584. * Gets the last frame
  36585. */
  36586. get to(): number;
  36587. /**
  36588. * Define if the animations are started
  36589. */
  36590. get isStarted(): boolean;
  36591. /**
  36592. * Gets a value indicating that the current group is playing
  36593. */
  36594. get isPlaying(): boolean;
  36595. /**
  36596. * Gets or sets the speed ratio to use for all animations
  36597. */
  36598. get speedRatio(): number;
  36599. /**
  36600. * Gets or sets the speed ratio to use for all animations
  36601. */
  36602. set speedRatio(value: number);
  36603. /**
  36604. * Gets or sets if all animations should loop or not
  36605. */
  36606. get loopAnimation(): boolean;
  36607. set loopAnimation(value: boolean);
  36608. /**
  36609. * Gets or sets if all animations should be evaluated additively
  36610. */
  36611. get isAdditive(): boolean;
  36612. set isAdditive(value: boolean);
  36613. /**
  36614. * Gets the targeted animations for this animation group
  36615. */
  36616. get targetedAnimations(): Array<TargetedAnimation>;
  36617. /**
  36618. * returning the list of animatables controlled by this animation group.
  36619. */
  36620. get animatables(): Array<Animatable>;
  36621. /**
  36622. * Instantiates a new Animation Group.
  36623. * This helps managing several animations at once.
  36624. * @see http://doc.babylonjs.com/how_to/group
  36625. * @param name Defines the name of the group
  36626. * @param scene Defines the scene the group belongs to
  36627. */
  36628. constructor(
  36629. /** The name of the animation group */
  36630. name: string, scene?: Nullable<Scene>);
  36631. /**
  36632. * Add an animation (with its target) in the group
  36633. * @param animation defines the animation we want to add
  36634. * @param target defines the target of the animation
  36635. * @returns the TargetedAnimation object
  36636. */
  36637. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36638. /**
  36639. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36640. * It can add constant keys at begin or end
  36641. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36642. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36643. * @returns the animation group
  36644. */
  36645. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36646. private _animationLoopCount;
  36647. private _animationLoopFlags;
  36648. private _processLoop;
  36649. /**
  36650. * Start all animations on given targets
  36651. * @param loop defines if animations must loop
  36652. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36653. * @param from defines the from key (optional)
  36654. * @param to defines the to key (optional)
  36655. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36656. * @returns the current animation group
  36657. */
  36658. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36659. /**
  36660. * Pause all animations
  36661. * @returns the animation group
  36662. */
  36663. pause(): AnimationGroup;
  36664. /**
  36665. * Play all animations to initial state
  36666. * This function will start() the animations if they were not started or will restart() them if they were paused
  36667. * @param loop defines if animations must loop
  36668. * @returns the animation group
  36669. */
  36670. play(loop?: boolean): AnimationGroup;
  36671. /**
  36672. * Reset all animations to initial state
  36673. * @returns the animation group
  36674. */
  36675. reset(): AnimationGroup;
  36676. /**
  36677. * Restart animations from key 0
  36678. * @returns the animation group
  36679. */
  36680. restart(): AnimationGroup;
  36681. /**
  36682. * Stop all animations
  36683. * @returns the animation group
  36684. */
  36685. stop(): AnimationGroup;
  36686. /**
  36687. * Set animation weight for all animatables
  36688. * @param weight defines the weight to use
  36689. * @return the animationGroup
  36690. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36691. */
  36692. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36693. /**
  36694. * Synchronize and normalize all animatables with a source animatable
  36695. * @param root defines the root animatable to synchronize with
  36696. * @return the animationGroup
  36697. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36698. */
  36699. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36700. /**
  36701. * Goes to a specific frame in this animation group
  36702. * @param frame the frame number to go to
  36703. * @return the animationGroup
  36704. */
  36705. goToFrame(frame: number): AnimationGroup;
  36706. /**
  36707. * Dispose all associated resources
  36708. */
  36709. dispose(): void;
  36710. private _checkAnimationGroupEnded;
  36711. /**
  36712. * Clone the current animation group and returns a copy
  36713. * @param newName defines the name of the new group
  36714. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36715. * @returns the new aniamtion group
  36716. */
  36717. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36718. /**
  36719. * Serializes the animationGroup to an object
  36720. * @returns Serialized object
  36721. */
  36722. serialize(): any;
  36723. /**
  36724. * Returns a new AnimationGroup object parsed from the source provided.
  36725. * @param parsedAnimationGroup defines the source
  36726. * @param scene defines the scene that will receive the animationGroup
  36727. * @returns a new AnimationGroup
  36728. */
  36729. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36730. /**
  36731. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36732. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36733. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36734. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36735. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36736. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36737. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36738. */
  36739. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36740. /**
  36741. * Returns the string "AnimationGroup"
  36742. * @returns "AnimationGroup"
  36743. */
  36744. getClassName(): string;
  36745. /**
  36746. * Creates a detailled string about the object
  36747. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36748. * @returns a string representing the object
  36749. */
  36750. toString(fullDetails?: boolean): string;
  36751. }
  36752. }
  36753. declare module "babylonjs/scene" {
  36754. import { Nullable } from "babylonjs/types";
  36755. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36756. import { Observable } from "babylonjs/Misc/observable";
  36757. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36758. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36759. import { Geometry } from "babylonjs/Meshes/geometry";
  36760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36761. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36763. import { Mesh } from "babylonjs/Meshes/mesh";
  36764. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36765. import { Bone } from "babylonjs/Bones/bone";
  36766. import { Skeleton } from "babylonjs/Bones/skeleton";
  36767. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36768. import { Camera } from "babylonjs/Cameras/camera";
  36769. import { AbstractScene } from "babylonjs/abstractScene";
  36770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36772. import { Material } from "babylonjs/Materials/material";
  36773. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36774. import { Effect } from "babylonjs/Materials/effect";
  36775. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36776. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36777. import { Light } from "babylonjs/Lights/light";
  36778. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36779. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36780. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36781. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36782. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36783. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36784. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36785. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36786. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36787. import { Engine } from "babylonjs/Engines/engine";
  36788. import { Node } from "babylonjs/node";
  36789. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36790. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36791. import { WebRequest } from "babylonjs/Misc/webRequest";
  36792. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36793. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36794. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36795. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36796. import { Plane } from "babylonjs/Maths/math.plane";
  36797. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36798. import { Ray } from "babylonjs/Culling/ray";
  36799. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36800. import { Animation } from "babylonjs/Animations/animation";
  36801. import { Animatable } from "babylonjs/Animations/animatable";
  36802. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36803. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36804. import { Collider } from "babylonjs/Collisions/collider";
  36805. /**
  36806. * Define an interface for all classes that will hold resources
  36807. */
  36808. export interface IDisposable {
  36809. /**
  36810. * Releases all held resources
  36811. */
  36812. dispose(): void;
  36813. }
  36814. /** Interface defining initialization parameters for Scene class */
  36815. export interface SceneOptions {
  36816. /**
  36817. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36818. * It will improve performance when the number of geometries becomes important.
  36819. */
  36820. useGeometryUniqueIdsMap?: boolean;
  36821. /**
  36822. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36823. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36824. */
  36825. useMaterialMeshMap?: boolean;
  36826. /**
  36827. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36828. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36829. */
  36830. useClonedMeshMap?: boolean;
  36831. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36832. virtual?: boolean;
  36833. }
  36834. /**
  36835. * Represents a scene to be rendered by the engine.
  36836. * @see http://doc.babylonjs.com/features/scene
  36837. */
  36838. export class Scene extends AbstractScene implements IAnimatable {
  36839. /** The fog is deactivated */
  36840. static readonly FOGMODE_NONE: number;
  36841. /** The fog density is following an exponential function */
  36842. static readonly FOGMODE_EXP: number;
  36843. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36844. static readonly FOGMODE_EXP2: number;
  36845. /** The fog density is following a linear function. */
  36846. static readonly FOGMODE_LINEAR: number;
  36847. /**
  36848. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36850. */
  36851. static MinDeltaTime: number;
  36852. /**
  36853. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36854. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36855. */
  36856. static MaxDeltaTime: number;
  36857. /**
  36858. * Factory used to create the default material.
  36859. * @param name The name of the material to create
  36860. * @param scene The scene to create the material for
  36861. * @returns The default material
  36862. */
  36863. static DefaultMaterialFactory(scene: Scene): Material;
  36864. /**
  36865. * Factory used to create the a collision coordinator.
  36866. * @returns The collision coordinator
  36867. */
  36868. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36869. /** @hidden */
  36870. _inputManager: InputManager;
  36871. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36872. cameraToUseForPointers: Nullable<Camera>;
  36873. /** @hidden */
  36874. readonly _isScene: boolean;
  36875. /** @hidden */
  36876. _blockEntityCollection: boolean;
  36877. /**
  36878. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36879. */
  36880. autoClear: boolean;
  36881. /**
  36882. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36883. */
  36884. autoClearDepthAndStencil: boolean;
  36885. /**
  36886. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36887. */
  36888. clearColor: Color4;
  36889. /**
  36890. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36891. */
  36892. ambientColor: Color3;
  36893. /**
  36894. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36895. * It should only be one of the following (if not the default embedded one):
  36896. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36897. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36898. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36899. * The material properties need to be setup according to the type of texture in use.
  36900. */
  36901. environmentBRDFTexture: BaseTexture;
  36902. /** @hidden */
  36903. protected _environmentTexture: Nullable<BaseTexture>;
  36904. /**
  36905. * Texture used in all pbr material as the reflection texture.
  36906. * As in the majority of the scene they are the same (exception for multi room and so on),
  36907. * this is easier to reference from here than from all the materials.
  36908. */
  36909. get environmentTexture(): Nullable<BaseTexture>;
  36910. /**
  36911. * Texture used in all pbr material as the reflection texture.
  36912. * As in the majority of the scene they are the same (exception for multi room and so on),
  36913. * this is easier to set here than in all the materials.
  36914. */
  36915. set environmentTexture(value: Nullable<BaseTexture>);
  36916. /** @hidden */
  36917. protected _environmentIntensity: number;
  36918. /**
  36919. * Intensity of the environment in all pbr material.
  36920. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36921. * As in the majority of the scene they are the same (exception for multi room and so on),
  36922. * this is easier to reference from here than from all the materials.
  36923. */
  36924. get environmentIntensity(): number;
  36925. /**
  36926. * Intensity of the environment in all pbr material.
  36927. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36928. * As in the majority of the scene they are the same (exception for multi room and so on),
  36929. * this is easier to set here than in all the materials.
  36930. */
  36931. set environmentIntensity(value: number);
  36932. /** @hidden */
  36933. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36934. /**
  36935. * Default image processing configuration used either in the rendering
  36936. * Forward main pass or through the imageProcessingPostProcess if present.
  36937. * As in the majority of the scene they are the same (exception for multi camera),
  36938. * this is easier to reference from here than from all the materials and post process.
  36939. *
  36940. * No setter as we it is a shared configuration, you can set the values instead.
  36941. */
  36942. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36943. private _forceWireframe;
  36944. /**
  36945. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36946. */
  36947. set forceWireframe(value: boolean);
  36948. get forceWireframe(): boolean;
  36949. private _skipFrustumClipping;
  36950. /**
  36951. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36952. */
  36953. set skipFrustumClipping(value: boolean);
  36954. get skipFrustumClipping(): boolean;
  36955. private _forcePointsCloud;
  36956. /**
  36957. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36958. */
  36959. set forcePointsCloud(value: boolean);
  36960. get forcePointsCloud(): boolean;
  36961. /**
  36962. * Gets or sets the active clipplane 1
  36963. */
  36964. clipPlane: Nullable<Plane>;
  36965. /**
  36966. * Gets or sets the active clipplane 2
  36967. */
  36968. clipPlane2: Nullable<Plane>;
  36969. /**
  36970. * Gets or sets the active clipplane 3
  36971. */
  36972. clipPlane3: Nullable<Plane>;
  36973. /**
  36974. * Gets or sets the active clipplane 4
  36975. */
  36976. clipPlane4: Nullable<Plane>;
  36977. /**
  36978. * Gets or sets the active clipplane 5
  36979. */
  36980. clipPlane5: Nullable<Plane>;
  36981. /**
  36982. * Gets or sets the active clipplane 6
  36983. */
  36984. clipPlane6: Nullable<Plane>;
  36985. /**
  36986. * Gets or sets a boolean indicating if animations are enabled
  36987. */
  36988. animationsEnabled: boolean;
  36989. private _animationPropertiesOverride;
  36990. /**
  36991. * Gets or sets the animation properties override
  36992. */
  36993. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36994. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36995. /**
  36996. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36997. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36998. */
  36999. useConstantAnimationDeltaTime: boolean;
  37000. /**
  37001. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  37002. * Please note that it requires to run a ray cast through the scene on every frame
  37003. */
  37004. constantlyUpdateMeshUnderPointer: boolean;
  37005. /**
  37006. * Defines the HTML cursor to use when hovering over interactive elements
  37007. */
  37008. hoverCursor: string;
  37009. /**
  37010. * Defines the HTML default cursor to use (empty by default)
  37011. */
  37012. defaultCursor: string;
  37013. /**
  37014. * Defines whether cursors are handled by the scene.
  37015. */
  37016. doNotHandleCursors: boolean;
  37017. /**
  37018. * This is used to call preventDefault() on pointer down
  37019. * in order to block unwanted artifacts like system double clicks
  37020. */
  37021. preventDefaultOnPointerDown: boolean;
  37022. /**
  37023. * This is used to call preventDefault() on pointer up
  37024. * in order to block unwanted artifacts like system double clicks
  37025. */
  37026. preventDefaultOnPointerUp: boolean;
  37027. /**
  37028. * Gets or sets user defined metadata
  37029. */
  37030. metadata: any;
  37031. /**
  37032. * For internal use only. Please do not use.
  37033. */
  37034. reservedDataStore: any;
  37035. /**
  37036. * Gets the name of the plugin used to load this scene (null by default)
  37037. */
  37038. loadingPluginName: string;
  37039. /**
  37040. * Use this array to add regular expressions used to disable offline support for specific urls
  37041. */
  37042. disableOfflineSupportExceptionRules: RegExp[];
  37043. /**
  37044. * An event triggered when the scene is disposed.
  37045. */
  37046. onDisposeObservable: Observable<Scene>;
  37047. private _onDisposeObserver;
  37048. /** Sets a function to be executed when this scene is disposed. */
  37049. set onDispose(callback: () => void);
  37050. /**
  37051. * An event triggered before rendering the scene (right after animations and physics)
  37052. */
  37053. onBeforeRenderObservable: Observable<Scene>;
  37054. private _onBeforeRenderObserver;
  37055. /** Sets a function to be executed before rendering this scene */
  37056. set beforeRender(callback: Nullable<() => void>);
  37057. /**
  37058. * An event triggered after rendering the scene
  37059. */
  37060. onAfterRenderObservable: Observable<Scene>;
  37061. /**
  37062. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  37063. */
  37064. onAfterRenderCameraObservable: Observable<Camera>;
  37065. private _onAfterRenderObserver;
  37066. /** Sets a function to be executed after rendering this scene */
  37067. set afterRender(callback: Nullable<() => void>);
  37068. /**
  37069. * An event triggered before animating the scene
  37070. */
  37071. onBeforeAnimationsObservable: Observable<Scene>;
  37072. /**
  37073. * An event triggered after animations processing
  37074. */
  37075. onAfterAnimationsObservable: Observable<Scene>;
  37076. /**
  37077. * An event triggered before draw calls are ready to be sent
  37078. */
  37079. onBeforeDrawPhaseObservable: Observable<Scene>;
  37080. /**
  37081. * An event triggered after draw calls have been sent
  37082. */
  37083. onAfterDrawPhaseObservable: Observable<Scene>;
  37084. /**
  37085. * An event triggered when the scene is ready
  37086. */
  37087. onReadyObservable: Observable<Scene>;
  37088. /**
  37089. * An event triggered before rendering a camera
  37090. */
  37091. onBeforeCameraRenderObservable: Observable<Camera>;
  37092. private _onBeforeCameraRenderObserver;
  37093. /** Sets a function to be executed before rendering a camera*/
  37094. set beforeCameraRender(callback: () => void);
  37095. /**
  37096. * An event triggered after rendering a camera
  37097. */
  37098. onAfterCameraRenderObservable: Observable<Camera>;
  37099. private _onAfterCameraRenderObserver;
  37100. /** Sets a function to be executed after rendering a camera*/
  37101. set afterCameraRender(callback: () => void);
  37102. /**
  37103. * An event triggered when active meshes evaluation is about to start
  37104. */
  37105. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  37106. /**
  37107. * An event triggered when active meshes evaluation is done
  37108. */
  37109. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  37110. /**
  37111. * An event triggered when particles rendering is about to start
  37112. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37113. */
  37114. onBeforeParticlesRenderingObservable: Observable<Scene>;
  37115. /**
  37116. * An event triggered when particles rendering is done
  37117. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37118. */
  37119. onAfterParticlesRenderingObservable: Observable<Scene>;
  37120. /**
  37121. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  37122. */
  37123. onDataLoadedObservable: Observable<Scene>;
  37124. /**
  37125. * An event triggered when a camera is created
  37126. */
  37127. onNewCameraAddedObservable: Observable<Camera>;
  37128. /**
  37129. * An event triggered when a camera is removed
  37130. */
  37131. onCameraRemovedObservable: Observable<Camera>;
  37132. /**
  37133. * An event triggered when a light is created
  37134. */
  37135. onNewLightAddedObservable: Observable<Light>;
  37136. /**
  37137. * An event triggered when a light is removed
  37138. */
  37139. onLightRemovedObservable: Observable<Light>;
  37140. /**
  37141. * An event triggered when a geometry is created
  37142. */
  37143. onNewGeometryAddedObservable: Observable<Geometry>;
  37144. /**
  37145. * An event triggered when a geometry is removed
  37146. */
  37147. onGeometryRemovedObservable: Observable<Geometry>;
  37148. /**
  37149. * An event triggered when a transform node is created
  37150. */
  37151. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  37152. /**
  37153. * An event triggered when a transform node is removed
  37154. */
  37155. onTransformNodeRemovedObservable: Observable<TransformNode>;
  37156. /**
  37157. * An event triggered when a mesh is created
  37158. */
  37159. onNewMeshAddedObservable: Observable<AbstractMesh>;
  37160. /**
  37161. * An event triggered when a mesh is removed
  37162. */
  37163. onMeshRemovedObservable: Observable<AbstractMesh>;
  37164. /**
  37165. * An event triggered when a skeleton is created
  37166. */
  37167. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37168. /**
  37169. * An event triggered when a skeleton is removed
  37170. */
  37171. onSkeletonRemovedObservable: Observable<Skeleton>;
  37172. /**
  37173. * An event triggered when a material is created
  37174. */
  37175. onNewMaterialAddedObservable: Observable<Material>;
  37176. /**
  37177. * An event triggered when a material is removed
  37178. */
  37179. onMaterialRemovedObservable: Observable<Material>;
  37180. /**
  37181. * An event triggered when a texture is created
  37182. */
  37183. onNewTextureAddedObservable: Observable<BaseTexture>;
  37184. /**
  37185. * An event triggered when a texture is removed
  37186. */
  37187. onTextureRemovedObservable: Observable<BaseTexture>;
  37188. /**
  37189. * An event triggered when render targets are about to be rendered
  37190. * Can happen multiple times per frame.
  37191. */
  37192. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37193. /**
  37194. * An event triggered when render targets were rendered.
  37195. * Can happen multiple times per frame.
  37196. */
  37197. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37198. /**
  37199. * An event triggered before calculating deterministic simulation step
  37200. */
  37201. onBeforeStepObservable: Observable<Scene>;
  37202. /**
  37203. * An event triggered after calculating deterministic simulation step
  37204. */
  37205. onAfterStepObservable: Observable<Scene>;
  37206. /**
  37207. * An event triggered when the activeCamera property is updated
  37208. */
  37209. onActiveCameraChanged: Observable<Scene>;
  37210. /**
  37211. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37212. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37213. * 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)
  37214. */
  37215. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37216. /**
  37217. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37218. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37219. * 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)
  37220. */
  37221. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37222. /**
  37223. * This Observable will when a mesh has been imported into the scene.
  37224. */
  37225. onMeshImportedObservable: Observable<AbstractMesh>;
  37226. /**
  37227. * This Observable will when an animation file has been imported into the scene.
  37228. */
  37229. onAnimationFileImportedObservable: Observable<Scene>;
  37230. /**
  37231. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37232. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37233. */
  37234. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37235. /** @hidden */
  37236. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37237. /**
  37238. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37239. */
  37240. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37241. /**
  37242. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37243. */
  37244. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37245. /**
  37246. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37247. */
  37248. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37249. /** Callback called when a pointer move is detected */
  37250. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37251. /** Callback called when a pointer down is detected */
  37252. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37253. /** Callback called when a pointer up is detected */
  37254. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37255. /** Callback called when a pointer pick is detected */
  37256. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37257. /**
  37258. * 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).
  37259. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37260. */
  37261. onPrePointerObservable: Observable<PointerInfoPre>;
  37262. /**
  37263. * Observable event triggered each time an input event is received from the rendering canvas
  37264. */
  37265. onPointerObservable: Observable<PointerInfo>;
  37266. /**
  37267. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37268. */
  37269. get unTranslatedPointer(): Vector2;
  37270. /**
  37271. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37272. */
  37273. static get DragMovementThreshold(): number;
  37274. static set DragMovementThreshold(value: number);
  37275. /**
  37276. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37277. */
  37278. static get LongPressDelay(): number;
  37279. static set LongPressDelay(value: number);
  37280. /**
  37281. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37282. */
  37283. static get DoubleClickDelay(): number;
  37284. static set DoubleClickDelay(value: number);
  37285. /** If you need to check double click without raising a single click at first click, enable this flag */
  37286. static get ExclusiveDoubleClickMode(): boolean;
  37287. static set ExclusiveDoubleClickMode(value: boolean);
  37288. /** @hidden */
  37289. _mirroredCameraPosition: Nullable<Vector3>;
  37290. /**
  37291. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37292. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37293. */
  37294. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37295. /**
  37296. * Observable event triggered each time an keyboard event is received from the hosting window
  37297. */
  37298. onKeyboardObservable: Observable<KeyboardInfo>;
  37299. private _useRightHandedSystem;
  37300. /**
  37301. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37302. */
  37303. set useRightHandedSystem(value: boolean);
  37304. get useRightHandedSystem(): boolean;
  37305. private _timeAccumulator;
  37306. private _currentStepId;
  37307. private _currentInternalStep;
  37308. /**
  37309. * Sets the step Id used by deterministic lock step
  37310. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37311. * @param newStepId defines the step Id
  37312. */
  37313. setStepId(newStepId: number): void;
  37314. /**
  37315. * Gets the step Id used by deterministic lock step
  37316. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37317. * @returns the step Id
  37318. */
  37319. getStepId(): number;
  37320. /**
  37321. * Gets the internal step used by deterministic lock step
  37322. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37323. * @returns the internal step
  37324. */
  37325. getInternalStep(): number;
  37326. private _fogEnabled;
  37327. /**
  37328. * Gets or sets a boolean indicating if fog is enabled on this scene
  37329. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37330. * (Default is true)
  37331. */
  37332. set fogEnabled(value: boolean);
  37333. get fogEnabled(): boolean;
  37334. private _fogMode;
  37335. /**
  37336. * Gets or sets the fog mode to use
  37337. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37338. * | mode | value |
  37339. * | --- | --- |
  37340. * | FOGMODE_NONE | 0 |
  37341. * | FOGMODE_EXP | 1 |
  37342. * | FOGMODE_EXP2 | 2 |
  37343. * | FOGMODE_LINEAR | 3 |
  37344. */
  37345. set fogMode(value: number);
  37346. get fogMode(): number;
  37347. /**
  37348. * Gets or sets the fog color to use
  37349. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37350. * (Default is Color3(0.2, 0.2, 0.3))
  37351. */
  37352. fogColor: Color3;
  37353. /**
  37354. * Gets or sets the fog density to use
  37355. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37356. * (Default is 0.1)
  37357. */
  37358. fogDensity: number;
  37359. /**
  37360. * Gets or sets the fog start distance to use
  37361. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37362. * (Default is 0)
  37363. */
  37364. fogStart: number;
  37365. /**
  37366. * Gets or sets the fog end distance to use
  37367. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37368. * (Default is 1000)
  37369. */
  37370. fogEnd: number;
  37371. private _shadowsEnabled;
  37372. /**
  37373. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37374. */
  37375. set shadowsEnabled(value: boolean);
  37376. get shadowsEnabled(): boolean;
  37377. private _lightsEnabled;
  37378. /**
  37379. * Gets or sets a boolean indicating if lights are enabled on this scene
  37380. */
  37381. set lightsEnabled(value: boolean);
  37382. get lightsEnabled(): boolean;
  37383. /** All of the active cameras added to this scene. */
  37384. activeCameras: Camera[];
  37385. /** @hidden */
  37386. _activeCamera: Nullable<Camera>;
  37387. /** Gets or sets the current active camera */
  37388. get activeCamera(): Nullable<Camera>;
  37389. set activeCamera(value: Nullable<Camera>);
  37390. private _defaultMaterial;
  37391. /** The default material used on meshes when no material is affected */
  37392. get defaultMaterial(): Material;
  37393. /** The default material used on meshes when no material is affected */
  37394. set defaultMaterial(value: Material);
  37395. private _texturesEnabled;
  37396. /**
  37397. * Gets or sets a boolean indicating if textures are enabled on this scene
  37398. */
  37399. set texturesEnabled(value: boolean);
  37400. get texturesEnabled(): boolean;
  37401. /**
  37402. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  37403. */
  37404. physicsEnabled: boolean;
  37405. /**
  37406. * Gets or sets a boolean indicating if particles are enabled on this scene
  37407. */
  37408. particlesEnabled: boolean;
  37409. /**
  37410. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37411. */
  37412. spritesEnabled: boolean;
  37413. private _skeletonsEnabled;
  37414. /**
  37415. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37416. */
  37417. set skeletonsEnabled(value: boolean);
  37418. get skeletonsEnabled(): boolean;
  37419. /**
  37420. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37421. */
  37422. lensFlaresEnabled: boolean;
  37423. /**
  37424. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37426. */
  37427. collisionsEnabled: boolean;
  37428. private _collisionCoordinator;
  37429. /** @hidden */
  37430. get collisionCoordinator(): ICollisionCoordinator;
  37431. /**
  37432. * Defines the gravity applied to this scene (used only for collisions)
  37433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37434. */
  37435. gravity: Vector3;
  37436. /**
  37437. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37438. */
  37439. postProcessesEnabled: boolean;
  37440. /**
  37441. * The list of postprocesses added to the scene
  37442. */
  37443. postProcesses: PostProcess[];
  37444. /**
  37445. * Gets the current postprocess manager
  37446. */
  37447. postProcessManager: PostProcessManager;
  37448. /**
  37449. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37450. */
  37451. renderTargetsEnabled: boolean;
  37452. /**
  37453. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37454. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37455. */
  37456. dumpNextRenderTargets: boolean;
  37457. /**
  37458. * The list of user defined render targets added to the scene
  37459. */
  37460. customRenderTargets: RenderTargetTexture[];
  37461. /**
  37462. * Defines if texture loading must be delayed
  37463. * If true, textures will only be loaded when they need to be rendered
  37464. */
  37465. useDelayedTextureLoading: boolean;
  37466. /**
  37467. * Gets the list of meshes imported to the scene through SceneLoader
  37468. */
  37469. importedMeshesFiles: String[];
  37470. /**
  37471. * Gets or sets a boolean indicating if probes are enabled on this scene
  37472. */
  37473. probesEnabled: boolean;
  37474. /**
  37475. * Gets or sets the current offline provider to use to store scene data
  37476. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37477. */
  37478. offlineProvider: IOfflineProvider;
  37479. /**
  37480. * Gets or sets the action manager associated with the scene
  37481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37482. */
  37483. actionManager: AbstractActionManager;
  37484. private _meshesForIntersections;
  37485. /**
  37486. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37487. */
  37488. proceduralTexturesEnabled: boolean;
  37489. private _engine;
  37490. private _totalVertices;
  37491. /** @hidden */
  37492. _activeIndices: PerfCounter;
  37493. /** @hidden */
  37494. _activeParticles: PerfCounter;
  37495. /** @hidden */
  37496. _activeBones: PerfCounter;
  37497. private _animationRatio;
  37498. /** @hidden */
  37499. _animationTimeLast: number;
  37500. /** @hidden */
  37501. _animationTime: number;
  37502. /**
  37503. * Gets or sets a general scale for animation speed
  37504. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37505. */
  37506. animationTimeScale: number;
  37507. /** @hidden */
  37508. _cachedMaterial: Nullable<Material>;
  37509. /** @hidden */
  37510. _cachedEffect: Nullable<Effect>;
  37511. /** @hidden */
  37512. _cachedVisibility: Nullable<number>;
  37513. private _renderId;
  37514. private _frameId;
  37515. private _executeWhenReadyTimeoutId;
  37516. private _intermediateRendering;
  37517. private _viewUpdateFlag;
  37518. private _projectionUpdateFlag;
  37519. /** @hidden */
  37520. _toBeDisposed: Nullable<IDisposable>[];
  37521. private _activeRequests;
  37522. /** @hidden */
  37523. _pendingData: any[];
  37524. private _isDisposed;
  37525. /**
  37526. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37527. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37528. */
  37529. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37530. private _activeMeshes;
  37531. private _processedMaterials;
  37532. private _renderTargets;
  37533. /** @hidden */
  37534. _activeParticleSystems: SmartArray<IParticleSystem>;
  37535. private _activeSkeletons;
  37536. private _softwareSkinnedMeshes;
  37537. private _renderingManager;
  37538. /** @hidden */
  37539. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37540. private _transformMatrix;
  37541. private _sceneUbo;
  37542. /** @hidden */
  37543. _viewMatrix: Matrix;
  37544. private _projectionMatrix;
  37545. /** @hidden */
  37546. _forcedViewPosition: Nullable<Vector3>;
  37547. /** @hidden */
  37548. _frustumPlanes: Plane[];
  37549. /**
  37550. * Gets the list of frustum planes (built from the active camera)
  37551. */
  37552. get frustumPlanes(): Plane[];
  37553. /**
  37554. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37555. * This is useful if there are more lights that the maximum simulteanous authorized
  37556. */
  37557. requireLightSorting: boolean;
  37558. /** @hidden */
  37559. readonly useMaterialMeshMap: boolean;
  37560. /** @hidden */
  37561. readonly useClonedMeshMap: boolean;
  37562. private _externalData;
  37563. private _uid;
  37564. /**
  37565. * @hidden
  37566. * Backing store of defined scene components.
  37567. */
  37568. _components: ISceneComponent[];
  37569. /**
  37570. * @hidden
  37571. * Backing store of defined scene components.
  37572. */
  37573. _serializableComponents: ISceneSerializableComponent[];
  37574. /**
  37575. * List of components to register on the next registration step.
  37576. */
  37577. private _transientComponents;
  37578. /**
  37579. * Registers the transient components if needed.
  37580. */
  37581. private _registerTransientComponents;
  37582. /**
  37583. * @hidden
  37584. * Add a component to the scene.
  37585. * Note that the ccomponent could be registered on th next frame if this is called after
  37586. * the register component stage.
  37587. * @param component Defines the component to add to the scene
  37588. */
  37589. _addComponent(component: ISceneComponent): void;
  37590. /**
  37591. * @hidden
  37592. * Gets a component from the scene.
  37593. * @param name defines the name of the component to retrieve
  37594. * @returns the component or null if not present
  37595. */
  37596. _getComponent(name: string): Nullable<ISceneComponent>;
  37597. /**
  37598. * @hidden
  37599. * Defines the actions happening before camera updates.
  37600. */
  37601. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37602. /**
  37603. * @hidden
  37604. * Defines the actions happening before clear the canvas.
  37605. */
  37606. _beforeClearStage: Stage<SimpleStageAction>;
  37607. /**
  37608. * @hidden
  37609. * Defines the actions when collecting render targets for the frame.
  37610. */
  37611. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37612. /**
  37613. * @hidden
  37614. * Defines the actions happening for one camera in the frame.
  37615. */
  37616. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37617. /**
  37618. * @hidden
  37619. * Defines the actions happening during the per mesh ready checks.
  37620. */
  37621. _isReadyForMeshStage: Stage<MeshStageAction>;
  37622. /**
  37623. * @hidden
  37624. * Defines the actions happening before evaluate active mesh checks.
  37625. */
  37626. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37627. /**
  37628. * @hidden
  37629. * Defines the actions happening during the evaluate sub mesh checks.
  37630. */
  37631. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37632. /**
  37633. * @hidden
  37634. * Defines the actions happening during the active mesh stage.
  37635. */
  37636. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37637. /**
  37638. * @hidden
  37639. * Defines the actions happening during the per camera render target step.
  37640. */
  37641. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37642. /**
  37643. * @hidden
  37644. * Defines the actions happening just before the active camera is drawing.
  37645. */
  37646. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37647. /**
  37648. * @hidden
  37649. * Defines the actions happening just before a render target is drawing.
  37650. */
  37651. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37652. /**
  37653. * @hidden
  37654. * Defines the actions happening just before a rendering group is drawing.
  37655. */
  37656. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37657. /**
  37658. * @hidden
  37659. * Defines the actions happening just before a mesh is drawing.
  37660. */
  37661. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37662. /**
  37663. * @hidden
  37664. * Defines the actions happening just after a mesh has been drawn.
  37665. */
  37666. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37667. /**
  37668. * @hidden
  37669. * Defines the actions happening just after a rendering group has been drawn.
  37670. */
  37671. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37672. /**
  37673. * @hidden
  37674. * Defines the actions happening just after the active camera has been drawn.
  37675. */
  37676. _afterCameraDrawStage: Stage<CameraStageAction>;
  37677. /**
  37678. * @hidden
  37679. * Defines the actions happening just after a render target has been drawn.
  37680. */
  37681. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37682. /**
  37683. * @hidden
  37684. * Defines the actions happening just after rendering all cameras and computing intersections.
  37685. */
  37686. _afterRenderStage: Stage<SimpleStageAction>;
  37687. /**
  37688. * @hidden
  37689. * Defines the actions happening when a pointer move event happens.
  37690. */
  37691. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37692. /**
  37693. * @hidden
  37694. * Defines the actions happening when a pointer down event happens.
  37695. */
  37696. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37697. /**
  37698. * @hidden
  37699. * Defines the actions happening when a pointer up event happens.
  37700. */
  37701. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37702. /**
  37703. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37704. */
  37705. private geometriesByUniqueId;
  37706. /**
  37707. * Creates a new Scene
  37708. * @param engine defines the engine to use to render this scene
  37709. * @param options defines the scene options
  37710. */
  37711. constructor(engine: Engine, options?: SceneOptions);
  37712. /**
  37713. * Gets a string idenfifying the name of the class
  37714. * @returns "Scene" string
  37715. */
  37716. getClassName(): string;
  37717. private _defaultMeshCandidates;
  37718. /**
  37719. * @hidden
  37720. */
  37721. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37722. private _defaultSubMeshCandidates;
  37723. /**
  37724. * @hidden
  37725. */
  37726. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37727. /**
  37728. * Sets the default candidate providers for the scene.
  37729. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37730. * and getCollidingSubMeshCandidates to their default function
  37731. */
  37732. setDefaultCandidateProviders(): void;
  37733. /**
  37734. * Gets the mesh that is currently under the pointer
  37735. */
  37736. get meshUnderPointer(): Nullable<AbstractMesh>;
  37737. /**
  37738. * Gets or sets the current on-screen X position of the pointer
  37739. */
  37740. get pointerX(): number;
  37741. set pointerX(value: number);
  37742. /**
  37743. * Gets or sets the current on-screen Y position of the pointer
  37744. */
  37745. get pointerY(): number;
  37746. set pointerY(value: number);
  37747. /**
  37748. * Gets the cached material (ie. the latest rendered one)
  37749. * @returns the cached material
  37750. */
  37751. getCachedMaterial(): Nullable<Material>;
  37752. /**
  37753. * Gets the cached effect (ie. the latest rendered one)
  37754. * @returns the cached effect
  37755. */
  37756. getCachedEffect(): Nullable<Effect>;
  37757. /**
  37758. * Gets the cached visibility state (ie. the latest rendered one)
  37759. * @returns the cached visibility state
  37760. */
  37761. getCachedVisibility(): Nullable<number>;
  37762. /**
  37763. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37764. * @param material defines the current material
  37765. * @param effect defines the current effect
  37766. * @param visibility defines the current visibility state
  37767. * @returns true if one parameter is not cached
  37768. */
  37769. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37770. /**
  37771. * Gets the engine associated with the scene
  37772. * @returns an Engine
  37773. */
  37774. getEngine(): Engine;
  37775. /**
  37776. * Gets the total number of vertices rendered per frame
  37777. * @returns the total number of vertices rendered per frame
  37778. */
  37779. getTotalVertices(): number;
  37780. /**
  37781. * Gets the performance counter for total vertices
  37782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37783. */
  37784. get totalVerticesPerfCounter(): PerfCounter;
  37785. /**
  37786. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37787. * @returns the total number of active indices rendered per frame
  37788. */
  37789. getActiveIndices(): number;
  37790. /**
  37791. * Gets the performance counter for active indices
  37792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37793. */
  37794. get totalActiveIndicesPerfCounter(): PerfCounter;
  37795. /**
  37796. * Gets the total number of active particles rendered per frame
  37797. * @returns the total number of active particles rendered per frame
  37798. */
  37799. getActiveParticles(): number;
  37800. /**
  37801. * Gets the performance counter for active particles
  37802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37803. */
  37804. get activeParticlesPerfCounter(): PerfCounter;
  37805. /**
  37806. * Gets the total number of active bones rendered per frame
  37807. * @returns the total number of active bones rendered per frame
  37808. */
  37809. getActiveBones(): number;
  37810. /**
  37811. * Gets the performance counter for active bones
  37812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37813. */
  37814. get activeBonesPerfCounter(): PerfCounter;
  37815. /**
  37816. * Gets the array of active meshes
  37817. * @returns an array of AbstractMesh
  37818. */
  37819. getActiveMeshes(): SmartArray<AbstractMesh>;
  37820. /**
  37821. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37822. * @returns a number
  37823. */
  37824. getAnimationRatio(): number;
  37825. /**
  37826. * Gets an unique Id for the current render phase
  37827. * @returns a number
  37828. */
  37829. getRenderId(): number;
  37830. /**
  37831. * Gets an unique Id for the current frame
  37832. * @returns a number
  37833. */
  37834. getFrameId(): number;
  37835. /** Call this function if you want to manually increment the render Id*/
  37836. incrementRenderId(): void;
  37837. private _createUbo;
  37838. /**
  37839. * Use this method to simulate a pointer move on a mesh
  37840. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37841. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37842. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37843. * @returns the current scene
  37844. */
  37845. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37846. /**
  37847. * Use this method to simulate a pointer down on a mesh
  37848. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37849. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37850. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37851. * @returns the current scene
  37852. */
  37853. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37854. /**
  37855. * Use this method to simulate a pointer up on a mesh
  37856. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37857. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37858. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37859. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37860. * @returns the current scene
  37861. */
  37862. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37863. /**
  37864. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37865. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37866. * @returns true if the pointer was captured
  37867. */
  37868. isPointerCaptured(pointerId?: number): boolean;
  37869. /**
  37870. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37871. * @param attachUp defines if you want to attach events to pointerup
  37872. * @param attachDown defines if you want to attach events to pointerdown
  37873. * @param attachMove defines if you want to attach events to pointermove
  37874. */
  37875. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37876. /** Detaches all event handlers*/
  37877. detachControl(): void;
  37878. /**
  37879. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37880. * Delay loaded resources are not taking in account
  37881. * @return true if all required resources are ready
  37882. */
  37883. isReady(): boolean;
  37884. /** Resets all cached information relative to material (including effect and visibility) */
  37885. resetCachedMaterial(): void;
  37886. /**
  37887. * Registers a function to be called before every frame render
  37888. * @param func defines the function to register
  37889. */
  37890. registerBeforeRender(func: () => void): void;
  37891. /**
  37892. * Unregisters a function called before every frame render
  37893. * @param func defines the function to unregister
  37894. */
  37895. unregisterBeforeRender(func: () => void): void;
  37896. /**
  37897. * Registers a function to be called after every frame render
  37898. * @param func defines the function to register
  37899. */
  37900. registerAfterRender(func: () => void): void;
  37901. /**
  37902. * Unregisters a function called after every frame render
  37903. * @param func defines the function to unregister
  37904. */
  37905. unregisterAfterRender(func: () => void): void;
  37906. private _executeOnceBeforeRender;
  37907. /**
  37908. * The provided function will run before render once and will be disposed afterwards.
  37909. * A timeout delay can be provided so that the function will be executed in N ms.
  37910. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37911. * @param func The function to be executed.
  37912. * @param timeout optional delay in ms
  37913. */
  37914. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37915. /** @hidden */
  37916. _addPendingData(data: any): void;
  37917. /** @hidden */
  37918. _removePendingData(data: any): void;
  37919. /**
  37920. * Returns the number of items waiting to be loaded
  37921. * @returns the number of items waiting to be loaded
  37922. */
  37923. getWaitingItemsCount(): number;
  37924. /**
  37925. * Returns a boolean indicating if the scene is still loading data
  37926. */
  37927. get isLoading(): boolean;
  37928. /**
  37929. * Registers a function to be executed when the scene is ready
  37930. * @param {Function} func - the function to be executed
  37931. */
  37932. executeWhenReady(func: () => void): void;
  37933. /**
  37934. * Returns a promise that resolves when the scene is ready
  37935. * @returns A promise that resolves when the scene is ready
  37936. */
  37937. whenReadyAsync(): Promise<void>;
  37938. /** @hidden */
  37939. _checkIsReady(): void;
  37940. /**
  37941. * Gets all animatable attached to the scene
  37942. */
  37943. get animatables(): Animatable[];
  37944. /**
  37945. * Resets the last animation time frame.
  37946. * Useful to override when animations start running when loading a scene for the first time.
  37947. */
  37948. resetLastAnimationTimeFrame(): void;
  37949. /**
  37950. * Gets the current view matrix
  37951. * @returns a Matrix
  37952. */
  37953. getViewMatrix(): Matrix;
  37954. /**
  37955. * Gets the current projection matrix
  37956. * @returns a Matrix
  37957. */
  37958. getProjectionMatrix(): Matrix;
  37959. /**
  37960. * Gets the current transform matrix
  37961. * @returns a Matrix made of View * Projection
  37962. */
  37963. getTransformMatrix(): Matrix;
  37964. /**
  37965. * Sets the current transform matrix
  37966. * @param viewL defines the View matrix to use
  37967. * @param projectionL defines the Projection matrix to use
  37968. * @param viewR defines the right View matrix to use (if provided)
  37969. * @param projectionR defines the right Projection matrix to use (if provided)
  37970. */
  37971. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37972. /**
  37973. * Gets the uniform buffer used to store scene data
  37974. * @returns a UniformBuffer
  37975. */
  37976. getSceneUniformBuffer(): UniformBuffer;
  37977. /**
  37978. * Gets an unique (relatively to the current scene) Id
  37979. * @returns an unique number for the scene
  37980. */
  37981. getUniqueId(): number;
  37982. /**
  37983. * Add a mesh to the list of scene's meshes
  37984. * @param newMesh defines the mesh to add
  37985. * @param recursive if all child meshes should also be added to the scene
  37986. */
  37987. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37988. /**
  37989. * Remove a mesh for the list of scene's meshes
  37990. * @param toRemove defines the mesh to remove
  37991. * @param recursive if all child meshes should also be removed from the scene
  37992. * @returns the index where the mesh was in the mesh list
  37993. */
  37994. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37995. /**
  37996. * Add a transform node to the list of scene's transform nodes
  37997. * @param newTransformNode defines the transform node to add
  37998. */
  37999. addTransformNode(newTransformNode: TransformNode): void;
  38000. /**
  38001. * Remove a transform node for the list of scene's transform nodes
  38002. * @param toRemove defines the transform node to remove
  38003. * @returns the index where the transform node was in the transform node list
  38004. */
  38005. removeTransformNode(toRemove: TransformNode): number;
  38006. /**
  38007. * Remove a skeleton for the list of scene's skeletons
  38008. * @param toRemove defines the skeleton to remove
  38009. * @returns the index where the skeleton was in the skeleton list
  38010. */
  38011. removeSkeleton(toRemove: Skeleton): number;
  38012. /**
  38013. * Remove a morph target for the list of scene's morph targets
  38014. * @param toRemove defines the morph target to remove
  38015. * @returns the index where the morph target was in the morph target list
  38016. */
  38017. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  38018. /**
  38019. * Remove a light for the list of scene's lights
  38020. * @param toRemove defines the light to remove
  38021. * @returns the index where the light was in the light list
  38022. */
  38023. removeLight(toRemove: Light): number;
  38024. /**
  38025. * Remove a camera for the list of scene's cameras
  38026. * @param toRemove defines the camera to remove
  38027. * @returns the index where the camera was in the camera list
  38028. */
  38029. removeCamera(toRemove: Camera): number;
  38030. /**
  38031. * Remove a particle system for the list of scene's particle systems
  38032. * @param toRemove defines the particle system to remove
  38033. * @returns the index where the particle system was in the particle system list
  38034. */
  38035. removeParticleSystem(toRemove: IParticleSystem): number;
  38036. /**
  38037. * Remove a animation for the list of scene's animations
  38038. * @param toRemove defines the animation to remove
  38039. * @returns the index where the animation was in the animation list
  38040. */
  38041. removeAnimation(toRemove: Animation): number;
  38042. /**
  38043. * Will stop the animation of the given target
  38044. * @param target - the target
  38045. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  38046. * @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)
  38047. */
  38048. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  38049. /**
  38050. * Removes the given animation group from this scene.
  38051. * @param toRemove The animation group to remove
  38052. * @returns The index of the removed animation group
  38053. */
  38054. removeAnimationGroup(toRemove: AnimationGroup): number;
  38055. /**
  38056. * Removes the given multi-material from this scene.
  38057. * @param toRemove The multi-material to remove
  38058. * @returns The index of the removed multi-material
  38059. */
  38060. removeMultiMaterial(toRemove: MultiMaterial): number;
  38061. /**
  38062. * Removes the given material from this scene.
  38063. * @param toRemove The material to remove
  38064. * @returns The index of the removed material
  38065. */
  38066. removeMaterial(toRemove: Material): number;
  38067. /**
  38068. * Removes the given action manager from this scene.
  38069. * @param toRemove The action manager to remove
  38070. * @returns The index of the removed action manager
  38071. */
  38072. removeActionManager(toRemove: AbstractActionManager): number;
  38073. /**
  38074. * Removes the given texture from this scene.
  38075. * @param toRemove The texture to remove
  38076. * @returns The index of the removed texture
  38077. */
  38078. removeTexture(toRemove: BaseTexture): number;
  38079. /**
  38080. * Adds the given light to this scene
  38081. * @param newLight The light to add
  38082. */
  38083. addLight(newLight: Light): void;
  38084. /**
  38085. * Sorts the list list based on light priorities
  38086. */
  38087. sortLightsByPriority(): void;
  38088. /**
  38089. * Adds the given camera to this scene
  38090. * @param newCamera The camera to add
  38091. */
  38092. addCamera(newCamera: Camera): void;
  38093. /**
  38094. * Adds the given skeleton to this scene
  38095. * @param newSkeleton The skeleton to add
  38096. */
  38097. addSkeleton(newSkeleton: Skeleton): void;
  38098. /**
  38099. * Adds the given particle system to this scene
  38100. * @param newParticleSystem The particle system to add
  38101. */
  38102. addParticleSystem(newParticleSystem: IParticleSystem): void;
  38103. /**
  38104. * Adds the given animation to this scene
  38105. * @param newAnimation The animation to add
  38106. */
  38107. addAnimation(newAnimation: Animation): void;
  38108. /**
  38109. * Adds the given animation group to this scene.
  38110. * @param newAnimationGroup The animation group to add
  38111. */
  38112. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  38113. /**
  38114. * Adds the given multi-material to this scene
  38115. * @param newMultiMaterial The multi-material to add
  38116. */
  38117. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  38118. /**
  38119. * Adds the given material to this scene
  38120. * @param newMaterial The material to add
  38121. */
  38122. addMaterial(newMaterial: Material): void;
  38123. /**
  38124. * Adds the given morph target to this scene
  38125. * @param newMorphTargetManager The morph target to add
  38126. */
  38127. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  38128. /**
  38129. * Adds the given geometry to this scene
  38130. * @param newGeometry The geometry to add
  38131. */
  38132. addGeometry(newGeometry: Geometry): void;
  38133. /**
  38134. * Adds the given action manager to this scene
  38135. * @param newActionManager The action manager to add
  38136. */
  38137. addActionManager(newActionManager: AbstractActionManager): void;
  38138. /**
  38139. * Adds the given texture to this scene.
  38140. * @param newTexture The texture to add
  38141. */
  38142. addTexture(newTexture: BaseTexture): void;
  38143. /**
  38144. * Switch active camera
  38145. * @param newCamera defines the new active camera
  38146. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  38147. */
  38148. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  38149. /**
  38150. * sets the active camera of the scene using its ID
  38151. * @param id defines the camera's ID
  38152. * @return the new active camera or null if none found.
  38153. */
  38154. setActiveCameraByID(id: string): Nullable<Camera>;
  38155. /**
  38156. * sets the active camera of the scene using its name
  38157. * @param name defines the camera's name
  38158. * @returns the new active camera or null if none found.
  38159. */
  38160. setActiveCameraByName(name: string): Nullable<Camera>;
  38161. /**
  38162. * get an animation group using its name
  38163. * @param name defines the material's name
  38164. * @return the animation group or null if none found.
  38165. */
  38166. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  38167. /**
  38168. * Get a material using its unique id
  38169. * @param uniqueId defines the material's unique id
  38170. * @return the material or null if none found.
  38171. */
  38172. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38173. /**
  38174. * get a material using its id
  38175. * @param id defines the material's ID
  38176. * @return the material or null if none found.
  38177. */
  38178. getMaterialByID(id: string): Nullable<Material>;
  38179. /**
  38180. * Gets a the last added material using a given id
  38181. * @param id defines the material's ID
  38182. * @return the last material with the given id or null if none found.
  38183. */
  38184. getLastMaterialByID(id: string): Nullable<Material>;
  38185. /**
  38186. * Gets a material using its name
  38187. * @param name defines the material's name
  38188. * @return the material or null if none found.
  38189. */
  38190. getMaterialByName(name: string): Nullable<Material>;
  38191. /**
  38192. * Get a texture using its unique id
  38193. * @param uniqueId defines the texture's unique id
  38194. * @return the texture or null if none found.
  38195. */
  38196. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38197. /**
  38198. * Gets a camera using its id
  38199. * @param id defines the id to look for
  38200. * @returns the camera or null if not found
  38201. */
  38202. getCameraByID(id: string): Nullable<Camera>;
  38203. /**
  38204. * Gets a camera using its unique id
  38205. * @param uniqueId defines the unique id to look for
  38206. * @returns the camera or null if not found
  38207. */
  38208. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38209. /**
  38210. * Gets a camera using its name
  38211. * @param name defines the camera's name
  38212. * @return the camera or null if none found.
  38213. */
  38214. getCameraByName(name: string): Nullable<Camera>;
  38215. /**
  38216. * Gets a bone using its id
  38217. * @param id defines the bone's id
  38218. * @return the bone or null if not found
  38219. */
  38220. getBoneByID(id: string): Nullable<Bone>;
  38221. /**
  38222. * Gets a bone using its id
  38223. * @param name defines the bone's name
  38224. * @return the bone or null if not found
  38225. */
  38226. getBoneByName(name: string): Nullable<Bone>;
  38227. /**
  38228. * Gets a light node using its name
  38229. * @param name defines the the light's name
  38230. * @return the light or null if none found.
  38231. */
  38232. getLightByName(name: string): Nullable<Light>;
  38233. /**
  38234. * Gets a light node using its id
  38235. * @param id defines the light's id
  38236. * @return the light or null if none found.
  38237. */
  38238. getLightByID(id: string): Nullable<Light>;
  38239. /**
  38240. * Gets a light node using its scene-generated unique ID
  38241. * @param uniqueId defines the light's unique id
  38242. * @return the light or null if none found.
  38243. */
  38244. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38245. /**
  38246. * Gets a particle system by id
  38247. * @param id defines the particle system id
  38248. * @return the corresponding system or null if none found
  38249. */
  38250. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38251. /**
  38252. * Gets a geometry using its ID
  38253. * @param id defines the geometry's id
  38254. * @return the geometry or null if none found.
  38255. */
  38256. getGeometryByID(id: string): Nullable<Geometry>;
  38257. private _getGeometryByUniqueID;
  38258. /**
  38259. * Add a new geometry to this scene
  38260. * @param geometry defines the geometry to be added to the scene.
  38261. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38262. * @return a boolean defining if the geometry was added or not
  38263. */
  38264. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38265. /**
  38266. * Removes an existing geometry
  38267. * @param geometry defines the geometry to be removed from the scene
  38268. * @return a boolean defining if the geometry was removed or not
  38269. */
  38270. removeGeometry(geometry: Geometry): boolean;
  38271. /**
  38272. * Gets the list of geometries attached to the scene
  38273. * @returns an array of Geometry
  38274. */
  38275. getGeometries(): Geometry[];
  38276. /**
  38277. * Gets the first added mesh found of a given ID
  38278. * @param id defines the id to search for
  38279. * @return the mesh found or null if not found at all
  38280. */
  38281. getMeshByID(id: string): Nullable<AbstractMesh>;
  38282. /**
  38283. * Gets a list of meshes using their id
  38284. * @param id defines the id to search for
  38285. * @returns a list of meshes
  38286. */
  38287. getMeshesByID(id: string): Array<AbstractMesh>;
  38288. /**
  38289. * Gets the first added transform node found of a given ID
  38290. * @param id defines the id to search for
  38291. * @return the found transform node or null if not found at all.
  38292. */
  38293. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38294. /**
  38295. * Gets a transform node with its auto-generated unique id
  38296. * @param uniqueId efines the unique id to search for
  38297. * @return the found transform node or null if not found at all.
  38298. */
  38299. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38300. /**
  38301. * Gets a list of transform nodes using their id
  38302. * @param id defines the id to search for
  38303. * @returns a list of transform nodes
  38304. */
  38305. getTransformNodesByID(id: string): Array<TransformNode>;
  38306. /**
  38307. * Gets a mesh with its auto-generated unique id
  38308. * @param uniqueId defines the unique id to search for
  38309. * @return the found mesh or null if not found at all.
  38310. */
  38311. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38312. /**
  38313. * Gets a the last added mesh using a given id
  38314. * @param id defines the id to search for
  38315. * @return the found mesh or null if not found at all.
  38316. */
  38317. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38318. /**
  38319. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38320. * @param id defines the id to search for
  38321. * @return the found node or null if not found at all
  38322. */
  38323. getLastEntryByID(id: string): Nullable<Node>;
  38324. /**
  38325. * Gets a node (Mesh, Camera, Light) using a given id
  38326. * @param id defines the id to search for
  38327. * @return the found node or null if not found at all
  38328. */
  38329. getNodeByID(id: string): Nullable<Node>;
  38330. /**
  38331. * Gets a node (Mesh, Camera, Light) using a given name
  38332. * @param name defines the name to search for
  38333. * @return the found node or null if not found at all.
  38334. */
  38335. getNodeByName(name: string): Nullable<Node>;
  38336. /**
  38337. * Gets a mesh using a given name
  38338. * @param name defines the name to search for
  38339. * @return the found mesh or null if not found at all.
  38340. */
  38341. getMeshByName(name: string): Nullable<AbstractMesh>;
  38342. /**
  38343. * Gets a transform node using a given name
  38344. * @param name defines the name to search for
  38345. * @return the found transform node or null if not found at all.
  38346. */
  38347. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38348. /**
  38349. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38350. * @param id defines the id to search for
  38351. * @return the found skeleton or null if not found at all.
  38352. */
  38353. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38354. /**
  38355. * Gets a skeleton using a given auto generated unique id
  38356. * @param uniqueId defines the unique id to search for
  38357. * @return the found skeleton or null if not found at all.
  38358. */
  38359. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38360. /**
  38361. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38362. * @param id defines the id to search for
  38363. * @return the found skeleton or null if not found at all.
  38364. */
  38365. getSkeletonById(id: string): Nullable<Skeleton>;
  38366. /**
  38367. * Gets a skeleton using a given name
  38368. * @param name defines the name to search for
  38369. * @return the found skeleton or null if not found at all.
  38370. */
  38371. getSkeletonByName(name: string): Nullable<Skeleton>;
  38372. /**
  38373. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38374. * @param id defines the id to search for
  38375. * @return the found morph target manager or null if not found at all.
  38376. */
  38377. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38378. /**
  38379. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38380. * @param id defines the id to search for
  38381. * @return the found morph target or null if not found at all.
  38382. */
  38383. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38384. /**
  38385. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38386. * @param name defines the name to search for
  38387. * @return the found morph target or null if not found at all.
  38388. */
  38389. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38390. /**
  38391. * Gets a boolean indicating if the given mesh is active
  38392. * @param mesh defines the mesh to look for
  38393. * @returns true if the mesh is in the active list
  38394. */
  38395. isActiveMesh(mesh: AbstractMesh): boolean;
  38396. /**
  38397. * Return a unique id as a string which can serve as an identifier for the scene
  38398. */
  38399. get uid(): string;
  38400. /**
  38401. * Add an externaly attached data from its key.
  38402. * This method call will fail and return false, if such key already exists.
  38403. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38404. * @param key the unique key that identifies the data
  38405. * @param data the data object to associate to the key for this Engine instance
  38406. * @return true if no such key were already present and the data was added successfully, false otherwise
  38407. */
  38408. addExternalData<T>(key: string, data: T): boolean;
  38409. /**
  38410. * Get an externaly attached data from its key
  38411. * @param key the unique key that identifies the data
  38412. * @return the associated data, if present (can be null), or undefined if not present
  38413. */
  38414. getExternalData<T>(key: string): Nullable<T>;
  38415. /**
  38416. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38417. * @param key the unique key that identifies the data
  38418. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38419. * @return the associated data, can be null if the factory returned null.
  38420. */
  38421. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38422. /**
  38423. * Remove an externaly attached data from the Engine instance
  38424. * @param key the unique key that identifies the data
  38425. * @return true if the data was successfully removed, false if it doesn't exist
  38426. */
  38427. removeExternalData(key: string): boolean;
  38428. private _evaluateSubMesh;
  38429. /**
  38430. * Clear the processed materials smart array preventing retention point in material dispose.
  38431. */
  38432. freeProcessedMaterials(): void;
  38433. private _preventFreeActiveMeshesAndRenderingGroups;
  38434. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38435. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38436. * when disposing several meshes in a row or a hierarchy of meshes.
  38437. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38438. */
  38439. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38440. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38441. /**
  38442. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38443. */
  38444. freeActiveMeshes(): void;
  38445. /**
  38446. * Clear the info related to rendering groups preventing retention points during dispose.
  38447. */
  38448. freeRenderingGroups(): void;
  38449. /** @hidden */
  38450. _isInIntermediateRendering(): boolean;
  38451. /**
  38452. * Lambda returning the list of potentially active meshes.
  38453. */
  38454. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38455. /**
  38456. * Lambda returning the list of potentially active sub meshes.
  38457. */
  38458. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38459. /**
  38460. * Lambda returning the list of potentially intersecting sub meshes.
  38461. */
  38462. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38463. /**
  38464. * Lambda returning the list of potentially colliding sub meshes.
  38465. */
  38466. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38467. private _activeMeshesFrozen;
  38468. private _skipEvaluateActiveMeshesCompletely;
  38469. /**
  38470. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38471. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38472. * @returns the current scene
  38473. */
  38474. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38475. /**
  38476. * Use this function to restart evaluating active meshes on every frame
  38477. * @returns the current scene
  38478. */
  38479. unfreezeActiveMeshes(): Scene;
  38480. private _evaluateActiveMeshes;
  38481. private _activeMesh;
  38482. /**
  38483. * Update the transform matrix to update from the current active camera
  38484. * @param force defines a boolean used to force the update even if cache is up to date
  38485. */
  38486. updateTransformMatrix(force?: boolean): void;
  38487. private _bindFrameBuffer;
  38488. /** @hidden */
  38489. _allowPostProcessClearColor: boolean;
  38490. /** @hidden */
  38491. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38492. private _processSubCameras;
  38493. private _checkIntersections;
  38494. /** @hidden */
  38495. _advancePhysicsEngineStep(step: number): void;
  38496. /**
  38497. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38498. */
  38499. getDeterministicFrameTime: () => number;
  38500. /** @hidden */
  38501. _animate(): void;
  38502. /** Execute all animations (for a frame) */
  38503. animate(): void;
  38504. /**
  38505. * Render the scene
  38506. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38507. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38508. */
  38509. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38510. /**
  38511. * Freeze all materials
  38512. * A frozen material will not be updatable but should be faster to render
  38513. */
  38514. freezeMaterials(): void;
  38515. /**
  38516. * Unfreeze all materials
  38517. * A frozen material will not be updatable but should be faster to render
  38518. */
  38519. unfreezeMaterials(): void;
  38520. /**
  38521. * Releases all held ressources
  38522. */
  38523. dispose(): void;
  38524. /**
  38525. * Gets if the scene is already disposed
  38526. */
  38527. get isDisposed(): boolean;
  38528. /**
  38529. * Call this function to reduce memory footprint of the scene.
  38530. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38531. */
  38532. clearCachedVertexData(): void;
  38533. /**
  38534. * This function will remove the local cached buffer data from texture.
  38535. * It will save memory but will prevent the texture from being rebuilt
  38536. */
  38537. cleanCachedTextureBuffer(): void;
  38538. /**
  38539. * Get the world extend vectors with an optional filter
  38540. *
  38541. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38542. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38543. */
  38544. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38545. min: Vector3;
  38546. max: Vector3;
  38547. };
  38548. /**
  38549. * Creates a ray that can be used to pick in the scene
  38550. * @param x defines the x coordinate of the origin (on-screen)
  38551. * @param y defines the y coordinate of the origin (on-screen)
  38552. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38553. * @param camera defines the camera to use for the picking
  38554. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38555. * @returns a Ray
  38556. */
  38557. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38558. /**
  38559. * Creates a ray that can be used to pick in the scene
  38560. * @param x defines the x coordinate of the origin (on-screen)
  38561. * @param y defines the y coordinate of the origin (on-screen)
  38562. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38563. * @param result defines the ray where to store the picking ray
  38564. * @param camera defines the camera to use for the picking
  38565. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38566. * @returns the current scene
  38567. */
  38568. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38569. /**
  38570. * Creates a ray that can be used to pick in the scene
  38571. * @param x defines the x coordinate of the origin (on-screen)
  38572. * @param y defines the y coordinate of the origin (on-screen)
  38573. * @param camera defines the camera to use for the picking
  38574. * @returns a Ray
  38575. */
  38576. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38577. /**
  38578. * Creates a ray that can be used to pick in the scene
  38579. * @param x defines the x coordinate of the origin (on-screen)
  38580. * @param y defines the y coordinate of the origin (on-screen)
  38581. * @param result defines the ray where to store the picking ray
  38582. * @param camera defines the camera to use for the picking
  38583. * @returns the current scene
  38584. */
  38585. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38586. /** Launch a ray to try to pick a mesh in the scene
  38587. * @param x position on screen
  38588. * @param y position on screen
  38589. * @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
  38590. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38591. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38593. * @returns a PickingInfo
  38594. */
  38595. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38596. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38597. * @param x position on screen
  38598. * @param y position on screen
  38599. * @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
  38600. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38601. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38602. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  38603. */
  38604. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38605. /** Use the given ray to pick a mesh in the scene
  38606. * @param ray The ray to use to pick meshes
  38607. * @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
  38608. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38609. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38610. * @returns a PickingInfo
  38611. */
  38612. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38613. /**
  38614. * Launch a ray to try to pick a mesh in the scene
  38615. * @param x X position on screen
  38616. * @param y Y position on screen
  38617. * @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
  38618. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38619. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38620. * @returns an array of PickingInfo
  38621. */
  38622. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38623. /**
  38624. * Launch a ray to try to pick a mesh in the scene
  38625. * @param ray Ray to use
  38626. * @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
  38627. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38628. * @returns an array of PickingInfo
  38629. */
  38630. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38631. /**
  38632. * Force the value of meshUnderPointer
  38633. * @param mesh defines the mesh to use
  38634. */
  38635. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38636. /**
  38637. * Gets the mesh under the pointer
  38638. * @returns a Mesh or null if no mesh is under the pointer
  38639. */
  38640. getPointerOverMesh(): Nullable<AbstractMesh>;
  38641. /** @hidden */
  38642. _rebuildGeometries(): void;
  38643. /** @hidden */
  38644. _rebuildTextures(): void;
  38645. private _getByTags;
  38646. /**
  38647. * Get a list of meshes by tags
  38648. * @param tagsQuery defines the tags query to use
  38649. * @param forEach defines a predicate used to filter results
  38650. * @returns an array of Mesh
  38651. */
  38652. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38653. /**
  38654. * Get a list of cameras by tags
  38655. * @param tagsQuery defines the tags query to use
  38656. * @param forEach defines a predicate used to filter results
  38657. * @returns an array of Camera
  38658. */
  38659. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38660. /**
  38661. * Get a list of lights by tags
  38662. * @param tagsQuery defines the tags query to use
  38663. * @param forEach defines a predicate used to filter results
  38664. * @returns an array of Light
  38665. */
  38666. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38667. /**
  38668. * Get a list of materials by tags
  38669. * @param tagsQuery defines the tags query to use
  38670. * @param forEach defines a predicate used to filter results
  38671. * @returns an array of Material
  38672. */
  38673. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38674. /**
  38675. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38676. * This allowed control for front to back rendering or reversly depending of the special needs.
  38677. *
  38678. * @param renderingGroupId The rendering group id corresponding to its index
  38679. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38680. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38681. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38682. */
  38683. 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;
  38684. /**
  38685. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38686. *
  38687. * @param renderingGroupId The rendering group id corresponding to its index
  38688. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38689. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38690. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38691. */
  38692. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38693. /**
  38694. * Gets the current auto clear configuration for one rendering group of the rendering
  38695. * manager.
  38696. * @param index the rendering group index to get the information for
  38697. * @returns The auto clear setup for the requested rendering group
  38698. */
  38699. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38700. private _blockMaterialDirtyMechanism;
  38701. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38702. get blockMaterialDirtyMechanism(): boolean;
  38703. set blockMaterialDirtyMechanism(value: boolean);
  38704. /**
  38705. * Will flag all materials as dirty to trigger new shader compilation
  38706. * @param flag defines the flag used to specify which material part must be marked as dirty
  38707. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38708. */
  38709. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38710. /** @hidden */
  38711. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  38712. /** @hidden */
  38713. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38714. /** @hidden */
  38715. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  38716. /** @hidden */
  38717. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38718. /** @hidden */
  38719. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38720. /** @hidden */
  38721. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38722. }
  38723. }
  38724. declare module "babylonjs/assetContainer" {
  38725. import { AbstractScene } from "babylonjs/abstractScene";
  38726. import { Scene } from "babylonjs/scene";
  38727. import { Mesh } from "babylonjs/Meshes/mesh";
  38728. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38729. import { Skeleton } from "babylonjs/Bones/skeleton";
  38730. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38731. import { Animatable } from "babylonjs/Animations/animatable";
  38732. import { Nullable } from "babylonjs/types";
  38733. import { Node } from "babylonjs/node";
  38734. /**
  38735. * Set of assets to keep when moving a scene into an asset container.
  38736. */
  38737. export class KeepAssets extends AbstractScene {
  38738. }
  38739. /**
  38740. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38741. */
  38742. export class InstantiatedEntries {
  38743. /**
  38744. * List of new root nodes (eg. nodes with no parent)
  38745. */
  38746. rootNodes: TransformNode[];
  38747. /**
  38748. * List of new skeletons
  38749. */
  38750. skeletons: Skeleton[];
  38751. /**
  38752. * List of new animation groups
  38753. */
  38754. animationGroups: AnimationGroup[];
  38755. }
  38756. /**
  38757. * Container with a set of assets that can be added or removed from a scene.
  38758. */
  38759. export class AssetContainer extends AbstractScene {
  38760. private _wasAddedToScene;
  38761. /**
  38762. * The scene the AssetContainer belongs to.
  38763. */
  38764. scene: Scene;
  38765. /**
  38766. * Instantiates an AssetContainer.
  38767. * @param scene The scene the AssetContainer belongs to.
  38768. */
  38769. constructor(scene: Scene);
  38770. /**
  38771. * Instantiate or clone all meshes and add the new ones to the scene.
  38772. * Skeletons and animation groups will all be cloned
  38773. * @param nameFunction defines an optional function used to get new names for clones
  38774. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38775. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38776. */
  38777. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38778. /**
  38779. * Adds all the assets from the container to the scene.
  38780. */
  38781. addAllToScene(): void;
  38782. /**
  38783. * Removes all the assets in the container from the scene
  38784. */
  38785. removeAllFromScene(): void;
  38786. /**
  38787. * Disposes all the assets in the container
  38788. */
  38789. dispose(): void;
  38790. private _moveAssets;
  38791. /**
  38792. * Removes all the assets contained in the scene and adds them to the container.
  38793. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38794. */
  38795. moveAllFromScene(keepAssets?: KeepAssets): void;
  38796. /**
  38797. * 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.
  38798. * @returns the root mesh
  38799. */
  38800. createRootMesh(): Mesh;
  38801. /**
  38802. * Merge animations (direct and animation groups) from this asset container into a scene
  38803. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38804. * @param animatables set of animatables to retarget to a node from the scene
  38805. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38806. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  38807. */
  38808. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  38809. }
  38810. }
  38811. declare module "babylonjs/abstractScene" {
  38812. import { Scene } from "babylonjs/scene";
  38813. import { Nullable } from "babylonjs/types";
  38814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38815. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38816. import { Geometry } from "babylonjs/Meshes/geometry";
  38817. import { Skeleton } from "babylonjs/Bones/skeleton";
  38818. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38819. import { AssetContainer } from "babylonjs/assetContainer";
  38820. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38821. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38823. import { Material } from "babylonjs/Materials/material";
  38824. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38825. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38826. import { Camera } from "babylonjs/Cameras/camera";
  38827. import { Light } from "babylonjs/Lights/light";
  38828. import { Node } from "babylonjs/node";
  38829. import { Animation } from "babylonjs/Animations/animation";
  38830. /**
  38831. * Defines how the parser contract is defined.
  38832. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38833. */
  38834. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38835. /**
  38836. * Defines how the individual parser contract is defined.
  38837. * These parser can parse an individual asset
  38838. */
  38839. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38840. /**
  38841. * Base class of the scene acting as a container for the different elements composing a scene.
  38842. * This class is dynamically extended by the different components of the scene increasing
  38843. * flexibility and reducing coupling
  38844. */
  38845. export abstract class AbstractScene {
  38846. /**
  38847. * Stores the list of available parsers in the application.
  38848. */
  38849. private static _BabylonFileParsers;
  38850. /**
  38851. * Stores the list of available individual parsers in the application.
  38852. */
  38853. private static _IndividualBabylonFileParsers;
  38854. /**
  38855. * Adds a parser in the list of available ones
  38856. * @param name Defines the name of the parser
  38857. * @param parser Defines the parser to add
  38858. */
  38859. static AddParser(name: string, parser: BabylonFileParser): void;
  38860. /**
  38861. * Gets a general parser from the list of avaialble ones
  38862. * @param name Defines the name of the parser
  38863. * @returns the requested parser or null
  38864. */
  38865. static GetParser(name: string): Nullable<BabylonFileParser>;
  38866. /**
  38867. * Adds n individual parser in the list of available ones
  38868. * @param name Defines the name of the parser
  38869. * @param parser Defines the parser to add
  38870. */
  38871. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38872. /**
  38873. * Gets an individual parser from the list of avaialble ones
  38874. * @param name Defines the name of the parser
  38875. * @returns the requested parser or null
  38876. */
  38877. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38878. /**
  38879. * Parser json data and populate both a scene and its associated container object
  38880. * @param jsonData Defines the data to parse
  38881. * @param scene Defines the scene to parse the data for
  38882. * @param container Defines the container attached to the parsing sequence
  38883. * @param rootUrl Defines the root url of the data
  38884. */
  38885. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38886. /**
  38887. * Gets the list of root nodes (ie. nodes with no parent)
  38888. */
  38889. rootNodes: Node[];
  38890. /** All of the cameras added to this scene
  38891. * @see http://doc.babylonjs.com/babylon101/cameras
  38892. */
  38893. cameras: Camera[];
  38894. /**
  38895. * All of the lights added to this scene
  38896. * @see http://doc.babylonjs.com/babylon101/lights
  38897. */
  38898. lights: Light[];
  38899. /**
  38900. * All of the (abstract) meshes added to this scene
  38901. */
  38902. meshes: AbstractMesh[];
  38903. /**
  38904. * The list of skeletons added to the scene
  38905. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38906. */
  38907. skeletons: Skeleton[];
  38908. /**
  38909. * All of the particle systems added to this scene
  38910. * @see http://doc.babylonjs.com/babylon101/particles
  38911. */
  38912. particleSystems: IParticleSystem[];
  38913. /**
  38914. * Gets a list of Animations associated with the scene
  38915. */
  38916. animations: Animation[];
  38917. /**
  38918. * All of the animation groups added to this scene
  38919. * @see http://doc.babylonjs.com/how_to/group
  38920. */
  38921. animationGroups: AnimationGroup[];
  38922. /**
  38923. * All of the multi-materials added to this scene
  38924. * @see http://doc.babylonjs.com/how_to/multi_materials
  38925. */
  38926. multiMaterials: MultiMaterial[];
  38927. /**
  38928. * All of the materials added to this scene
  38929. * In the context of a Scene, it is not supposed to be modified manually.
  38930. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38931. * Note also that the order of the Material within the array is not significant and might change.
  38932. * @see http://doc.babylonjs.com/babylon101/materials
  38933. */
  38934. materials: Material[];
  38935. /**
  38936. * The list of morph target managers added to the scene
  38937. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38938. */
  38939. morphTargetManagers: MorphTargetManager[];
  38940. /**
  38941. * The list of geometries used in the scene.
  38942. */
  38943. geometries: Geometry[];
  38944. /**
  38945. * All of the tranform nodes added to this scene
  38946. * In the context of a Scene, it is not supposed to be modified manually.
  38947. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38948. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38949. * @see http://doc.babylonjs.com/how_to/transformnode
  38950. */
  38951. transformNodes: TransformNode[];
  38952. /**
  38953. * ActionManagers available on the scene.
  38954. */
  38955. actionManagers: AbstractActionManager[];
  38956. /**
  38957. * Textures to keep.
  38958. */
  38959. textures: BaseTexture[];
  38960. /**
  38961. * Environment texture for the scene
  38962. */
  38963. environmentTexture: Nullable<BaseTexture>;
  38964. /**
  38965. * @returns all meshes, lights, cameras, transformNodes and bones
  38966. */
  38967. getNodes(): Array<Node>;
  38968. }
  38969. }
  38970. declare module "babylonjs/Audio/sound" {
  38971. import { Observable } from "babylonjs/Misc/observable";
  38972. import { Vector3 } from "babylonjs/Maths/math.vector";
  38973. import { Nullable } from "babylonjs/types";
  38974. import { Scene } from "babylonjs/scene";
  38975. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38976. /**
  38977. * Interface used to define options for Sound class
  38978. */
  38979. export interface ISoundOptions {
  38980. /**
  38981. * Does the sound autoplay once loaded.
  38982. */
  38983. autoplay?: boolean;
  38984. /**
  38985. * Does the sound loop after it finishes playing once.
  38986. */
  38987. loop?: boolean;
  38988. /**
  38989. * Sound's volume
  38990. */
  38991. volume?: number;
  38992. /**
  38993. * Is it a spatial sound?
  38994. */
  38995. spatialSound?: boolean;
  38996. /**
  38997. * Maximum distance to hear that sound
  38998. */
  38999. maxDistance?: number;
  39000. /**
  39001. * Uses user defined attenuation function
  39002. */
  39003. useCustomAttenuation?: boolean;
  39004. /**
  39005. * Define the roll off factor of spatial sounds.
  39006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39007. */
  39008. rolloffFactor?: number;
  39009. /**
  39010. * Define the reference distance the sound should be heard perfectly.
  39011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39012. */
  39013. refDistance?: number;
  39014. /**
  39015. * Define the distance attenuation model the sound will follow.
  39016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39017. */
  39018. distanceModel?: string;
  39019. /**
  39020. * Defines the playback speed (1 by default)
  39021. */
  39022. playbackRate?: number;
  39023. /**
  39024. * Defines if the sound is from a streaming source
  39025. */
  39026. streaming?: boolean;
  39027. /**
  39028. * Defines an optional length (in seconds) inside the sound file
  39029. */
  39030. length?: number;
  39031. /**
  39032. * Defines an optional offset (in seconds) inside the sound file
  39033. */
  39034. offset?: number;
  39035. /**
  39036. * If true, URLs will not be required to state the audio file codec to use.
  39037. */
  39038. skipCodecCheck?: boolean;
  39039. }
  39040. /**
  39041. * Defines a sound that can be played in the application.
  39042. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  39043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39044. */
  39045. export class Sound {
  39046. /**
  39047. * The name of the sound in the scene.
  39048. */
  39049. name: string;
  39050. /**
  39051. * Does the sound autoplay once loaded.
  39052. */
  39053. autoplay: boolean;
  39054. /**
  39055. * Does the sound loop after it finishes playing once.
  39056. */
  39057. loop: boolean;
  39058. /**
  39059. * Does the sound use a custom attenuation curve to simulate the falloff
  39060. * happening when the source gets further away from the camera.
  39061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39062. */
  39063. useCustomAttenuation: boolean;
  39064. /**
  39065. * The sound track id this sound belongs to.
  39066. */
  39067. soundTrackId: number;
  39068. /**
  39069. * Is this sound currently played.
  39070. */
  39071. isPlaying: boolean;
  39072. /**
  39073. * Is this sound currently paused.
  39074. */
  39075. isPaused: boolean;
  39076. /**
  39077. * Does this sound enables spatial sound.
  39078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39079. */
  39080. spatialSound: boolean;
  39081. /**
  39082. * Define the reference distance the sound should be heard perfectly.
  39083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39084. */
  39085. refDistance: number;
  39086. /**
  39087. * Define the roll off factor of spatial sounds.
  39088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39089. */
  39090. rolloffFactor: number;
  39091. /**
  39092. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  39093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39094. */
  39095. maxDistance: number;
  39096. /**
  39097. * Define the distance attenuation model the sound will follow.
  39098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39099. */
  39100. distanceModel: string;
  39101. /**
  39102. * @hidden
  39103. * Back Compat
  39104. **/
  39105. onended: () => any;
  39106. /**
  39107. * Observable event when the current playing sound finishes.
  39108. */
  39109. onEndedObservable: Observable<Sound>;
  39110. private _panningModel;
  39111. private _playbackRate;
  39112. private _streaming;
  39113. private _startTime;
  39114. private _startOffset;
  39115. private _position;
  39116. /** @hidden */
  39117. _positionInEmitterSpace: boolean;
  39118. private _localDirection;
  39119. private _volume;
  39120. private _isReadyToPlay;
  39121. private _isDirectional;
  39122. private _readyToPlayCallback;
  39123. private _audioBuffer;
  39124. private _soundSource;
  39125. private _streamingSource;
  39126. private _soundPanner;
  39127. private _soundGain;
  39128. private _inputAudioNode;
  39129. private _outputAudioNode;
  39130. private _coneInnerAngle;
  39131. private _coneOuterAngle;
  39132. private _coneOuterGain;
  39133. private _scene;
  39134. private _connectedTransformNode;
  39135. private _customAttenuationFunction;
  39136. private _registerFunc;
  39137. private _isOutputConnected;
  39138. private _htmlAudioElement;
  39139. private _urlType;
  39140. private _length?;
  39141. private _offset?;
  39142. /** @hidden */
  39143. static _SceneComponentInitialization: (scene: Scene) => void;
  39144. /**
  39145. * Create a sound and attach it to a scene
  39146. * @param name Name of your sound
  39147. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  39148. * @param scene defines the scene the sound belongs to
  39149. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  39150. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  39151. */
  39152. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  39153. /**
  39154. * Release the sound and its associated resources
  39155. */
  39156. dispose(): void;
  39157. /**
  39158. * Gets if the sounds is ready to be played or not.
  39159. * @returns true if ready, otherwise false
  39160. */
  39161. isReady(): boolean;
  39162. private _soundLoaded;
  39163. /**
  39164. * Sets the data of the sound from an audiobuffer
  39165. * @param audioBuffer The audioBuffer containing the data
  39166. */
  39167. setAudioBuffer(audioBuffer: AudioBuffer): void;
  39168. /**
  39169. * Updates the current sounds options such as maxdistance, loop...
  39170. * @param options A JSON object containing values named as the object properties
  39171. */
  39172. updateOptions(options: ISoundOptions): void;
  39173. private _createSpatialParameters;
  39174. private _updateSpatialParameters;
  39175. /**
  39176. * Switch the panning model to HRTF:
  39177. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39179. */
  39180. switchPanningModelToHRTF(): void;
  39181. /**
  39182. * Switch the panning model to Equal Power:
  39183. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39185. */
  39186. switchPanningModelToEqualPower(): void;
  39187. private _switchPanningModel;
  39188. /**
  39189. * Connect this sound to a sound track audio node like gain...
  39190. * @param soundTrackAudioNode the sound track audio node to connect to
  39191. */
  39192. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39193. /**
  39194. * Transform this sound into a directional source
  39195. * @param coneInnerAngle Size of the inner cone in degree
  39196. * @param coneOuterAngle Size of the outer cone in degree
  39197. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39198. */
  39199. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39200. /**
  39201. * Gets or sets the inner angle for the directional cone.
  39202. */
  39203. get directionalConeInnerAngle(): number;
  39204. /**
  39205. * Gets or sets the inner angle for the directional cone.
  39206. */
  39207. set directionalConeInnerAngle(value: number);
  39208. /**
  39209. * Gets or sets the outer angle for the directional cone.
  39210. */
  39211. get directionalConeOuterAngle(): number;
  39212. /**
  39213. * Gets or sets the outer angle for the directional cone.
  39214. */
  39215. set directionalConeOuterAngle(value: number);
  39216. /**
  39217. * Sets the position of the emitter if spatial sound is enabled
  39218. * @param newPosition Defines the new posisiton
  39219. */
  39220. setPosition(newPosition: Vector3): void;
  39221. /**
  39222. * Sets the local direction of the emitter if spatial sound is enabled
  39223. * @param newLocalDirection Defines the new local direction
  39224. */
  39225. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39226. private _updateDirection;
  39227. /** @hidden */
  39228. updateDistanceFromListener(): void;
  39229. /**
  39230. * Sets a new custom attenuation function for the sound.
  39231. * @param callback Defines the function used for the attenuation
  39232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39233. */
  39234. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39235. /**
  39236. * Play the sound
  39237. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39238. * @param offset (optional) Start the sound at a specific time in seconds
  39239. * @param length (optional) Sound duration (in seconds)
  39240. */
  39241. play(time?: number, offset?: number, length?: number): void;
  39242. private _onended;
  39243. /**
  39244. * Stop the sound
  39245. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39246. */
  39247. stop(time?: number): void;
  39248. /**
  39249. * Put the sound in pause
  39250. */
  39251. pause(): void;
  39252. /**
  39253. * Sets a dedicated volume for this sounds
  39254. * @param newVolume Define the new volume of the sound
  39255. * @param time Define time for gradual change to new volume
  39256. */
  39257. setVolume(newVolume: number, time?: number): void;
  39258. /**
  39259. * Set the sound play back rate
  39260. * @param newPlaybackRate Define the playback rate the sound should be played at
  39261. */
  39262. setPlaybackRate(newPlaybackRate: number): void;
  39263. /**
  39264. * Gets the volume of the sound.
  39265. * @returns the volume of the sound
  39266. */
  39267. getVolume(): number;
  39268. /**
  39269. * Attach the sound to a dedicated mesh
  39270. * @param transformNode The transform node to connect the sound with
  39271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39272. */
  39273. attachToMesh(transformNode: TransformNode): void;
  39274. /**
  39275. * Detach the sound from the previously attached mesh
  39276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39277. */
  39278. detachFromMesh(): void;
  39279. private _onRegisterAfterWorldMatrixUpdate;
  39280. /**
  39281. * Clone the current sound in the scene.
  39282. * @returns the new sound clone
  39283. */
  39284. clone(): Nullable<Sound>;
  39285. /**
  39286. * Gets the current underlying audio buffer containing the data
  39287. * @returns the audio buffer
  39288. */
  39289. getAudioBuffer(): Nullable<AudioBuffer>;
  39290. /**
  39291. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39292. * @returns the source node
  39293. */
  39294. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39295. /**
  39296. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39297. * @returns the gain node
  39298. */
  39299. getSoundGain(): Nullable<GainNode>;
  39300. /**
  39301. * Serializes the Sound in a JSON representation
  39302. * @returns the JSON representation of the sound
  39303. */
  39304. serialize(): any;
  39305. /**
  39306. * Parse a JSON representation of a sound to innstantiate in a given scene
  39307. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39308. * @param scene Define the scene the new parsed sound should be created in
  39309. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39310. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39311. * @returns the newly parsed sound
  39312. */
  39313. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39314. }
  39315. }
  39316. declare module "babylonjs/Actions/directAudioActions" {
  39317. import { Action } from "babylonjs/Actions/action";
  39318. import { Condition } from "babylonjs/Actions/condition";
  39319. import { Sound } from "babylonjs/Audio/sound";
  39320. /**
  39321. * This defines an action helpful to play a defined sound on a triggered action.
  39322. */
  39323. export class PlaySoundAction extends Action {
  39324. private _sound;
  39325. /**
  39326. * Instantiate the action
  39327. * @param triggerOptions defines the trigger options
  39328. * @param sound defines the sound to play
  39329. * @param condition defines the trigger related conditions
  39330. */
  39331. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39332. /** @hidden */
  39333. _prepare(): void;
  39334. /**
  39335. * Execute the action and play the sound.
  39336. */
  39337. execute(): void;
  39338. /**
  39339. * Serializes the actions and its related information.
  39340. * @param parent defines the object to serialize in
  39341. * @returns the serialized object
  39342. */
  39343. serialize(parent: any): any;
  39344. }
  39345. /**
  39346. * This defines an action helpful to stop a defined sound on a triggered action.
  39347. */
  39348. export class StopSoundAction extends Action {
  39349. private _sound;
  39350. /**
  39351. * Instantiate the action
  39352. * @param triggerOptions defines the trigger options
  39353. * @param sound defines the sound to stop
  39354. * @param condition defines the trigger related conditions
  39355. */
  39356. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39357. /** @hidden */
  39358. _prepare(): void;
  39359. /**
  39360. * Execute the action and stop the sound.
  39361. */
  39362. execute(): void;
  39363. /**
  39364. * Serializes the actions and its related information.
  39365. * @param parent defines the object to serialize in
  39366. * @returns the serialized object
  39367. */
  39368. serialize(parent: any): any;
  39369. }
  39370. }
  39371. declare module "babylonjs/Actions/interpolateValueAction" {
  39372. import { Action } from "babylonjs/Actions/action";
  39373. import { Condition } from "babylonjs/Actions/condition";
  39374. import { Observable } from "babylonjs/Misc/observable";
  39375. /**
  39376. * This defines an action responsible to change the value of a property
  39377. * by interpolating between its current value and the newly set one once triggered.
  39378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39379. */
  39380. export class InterpolateValueAction extends Action {
  39381. /**
  39382. * Defines the path of the property where the value should be interpolated
  39383. */
  39384. propertyPath: string;
  39385. /**
  39386. * Defines the target value at the end of the interpolation.
  39387. */
  39388. value: any;
  39389. /**
  39390. * Defines the time it will take for the property to interpolate to the value.
  39391. */
  39392. duration: number;
  39393. /**
  39394. * Defines if the other scene animations should be stopped when the action has been triggered
  39395. */
  39396. stopOtherAnimations?: boolean;
  39397. /**
  39398. * Defines a callback raised once the interpolation animation has been done.
  39399. */
  39400. onInterpolationDone?: () => void;
  39401. /**
  39402. * Observable triggered once the interpolation animation has been done.
  39403. */
  39404. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39405. private _target;
  39406. private _effectiveTarget;
  39407. private _property;
  39408. /**
  39409. * Instantiate the action
  39410. * @param triggerOptions defines the trigger options
  39411. * @param target defines the object containing the value to interpolate
  39412. * @param propertyPath defines the path to the property in the target object
  39413. * @param value defines the target value at the end of the interpolation
  39414. * @param duration deines the time it will take for the property to interpolate to the value.
  39415. * @param condition defines the trigger related conditions
  39416. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39417. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39418. */
  39419. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39420. /** @hidden */
  39421. _prepare(): void;
  39422. /**
  39423. * Execute the action starts the value interpolation.
  39424. */
  39425. execute(): void;
  39426. /**
  39427. * Serializes the actions and its related information.
  39428. * @param parent defines the object to serialize in
  39429. * @returns the serialized object
  39430. */
  39431. serialize(parent: any): any;
  39432. }
  39433. }
  39434. declare module "babylonjs/Actions/index" {
  39435. export * from "babylonjs/Actions/abstractActionManager";
  39436. export * from "babylonjs/Actions/action";
  39437. export * from "babylonjs/Actions/actionEvent";
  39438. export * from "babylonjs/Actions/actionManager";
  39439. export * from "babylonjs/Actions/condition";
  39440. export * from "babylonjs/Actions/directActions";
  39441. export * from "babylonjs/Actions/directAudioActions";
  39442. export * from "babylonjs/Actions/interpolateValueAction";
  39443. }
  39444. declare module "babylonjs/Animations/index" {
  39445. export * from "babylonjs/Animations/animatable";
  39446. export * from "babylonjs/Animations/animation";
  39447. export * from "babylonjs/Animations/animationGroup";
  39448. export * from "babylonjs/Animations/animationPropertiesOverride";
  39449. export * from "babylonjs/Animations/easing";
  39450. export * from "babylonjs/Animations/runtimeAnimation";
  39451. export * from "babylonjs/Animations/animationEvent";
  39452. export * from "babylonjs/Animations/animationGroup";
  39453. export * from "babylonjs/Animations/animationKey";
  39454. export * from "babylonjs/Animations/animationRange";
  39455. export * from "babylonjs/Animations/animatable.interface";
  39456. }
  39457. declare module "babylonjs/Audio/soundTrack" {
  39458. import { Sound } from "babylonjs/Audio/sound";
  39459. import { Analyser } from "babylonjs/Audio/analyser";
  39460. import { Scene } from "babylonjs/scene";
  39461. /**
  39462. * Options allowed during the creation of a sound track.
  39463. */
  39464. export interface ISoundTrackOptions {
  39465. /**
  39466. * The volume the sound track should take during creation
  39467. */
  39468. volume?: number;
  39469. /**
  39470. * Define if the sound track is the main sound track of the scene
  39471. */
  39472. mainTrack?: boolean;
  39473. }
  39474. /**
  39475. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39476. * It will be also used in a future release to apply effects on a specific track.
  39477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39478. */
  39479. export class SoundTrack {
  39480. /**
  39481. * The unique identifier of the sound track in the scene.
  39482. */
  39483. id: number;
  39484. /**
  39485. * The list of sounds included in the sound track.
  39486. */
  39487. soundCollection: Array<Sound>;
  39488. private _outputAudioNode;
  39489. private _scene;
  39490. private _connectedAnalyser;
  39491. private _options;
  39492. private _isInitialized;
  39493. /**
  39494. * Creates a new sound track.
  39495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39496. * @param scene Define the scene the sound track belongs to
  39497. * @param options
  39498. */
  39499. constructor(scene: Scene, options?: ISoundTrackOptions);
  39500. private _initializeSoundTrackAudioGraph;
  39501. /**
  39502. * Release the sound track and its associated resources
  39503. */
  39504. dispose(): void;
  39505. /**
  39506. * Adds a sound to this sound track
  39507. * @param sound define the cound to add
  39508. * @ignoreNaming
  39509. */
  39510. AddSound(sound: Sound): void;
  39511. /**
  39512. * Removes a sound to this sound track
  39513. * @param sound define the cound to remove
  39514. * @ignoreNaming
  39515. */
  39516. RemoveSound(sound: Sound): void;
  39517. /**
  39518. * Set a global volume for the full sound track.
  39519. * @param newVolume Define the new volume of the sound track
  39520. */
  39521. setVolume(newVolume: number): void;
  39522. /**
  39523. * Switch the panning model to HRTF:
  39524. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39526. */
  39527. switchPanningModelToHRTF(): void;
  39528. /**
  39529. * Switch the panning model to Equal Power:
  39530. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39532. */
  39533. switchPanningModelToEqualPower(): void;
  39534. /**
  39535. * Connect the sound track to an audio analyser allowing some amazing
  39536. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39538. * @param analyser The analyser to connect to the engine
  39539. */
  39540. connectToAnalyser(analyser: Analyser): void;
  39541. }
  39542. }
  39543. declare module "babylonjs/Audio/audioSceneComponent" {
  39544. import { Sound } from "babylonjs/Audio/sound";
  39545. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39546. import { Nullable } from "babylonjs/types";
  39547. import { Vector3 } from "babylonjs/Maths/math.vector";
  39548. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39549. import { Scene } from "babylonjs/scene";
  39550. import { AbstractScene } from "babylonjs/abstractScene";
  39551. import "babylonjs/Audio/audioEngine";
  39552. module "babylonjs/abstractScene" {
  39553. interface AbstractScene {
  39554. /**
  39555. * The list of sounds used in the scene.
  39556. */
  39557. sounds: Nullable<Array<Sound>>;
  39558. }
  39559. }
  39560. module "babylonjs/scene" {
  39561. interface Scene {
  39562. /**
  39563. * @hidden
  39564. * Backing field
  39565. */
  39566. _mainSoundTrack: SoundTrack;
  39567. /**
  39568. * The main sound track played by the scene.
  39569. * It cotains your primary collection of sounds.
  39570. */
  39571. mainSoundTrack: SoundTrack;
  39572. /**
  39573. * The list of sound tracks added to the scene
  39574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39575. */
  39576. soundTracks: Nullable<Array<SoundTrack>>;
  39577. /**
  39578. * Gets a sound using a given name
  39579. * @param name defines the name to search for
  39580. * @return the found sound or null if not found at all.
  39581. */
  39582. getSoundByName(name: string): Nullable<Sound>;
  39583. /**
  39584. * Gets or sets if audio support is enabled
  39585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39586. */
  39587. audioEnabled: boolean;
  39588. /**
  39589. * Gets or sets if audio will be output to headphones
  39590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39591. */
  39592. headphone: boolean;
  39593. /**
  39594. * Gets or sets custom audio listener position provider
  39595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39596. */
  39597. audioListenerPositionProvider: Nullable<() => Vector3>;
  39598. /**
  39599. * Gets or sets a refresh rate when using 3D audio positioning
  39600. */
  39601. audioPositioningRefreshRate: number;
  39602. }
  39603. }
  39604. /**
  39605. * Defines the sound scene component responsible to manage any sounds
  39606. * in a given scene.
  39607. */
  39608. export class AudioSceneComponent implements ISceneSerializableComponent {
  39609. /**
  39610. * The component name helpfull to identify the component in the list of scene components.
  39611. */
  39612. readonly name: string;
  39613. /**
  39614. * The scene the component belongs to.
  39615. */
  39616. scene: Scene;
  39617. private _audioEnabled;
  39618. /**
  39619. * Gets whether audio is enabled or not.
  39620. * Please use related enable/disable method to switch state.
  39621. */
  39622. get audioEnabled(): boolean;
  39623. private _headphone;
  39624. /**
  39625. * Gets whether audio is outputing to headphone or not.
  39626. * Please use the according Switch methods to change output.
  39627. */
  39628. get headphone(): boolean;
  39629. /**
  39630. * Gets or sets a refresh rate when using 3D audio positioning
  39631. */
  39632. audioPositioningRefreshRate: number;
  39633. private _audioListenerPositionProvider;
  39634. /**
  39635. * Gets the current audio listener position provider
  39636. */
  39637. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39638. /**
  39639. * Sets a custom listener position for all sounds in the scene
  39640. * By default, this is the position of the first active camera
  39641. */
  39642. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39643. /**
  39644. * Creates a new instance of the component for the given scene
  39645. * @param scene Defines the scene to register the component in
  39646. */
  39647. constructor(scene: Scene);
  39648. /**
  39649. * Registers the component in a given scene
  39650. */
  39651. register(): void;
  39652. /**
  39653. * Rebuilds the elements related to this component in case of
  39654. * context lost for instance.
  39655. */
  39656. rebuild(): void;
  39657. /**
  39658. * Serializes the component data to the specified json object
  39659. * @param serializationObject The object to serialize to
  39660. */
  39661. serialize(serializationObject: any): void;
  39662. /**
  39663. * Adds all the elements from the container to the scene
  39664. * @param container the container holding the elements
  39665. */
  39666. addFromContainer(container: AbstractScene): void;
  39667. /**
  39668. * Removes all the elements in the container from the scene
  39669. * @param container contains the elements to remove
  39670. * @param dispose if the removed element should be disposed (default: false)
  39671. */
  39672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39673. /**
  39674. * Disposes the component and the associated ressources.
  39675. */
  39676. dispose(): void;
  39677. /**
  39678. * Disables audio in the associated scene.
  39679. */
  39680. disableAudio(): void;
  39681. /**
  39682. * Enables audio in the associated scene.
  39683. */
  39684. enableAudio(): void;
  39685. /**
  39686. * Switch audio to headphone output.
  39687. */
  39688. switchAudioModeForHeadphones(): void;
  39689. /**
  39690. * Switch audio to normal speakers.
  39691. */
  39692. switchAudioModeForNormalSpeakers(): void;
  39693. private _cachedCameraDirection;
  39694. private _cachedCameraPosition;
  39695. private _lastCheck;
  39696. private _afterRender;
  39697. }
  39698. }
  39699. declare module "babylonjs/Audio/weightedsound" {
  39700. import { Sound } from "babylonjs/Audio/sound";
  39701. /**
  39702. * Wraps one or more Sound objects and selects one with random weight for playback.
  39703. */
  39704. export class WeightedSound {
  39705. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39706. loop: boolean;
  39707. private _coneInnerAngle;
  39708. private _coneOuterAngle;
  39709. private _volume;
  39710. /** A Sound is currently playing. */
  39711. isPlaying: boolean;
  39712. /** A Sound is currently paused. */
  39713. isPaused: boolean;
  39714. private _sounds;
  39715. private _weights;
  39716. private _currentIndex?;
  39717. /**
  39718. * Creates a new WeightedSound from the list of sounds given.
  39719. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39720. * @param sounds Array of Sounds that will be selected from.
  39721. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39722. */
  39723. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39724. /**
  39725. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39726. */
  39727. get directionalConeInnerAngle(): number;
  39728. /**
  39729. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39730. */
  39731. set directionalConeInnerAngle(value: number);
  39732. /**
  39733. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39734. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39735. */
  39736. get directionalConeOuterAngle(): number;
  39737. /**
  39738. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39739. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39740. */
  39741. set directionalConeOuterAngle(value: number);
  39742. /**
  39743. * Playback volume.
  39744. */
  39745. get volume(): number;
  39746. /**
  39747. * Playback volume.
  39748. */
  39749. set volume(value: number);
  39750. private _onended;
  39751. /**
  39752. * Suspend playback
  39753. */
  39754. pause(): void;
  39755. /**
  39756. * Stop playback
  39757. */
  39758. stop(): void;
  39759. /**
  39760. * Start playback.
  39761. * @param startOffset Position the clip head at a specific time in seconds.
  39762. */
  39763. play(startOffset?: number): void;
  39764. }
  39765. }
  39766. declare module "babylonjs/Audio/index" {
  39767. export * from "babylonjs/Audio/analyser";
  39768. export * from "babylonjs/Audio/audioEngine";
  39769. export * from "babylonjs/Audio/audioSceneComponent";
  39770. export * from "babylonjs/Audio/sound";
  39771. export * from "babylonjs/Audio/soundTrack";
  39772. export * from "babylonjs/Audio/weightedsound";
  39773. }
  39774. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39775. import { Behavior } from "babylonjs/Behaviors/behavior";
  39776. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39777. import { BackEase } from "babylonjs/Animations/easing";
  39778. /**
  39779. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39781. */
  39782. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39783. /**
  39784. * Gets the name of the behavior.
  39785. */
  39786. get name(): string;
  39787. /**
  39788. * The easing function used by animations
  39789. */
  39790. static EasingFunction: BackEase;
  39791. /**
  39792. * The easing mode used by animations
  39793. */
  39794. static EasingMode: number;
  39795. /**
  39796. * The duration of the animation, in milliseconds
  39797. */
  39798. transitionDuration: number;
  39799. /**
  39800. * Length of the distance animated by the transition when lower radius is reached
  39801. */
  39802. lowerRadiusTransitionRange: number;
  39803. /**
  39804. * Length of the distance animated by the transition when upper radius is reached
  39805. */
  39806. upperRadiusTransitionRange: number;
  39807. private _autoTransitionRange;
  39808. /**
  39809. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39810. */
  39811. get autoTransitionRange(): boolean;
  39812. /**
  39813. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39814. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39815. */
  39816. set autoTransitionRange(value: boolean);
  39817. private _attachedCamera;
  39818. private _onAfterCheckInputsObserver;
  39819. private _onMeshTargetChangedObserver;
  39820. /**
  39821. * Initializes the behavior.
  39822. */
  39823. init(): void;
  39824. /**
  39825. * Attaches the behavior to its arc rotate camera.
  39826. * @param camera Defines the camera to attach the behavior to
  39827. */
  39828. attach(camera: ArcRotateCamera): void;
  39829. /**
  39830. * Detaches the behavior from its current arc rotate camera.
  39831. */
  39832. detach(): void;
  39833. private _radiusIsAnimating;
  39834. private _radiusBounceTransition;
  39835. private _animatables;
  39836. private _cachedWheelPrecision;
  39837. /**
  39838. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39839. * @param radiusLimit The limit to check against.
  39840. * @return Bool to indicate if at limit.
  39841. */
  39842. private _isRadiusAtLimit;
  39843. /**
  39844. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39845. * @param radiusDelta The delta by which to animate to. Can be negative.
  39846. */
  39847. private _applyBoundRadiusAnimation;
  39848. /**
  39849. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39850. */
  39851. protected _clearAnimationLocks(): void;
  39852. /**
  39853. * Stops and removes all animations that have been applied to the camera
  39854. */
  39855. stopAllAnimations(): void;
  39856. }
  39857. }
  39858. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39859. import { Behavior } from "babylonjs/Behaviors/behavior";
  39860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39861. import { ExponentialEase } from "babylonjs/Animations/easing";
  39862. import { Nullable } from "babylonjs/types";
  39863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39864. import { Vector3 } from "babylonjs/Maths/math.vector";
  39865. /**
  39866. * 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.
  39867. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39868. */
  39869. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39870. /**
  39871. * Gets the name of the behavior.
  39872. */
  39873. get name(): string;
  39874. private _mode;
  39875. private _radiusScale;
  39876. private _positionScale;
  39877. private _defaultElevation;
  39878. private _elevationReturnTime;
  39879. private _elevationReturnWaitTime;
  39880. private _zoomStopsAnimation;
  39881. private _framingTime;
  39882. /**
  39883. * The easing function used by animations
  39884. */
  39885. static EasingFunction: ExponentialEase;
  39886. /**
  39887. * The easing mode used by animations
  39888. */
  39889. static EasingMode: number;
  39890. /**
  39891. * Sets the current mode used by the behavior
  39892. */
  39893. set mode(mode: number);
  39894. /**
  39895. * Gets current mode used by the behavior.
  39896. */
  39897. get mode(): number;
  39898. /**
  39899. * Sets the scale applied to the radius (1 by default)
  39900. */
  39901. set radiusScale(radius: number);
  39902. /**
  39903. * Gets the scale applied to the radius
  39904. */
  39905. get radiusScale(): number;
  39906. /**
  39907. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39908. */
  39909. set positionScale(scale: number);
  39910. /**
  39911. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39912. */
  39913. get positionScale(): number;
  39914. /**
  39915. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39916. * behaviour is triggered, in radians.
  39917. */
  39918. set defaultElevation(elevation: number);
  39919. /**
  39920. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39921. * behaviour is triggered, in radians.
  39922. */
  39923. get defaultElevation(): number;
  39924. /**
  39925. * Sets the time (in milliseconds) taken to return to the default beta position.
  39926. * Negative value indicates camera should not return to default.
  39927. */
  39928. set elevationReturnTime(speed: number);
  39929. /**
  39930. * Gets the time (in milliseconds) taken to return to the default beta position.
  39931. * Negative value indicates camera should not return to default.
  39932. */
  39933. get elevationReturnTime(): number;
  39934. /**
  39935. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39936. */
  39937. set elevationReturnWaitTime(time: number);
  39938. /**
  39939. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39940. */
  39941. get elevationReturnWaitTime(): number;
  39942. /**
  39943. * Sets the flag that indicates if user zooming should stop animation.
  39944. */
  39945. set zoomStopsAnimation(flag: boolean);
  39946. /**
  39947. * Gets the flag that indicates if user zooming should stop animation.
  39948. */
  39949. get zoomStopsAnimation(): boolean;
  39950. /**
  39951. * Sets the transition time when framing the mesh, in milliseconds
  39952. */
  39953. set framingTime(time: number);
  39954. /**
  39955. * Gets the transition time when framing the mesh, in milliseconds
  39956. */
  39957. get framingTime(): number;
  39958. /**
  39959. * Define if the behavior should automatically change the configured
  39960. * camera limits and sensibilities.
  39961. */
  39962. autoCorrectCameraLimitsAndSensibility: boolean;
  39963. private _onPrePointerObservableObserver;
  39964. private _onAfterCheckInputsObserver;
  39965. private _onMeshTargetChangedObserver;
  39966. private _attachedCamera;
  39967. private _isPointerDown;
  39968. private _lastInteractionTime;
  39969. /**
  39970. * Initializes the behavior.
  39971. */
  39972. init(): void;
  39973. /**
  39974. * Attaches the behavior to its arc rotate camera.
  39975. * @param camera Defines the camera to attach the behavior to
  39976. */
  39977. attach(camera: ArcRotateCamera): void;
  39978. /**
  39979. * Detaches the behavior from its current arc rotate camera.
  39980. */
  39981. detach(): void;
  39982. private _animatables;
  39983. private _betaIsAnimating;
  39984. private _betaTransition;
  39985. private _radiusTransition;
  39986. private _vectorTransition;
  39987. /**
  39988. * Targets the given mesh and updates zoom level accordingly.
  39989. * @param mesh The mesh to target.
  39990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39992. */
  39993. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39994. /**
  39995. * Targets the given mesh with its children and updates zoom level accordingly.
  39996. * @param mesh The mesh to target.
  39997. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39998. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39999. */
  40000. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40001. /**
  40002. * Targets the given meshes with their children and updates zoom level accordingly.
  40003. * @param meshes The mesh to target.
  40004. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40005. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40006. */
  40007. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40008. /**
  40009. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40010. * @param minimumWorld Determines the smaller position of the bounding box extend
  40011. * @param maximumWorld Determines the bigger position of the bounding box extend
  40012. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40013. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40014. */
  40015. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40016. /**
  40017. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40018. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40019. * frustum width.
  40020. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40021. * to fully enclose the mesh in the viewing frustum.
  40022. */
  40023. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40024. /**
  40025. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40026. * is automatically returned to its default position (expected to be above ground plane).
  40027. */
  40028. private _maintainCameraAboveGround;
  40029. /**
  40030. * Returns the frustum slope based on the canvas ratio and camera FOV
  40031. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40032. */
  40033. private _getFrustumSlope;
  40034. /**
  40035. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40036. */
  40037. private _clearAnimationLocks;
  40038. /**
  40039. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40040. */
  40041. private _applyUserInteraction;
  40042. /**
  40043. * Stops and removes all animations that have been applied to the camera
  40044. */
  40045. stopAllAnimations(): void;
  40046. /**
  40047. * Gets a value indicating if the user is moving the camera
  40048. */
  40049. get isUserIsMoving(): boolean;
  40050. /**
  40051. * The camera can move all the way towards the mesh.
  40052. */
  40053. static IgnoreBoundsSizeMode: number;
  40054. /**
  40055. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40056. */
  40057. static FitFrustumSidesMode: number;
  40058. }
  40059. }
  40060. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  40061. import { Nullable } from "babylonjs/types";
  40062. import { Camera } from "babylonjs/Cameras/camera";
  40063. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40064. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40065. /**
  40066. * Base class for Camera Pointer Inputs.
  40067. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  40068. * for example usage.
  40069. */
  40070. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  40071. /**
  40072. * Defines the camera the input is attached to.
  40073. */
  40074. abstract camera: Camera;
  40075. /**
  40076. * Whether keyboard modifier keys are pressed at time of last mouse event.
  40077. */
  40078. protected _altKey: boolean;
  40079. protected _ctrlKey: boolean;
  40080. protected _metaKey: boolean;
  40081. protected _shiftKey: boolean;
  40082. /**
  40083. * Which mouse buttons were pressed at time of last mouse event.
  40084. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  40085. */
  40086. protected _buttonsPressed: number;
  40087. /**
  40088. * Defines the buttons associated with the input to handle camera move.
  40089. */
  40090. buttons: number[];
  40091. /**
  40092. * Attach the input controls to a specific dom element to get the input from.
  40093. * @param element Defines the element the controls should be listened from
  40094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40095. */
  40096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40097. /**
  40098. * Detach the current controls from the specified dom element.
  40099. * @param element Defines the element to stop listening the inputs from
  40100. */
  40101. detachControl(element: Nullable<HTMLElement>): void;
  40102. /**
  40103. * Gets the class name of the current input.
  40104. * @returns the class name
  40105. */
  40106. getClassName(): string;
  40107. /**
  40108. * Get the friendly name associated with the input class.
  40109. * @returns the input friendly name
  40110. */
  40111. getSimpleName(): string;
  40112. /**
  40113. * Called on pointer POINTERDOUBLETAP event.
  40114. * Override this method to provide functionality on POINTERDOUBLETAP event.
  40115. */
  40116. protected onDoubleTap(type: string): void;
  40117. /**
  40118. * Called on pointer POINTERMOVE event if only a single touch is active.
  40119. * Override this method to provide functionality.
  40120. */
  40121. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40122. /**
  40123. * Called on pointer POINTERMOVE event if multiple touches are active.
  40124. * Override this method to provide functionality.
  40125. */
  40126. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40127. /**
  40128. * Called on JS contextmenu event.
  40129. * Override this method to provide functionality.
  40130. */
  40131. protected onContextMenu(evt: PointerEvent): void;
  40132. /**
  40133. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40134. * press.
  40135. * Override this method to provide functionality.
  40136. */
  40137. protected onButtonDown(evt: PointerEvent): void;
  40138. /**
  40139. * Called each time a new POINTERUP event occurs. Ie, for each button
  40140. * release.
  40141. * Override this method to provide functionality.
  40142. */
  40143. protected onButtonUp(evt: PointerEvent): void;
  40144. /**
  40145. * Called when window becomes inactive.
  40146. * Override this method to provide functionality.
  40147. */
  40148. protected onLostFocus(): void;
  40149. private _pointerInput;
  40150. private _observer;
  40151. private _onLostFocus;
  40152. private pointA;
  40153. private pointB;
  40154. }
  40155. }
  40156. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  40157. import { Nullable } from "babylonjs/types";
  40158. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40159. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40160. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40161. /**
  40162. * Manage the pointers inputs to control an arc rotate camera.
  40163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40164. */
  40165. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  40166. /**
  40167. * Defines the camera the input is attached to.
  40168. */
  40169. camera: ArcRotateCamera;
  40170. /**
  40171. * Gets the class name of the current input.
  40172. * @returns the class name
  40173. */
  40174. getClassName(): string;
  40175. /**
  40176. * Defines the buttons associated with the input to handle camera move.
  40177. */
  40178. buttons: number[];
  40179. /**
  40180. * Defines the pointer angular sensibility along the X axis or how fast is
  40181. * the camera rotating.
  40182. */
  40183. angularSensibilityX: number;
  40184. /**
  40185. * Defines the pointer angular sensibility along the Y axis or how fast is
  40186. * the camera rotating.
  40187. */
  40188. angularSensibilityY: number;
  40189. /**
  40190. * Defines the pointer pinch precision or how fast is the camera zooming.
  40191. */
  40192. pinchPrecision: number;
  40193. /**
  40194. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40195. * from 0.
  40196. * It defines the percentage of current camera.radius to use as delta when
  40197. * pinch zoom is used.
  40198. */
  40199. pinchDeltaPercentage: number;
  40200. /**
  40201. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40202. * that any object in the plane at the camera's target point will scale
  40203. * perfectly with finger motion.
  40204. * Overrides pinchDeltaPercentage and pinchPrecision.
  40205. */
  40206. useNaturalPinchZoom: boolean;
  40207. /**
  40208. * Defines the pointer panning sensibility or how fast is the camera moving.
  40209. */
  40210. panningSensibility: number;
  40211. /**
  40212. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40213. */
  40214. multiTouchPanning: boolean;
  40215. /**
  40216. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40217. * zoom (pinch) through multitouch.
  40218. */
  40219. multiTouchPanAndZoom: boolean;
  40220. /**
  40221. * Revers pinch action direction.
  40222. */
  40223. pinchInwards: boolean;
  40224. private _isPanClick;
  40225. private _twoFingerActivityCount;
  40226. private _isPinching;
  40227. /**
  40228. * Called on pointer POINTERMOVE event if only a single touch is active.
  40229. */
  40230. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40231. /**
  40232. * Called on pointer POINTERDOUBLETAP event.
  40233. */
  40234. protected onDoubleTap(type: string): void;
  40235. /**
  40236. * Called on pointer POINTERMOVE event if multiple touches are active.
  40237. */
  40238. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40239. /**
  40240. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40241. * press.
  40242. */
  40243. protected onButtonDown(evt: PointerEvent): void;
  40244. /**
  40245. * Called each time a new POINTERUP event occurs. Ie, for each button
  40246. * release.
  40247. */
  40248. protected onButtonUp(evt: PointerEvent): void;
  40249. /**
  40250. * Called when window becomes inactive.
  40251. */
  40252. protected onLostFocus(): void;
  40253. }
  40254. }
  40255. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40256. import { Nullable } from "babylonjs/types";
  40257. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40259. /**
  40260. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40262. */
  40263. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40264. /**
  40265. * Defines the camera the input is attached to.
  40266. */
  40267. camera: ArcRotateCamera;
  40268. /**
  40269. * Defines the list of key codes associated with the up action (increase alpha)
  40270. */
  40271. keysUp: number[];
  40272. /**
  40273. * Defines the list of key codes associated with the down action (decrease alpha)
  40274. */
  40275. keysDown: number[];
  40276. /**
  40277. * Defines the list of key codes associated with the left action (increase beta)
  40278. */
  40279. keysLeft: number[];
  40280. /**
  40281. * Defines the list of key codes associated with the right action (decrease beta)
  40282. */
  40283. keysRight: number[];
  40284. /**
  40285. * Defines the list of key codes associated with the reset action.
  40286. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40287. */
  40288. keysReset: number[];
  40289. /**
  40290. * Defines the panning sensibility of the inputs.
  40291. * (How fast is the camera panning)
  40292. */
  40293. panningSensibility: number;
  40294. /**
  40295. * Defines the zooming sensibility of the inputs.
  40296. * (How fast is the camera zooming)
  40297. */
  40298. zoomingSensibility: number;
  40299. /**
  40300. * Defines whether maintaining the alt key down switch the movement mode from
  40301. * orientation to zoom.
  40302. */
  40303. useAltToZoom: boolean;
  40304. /**
  40305. * Rotation speed of the camera
  40306. */
  40307. angularSpeed: number;
  40308. private _keys;
  40309. private _ctrlPressed;
  40310. private _altPressed;
  40311. private _onCanvasBlurObserver;
  40312. private _onKeyboardObserver;
  40313. private _engine;
  40314. private _scene;
  40315. /**
  40316. * Attach the input controls to a specific dom element to get the input from.
  40317. * @param element Defines the element the controls should be listened from
  40318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40319. */
  40320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40321. /**
  40322. * Detach the current controls from the specified dom element.
  40323. * @param element Defines the element to stop listening the inputs from
  40324. */
  40325. detachControl(element: Nullable<HTMLElement>): void;
  40326. /**
  40327. * Update the current camera state depending on the inputs that have been used this frame.
  40328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40329. */
  40330. checkInputs(): void;
  40331. /**
  40332. * Gets the class name of the current intput.
  40333. * @returns the class name
  40334. */
  40335. getClassName(): string;
  40336. /**
  40337. * Get the friendly name associated with the input class.
  40338. * @returns the input friendly name
  40339. */
  40340. getSimpleName(): string;
  40341. }
  40342. }
  40343. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40344. import { Nullable } from "babylonjs/types";
  40345. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40346. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40347. /**
  40348. * Manage the mouse wheel inputs to control an arc rotate camera.
  40349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40350. */
  40351. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40352. /**
  40353. * Defines the camera the input is attached to.
  40354. */
  40355. camera: ArcRotateCamera;
  40356. /**
  40357. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40358. */
  40359. wheelPrecision: number;
  40360. /**
  40361. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40362. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40363. */
  40364. wheelDeltaPercentage: number;
  40365. private _wheel;
  40366. private _observer;
  40367. private computeDeltaFromMouseWheelLegacyEvent;
  40368. /**
  40369. * Attach the input controls to a specific dom element to get the input from.
  40370. * @param element Defines the element the controls should be listened from
  40371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40372. */
  40373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40374. /**
  40375. * Detach the current controls from the specified dom element.
  40376. * @param element Defines the element to stop listening the inputs from
  40377. */
  40378. detachControl(element: Nullable<HTMLElement>): void;
  40379. /**
  40380. * Gets the class name of the current intput.
  40381. * @returns the class name
  40382. */
  40383. getClassName(): string;
  40384. /**
  40385. * Get the friendly name associated with the input class.
  40386. * @returns the input friendly name
  40387. */
  40388. getSimpleName(): string;
  40389. }
  40390. }
  40391. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40393. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40394. /**
  40395. * Default Inputs manager for the ArcRotateCamera.
  40396. * It groups all the default supported inputs for ease of use.
  40397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40398. */
  40399. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40400. /**
  40401. * Instantiates a new ArcRotateCameraInputsManager.
  40402. * @param camera Defines the camera the inputs belong to
  40403. */
  40404. constructor(camera: ArcRotateCamera);
  40405. /**
  40406. * Add mouse wheel input support to the input manager.
  40407. * @returns the current input manager
  40408. */
  40409. addMouseWheel(): ArcRotateCameraInputsManager;
  40410. /**
  40411. * Add pointers input support to the input manager.
  40412. * @returns the current input manager
  40413. */
  40414. addPointers(): ArcRotateCameraInputsManager;
  40415. /**
  40416. * Add keyboard input support to the input manager.
  40417. * @returns the current input manager
  40418. */
  40419. addKeyboard(): ArcRotateCameraInputsManager;
  40420. }
  40421. }
  40422. declare module "babylonjs/Cameras/arcRotateCamera" {
  40423. import { Observable } from "babylonjs/Misc/observable";
  40424. import { Nullable } from "babylonjs/types";
  40425. import { Scene } from "babylonjs/scene";
  40426. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40428. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40429. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40430. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40431. import { Camera } from "babylonjs/Cameras/camera";
  40432. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40433. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40434. import { Collider } from "babylonjs/Collisions/collider";
  40435. /**
  40436. * This represents an orbital type of camera.
  40437. *
  40438. * 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.
  40439. * 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.
  40440. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40441. */
  40442. export class ArcRotateCamera extends TargetCamera {
  40443. /**
  40444. * Defines the rotation angle of the camera along the longitudinal axis.
  40445. */
  40446. alpha: number;
  40447. /**
  40448. * Defines the rotation angle of the camera along the latitudinal axis.
  40449. */
  40450. beta: number;
  40451. /**
  40452. * Defines the radius of the camera from it s target point.
  40453. */
  40454. radius: number;
  40455. protected _target: Vector3;
  40456. protected _targetHost: Nullable<AbstractMesh>;
  40457. /**
  40458. * Defines the target point of the camera.
  40459. * The camera looks towards it form the radius distance.
  40460. */
  40461. get target(): Vector3;
  40462. set target(value: Vector3);
  40463. /**
  40464. * Define the current local position of the camera in the scene
  40465. */
  40466. get position(): Vector3;
  40467. set position(newPosition: Vector3);
  40468. protected _upVector: Vector3;
  40469. protected _upToYMatrix: Matrix;
  40470. protected _YToUpMatrix: Matrix;
  40471. /**
  40472. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40473. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40474. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40475. */
  40476. set upVector(vec: Vector3);
  40477. get upVector(): Vector3;
  40478. /**
  40479. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40480. */
  40481. setMatUp(): void;
  40482. /**
  40483. * Current inertia value on the longitudinal axis.
  40484. * The bigger this number the longer it will take for the camera to stop.
  40485. */
  40486. inertialAlphaOffset: number;
  40487. /**
  40488. * Current inertia value on the latitudinal axis.
  40489. * The bigger this number the longer it will take for the camera to stop.
  40490. */
  40491. inertialBetaOffset: number;
  40492. /**
  40493. * Current inertia value on the radius axis.
  40494. * The bigger this number the longer it will take for the camera to stop.
  40495. */
  40496. inertialRadiusOffset: number;
  40497. /**
  40498. * Minimum allowed angle on the longitudinal axis.
  40499. * This can help limiting how the Camera is able to move in the scene.
  40500. */
  40501. lowerAlphaLimit: Nullable<number>;
  40502. /**
  40503. * Maximum allowed angle on the longitudinal axis.
  40504. * This can help limiting how the Camera is able to move in the scene.
  40505. */
  40506. upperAlphaLimit: Nullable<number>;
  40507. /**
  40508. * Minimum allowed angle on the latitudinal axis.
  40509. * This can help limiting how the Camera is able to move in the scene.
  40510. */
  40511. lowerBetaLimit: number;
  40512. /**
  40513. * Maximum allowed angle on the latitudinal axis.
  40514. * This can help limiting how the Camera is able to move in the scene.
  40515. */
  40516. upperBetaLimit: number;
  40517. /**
  40518. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40519. * This can help limiting how the Camera is able to move in the scene.
  40520. */
  40521. lowerRadiusLimit: Nullable<number>;
  40522. /**
  40523. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40524. * This can help limiting how the Camera is able to move in the scene.
  40525. */
  40526. upperRadiusLimit: Nullable<number>;
  40527. /**
  40528. * Defines the current inertia value used during panning of the camera along the X axis.
  40529. */
  40530. inertialPanningX: number;
  40531. /**
  40532. * Defines the current inertia value used during panning of the camera along the Y axis.
  40533. */
  40534. inertialPanningY: number;
  40535. /**
  40536. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40537. * Basically if your fingers moves away from more than this distance you will be considered
  40538. * in pinch mode.
  40539. */
  40540. pinchToPanMaxDistance: number;
  40541. /**
  40542. * Defines the maximum distance the camera can pan.
  40543. * This could help keeping the cammera always in your scene.
  40544. */
  40545. panningDistanceLimit: Nullable<number>;
  40546. /**
  40547. * Defines the target of the camera before paning.
  40548. */
  40549. panningOriginTarget: Vector3;
  40550. /**
  40551. * Defines the value of the inertia used during panning.
  40552. * 0 would mean stop inertia and one would mean no decelleration at all.
  40553. */
  40554. panningInertia: number;
  40555. /**
  40556. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40557. */
  40558. get angularSensibilityX(): number;
  40559. set angularSensibilityX(value: number);
  40560. /**
  40561. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40562. */
  40563. get angularSensibilityY(): number;
  40564. set angularSensibilityY(value: number);
  40565. /**
  40566. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40567. */
  40568. get pinchPrecision(): number;
  40569. set pinchPrecision(value: number);
  40570. /**
  40571. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40572. * It will be used instead of pinchDeltaPrecision if different from 0.
  40573. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40574. */
  40575. get pinchDeltaPercentage(): number;
  40576. set pinchDeltaPercentage(value: number);
  40577. /**
  40578. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40579. * and pinch delta percentage.
  40580. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40581. * that any object in the plane at the camera's target point will scale
  40582. * perfectly with finger motion.
  40583. */
  40584. get useNaturalPinchZoom(): boolean;
  40585. set useNaturalPinchZoom(value: boolean);
  40586. /**
  40587. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40588. */
  40589. get panningSensibility(): number;
  40590. set panningSensibility(value: number);
  40591. /**
  40592. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40593. */
  40594. get keysUp(): number[];
  40595. set keysUp(value: number[]);
  40596. /**
  40597. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40598. */
  40599. get keysDown(): number[];
  40600. set keysDown(value: number[]);
  40601. /**
  40602. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40603. */
  40604. get keysLeft(): number[];
  40605. set keysLeft(value: number[]);
  40606. /**
  40607. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40608. */
  40609. get keysRight(): number[];
  40610. set keysRight(value: number[]);
  40611. /**
  40612. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40613. */
  40614. get wheelPrecision(): number;
  40615. set wheelPrecision(value: number);
  40616. /**
  40617. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40618. * It will be used instead of pinchDeltaPrecision if different from 0.
  40619. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40620. */
  40621. get wheelDeltaPercentage(): number;
  40622. set wheelDeltaPercentage(value: number);
  40623. /**
  40624. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40625. */
  40626. zoomOnFactor: number;
  40627. /**
  40628. * Defines a screen offset for the camera position.
  40629. */
  40630. targetScreenOffset: Vector2;
  40631. /**
  40632. * Allows the camera to be completely reversed.
  40633. * If false the camera can not arrive upside down.
  40634. */
  40635. allowUpsideDown: boolean;
  40636. /**
  40637. * Define if double tap/click is used to restore the previously saved state of the camera.
  40638. */
  40639. useInputToRestoreState: boolean;
  40640. /** @hidden */
  40641. _viewMatrix: Matrix;
  40642. /** @hidden */
  40643. _useCtrlForPanning: boolean;
  40644. /** @hidden */
  40645. _panningMouseButton: number;
  40646. /**
  40647. * Defines the input associated to the camera.
  40648. */
  40649. inputs: ArcRotateCameraInputsManager;
  40650. /** @hidden */
  40651. _reset: () => void;
  40652. /**
  40653. * Defines the allowed panning axis.
  40654. */
  40655. panningAxis: Vector3;
  40656. protected _localDirection: Vector3;
  40657. protected _transformedDirection: Vector3;
  40658. private _bouncingBehavior;
  40659. /**
  40660. * Gets the bouncing behavior of the camera if it has been enabled.
  40661. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40662. */
  40663. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40664. /**
  40665. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40666. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40667. */
  40668. get useBouncingBehavior(): boolean;
  40669. set useBouncingBehavior(value: boolean);
  40670. private _framingBehavior;
  40671. /**
  40672. * Gets the framing behavior of the camera if it has been enabled.
  40673. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40674. */
  40675. get framingBehavior(): Nullable<FramingBehavior>;
  40676. /**
  40677. * Defines if the framing behavior of the camera is enabled on the camera.
  40678. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40679. */
  40680. get useFramingBehavior(): boolean;
  40681. set useFramingBehavior(value: boolean);
  40682. private _autoRotationBehavior;
  40683. /**
  40684. * Gets the auto rotation behavior of the camera if it has been enabled.
  40685. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40686. */
  40687. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40688. /**
  40689. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40690. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40691. */
  40692. get useAutoRotationBehavior(): boolean;
  40693. set useAutoRotationBehavior(value: boolean);
  40694. /**
  40695. * Observable triggered when the mesh target has been changed on the camera.
  40696. */
  40697. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40698. /**
  40699. * Event raised when the camera is colliding with a mesh.
  40700. */
  40701. onCollide: (collidedMesh: AbstractMesh) => void;
  40702. /**
  40703. * Defines whether the camera should check collision with the objects oh the scene.
  40704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40705. */
  40706. checkCollisions: boolean;
  40707. /**
  40708. * Defines the collision radius of the camera.
  40709. * This simulates a sphere around the camera.
  40710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40711. */
  40712. collisionRadius: Vector3;
  40713. protected _collider: Collider;
  40714. protected _previousPosition: Vector3;
  40715. protected _collisionVelocity: Vector3;
  40716. protected _newPosition: Vector3;
  40717. protected _previousAlpha: number;
  40718. protected _previousBeta: number;
  40719. protected _previousRadius: number;
  40720. protected _collisionTriggered: boolean;
  40721. protected _targetBoundingCenter: Nullable<Vector3>;
  40722. private _computationVector;
  40723. /**
  40724. * Instantiates a new ArcRotateCamera in a given scene
  40725. * @param name Defines the name of the camera
  40726. * @param alpha Defines the camera rotation along the logitudinal axis
  40727. * @param beta Defines the camera rotation along the latitudinal axis
  40728. * @param radius Defines the camera distance from its target
  40729. * @param target Defines the camera target
  40730. * @param scene Defines the scene the camera belongs to
  40731. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40732. */
  40733. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40734. /** @hidden */
  40735. _initCache(): void;
  40736. /** @hidden */
  40737. _updateCache(ignoreParentClass?: boolean): void;
  40738. protected _getTargetPosition(): Vector3;
  40739. private _storedAlpha;
  40740. private _storedBeta;
  40741. private _storedRadius;
  40742. private _storedTarget;
  40743. private _storedTargetScreenOffset;
  40744. /**
  40745. * Stores the current state of the camera (alpha, beta, radius and target)
  40746. * @returns the camera itself
  40747. */
  40748. storeState(): Camera;
  40749. /**
  40750. * @hidden
  40751. * Restored camera state. You must call storeState() first
  40752. */
  40753. _restoreStateValues(): boolean;
  40754. /** @hidden */
  40755. _isSynchronizedViewMatrix(): boolean;
  40756. /**
  40757. * Attached controls to the current camera.
  40758. * @param element Defines the element the controls should be listened from
  40759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40760. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40761. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40762. */
  40763. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40764. /**
  40765. * Detach the current controls from the camera.
  40766. * The camera will stop reacting to inputs.
  40767. * @param element Defines the element to stop listening the inputs from
  40768. */
  40769. detachControl(element: HTMLElement): void;
  40770. /** @hidden */
  40771. _checkInputs(): void;
  40772. protected _checkLimits(): void;
  40773. /**
  40774. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40775. */
  40776. rebuildAnglesAndRadius(): void;
  40777. /**
  40778. * Use a position to define the current camera related information like alpha, beta and radius
  40779. * @param position Defines the position to set the camera at
  40780. */
  40781. setPosition(position: Vector3): void;
  40782. /**
  40783. * Defines the target the camera should look at.
  40784. * This will automatically adapt alpha beta and radius to fit within the new target.
  40785. * @param target Defines the new target as a Vector or a mesh
  40786. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40787. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40788. */
  40789. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40790. /** @hidden */
  40791. _getViewMatrix(): Matrix;
  40792. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40793. /**
  40794. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40795. * @param meshes Defines the mesh to zoom on
  40796. * @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)
  40797. */
  40798. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40799. /**
  40800. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40801. * The target will be changed but the radius
  40802. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40803. * @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)
  40804. */
  40805. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40806. min: Vector3;
  40807. max: Vector3;
  40808. distance: number;
  40809. }, doNotUpdateMaxZ?: boolean): void;
  40810. /**
  40811. * @override
  40812. * Override Camera.createRigCamera
  40813. */
  40814. createRigCamera(name: string, cameraIndex: number): Camera;
  40815. /**
  40816. * @hidden
  40817. * @override
  40818. * Override Camera._updateRigCameras
  40819. */
  40820. _updateRigCameras(): void;
  40821. /**
  40822. * Destroy the camera and release the current resources hold by it.
  40823. */
  40824. dispose(): void;
  40825. /**
  40826. * Gets the current object class name.
  40827. * @return the class name
  40828. */
  40829. getClassName(): string;
  40830. }
  40831. }
  40832. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40833. import { Behavior } from "babylonjs/Behaviors/behavior";
  40834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40835. /**
  40836. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40837. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40838. */
  40839. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40840. /**
  40841. * Gets the name of the behavior.
  40842. */
  40843. get name(): string;
  40844. private _zoomStopsAnimation;
  40845. private _idleRotationSpeed;
  40846. private _idleRotationWaitTime;
  40847. private _idleRotationSpinupTime;
  40848. /**
  40849. * Sets the flag that indicates if user zooming should stop animation.
  40850. */
  40851. set zoomStopsAnimation(flag: boolean);
  40852. /**
  40853. * Gets the flag that indicates if user zooming should stop animation.
  40854. */
  40855. get zoomStopsAnimation(): boolean;
  40856. /**
  40857. * Sets the default speed at which the camera rotates around the model.
  40858. */
  40859. set idleRotationSpeed(speed: number);
  40860. /**
  40861. * Gets the default speed at which the camera rotates around the model.
  40862. */
  40863. get idleRotationSpeed(): number;
  40864. /**
  40865. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40866. */
  40867. set idleRotationWaitTime(time: number);
  40868. /**
  40869. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40870. */
  40871. get idleRotationWaitTime(): number;
  40872. /**
  40873. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40874. */
  40875. set idleRotationSpinupTime(time: number);
  40876. /**
  40877. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40878. */
  40879. get idleRotationSpinupTime(): number;
  40880. /**
  40881. * Gets a value indicating if the camera is currently rotating because of this behavior
  40882. */
  40883. get rotationInProgress(): boolean;
  40884. private _onPrePointerObservableObserver;
  40885. private _onAfterCheckInputsObserver;
  40886. private _attachedCamera;
  40887. private _isPointerDown;
  40888. private _lastFrameTime;
  40889. private _lastInteractionTime;
  40890. private _cameraRotationSpeed;
  40891. /**
  40892. * Initializes the behavior.
  40893. */
  40894. init(): void;
  40895. /**
  40896. * Attaches the behavior to its arc rotate camera.
  40897. * @param camera Defines the camera to attach the behavior to
  40898. */
  40899. attach(camera: ArcRotateCamera): void;
  40900. /**
  40901. * Detaches the behavior from its current arc rotate camera.
  40902. */
  40903. detach(): void;
  40904. /**
  40905. * Returns true if user is scrolling.
  40906. * @return true if user is scrolling.
  40907. */
  40908. private _userIsZooming;
  40909. private _lastFrameRadius;
  40910. private _shouldAnimationStopForInteraction;
  40911. /**
  40912. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40913. */
  40914. private _applyUserInteraction;
  40915. private _userIsMoving;
  40916. }
  40917. }
  40918. declare module "babylonjs/Behaviors/Cameras/index" {
  40919. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40920. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40921. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40922. }
  40923. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40924. import { Mesh } from "babylonjs/Meshes/mesh";
  40925. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40926. import { Behavior } from "babylonjs/Behaviors/behavior";
  40927. /**
  40928. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40929. */
  40930. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40931. private ui;
  40932. /**
  40933. * The name of the behavior
  40934. */
  40935. name: string;
  40936. /**
  40937. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40938. */
  40939. distanceAwayFromFace: number;
  40940. /**
  40941. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40942. */
  40943. distanceAwayFromBottomOfFace: number;
  40944. private _faceVectors;
  40945. private _target;
  40946. private _scene;
  40947. private _onRenderObserver;
  40948. private _tmpMatrix;
  40949. private _tmpVector;
  40950. /**
  40951. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40952. * @param ui The transform node that should be attched to the mesh
  40953. */
  40954. constructor(ui: TransformNode);
  40955. /**
  40956. * Initializes the behavior
  40957. */
  40958. init(): void;
  40959. private _closestFace;
  40960. private _zeroVector;
  40961. private _lookAtTmpMatrix;
  40962. private _lookAtToRef;
  40963. /**
  40964. * Attaches the AttachToBoxBehavior to the passed in mesh
  40965. * @param target The mesh that the specified node will be attached to
  40966. */
  40967. attach(target: Mesh): void;
  40968. /**
  40969. * Detaches the behavior from the mesh
  40970. */
  40971. detach(): void;
  40972. }
  40973. }
  40974. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40975. import { Behavior } from "babylonjs/Behaviors/behavior";
  40976. import { Mesh } from "babylonjs/Meshes/mesh";
  40977. /**
  40978. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40979. */
  40980. export class FadeInOutBehavior implements Behavior<Mesh> {
  40981. /**
  40982. * Time in milliseconds to delay before fading in (Default: 0)
  40983. */
  40984. delay: number;
  40985. /**
  40986. * Time in milliseconds for the mesh to fade in (Default: 300)
  40987. */
  40988. fadeInTime: number;
  40989. private _millisecondsPerFrame;
  40990. private _hovered;
  40991. private _hoverValue;
  40992. private _ownerNode;
  40993. /**
  40994. * Instatiates the FadeInOutBehavior
  40995. */
  40996. constructor();
  40997. /**
  40998. * The name of the behavior
  40999. */
  41000. get name(): string;
  41001. /**
  41002. * Initializes the behavior
  41003. */
  41004. init(): void;
  41005. /**
  41006. * Attaches the fade behavior on the passed in mesh
  41007. * @param ownerNode The mesh that will be faded in/out once attached
  41008. */
  41009. attach(ownerNode: Mesh): void;
  41010. /**
  41011. * Detaches the behavior from the mesh
  41012. */
  41013. detach(): void;
  41014. /**
  41015. * Triggers the mesh to begin fading in or out
  41016. * @param value if the object should fade in or out (true to fade in)
  41017. */
  41018. fadeIn(value: boolean): void;
  41019. private _update;
  41020. private _setAllVisibility;
  41021. }
  41022. }
  41023. declare module "babylonjs/Misc/pivotTools" {
  41024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41025. /**
  41026. * Class containing a set of static utilities functions for managing Pivots
  41027. * @hidden
  41028. */
  41029. export class PivotTools {
  41030. private static _PivotCached;
  41031. private static _OldPivotPoint;
  41032. private static _PivotTranslation;
  41033. private static _PivotTmpVector;
  41034. /** @hidden */
  41035. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  41036. /** @hidden */
  41037. static _RestorePivotPoint(mesh: AbstractMesh): void;
  41038. }
  41039. }
  41040. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  41041. import { Scene } from "babylonjs/scene";
  41042. import { Vector4 } from "babylonjs/Maths/math.vector";
  41043. import { Mesh } from "babylonjs/Meshes/mesh";
  41044. import { Nullable } from "babylonjs/types";
  41045. import { Plane } from "babylonjs/Maths/math.plane";
  41046. /**
  41047. * Class containing static functions to help procedurally build meshes
  41048. */
  41049. export class PlaneBuilder {
  41050. /**
  41051. * Creates a plane mesh
  41052. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  41053. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  41054. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  41055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41056. * * 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
  41057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41058. * @param name defines the name of the mesh
  41059. * @param options defines the options used to create the mesh
  41060. * @param scene defines the hosting scene
  41061. * @returns the plane mesh
  41062. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  41063. */
  41064. static CreatePlane(name: string, options: {
  41065. size?: number;
  41066. width?: number;
  41067. height?: number;
  41068. sideOrientation?: number;
  41069. frontUVs?: Vector4;
  41070. backUVs?: Vector4;
  41071. updatable?: boolean;
  41072. sourcePlane?: Plane;
  41073. }, scene?: Nullable<Scene>): Mesh;
  41074. }
  41075. }
  41076. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  41077. import { Behavior } from "babylonjs/Behaviors/behavior";
  41078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41079. import { Observable } from "babylonjs/Misc/observable";
  41080. import { Vector3 } from "babylonjs/Maths/math.vector";
  41081. import { Ray } from "babylonjs/Culling/ray";
  41082. import "babylonjs/Meshes/Builders/planeBuilder";
  41083. /**
  41084. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41085. */
  41086. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  41087. private static _AnyMouseID;
  41088. /**
  41089. * Abstract mesh the behavior is set on
  41090. */
  41091. attachedNode: AbstractMesh;
  41092. private _dragPlane;
  41093. private _scene;
  41094. private _pointerObserver;
  41095. private _beforeRenderObserver;
  41096. private static _planeScene;
  41097. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  41098. /**
  41099. * 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)
  41100. */
  41101. maxDragAngle: number;
  41102. /**
  41103. * @hidden
  41104. */
  41105. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41106. /**
  41107. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41108. */
  41109. currentDraggingPointerID: number;
  41110. /**
  41111. * The last position where the pointer hit the drag plane in world space
  41112. */
  41113. lastDragPosition: Vector3;
  41114. /**
  41115. * If the behavior is currently in a dragging state
  41116. */
  41117. dragging: boolean;
  41118. /**
  41119. * 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)
  41120. */
  41121. dragDeltaRatio: number;
  41122. /**
  41123. * If the drag plane orientation should be updated during the dragging (Default: true)
  41124. */
  41125. updateDragPlane: boolean;
  41126. private _debugMode;
  41127. private _moving;
  41128. /**
  41129. * Fires each time the attached mesh is dragged with the pointer
  41130. * * delta between last drag position and current drag position in world space
  41131. * * dragDistance along the drag axis
  41132. * * dragPlaneNormal normal of the current drag plane used during the drag
  41133. * * dragPlanePoint in world space where the drag intersects the drag plane
  41134. */
  41135. onDragObservable: Observable<{
  41136. delta: Vector3;
  41137. dragPlanePoint: Vector3;
  41138. dragPlaneNormal: Vector3;
  41139. dragDistance: number;
  41140. pointerId: number;
  41141. }>;
  41142. /**
  41143. * Fires each time a drag begins (eg. mouse down on mesh)
  41144. */
  41145. onDragStartObservable: Observable<{
  41146. dragPlanePoint: Vector3;
  41147. pointerId: number;
  41148. }>;
  41149. /**
  41150. * Fires each time a drag ends (eg. mouse release after drag)
  41151. */
  41152. onDragEndObservable: Observable<{
  41153. dragPlanePoint: Vector3;
  41154. pointerId: number;
  41155. }>;
  41156. /**
  41157. * If the attached mesh should be moved when dragged
  41158. */
  41159. moveAttached: boolean;
  41160. /**
  41161. * If the drag behavior will react to drag events (Default: true)
  41162. */
  41163. enabled: boolean;
  41164. /**
  41165. * If pointer events should start and release the drag (Default: true)
  41166. */
  41167. startAndReleaseDragOnPointerEvents: boolean;
  41168. /**
  41169. * If camera controls should be detached during the drag
  41170. */
  41171. detachCameraControls: boolean;
  41172. /**
  41173. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41174. */
  41175. useObjectOrientationForDragging: boolean;
  41176. private _options;
  41177. /**
  41178. * Gets the options used by the behavior
  41179. */
  41180. get options(): {
  41181. dragAxis?: Vector3;
  41182. dragPlaneNormal?: Vector3;
  41183. };
  41184. /**
  41185. * Sets the options used by the behavior
  41186. */
  41187. set options(options: {
  41188. dragAxis?: Vector3;
  41189. dragPlaneNormal?: Vector3;
  41190. });
  41191. /**
  41192. * Creates a pointer drag behavior that can be attached to a mesh
  41193. * @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)
  41194. */
  41195. constructor(options?: {
  41196. dragAxis?: Vector3;
  41197. dragPlaneNormal?: Vector3;
  41198. });
  41199. /**
  41200. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41201. */
  41202. validateDrag: (targetPosition: Vector3) => boolean;
  41203. /**
  41204. * The name of the behavior
  41205. */
  41206. get name(): string;
  41207. /**
  41208. * Initializes the behavior
  41209. */
  41210. init(): void;
  41211. private _tmpVector;
  41212. private _alternatePickedPoint;
  41213. private _worldDragAxis;
  41214. private _targetPosition;
  41215. private _attachedElement;
  41216. /**
  41217. * Attaches the drag behavior the passed in mesh
  41218. * @param ownerNode The mesh that will be dragged around once attached
  41219. * @param predicate Predicate to use for pick filtering
  41220. */
  41221. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41222. /**
  41223. * Force relase the drag action by code.
  41224. */
  41225. releaseDrag(): void;
  41226. private _startDragRay;
  41227. private _lastPointerRay;
  41228. /**
  41229. * Simulates the start of a pointer drag event on the behavior
  41230. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41231. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41232. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41233. */
  41234. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41235. private _startDrag;
  41236. private _dragDelta;
  41237. private _moveDrag;
  41238. private _pickWithRayOnDragPlane;
  41239. private _pointA;
  41240. private _pointB;
  41241. private _pointC;
  41242. private _lineA;
  41243. private _lineB;
  41244. private _localAxis;
  41245. private _lookAt;
  41246. private _updateDragPlanePosition;
  41247. /**
  41248. * Detaches the behavior from the mesh
  41249. */
  41250. detach(): void;
  41251. }
  41252. }
  41253. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41254. import { Mesh } from "babylonjs/Meshes/mesh";
  41255. import { Behavior } from "babylonjs/Behaviors/behavior";
  41256. /**
  41257. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41258. */
  41259. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41260. private _dragBehaviorA;
  41261. private _dragBehaviorB;
  41262. private _startDistance;
  41263. private _initialScale;
  41264. private _targetScale;
  41265. private _ownerNode;
  41266. private _sceneRenderObserver;
  41267. /**
  41268. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41269. */
  41270. constructor();
  41271. /**
  41272. * The name of the behavior
  41273. */
  41274. get name(): string;
  41275. /**
  41276. * Initializes the behavior
  41277. */
  41278. init(): void;
  41279. private _getCurrentDistance;
  41280. /**
  41281. * Attaches the scale behavior the passed in mesh
  41282. * @param ownerNode The mesh that will be scaled around once attached
  41283. */
  41284. attach(ownerNode: Mesh): void;
  41285. /**
  41286. * Detaches the behavior from the mesh
  41287. */
  41288. detach(): void;
  41289. }
  41290. }
  41291. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41292. import { Behavior } from "babylonjs/Behaviors/behavior";
  41293. import { Mesh } from "babylonjs/Meshes/mesh";
  41294. import { Observable } from "babylonjs/Misc/observable";
  41295. /**
  41296. * 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
  41297. */
  41298. export class SixDofDragBehavior implements Behavior<Mesh> {
  41299. private static _virtualScene;
  41300. private _ownerNode;
  41301. private _sceneRenderObserver;
  41302. private _scene;
  41303. private _targetPosition;
  41304. private _virtualOriginMesh;
  41305. private _virtualDragMesh;
  41306. private _pointerObserver;
  41307. private _moving;
  41308. private _startingOrientation;
  41309. private _attachedElement;
  41310. /**
  41311. * 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)
  41312. */
  41313. private zDragFactor;
  41314. /**
  41315. * If the object should rotate to face the drag origin
  41316. */
  41317. rotateDraggedObject: boolean;
  41318. /**
  41319. * If the behavior is currently in a dragging state
  41320. */
  41321. dragging: boolean;
  41322. /**
  41323. * 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)
  41324. */
  41325. dragDeltaRatio: number;
  41326. /**
  41327. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41328. */
  41329. currentDraggingPointerID: number;
  41330. /**
  41331. * If camera controls should be detached during the drag
  41332. */
  41333. detachCameraControls: boolean;
  41334. /**
  41335. * Fires each time a drag starts
  41336. */
  41337. onDragStartObservable: Observable<{}>;
  41338. /**
  41339. * Fires each time a drag ends (eg. mouse release after drag)
  41340. */
  41341. onDragEndObservable: Observable<{}>;
  41342. /**
  41343. * 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
  41344. */
  41345. constructor();
  41346. /**
  41347. * The name of the behavior
  41348. */
  41349. get name(): string;
  41350. /**
  41351. * Initializes the behavior
  41352. */
  41353. init(): void;
  41354. /**
  41355. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41356. */
  41357. private get _pointerCamera();
  41358. /**
  41359. * Attaches the scale behavior the passed in mesh
  41360. * @param ownerNode The mesh that will be scaled around once attached
  41361. */
  41362. attach(ownerNode: Mesh): void;
  41363. /**
  41364. * Detaches the behavior from the mesh
  41365. */
  41366. detach(): void;
  41367. }
  41368. }
  41369. declare module "babylonjs/Behaviors/Meshes/index" {
  41370. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41371. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41372. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41373. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41374. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41375. }
  41376. declare module "babylonjs/Behaviors/index" {
  41377. export * from "babylonjs/Behaviors/behavior";
  41378. export * from "babylonjs/Behaviors/Cameras/index";
  41379. export * from "babylonjs/Behaviors/Meshes/index";
  41380. }
  41381. declare module "babylonjs/Bones/boneIKController" {
  41382. import { Bone } from "babylonjs/Bones/bone";
  41383. import { Vector3 } from "babylonjs/Maths/math.vector";
  41384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41385. import { Nullable } from "babylonjs/types";
  41386. /**
  41387. * Class used to apply inverse kinematics to bones
  41388. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41389. */
  41390. export class BoneIKController {
  41391. private static _tmpVecs;
  41392. private static _tmpQuat;
  41393. private static _tmpMats;
  41394. /**
  41395. * Gets or sets the target mesh
  41396. */
  41397. targetMesh: AbstractMesh;
  41398. /** Gets or sets the mesh used as pole */
  41399. poleTargetMesh: AbstractMesh;
  41400. /**
  41401. * Gets or sets the bone used as pole
  41402. */
  41403. poleTargetBone: Nullable<Bone>;
  41404. /**
  41405. * Gets or sets the target position
  41406. */
  41407. targetPosition: Vector3;
  41408. /**
  41409. * Gets or sets the pole target position
  41410. */
  41411. poleTargetPosition: Vector3;
  41412. /**
  41413. * Gets or sets the pole target local offset
  41414. */
  41415. poleTargetLocalOffset: Vector3;
  41416. /**
  41417. * Gets or sets the pole angle
  41418. */
  41419. poleAngle: number;
  41420. /**
  41421. * Gets or sets the mesh associated with the controller
  41422. */
  41423. mesh: AbstractMesh;
  41424. /**
  41425. * 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)
  41426. */
  41427. slerpAmount: number;
  41428. private _bone1Quat;
  41429. private _bone1Mat;
  41430. private _bone2Ang;
  41431. private _bone1;
  41432. private _bone2;
  41433. private _bone1Length;
  41434. private _bone2Length;
  41435. private _maxAngle;
  41436. private _maxReach;
  41437. private _rightHandedSystem;
  41438. private _bendAxis;
  41439. private _slerping;
  41440. private _adjustRoll;
  41441. /**
  41442. * Gets or sets maximum allowed angle
  41443. */
  41444. get maxAngle(): number;
  41445. set maxAngle(value: number);
  41446. /**
  41447. * Creates a new BoneIKController
  41448. * @param mesh defines the mesh to control
  41449. * @param bone defines the bone to control
  41450. * @param options defines options to set up the controller
  41451. */
  41452. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41453. targetMesh?: AbstractMesh;
  41454. poleTargetMesh?: AbstractMesh;
  41455. poleTargetBone?: Bone;
  41456. poleTargetLocalOffset?: Vector3;
  41457. poleAngle?: number;
  41458. bendAxis?: Vector3;
  41459. maxAngle?: number;
  41460. slerpAmount?: number;
  41461. });
  41462. private _setMaxAngle;
  41463. /**
  41464. * Force the controller to update the bones
  41465. */
  41466. update(): void;
  41467. }
  41468. }
  41469. declare module "babylonjs/Bones/boneLookController" {
  41470. import { Vector3 } from "babylonjs/Maths/math.vector";
  41471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41472. import { Bone } from "babylonjs/Bones/bone";
  41473. import { Space } from "babylonjs/Maths/math.axis";
  41474. /**
  41475. * Class used to make a bone look toward a point in space
  41476. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41477. */
  41478. export class BoneLookController {
  41479. private static _tmpVecs;
  41480. private static _tmpQuat;
  41481. private static _tmpMats;
  41482. /**
  41483. * The target Vector3 that the bone will look at
  41484. */
  41485. target: Vector3;
  41486. /**
  41487. * The mesh that the bone is attached to
  41488. */
  41489. mesh: AbstractMesh;
  41490. /**
  41491. * The bone that will be looking to the target
  41492. */
  41493. bone: Bone;
  41494. /**
  41495. * The up axis of the coordinate system that is used when the bone is rotated
  41496. */
  41497. upAxis: Vector3;
  41498. /**
  41499. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41500. */
  41501. upAxisSpace: Space;
  41502. /**
  41503. * Used to make an adjustment to the yaw of the bone
  41504. */
  41505. adjustYaw: number;
  41506. /**
  41507. * Used to make an adjustment to the pitch of the bone
  41508. */
  41509. adjustPitch: number;
  41510. /**
  41511. * Used to make an adjustment to the roll of the bone
  41512. */
  41513. adjustRoll: number;
  41514. /**
  41515. * 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)
  41516. */
  41517. slerpAmount: number;
  41518. private _minYaw;
  41519. private _maxYaw;
  41520. private _minPitch;
  41521. private _maxPitch;
  41522. private _minYawSin;
  41523. private _minYawCos;
  41524. private _maxYawSin;
  41525. private _maxYawCos;
  41526. private _midYawConstraint;
  41527. private _minPitchTan;
  41528. private _maxPitchTan;
  41529. private _boneQuat;
  41530. private _slerping;
  41531. private _transformYawPitch;
  41532. private _transformYawPitchInv;
  41533. private _firstFrameSkipped;
  41534. private _yawRange;
  41535. private _fowardAxis;
  41536. /**
  41537. * Gets or sets the minimum yaw angle that the bone can look to
  41538. */
  41539. get minYaw(): number;
  41540. set minYaw(value: number);
  41541. /**
  41542. * Gets or sets the maximum yaw angle that the bone can look to
  41543. */
  41544. get maxYaw(): number;
  41545. set maxYaw(value: number);
  41546. /**
  41547. * Gets or sets the minimum pitch angle that the bone can look to
  41548. */
  41549. get minPitch(): number;
  41550. set minPitch(value: number);
  41551. /**
  41552. * Gets or sets the maximum pitch angle that the bone can look to
  41553. */
  41554. get maxPitch(): number;
  41555. set maxPitch(value: number);
  41556. /**
  41557. * Create a BoneLookController
  41558. * @param mesh the mesh that the bone belongs to
  41559. * @param bone the bone that will be looking to the target
  41560. * @param target the target Vector3 to look at
  41561. * @param options optional settings:
  41562. * * maxYaw: the maximum angle the bone will yaw to
  41563. * * minYaw: the minimum angle the bone will yaw to
  41564. * * maxPitch: the maximum angle the bone will pitch to
  41565. * * minPitch: the minimum angle the bone will yaw to
  41566. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41567. * * upAxis: the up axis of the coordinate system
  41568. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41569. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41570. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41571. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41572. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41573. * * adjustRoll: used to make an adjustment to the roll of the bone
  41574. **/
  41575. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41576. maxYaw?: number;
  41577. minYaw?: number;
  41578. maxPitch?: number;
  41579. minPitch?: number;
  41580. slerpAmount?: number;
  41581. upAxis?: Vector3;
  41582. upAxisSpace?: Space;
  41583. yawAxis?: Vector3;
  41584. pitchAxis?: Vector3;
  41585. adjustYaw?: number;
  41586. adjustPitch?: number;
  41587. adjustRoll?: number;
  41588. });
  41589. /**
  41590. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41591. */
  41592. update(): void;
  41593. private _getAngleDiff;
  41594. private _getAngleBetween;
  41595. private _isAngleBetween;
  41596. }
  41597. }
  41598. declare module "babylonjs/Bones/index" {
  41599. export * from "babylonjs/Bones/bone";
  41600. export * from "babylonjs/Bones/boneIKController";
  41601. export * from "babylonjs/Bones/boneLookController";
  41602. export * from "babylonjs/Bones/skeleton";
  41603. }
  41604. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41605. import { Nullable } from "babylonjs/types";
  41606. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41608. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41609. /**
  41610. * Manage the gamepad inputs to control an arc rotate camera.
  41611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41612. */
  41613. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41614. /**
  41615. * Defines the camera the input is attached to.
  41616. */
  41617. camera: ArcRotateCamera;
  41618. /**
  41619. * Defines the gamepad the input is gathering event from.
  41620. */
  41621. gamepad: Nullable<Gamepad>;
  41622. /**
  41623. * Defines the gamepad rotation sensiblity.
  41624. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41625. */
  41626. gamepadRotationSensibility: number;
  41627. /**
  41628. * Defines the gamepad move sensiblity.
  41629. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41630. */
  41631. gamepadMoveSensibility: number;
  41632. private _yAxisScale;
  41633. /**
  41634. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41635. */
  41636. get invertYAxis(): boolean;
  41637. set invertYAxis(value: boolean);
  41638. private _onGamepadConnectedObserver;
  41639. private _onGamepadDisconnectedObserver;
  41640. /**
  41641. * Attach the input controls to a specific dom element to get the input from.
  41642. * @param element Defines the element the controls should be listened from
  41643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41644. */
  41645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41646. /**
  41647. * Detach the current controls from the specified dom element.
  41648. * @param element Defines the element to stop listening the inputs from
  41649. */
  41650. detachControl(element: Nullable<HTMLElement>): void;
  41651. /**
  41652. * Update the current camera state depending on the inputs that have been used this frame.
  41653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41654. */
  41655. checkInputs(): void;
  41656. /**
  41657. * Gets the class name of the current intput.
  41658. * @returns the class name
  41659. */
  41660. getClassName(): string;
  41661. /**
  41662. * Get the friendly name associated with the input class.
  41663. * @returns the input friendly name
  41664. */
  41665. getSimpleName(): string;
  41666. }
  41667. }
  41668. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41669. import { Nullable } from "babylonjs/types";
  41670. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41671. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41672. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41673. interface ArcRotateCameraInputsManager {
  41674. /**
  41675. * Add orientation input support to the input manager.
  41676. * @returns the current input manager
  41677. */
  41678. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41679. }
  41680. }
  41681. /**
  41682. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41684. */
  41685. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41686. /**
  41687. * Defines the camera the input is attached to.
  41688. */
  41689. camera: ArcRotateCamera;
  41690. /**
  41691. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41692. */
  41693. alphaCorrection: number;
  41694. /**
  41695. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41696. */
  41697. gammaCorrection: number;
  41698. private _alpha;
  41699. private _gamma;
  41700. private _dirty;
  41701. private _deviceOrientationHandler;
  41702. /**
  41703. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41704. */
  41705. constructor();
  41706. /**
  41707. * Attach the input controls to a specific dom element to get the input from.
  41708. * @param element Defines the element the controls should be listened from
  41709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41710. */
  41711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41712. /** @hidden */
  41713. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41714. /**
  41715. * Update the current camera state depending on the inputs that have been used this frame.
  41716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41717. */
  41718. checkInputs(): void;
  41719. /**
  41720. * Detach the current controls from the specified dom element.
  41721. * @param element Defines the element to stop listening the inputs from
  41722. */
  41723. detachControl(element: Nullable<HTMLElement>): void;
  41724. /**
  41725. * Gets the class name of the current intput.
  41726. * @returns the class name
  41727. */
  41728. getClassName(): string;
  41729. /**
  41730. * Get the friendly name associated with the input class.
  41731. * @returns the input friendly name
  41732. */
  41733. getSimpleName(): string;
  41734. }
  41735. }
  41736. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41737. import { Nullable } from "babylonjs/types";
  41738. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41739. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41740. /**
  41741. * Listen to mouse events to control the camera.
  41742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41743. */
  41744. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41745. /**
  41746. * Defines the camera the input is attached to.
  41747. */
  41748. camera: FlyCamera;
  41749. /**
  41750. * Defines if touch is enabled. (Default is true.)
  41751. */
  41752. touchEnabled: boolean;
  41753. /**
  41754. * Defines the buttons associated with the input to handle camera rotation.
  41755. */
  41756. buttons: number[];
  41757. /**
  41758. * Assign buttons for Yaw control.
  41759. */
  41760. buttonsYaw: number[];
  41761. /**
  41762. * Assign buttons for Pitch control.
  41763. */
  41764. buttonsPitch: number[];
  41765. /**
  41766. * Assign buttons for Roll control.
  41767. */
  41768. buttonsRoll: number[];
  41769. /**
  41770. * Detect if any button is being pressed while mouse is moved.
  41771. * -1 = Mouse locked.
  41772. * 0 = Left button.
  41773. * 1 = Middle Button.
  41774. * 2 = Right Button.
  41775. */
  41776. activeButton: number;
  41777. /**
  41778. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41779. * Higher values reduce its sensitivity.
  41780. */
  41781. angularSensibility: number;
  41782. private _mousemoveCallback;
  41783. private _observer;
  41784. private _rollObserver;
  41785. private previousPosition;
  41786. private noPreventDefault;
  41787. private element;
  41788. /**
  41789. * Listen to mouse events to control the camera.
  41790. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41792. */
  41793. constructor(touchEnabled?: boolean);
  41794. /**
  41795. * Attach the mouse control to the HTML DOM element.
  41796. * @param element Defines the element that listens to the input events.
  41797. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41798. */
  41799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41800. /**
  41801. * Detach the current controls from the specified dom element.
  41802. * @param element Defines the element to stop listening the inputs from
  41803. */
  41804. detachControl(element: Nullable<HTMLElement>): void;
  41805. /**
  41806. * Gets the class name of the current input.
  41807. * @returns the class name.
  41808. */
  41809. getClassName(): string;
  41810. /**
  41811. * Get the friendly name associated with the input class.
  41812. * @returns the input's friendly name.
  41813. */
  41814. getSimpleName(): string;
  41815. private _pointerInput;
  41816. private _onMouseMove;
  41817. /**
  41818. * Rotate camera by mouse offset.
  41819. */
  41820. private rotateCamera;
  41821. }
  41822. }
  41823. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41824. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41825. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41826. /**
  41827. * Default Inputs manager for the FlyCamera.
  41828. * It groups all the default supported inputs for ease of use.
  41829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41830. */
  41831. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41832. /**
  41833. * Instantiates a new FlyCameraInputsManager.
  41834. * @param camera Defines the camera the inputs belong to.
  41835. */
  41836. constructor(camera: FlyCamera);
  41837. /**
  41838. * Add keyboard input support to the input manager.
  41839. * @returns the new FlyCameraKeyboardMoveInput().
  41840. */
  41841. addKeyboard(): FlyCameraInputsManager;
  41842. /**
  41843. * Add mouse input support to the input manager.
  41844. * @param touchEnabled Enable touch screen support.
  41845. * @returns the new FlyCameraMouseInput().
  41846. */
  41847. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41848. }
  41849. }
  41850. declare module "babylonjs/Cameras/flyCamera" {
  41851. import { Scene } from "babylonjs/scene";
  41852. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41854. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41855. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41856. /**
  41857. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41858. * such as in a 3D Space Shooter or a Flight Simulator.
  41859. */
  41860. export class FlyCamera extends TargetCamera {
  41861. /**
  41862. * Define the collision ellipsoid of the camera.
  41863. * This is helpful for simulating a camera body, like a player's body.
  41864. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41865. */
  41866. ellipsoid: Vector3;
  41867. /**
  41868. * Define an offset for the position of the ellipsoid around the camera.
  41869. * This can be helpful if the camera is attached away from the player's body center,
  41870. * such as at its head.
  41871. */
  41872. ellipsoidOffset: Vector3;
  41873. /**
  41874. * Enable or disable collisions of the camera with the rest of the scene objects.
  41875. */
  41876. checkCollisions: boolean;
  41877. /**
  41878. * Enable or disable gravity on the camera.
  41879. */
  41880. applyGravity: boolean;
  41881. /**
  41882. * Define the current direction the camera is moving to.
  41883. */
  41884. cameraDirection: Vector3;
  41885. /**
  41886. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41887. * This overrides and empties cameraRotation.
  41888. */
  41889. rotationQuaternion: Quaternion;
  41890. /**
  41891. * Track Roll to maintain the wanted Rolling when looking around.
  41892. */
  41893. _trackRoll: number;
  41894. /**
  41895. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41896. */
  41897. rollCorrect: number;
  41898. /**
  41899. * Mimic a banked turn, Rolling the camera when Yawing.
  41900. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41901. */
  41902. bankedTurn: boolean;
  41903. /**
  41904. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41905. */
  41906. bankedTurnLimit: number;
  41907. /**
  41908. * Value of 0 disables the banked Roll.
  41909. * Value of 1 is equal to the Yaw angle in radians.
  41910. */
  41911. bankedTurnMultiplier: number;
  41912. /**
  41913. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41914. */
  41915. inputs: FlyCameraInputsManager;
  41916. /**
  41917. * Gets the input sensibility for mouse input.
  41918. * Higher values reduce sensitivity.
  41919. */
  41920. get angularSensibility(): number;
  41921. /**
  41922. * Sets the input sensibility for a mouse input.
  41923. * Higher values reduce sensitivity.
  41924. */
  41925. set angularSensibility(value: number);
  41926. /**
  41927. * Get the keys for camera movement forward.
  41928. */
  41929. get keysForward(): number[];
  41930. /**
  41931. * Set the keys for camera movement forward.
  41932. */
  41933. set keysForward(value: number[]);
  41934. /**
  41935. * Get the keys for camera movement backward.
  41936. */
  41937. get keysBackward(): number[];
  41938. set keysBackward(value: number[]);
  41939. /**
  41940. * Get the keys for camera movement up.
  41941. */
  41942. get keysUp(): number[];
  41943. /**
  41944. * Set the keys for camera movement up.
  41945. */
  41946. set keysUp(value: number[]);
  41947. /**
  41948. * Get the keys for camera movement down.
  41949. */
  41950. get keysDown(): number[];
  41951. /**
  41952. * Set the keys for camera movement down.
  41953. */
  41954. set keysDown(value: number[]);
  41955. /**
  41956. * Get the keys for camera movement left.
  41957. */
  41958. get keysLeft(): number[];
  41959. /**
  41960. * Set the keys for camera movement left.
  41961. */
  41962. set keysLeft(value: number[]);
  41963. /**
  41964. * Set the keys for camera movement right.
  41965. */
  41966. get keysRight(): number[];
  41967. /**
  41968. * Set the keys for camera movement right.
  41969. */
  41970. set keysRight(value: number[]);
  41971. /**
  41972. * Event raised when the camera collides with a mesh in the scene.
  41973. */
  41974. onCollide: (collidedMesh: AbstractMesh) => void;
  41975. private _collider;
  41976. private _needMoveForGravity;
  41977. private _oldPosition;
  41978. private _diffPosition;
  41979. private _newPosition;
  41980. /** @hidden */
  41981. _localDirection: Vector3;
  41982. /** @hidden */
  41983. _transformedDirection: Vector3;
  41984. /**
  41985. * Instantiates a FlyCamera.
  41986. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41987. * such as in a 3D Space Shooter or a Flight Simulator.
  41988. * @param name Define the name of the camera in the scene.
  41989. * @param position Define the starting position of the camera in the scene.
  41990. * @param scene Define the scene the camera belongs to.
  41991. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41992. */
  41993. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41994. /**
  41995. * Attach a control to the HTML DOM element.
  41996. * @param element Defines the element that listens to the input events.
  41997. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41998. */
  41999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42000. /**
  42001. * Detach a control from the HTML DOM element.
  42002. * The camera will stop reacting to that input.
  42003. * @param element Defines the element that listens to the input events.
  42004. */
  42005. detachControl(element: HTMLElement): void;
  42006. private _collisionMask;
  42007. /**
  42008. * Get the mask that the camera ignores in collision events.
  42009. */
  42010. get collisionMask(): number;
  42011. /**
  42012. * Set the mask that the camera ignores in collision events.
  42013. */
  42014. set collisionMask(mask: number);
  42015. /** @hidden */
  42016. _collideWithWorld(displacement: Vector3): void;
  42017. /** @hidden */
  42018. private _onCollisionPositionChange;
  42019. /** @hidden */
  42020. _checkInputs(): void;
  42021. /** @hidden */
  42022. _decideIfNeedsToMove(): boolean;
  42023. /** @hidden */
  42024. _updatePosition(): void;
  42025. /**
  42026. * Restore the Roll to its target value at the rate specified.
  42027. * @param rate - Higher means slower restoring.
  42028. * @hidden
  42029. */
  42030. restoreRoll(rate: number): void;
  42031. /**
  42032. * Destroy the camera and release the current resources held by it.
  42033. */
  42034. dispose(): void;
  42035. /**
  42036. * Get the current object class name.
  42037. * @returns the class name.
  42038. */
  42039. getClassName(): string;
  42040. }
  42041. }
  42042. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  42043. import { Nullable } from "babylonjs/types";
  42044. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42045. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  42046. /**
  42047. * Listen to keyboard events to control the camera.
  42048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42049. */
  42050. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  42051. /**
  42052. * Defines the camera the input is attached to.
  42053. */
  42054. camera: FlyCamera;
  42055. /**
  42056. * The list of keyboard keys used to control the forward move of the camera.
  42057. */
  42058. keysForward: number[];
  42059. /**
  42060. * The list of keyboard keys used to control the backward move of the camera.
  42061. */
  42062. keysBackward: number[];
  42063. /**
  42064. * The list of keyboard keys used to control the forward move of the camera.
  42065. */
  42066. keysUp: number[];
  42067. /**
  42068. * The list of keyboard keys used to control the backward move of the camera.
  42069. */
  42070. keysDown: number[];
  42071. /**
  42072. * The list of keyboard keys used to control the right strafe move of the camera.
  42073. */
  42074. keysRight: number[];
  42075. /**
  42076. * The list of keyboard keys used to control the left strafe move of the camera.
  42077. */
  42078. keysLeft: number[];
  42079. private _keys;
  42080. private _onCanvasBlurObserver;
  42081. private _onKeyboardObserver;
  42082. private _engine;
  42083. private _scene;
  42084. /**
  42085. * Attach the input controls to a specific dom element to get the input from.
  42086. * @param element Defines the element the controls should be listened from
  42087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42088. */
  42089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42090. /**
  42091. * Detach the current controls from the specified dom element.
  42092. * @param element Defines the element to stop listening the inputs from
  42093. */
  42094. detachControl(element: Nullable<HTMLElement>): void;
  42095. /**
  42096. * Gets the class name of the current intput.
  42097. * @returns the class name
  42098. */
  42099. getClassName(): string;
  42100. /** @hidden */
  42101. _onLostFocus(e: FocusEvent): void;
  42102. /**
  42103. * Get the friendly name associated with the input class.
  42104. * @returns the input friendly name
  42105. */
  42106. getSimpleName(): string;
  42107. /**
  42108. * Update the current camera state depending on the inputs that have been used this frame.
  42109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42110. */
  42111. checkInputs(): void;
  42112. }
  42113. }
  42114. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  42115. import { Nullable } from "babylonjs/types";
  42116. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42118. /**
  42119. * Manage the mouse wheel inputs to control a follow camera.
  42120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42121. */
  42122. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  42123. /**
  42124. * Defines the camera the input is attached to.
  42125. */
  42126. camera: FollowCamera;
  42127. /**
  42128. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  42129. */
  42130. axisControlRadius: boolean;
  42131. /**
  42132. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  42133. */
  42134. axisControlHeight: boolean;
  42135. /**
  42136. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  42137. */
  42138. axisControlRotation: boolean;
  42139. /**
  42140. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  42141. * relation to mouseWheel events.
  42142. */
  42143. wheelPrecision: number;
  42144. /**
  42145. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42146. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42147. */
  42148. wheelDeltaPercentage: number;
  42149. private _wheel;
  42150. private _observer;
  42151. /**
  42152. * Attach the input controls to a specific dom element to get the input from.
  42153. * @param element Defines the element the controls should be listened from
  42154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42155. */
  42156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42157. /**
  42158. * Detach the current controls from the specified dom element.
  42159. * @param element Defines the element to stop listening the inputs from
  42160. */
  42161. detachControl(element: Nullable<HTMLElement>): void;
  42162. /**
  42163. * Gets the class name of the current intput.
  42164. * @returns the class name
  42165. */
  42166. getClassName(): string;
  42167. /**
  42168. * Get the friendly name associated with the input class.
  42169. * @returns the input friendly name
  42170. */
  42171. getSimpleName(): string;
  42172. }
  42173. }
  42174. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42175. import { Nullable } from "babylonjs/types";
  42176. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42177. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42178. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42179. /**
  42180. * Manage the pointers inputs to control an follow camera.
  42181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42182. */
  42183. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42184. /**
  42185. * Defines the camera the input is attached to.
  42186. */
  42187. camera: FollowCamera;
  42188. /**
  42189. * Gets the class name of the current input.
  42190. * @returns the class name
  42191. */
  42192. getClassName(): string;
  42193. /**
  42194. * Defines the pointer angular sensibility along the X axis or how fast is
  42195. * the camera rotating.
  42196. * A negative number will reverse the axis direction.
  42197. */
  42198. angularSensibilityX: number;
  42199. /**
  42200. * Defines the pointer angular sensibility along the Y axis or how fast is
  42201. * the camera rotating.
  42202. * A negative number will reverse the axis direction.
  42203. */
  42204. angularSensibilityY: number;
  42205. /**
  42206. * Defines the pointer pinch precision or how fast is the camera zooming.
  42207. * A negative number will reverse the axis direction.
  42208. */
  42209. pinchPrecision: number;
  42210. /**
  42211. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42212. * from 0.
  42213. * It defines the percentage of current camera.radius to use as delta when
  42214. * pinch zoom is used.
  42215. */
  42216. pinchDeltaPercentage: number;
  42217. /**
  42218. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42219. */
  42220. axisXControlRadius: boolean;
  42221. /**
  42222. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42223. */
  42224. axisXControlHeight: boolean;
  42225. /**
  42226. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42227. */
  42228. axisXControlRotation: boolean;
  42229. /**
  42230. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42231. */
  42232. axisYControlRadius: boolean;
  42233. /**
  42234. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42235. */
  42236. axisYControlHeight: boolean;
  42237. /**
  42238. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42239. */
  42240. axisYControlRotation: boolean;
  42241. /**
  42242. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42243. */
  42244. axisPinchControlRadius: boolean;
  42245. /**
  42246. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42247. */
  42248. axisPinchControlHeight: boolean;
  42249. /**
  42250. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42251. */
  42252. axisPinchControlRotation: boolean;
  42253. /**
  42254. * Log error messages if basic misconfiguration has occurred.
  42255. */
  42256. warningEnable: boolean;
  42257. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42258. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42259. private _warningCounter;
  42260. private _warning;
  42261. }
  42262. }
  42263. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42264. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42265. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42266. /**
  42267. * Default Inputs manager for the FollowCamera.
  42268. * It groups all the default supported inputs for ease of use.
  42269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42270. */
  42271. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42272. /**
  42273. * Instantiates a new FollowCameraInputsManager.
  42274. * @param camera Defines the camera the inputs belong to
  42275. */
  42276. constructor(camera: FollowCamera);
  42277. /**
  42278. * Add keyboard input support to the input manager.
  42279. * @returns the current input manager
  42280. */
  42281. addKeyboard(): FollowCameraInputsManager;
  42282. /**
  42283. * Add mouse wheel input support to the input manager.
  42284. * @returns the current input manager
  42285. */
  42286. addMouseWheel(): FollowCameraInputsManager;
  42287. /**
  42288. * Add pointers input support to the input manager.
  42289. * @returns the current input manager
  42290. */
  42291. addPointers(): FollowCameraInputsManager;
  42292. /**
  42293. * Add orientation input support to the input manager.
  42294. * @returns the current input manager
  42295. */
  42296. addVRDeviceOrientation(): FollowCameraInputsManager;
  42297. }
  42298. }
  42299. declare module "babylonjs/Cameras/followCamera" {
  42300. import { Nullable } from "babylonjs/types";
  42301. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42302. import { Scene } from "babylonjs/scene";
  42303. import { Vector3 } from "babylonjs/Maths/math.vector";
  42304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42305. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42306. /**
  42307. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42308. * an arc rotate version arcFollowCamera are available.
  42309. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42310. */
  42311. export class FollowCamera extends TargetCamera {
  42312. /**
  42313. * Distance the follow camera should follow an object at
  42314. */
  42315. radius: number;
  42316. /**
  42317. * Minimum allowed distance of the camera to the axis of rotation
  42318. * (The camera can not get closer).
  42319. * This can help limiting how the Camera is able to move in the scene.
  42320. */
  42321. lowerRadiusLimit: Nullable<number>;
  42322. /**
  42323. * Maximum allowed distance of the camera to the axis of rotation
  42324. * (The camera can not get further).
  42325. * This can help limiting how the Camera is able to move in the scene.
  42326. */
  42327. upperRadiusLimit: Nullable<number>;
  42328. /**
  42329. * Define a rotation offset between the camera and the object it follows
  42330. */
  42331. rotationOffset: number;
  42332. /**
  42333. * Minimum allowed angle to camera position relative to target object.
  42334. * This can help limiting how the Camera is able to move in the scene.
  42335. */
  42336. lowerRotationOffsetLimit: Nullable<number>;
  42337. /**
  42338. * Maximum allowed angle to camera position relative to target object.
  42339. * This can help limiting how the Camera is able to move in the scene.
  42340. */
  42341. upperRotationOffsetLimit: Nullable<number>;
  42342. /**
  42343. * Define a height offset between the camera and the object it follows.
  42344. * It can help following an object from the top (like a car chaing a plane)
  42345. */
  42346. heightOffset: number;
  42347. /**
  42348. * Minimum allowed height of camera position relative to target object.
  42349. * This can help limiting how the Camera is able to move in the scene.
  42350. */
  42351. lowerHeightOffsetLimit: Nullable<number>;
  42352. /**
  42353. * Maximum allowed height of camera position relative to target object.
  42354. * This can help limiting how the Camera is able to move in the scene.
  42355. */
  42356. upperHeightOffsetLimit: Nullable<number>;
  42357. /**
  42358. * Define how fast the camera can accelerate to follow it s target.
  42359. */
  42360. cameraAcceleration: number;
  42361. /**
  42362. * Define the speed limit of the camera following an object.
  42363. */
  42364. maxCameraSpeed: number;
  42365. /**
  42366. * Define the target of the camera.
  42367. */
  42368. lockedTarget: Nullable<AbstractMesh>;
  42369. /**
  42370. * Defines the input associated with the camera.
  42371. */
  42372. inputs: FollowCameraInputsManager;
  42373. /**
  42374. * Instantiates the follow camera.
  42375. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42376. * @param name Define the name of the camera in the scene
  42377. * @param position Define the position of the camera
  42378. * @param scene Define the scene the camera belong to
  42379. * @param lockedTarget Define the target of the camera
  42380. */
  42381. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42382. private _follow;
  42383. /**
  42384. * Attached controls to the current camera.
  42385. * @param element Defines the element the controls should be listened from
  42386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42387. */
  42388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42389. /**
  42390. * Detach the current controls from the camera.
  42391. * The camera will stop reacting to inputs.
  42392. * @param element Defines the element to stop listening the inputs from
  42393. */
  42394. detachControl(element: HTMLElement): void;
  42395. /** @hidden */
  42396. _checkInputs(): void;
  42397. private _checkLimits;
  42398. /**
  42399. * Gets the camera class name.
  42400. * @returns the class name
  42401. */
  42402. getClassName(): string;
  42403. }
  42404. /**
  42405. * Arc Rotate version of the follow camera.
  42406. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42407. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42408. */
  42409. export class ArcFollowCamera extends TargetCamera {
  42410. /** The longitudinal angle of the camera */
  42411. alpha: number;
  42412. /** The latitudinal angle of the camera */
  42413. beta: number;
  42414. /** The radius of the camera from its target */
  42415. radius: number;
  42416. /** Define the camera target (the messh it should follow) */
  42417. target: Nullable<AbstractMesh>;
  42418. private _cartesianCoordinates;
  42419. /**
  42420. * Instantiates a new ArcFollowCamera
  42421. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42422. * @param name Define the name of the camera
  42423. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42424. * @param beta Define the rotation angle of the camera around the elevation axis
  42425. * @param radius Define the radius of the camera from its target point
  42426. * @param target Define the target of the camera
  42427. * @param scene Define the scene the camera belongs to
  42428. */
  42429. constructor(name: string,
  42430. /** The longitudinal angle of the camera */
  42431. alpha: number,
  42432. /** The latitudinal angle of the camera */
  42433. beta: number,
  42434. /** The radius of the camera from its target */
  42435. radius: number,
  42436. /** Define the camera target (the messh it should follow) */
  42437. target: Nullable<AbstractMesh>, scene: Scene);
  42438. private _follow;
  42439. /** @hidden */
  42440. _checkInputs(): void;
  42441. /**
  42442. * Returns the class name of the object.
  42443. * It is mostly used internally for serialization purposes.
  42444. */
  42445. getClassName(): string;
  42446. }
  42447. }
  42448. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42449. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42450. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42451. import { Nullable } from "babylonjs/types";
  42452. /**
  42453. * Manage the keyboard inputs to control the movement of a follow camera.
  42454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42455. */
  42456. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42457. /**
  42458. * Defines the camera the input is attached to.
  42459. */
  42460. camera: FollowCamera;
  42461. /**
  42462. * Defines the list of key codes associated with the up action (increase heightOffset)
  42463. */
  42464. keysHeightOffsetIncr: number[];
  42465. /**
  42466. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42467. */
  42468. keysHeightOffsetDecr: number[];
  42469. /**
  42470. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42471. */
  42472. keysHeightOffsetModifierAlt: boolean;
  42473. /**
  42474. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42475. */
  42476. keysHeightOffsetModifierCtrl: boolean;
  42477. /**
  42478. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42479. */
  42480. keysHeightOffsetModifierShift: boolean;
  42481. /**
  42482. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42483. */
  42484. keysRotationOffsetIncr: number[];
  42485. /**
  42486. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42487. */
  42488. keysRotationOffsetDecr: number[];
  42489. /**
  42490. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42491. */
  42492. keysRotationOffsetModifierAlt: boolean;
  42493. /**
  42494. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42495. */
  42496. keysRotationOffsetModifierCtrl: boolean;
  42497. /**
  42498. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42499. */
  42500. keysRotationOffsetModifierShift: boolean;
  42501. /**
  42502. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42503. */
  42504. keysRadiusIncr: number[];
  42505. /**
  42506. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42507. */
  42508. keysRadiusDecr: number[];
  42509. /**
  42510. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42511. */
  42512. keysRadiusModifierAlt: boolean;
  42513. /**
  42514. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42515. */
  42516. keysRadiusModifierCtrl: boolean;
  42517. /**
  42518. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42519. */
  42520. keysRadiusModifierShift: boolean;
  42521. /**
  42522. * Defines the rate of change of heightOffset.
  42523. */
  42524. heightSensibility: number;
  42525. /**
  42526. * Defines the rate of change of rotationOffset.
  42527. */
  42528. rotationSensibility: number;
  42529. /**
  42530. * Defines the rate of change of radius.
  42531. */
  42532. radiusSensibility: number;
  42533. private _keys;
  42534. private _ctrlPressed;
  42535. private _altPressed;
  42536. private _shiftPressed;
  42537. private _onCanvasBlurObserver;
  42538. private _onKeyboardObserver;
  42539. private _engine;
  42540. private _scene;
  42541. /**
  42542. * Attach the input controls to a specific dom element to get the input from.
  42543. * @param element Defines the element the controls should be listened from
  42544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42545. */
  42546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42547. /**
  42548. * Detach the current controls from the specified dom element.
  42549. * @param element Defines the element to stop listening the inputs from
  42550. */
  42551. detachControl(element: Nullable<HTMLElement>): void;
  42552. /**
  42553. * Update the current camera state depending on the inputs that have been used this frame.
  42554. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42555. */
  42556. checkInputs(): void;
  42557. /**
  42558. * Gets the class name of the current input.
  42559. * @returns the class name
  42560. */
  42561. getClassName(): string;
  42562. /**
  42563. * Get the friendly name associated with the input class.
  42564. * @returns the input friendly name
  42565. */
  42566. getSimpleName(): string;
  42567. /**
  42568. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42569. * allow modification of the heightOffset value.
  42570. */
  42571. private _modifierHeightOffset;
  42572. /**
  42573. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42574. * allow modification of the rotationOffset value.
  42575. */
  42576. private _modifierRotationOffset;
  42577. /**
  42578. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42579. * allow modification of the radius value.
  42580. */
  42581. private _modifierRadius;
  42582. }
  42583. }
  42584. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42585. import { Nullable } from "babylonjs/types";
  42586. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42588. import { Observable } from "babylonjs/Misc/observable";
  42589. module "babylonjs/Cameras/freeCameraInputsManager" {
  42590. interface FreeCameraInputsManager {
  42591. /**
  42592. * @hidden
  42593. */
  42594. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42595. /**
  42596. * Add orientation input support to the input manager.
  42597. * @returns the current input manager
  42598. */
  42599. addDeviceOrientation(): FreeCameraInputsManager;
  42600. }
  42601. }
  42602. /**
  42603. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42604. * Screen rotation is taken into account.
  42605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42606. */
  42607. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42608. private _camera;
  42609. private _screenOrientationAngle;
  42610. private _constantTranform;
  42611. private _screenQuaternion;
  42612. private _alpha;
  42613. private _beta;
  42614. private _gamma;
  42615. /**
  42616. * Can be used to detect if a device orientation sensor is available on a device
  42617. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42618. * @returns a promise that will resolve on orientation change
  42619. */
  42620. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42621. /**
  42622. * @hidden
  42623. */
  42624. _onDeviceOrientationChangedObservable: Observable<void>;
  42625. /**
  42626. * Instantiates a new input
  42627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42628. */
  42629. constructor();
  42630. /**
  42631. * Define the camera controlled by the input.
  42632. */
  42633. get camera(): FreeCamera;
  42634. set camera(camera: FreeCamera);
  42635. /**
  42636. * Attach the input controls to a specific dom element to get the input from.
  42637. * @param element Defines the element the controls should be listened from
  42638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42639. */
  42640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42641. private _orientationChanged;
  42642. private _deviceOrientation;
  42643. /**
  42644. * Detach the current controls from the specified dom element.
  42645. * @param element Defines the element to stop listening the inputs from
  42646. */
  42647. detachControl(element: Nullable<HTMLElement>): void;
  42648. /**
  42649. * Update the current camera state depending on the inputs that have been used this frame.
  42650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42651. */
  42652. checkInputs(): void;
  42653. /**
  42654. * Gets the class name of the current intput.
  42655. * @returns the class name
  42656. */
  42657. getClassName(): string;
  42658. /**
  42659. * Get the friendly name associated with the input class.
  42660. * @returns the input friendly name
  42661. */
  42662. getSimpleName(): string;
  42663. }
  42664. }
  42665. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42666. import { Nullable } from "babylonjs/types";
  42667. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42668. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42669. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42670. /**
  42671. * Manage the gamepad inputs to control a free camera.
  42672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42673. */
  42674. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42675. /**
  42676. * Define the camera the input is attached to.
  42677. */
  42678. camera: FreeCamera;
  42679. /**
  42680. * Define the Gamepad controlling the input
  42681. */
  42682. gamepad: Nullable<Gamepad>;
  42683. /**
  42684. * Defines the gamepad rotation sensiblity.
  42685. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42686. */
  42687. gamepadAngularSensibility: number;
  42688. /**
  42689. * Defines the gamepad move sensiblity.
  42690. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42691. */
  42692. gamepadMoveSensibility: number;
  42693. private _yAxisScale;
  42694. /**
  42695. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42696. */
  42697. get invertYAxis(): boolean;
  42698. set invertYAxis(value: boolean);
  42699. private _onGamepadConnectedObserver;
  42700. private _onGamepadDisconnectedObserver;
  42701. private _cameraTransform;
  42702. private _deltaTransform;
  42703. private _vector3;
  42704. private _vector2;
  42705. /**
  42706. * Attach the input controls to a specific dom element to get the input from.
  42707. * @param element Defines the element the controls should be listened from
  42708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42709. */
  42710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42711. /**
  42712. * Detach the current controls from the specified dom element.
  42713. * @param element Defines the element to stop listening the inputs from
  42714. */
  42715. detachControl(element: Nullable<HTMLElement>): void;
  42716. /**
  42717. * Update the current camera state depending on the inputs that have been used this frame.
  42718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42719. */
  42720. checkInputs(): void;
  42721. /**
  42722. * Gets the class name of the current intput.
  42723. * @returns the class name
  42724. */
  42725. getClassName(): string;
  42726. /**
  42727. * Get the friendly name associated with the input class.
  42728. * @returns the input friendly name
  42729. */
  42730. getSimpleName(): string;
  42731. }
  42732. }
  42733. declare module "babylonjs/Misc/virtualJoystick" {
  42734. import { Nullable } from "babylonjs/types";
  42735. import { Vector3 } from "babylonjs/Maths/math.vector";
  42736. /**
  42737. * Defines the potential axis of a Joystick
  42738. */
  42739. export enum JoystickAxis {
  42740. /** X axis */
  42741. X = 0,
  42742. /** Y axis */
  42743. Y = 1,
  42744. /** Z axis */
  42745. Z = 2
  42746. }
  42747. /**
  42748. * Class used to define virtual joystick (used in touch mode)
  42749. */
  42750. export class VirtualJoystick {
  42751. /**
  42752. * Gets or sets a boolean indicating that left and right values must be inverted
  42753. */
  42754. reverseLeftRight: boolean;
  42755. /**
  42756. * Gets or sets a boolean indicating that up and down values must be inverted
  42757. */
  42758. reverseUpDown: boolean;
  42759. /**
  42760. * Gets the offset value for the position (ie. the change of the position value)
  42761. */
  42762. deltaPosition: Vector3;
  42763. /**
  42764. * Gets a boolean indicating if the virtual joystick was pressed
  42765. */
  42766. pressed: boolean;
  42767. /**
  42768. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42769. */
  42770. static Canvas: Nullable<HTMLCanvasElement>;
  42771. private static _globalJoystickIndex;
  42772. private static vjCanvasContext;
  42773. private static vjCanvasWidth;
  42774. private static vjCanvasHeight;
  42775. private static halfWidth;
  42776. private _action;
  42777. private _axisTargetedByLeftAndRight;
  42778. private _axisTargetedByUpAndDown;
  42779. private _joystickSensibility;
  42780. private _inversedSensibility;
  42781. private _joystickPointerID;
  42782. private _joystickColor;
  42783. private _joystickPointerPos;
  42784. private _joystickPreviousPointerPos;
  42785. private _joystickPointerStartPos;
  42786. private _deltaJoystickVector;
  42787. private _leftJoystick;
  42788. private _touches;
  42789. private _onPointerDownHandlerRef;
  42790. private _onPointerMoveHandlerRef;
  42791. private _onPointerUpHandlerRef;
  42792. private _onResize;
  42793. /**
  42794. * Creates a new virtual joystick
  42795. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42796. */
  42797. constructor(leftJoystick?: boolean);
  42798. /**
  42799. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42800. * @param newJoystickSensibility defines the new sensibility
  42801. */
  42802. setJoystickSensibility(newJoystickSensibility: number): void;
  42803. private _onPointerDown;
  42804. private _onPointerMove;
  42805. private _onPointerUp;
  42806. /**
  42807. * Change the color of the virtual joystick
  42808. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42809. */
  42810. setJoystickColor(newColor: string): void;
  42811. /**
  42812. * Defines a callback to call when the joystick is touched
  42813. * @param action defines the callback
  42814. */
  42815. setActionOnTouch(action: () => any): void;
  42816. /**
  42817. * Defines which axis you'd like to control for left & right
  42818. * @param axis defines the axis to use
  42819. */
  42820. setAxisForLeftRight(axis: JoystickAxis): void;
  42821. /**
  42822. * Defines which axis you'd like to control for up & down
  42823. * @param axis defines the axis to use
  42824. */
  42825. setAxisForUpDown(axis: JoystickAxis): void;
  42826. private _drawVirtualJoystick;
  42827. /**
  42828. * Release internal HTML canvas
  42829. */
  42830. releaseCanvas(): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42834. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42835. import { Nullable } from "babylonjs/types";
  42836. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42837. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42838. module "babylonjs/Cameras/freeCameraInputsManager" {
  42839. interface FreeCameraInputsManager {
  42840. /**
  42841. * Add virtual joystick input support to the input manager.
  42842. * @returns the current input manager
  42843. */
  42844. addVirtualJoystick(): FreeCameraInputsManager;
  42845. }
  42846. }
  42847. /**
  42848. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42850. */
  42851. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42852. /**
  42853. * Defines the camera the input is attached to.
  42854. */
  42855. camera: FreeCamera;
  42856. private _leftjoystick;
  42857. private _rightjoystick;
  42858. /**
  42859. * Gets the left stick of the virtual joystick.
  42860. * @returns The virtual Joystick
  42861. */
  42862. getLeftJoystick(): VirtualJoystick;
  42863. /**
  42864. * Gets the right stick of the virtual joystick.
  42865. * @returns The virtual Joystick
  42866. */
  42867. getRightJoystick(): VirtualJoystick;
  42868. /**
  42869. * Update the current camera state depending on the inputs that have been used this frame.
  42870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42871. */
  42872. checkInputs(): void;
  42873. /**
  42874. * Attach the input controls to a specific dom element to get the input from.
  42875. * @param element Defines the element the controls should be listened from
  42876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42877. */
  42878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42879. /**
  42880. * Detach the current controls from the specified dom element.
  42881. * @param element Defines the element to stop listening the inputs from
  42882. */
  42883. detachControl(element: Nullable<HTMLElement>): void;
  42884. /**
  42885. * Gets the class name of the current intput.
  42886. * @returns the class name
  42887. */
  42888. getClassName(): string;
  42889. /**
  42890. * Get the friendly name associated with the input class.
  42891. * @returns the input friendly name
  42892. */
  42893. getSimpleName(): string;
  42894. }
  42895. }
  42896. declare module "babylonjs/Cameras/Inputs/index" {
  42897. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42898. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42899. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42900. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42901. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42902. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42903. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42904. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42905. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42906. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42907. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42908. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42909. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42910. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42911. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42912. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42913. }
  42914. declare module "babylonjs/Cameras/touchCamera" {
  42915. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42916. import { Scene } from "babylonjs/scene";
  42917. import { Vector3 } from "babylonjs/Maths/math.vector";
  42918. /**
  42919. * This represents a FPS type of camera controlled by touch.
  42920. * This is like a universal camera minus the Gamepad controls.
  42921. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42922. */
  42923. export class TouchCamera extends FreeCamera {
  42924. /**
  42925. * Defines the touch sensibility for rotation.
  42926. * The higher the faster.
  42927. */
  42928. get touchAngularSensibility(): number;
  42929. set touchAngularSensibility(value: number);
  42930. /**
  42931. * Defines the touch sensibility for move.
  42932. * The higher the faster.
  42933. */
  42934. get touchMoveSensibility(): number;
  42935. set touchMoveSensibility(value: number);
  42936. /**
  42937. * Instantiates a new touch camera.
  42938. * This represents a FPS type of camera controlled by touch.
  42939. * This is like a universal camera minus the Gamepad controls.
  42940. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42941. * @param name Define the name of the camera in the scene
  42942. * @param position Define the start position of the camera in the scene
  42943. * @param scene Define the scene the camera belongs to
  42944. */
  42945. constructor(name: string, position: Vector3, scene: Scene);
  42946. /**
  42947. * Gets the current object class name.
  42948. * @return the class name
  42949. */
  42950. getClassName(): string;
  42951. /** @hidden */
  42952. _setupInputs(): void;
  42953. }
  42954. }
  42955. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42957. import { Scene } from "babylonjs/scene";
  42958. import { Vector3 } from "babylonjs/Maths/math.vector";
  42959. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42960. import { Axis } from "babylonjs/Maths/math.axis";
  42961. /**
  42962. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42963. * being tilted forward or back and left or right.
  42964. */
  42965. export class DeviceOrientationCamera extends FreeCamera {
  42966. private _initialQuaternion;
  42967. private _quaternionCache;
  42968. private _tmpDragQuaternion;
  42969. private _disablePointerInputWhenUsingDeviceOrientation;
  42970. /**
  42971. * Creates a new device orientation camera
  42972. * @param name The name of the camera
  42973. * @param position The start position camera
  42974. * @param scene The scene the camera belongs to
  42975. */
  42976. constructor(name: string, position: Vector3, scene: Scene);
  42977. /**
  42978. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42979. */
  42980. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42981. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42982. private _dragFactor;
  42983. /**
  42984. * Enabled turning on the y axis when the orientation sensor is active
  42985. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42986. */
  42987. enableHorizontalDragging(dragFactor?: number): void;
  42988. /**
  42989. * Gets the current instance class name ("DeviceOrientationCamera").
  42990. * This helps avoiding instanceof at run time.
  42991. * @returns the class name
  42992. */
  42993. getClassName(): string;
  42994. /**
  42995. * @hidden
  42996. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42997. */
  42998. _checkInputs(): void;
  42999. /**
  43000. * Reset the camera to its default orientation on the specified axis only.
  43001. * @param axis The axis to reset
  43002. */
  43003. resetToCurrentRotation(axis?: Axis): void;
  43004. }
  43005. }
  43006. declare module "babylonjs/Gamepads/xboxGamepad" {
  43007. import { Observable } from "babylonjs/Misc/observable";
  43008. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43009. /**
  43010. * Defines supported buttons for XBox360 compatible gamepads
  43011. */
  43012. export enum Xbox360Button {
  43013. /** A */
  43014. A = 0,
  43015. /** B */
  43016. B = 1,
  43017. /** X */
  43018. X = 2,
  43019. /** Y */
  43020. Y = 3,
  43021. /** Left button */
  43022. LB = 4,
  43023. /** Right button */
  43024. RB = 5,
  43025. /** Back */
  43026. Back = 8,
  43027. /** Start */
  43028. Start = 9,
  43029. /** Left stick */
  43030. LeftStick = 10,
  43031. /** Right stick */
  43032. RightStick = 11
  43033. }
  43034. /** Defines values for XBox360 DPad */
  43035. export enum Xbox360Dpad {
  43036. /** Up */
  43037. Up = 12,
  43038. /** Down */
  43039. Down = 13,
  43040. /** Left */
  43041. Left = 14,
  43042. /** Right */
  43043. Right = 15
  43044. }
  43045. /**
  43046. * Defines a XBox360 gamepad
  43047. */
  43048. export class Xbox360Pad extends Gamepad {
  43049. private _leftTrigger;
  43050. private _rightTrigger;
  43051. private _onlefttriggerchanged;
  43052. private _onrighttriggerchanged;
  43053. private _onbuttondown;
  43054. private _onbuttonup;
  43055. private _ondpaddown;
  43056. private _ondpadup;
  43057. /** Observable raised when a button is pressed */
  43058. onButtonDownObservable: Observable<Xbox360Button>;
  43059. /** Observable raised when a button is released */
  43060. onButtonUpObservable: Observable<Xbox360Button>;
  43061. /** Observable raised when a pad is pressed */
  43062. onPadDownObservable: Observable<Xbox360Dpad>;
  43063. /** Observable raised when a pad is released */
  43064. onPadUpObservable: Observable<Xbox360Dpad>;
  43065. private _buttonA;
  43066. private _buttonB;
  43067. private _buttonX;
  43068. private _buttonY;
  43069. private _buttonBack;
  43070. private _buttonStart;
  43071. private _buttonLB;
  43072. private _buttonRB;
  43073. private _buttonLeftStick;
  43074. private _buttonRightStick;
  43075. private _dPadUp;
  43076. private _dPadDown;
  43077. private _dPadLeft;
  43078. private _dPadRight;
  43079. private _isXboxOnePad;
  43080. /**
  43081. * Creates a new XBox360 gamepad object
  43082. * @param id defines the id of this gamepad
  43083. * @param index defines its index
  43084. * @param gamepad defines the internal HTML gamepad object
  43085. * @param xboxOne defines if it is a XBox One gamepad
  43086. */
  43087. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  43088. /**
  43089. * Defines the callback to call when left trigger is pressed
  43090. * @param callback defines the callback to use
  43091. */
  43092. onlefttriggerchanged(callback: (value: number) => void): void;
  43093. /**
  43094. * Defines the callback to call when right trigger is pressed
  43095. * @param callback defines the callback to use
  43096. */
  43097. onrighttriggerchanged(callback: (value: number) => void): void;
  43098. /**
  43099. * Gets the left trigger value
  43100. */
  43101. get leftTrigger(): number;
  43102. /**
  43103. * Sets the left trigger value
  43104. */
  43105. set leftTrigger(newValue: number);
  43106. /**
  43107. * Gets the right trigger value
  43108. */
  43109. get rightTrigger(): number;
  43110. /**
  43111. * Sets the right trigger value
  43112. */
  43113. set rightTrigger(newValue: number);
  43114. /**
  43115. * Defines the callback to call when a button is pressed
  43116. * @param callback defines the callback to use
  43117. */
  43118. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  43119. /**
  43120. * Defines the callback to call when a button is released
  43121. * @param callback defines the callback to use
  43122. */
  43123. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  43124. /**
  43125. * Defines the callback to call when a pad is pressed
  43126. * @param callback defines the callback to use
  43127. */
  43128. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  43129. /**
  43130. * Defines the callback to call when a pad is released
  43131. * @param callback defines the callback to use
  43132. */
  43133. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  43134. private _setButtonValue;
  43135. private _setDPadValue;
  43136. /**
  43137. * Gets the value of the `A` button
  43138. */
  43139. get buttonA(): number;
  43140. /**
  43141. * Sets the value of the `A` button
  43142. */
  43143. set buttonA(value: number);
  43144. /**
  43145. * Gets the value of the `B` button
  43146. */
  43147. get buttonB(): number;
  43148. /**
  43149. * Sets the value of the `B` button
  43150. */
  43151. set buttonB(value: number);
  43152. /**
  43153. * Gets the value of the `X` button
  43154. */
  43155. get buttonX(): number;
  43156. /**
  43157. * Sets the value of the `X` button
  43158. */
  43159. set buttonX(value: number);
  43160. /**
  43161. * Gets the value of the `Y` button
  43162. */
  43163. get buttonY(): number;
  43164. /**
  43165. * Sets the value of the `Y` button
  43166. */
  43167. set buttonY(value: number);
  43168. /**
  43169. * Gets the value of the `Start` button
  43170. */
  43171. get buttonStart(): number;
  43172. /**
  43173. * Sets the value of the `Start` button
  43174. */
  43175. set buttonStart(value: number);
  43176. /**
  43177. * Gets the value of the `Back` button
  43178. */
  43179. get buttonBack(): number;
  43180. /**
  43181. * Sets the value of the `Back` button
  43182. */
  43183. set buttonBack(value: number);
  43184. /**
  43185. * Gets the value of the `Left` button
  43186. */
  43187. get buttonLB(): number;
  43188. /**
  43189. * Sets the value of the `Left` button
  43190. */
  43191. set buttonLB(value: number);
  43192. /**
  43193. * Gets the value of the `Right` button
  43194. */
  43195. get buttonRB(): number;
  43196. /**
  43197. * Sets the value of the `Right` button
  43198. */
  43199. set buttonRB(value: number);
  43200. /**
  43201. * Gets the value of the Left joystick
  43202. */
  43203. get buttonLeftStick(): number;
  43204. /**
  43205. * Sets the value of the Left joystick
  43206. */
  43207. set buttonLeftStick(value: number);
  43208. /**
  43209. * Gets the value of the Right joystick
  43210. */
  43211. get buttonRightStick(): number;
  43212. /**
  43213. * Sets the value of the Right joystick
  43214. */
  43215. set buttonRightStick(value: number);
  43216. /**
  43217. * Gets the value of D-pad up
  43218. */
  43219. get dPadUp(): number;
  43220. /**
  43221. * Sets the value of D-pad up
  43222. */
  43223. set dPadUp(value: number);
  43224. /**
  43225. * Gets the value of D-pad down
  43226. */
  43227. get dPadDown(): number;
  43228. /**
  43229. * Sets the value of D-pad down
  43230. */
  43231. set dPadDown(value: number);
  43232. /**
  43233. * Gets the value of D-pad left
  43234. */
  43235. get dPadLeft(): number;
  43236. /**
  43237. * Sets the value of D-pad left
  43238. */
  43239. set dPadLeft(value: number);
  43240. /**
  43241. * Gets the value of D-pad right
  43242. */
  43243. get dPadRight(): number;
  43244. /**
  43245. * Sets the value of D-pad right
  43246. */
  43247. set dPadRight(value: number);
  43248. /**
  43249. * Force the gamepad to synchronize with device values
  43250. */
  43251. update(): void;
  43252. /**
  43253. * Disposes the gamepad
  43254. */
  43255. dispose(): void;
  43256. }
  43257. }
  43258. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43259. import { Observable } from "babylonjs/Misc/observable";
  43260. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43261. /**
  43262. * Defines supported buttons for DualShock compatible gamepads
  43263. */
  43264. export enum DualShockButton {
  43265. /** Cross */
  43266. Cross = 0,
  43267. /** Circle */
  43268. Circle = 1,
  43269. /** Square */
  43270. Square = 2,
  43271. /** Triangle */
  43272. Triangle = 3,
  43273. /** L1 */
  43274. L1 = 4,
  43275. /** R1 */
  43276. R1 = 5,
  43277. /** Share */
  43278. Share = 8,
  43279. /** Options */
  43280. Options = 9,
  43281. /** Left stick */
  43282. LeftStick = 10,
  43283. /** Right stick */
  43284. RightStick = 11
  43285. }
  43286. /** Defines values for DualShock DPad */
  43287. export enum DualShockDpad {
  43288. /** Up */
  43289. Up = 12,
  43290. /** Down */
  43291. Down = 13,
  43292. /** Left */
  43293. Left = 14,
  43294. /** Right */
  43295. Right = 15
  43296. }
  43297. /**
  43298. * Defines a DualShock gamepad
  43299. */
  43300. export class DualShockPad extends Gamepad {
  43301. private _leftTrigger;
  43302. private _rightTrigger;
  43303. private _onlefttriggerchanged;
  43304. private _onrighttriggerchanged;
  43305. private _onbuttondown;
  43306. private _onbuttonup;
  43307. private _ondpaddown;
  43308. private _ondpadup;
  43309. /** Observable raised when a button is pressed */
  43310. onButtonDownObservable: Observable<DualShockButton>;
  43311. /** Observable raised when a button is released */
  43312. onButtonUpObservable: Observable<DualShockButton>;
  43313. /** Observable raised when a pad is pressed */
  43314. onPadDownObservable: Observable<DualShockDpad>;
  43315. /** Observable raised when a pad is released */
  43316. onPadUpObservable: Observable<DualShockDpad>;
  43317. private _buttonCross;
  43318. private _buttonCircle;
  43319. private _buttonSquare;
  43320. private _buttonTriangle;
  43321. private _buttonShare;
  43322. private _buttonOptions;
  43323. private _buttonL1;
  43324. private _buttonR1;
  43325. private _buttonLeftStick;
  43326. private _buttonRightStick;
  43327. private _dPadUp;
  43328. private _dPadDown;
  43329. private _dPadLeft;
  43330. private _dPadRight;
  43331. /**
  43332. * Creates a new DualShock gamepad object
  43333. * @param id defines the id of this gamepad
  43334. * @param index defines its index
  43335. * @param gamepad defines the internal HTML gamepad object
  43336. */
  43337. constructor(id: string, index: number, gamepad: any);
  43338. /**
  43339. * Defines the callback to call when left trigger is pressed
  43340. * @param callback defines the callback to use
  43341. */
  43342. onlefttriggerchanged(callback: (value: number) => void): void;
  43343. /**
  43344. * Defines the callback to call when right trigger is pressed
  43345. * @param callback defines the callback to use
  43346. */
  43347. onrighttriggerchanged(callback: (value: number) => void): void;
  43348. /**
  43349. * Gets the left trigger value
  43350. */
  43351. get leftTrigger(): number;
  43352. /**
  43353. * Sets the left trigger value
  43354. */
  43355. set leftTrigger(newValue: number);
  43356. /**
  43357. * Gets the right trigger value
  43358. */
  43359. get rightTrigger(): number;
  43360. /**
  43361. * Sets the right trigger value
  43362. */
  43363. set rightTrigger(newValue: number);
  43364. /**
  43365. * Defines the callback to call when a button is pressed
  43366. * @param callback defines the callback to use
  43367. */
  43368. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43369. /**
  43370. * Defines the callback to call when a button is released
  43371. * @param callback defines the callback to use
  43372. */
  43373. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43374. /**
  43375. * Defines the callback to call when a pad is pressed
  43376. * @param callback defines the callback to use
  43377. */
  43378. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43379. /**
  43380. * Defines the callback to call when a pad is released
  43381. * @param callback defines the callback to use
  43382. */
  43383. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43384. private _setButtonValue;
  43385. private _setDPadValue;
  43386. /**
  43387. * Gets the value of the `Cross` button
  43388. */
  43389. get buttonCross(): number;
  43390. /**
  43391. * Sets the value of the `Cross` button
  43392. */
  43393. set buttonCross(value: number);
  43394. /**
  43395. * Gets the value of the `Circle` button
  43396. */
  43397. get buttonCircle(): number;
  43398. /**
  43399. * Sets the value of the `Circle` button
  43400. */
  43401. set buttonCircle(value: number);
  43402. /**
  43403. * Gets the value of the `Square` button
  43404. */
  43405. get buttonSquare(): number;
  43406. /**
  43407. * Sets the value of the `Square` button
  43408. */
  43409. set buttonSquare(value: number);
  43410. /**
  43411. * Gets the value of the `Triangle` button
  43412. */
  43413. get buttonTriangle(): number;
  43414. /**
  43415. * Sets the value of the `Triangle` button
  43416. */
  43417. set buttonTriangle(value: number);
  43418. /**
  43419. * Gets the value of the `Options` button
  43420. */
  43421. get buttonOptions(): number;
  43422. /**
  43423. * Sets the value of the `Options` button
  43424. */
  43425. set buttonOptions(value: number);
  43426. /**
  43427. * Gets the value of the `Share` button
  43428. */
  43429. get buttonShare(): number;
  43430. /**
  43431. * Sets the value of the `Share` button
  43432. */
  43433. set buttonShare(value: number);
  43434. /**
  43435. * Gets the value of the `L1` button
  43436. */
  43437. get buttonL1(): number;
  43438. /**
  43439. * Sets the value of the `L1` button
  43440. */
  43441. set buttonL1(value: number);
  43442. /**
  43443. * Gets the value of the `R1` button
  43444. */
  43445. get buttonR1(): number;
  43446. /**
  43447. * Sets the value of the `R1` button
  43448. */
  43449. set buttonR1(value: number);
  43450. /**
  43451. * Gets the value of the Left joystick
  43452. */
  43453. get buttonLeftStick(): number;
  43454. /**
  43455. * Sets the value of the Left joystick
  43456. */
  43457. set buttonLeftStick(value: number);
  43458. /**
  43459. * Gets the value of the Right joystick
  43460. */
  43461. get buttonRightStick(): number;
  43462. /**
  43463. * Sets the value of the Right joystick
  43464. */
  43465. set buttonRightStick(value: number);
  43466. /**
  43467. * Gets the value of D-pad up
  43468. */
  43469. get dPadUp(): number;
  43470. /**
  43471. * Sets the value of D-pad up
  43472. */
  43473. set dPadUp(value: number);
  43474. /**
  43475. * Gets the value of D-pad down
  43476. */
  43477. get dPadDown(): number;
  43478. /**
  43479. * Sets the value of D-pad down
  43480. */
  43481. set dPadDown(value: number);
  43482. /**
  43483. * Gets the value of D-pad left
  43484. */
  43485. get dPadLeft(): number;
  43486. /**
  43487. * Sets the value of D-pad left
  43488. */
  43489. set dPadLeft(value: number);
  43490. /**
  43491. * Gets the value of D-pad right
  43492. */
  43493. get dPadRight(): number;
  43494. /**
  43495. * Sets the value of D-pad right
  43496. */
  43497. set dPadRight(value: number);
  43498. /**
  43499. * Force the gamepad to synchronize with device values
  43500. */
  43501. update(): void;
  43502. /**
  43503. * Disposes the gamepad
  43504. */
  43505. dispose(): void;
  43506. }
  43507. }
  43508. declare module "babylonjs/Gamepads/gamepadManager" {
  43509. import { Observable } from "babylonjs/Misc/observable";
  43510. import { Nullable } from "babylonjs/types";
  43511. import { Scene } from "babylonjs/scene";
  43512. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43513. /**
  43514. * Manager for handling gamepads
  43515. */
  43516. export class GamepadManager {
  43517. private _scene?;
  43518. private _babylonGamepads;
  43519. private _oneGamepadConnected;
  43520. /** @hidden */
  43521. _isMonitoring: boolean;
  43522. private _gamepadEventSupported;
  43523. private _gamepadSupport?;
  43524. /**
  43525. * observable to be triggered when the gamepad controller has been connected
  43526. */
  43527. onGamepadConnectedObservable: Observable<Gamepad>;
  43528. /**
  43529. * observable to be triggered when the gamepad controller has been disconnected
  43530. */
  43531. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43532. private _onGamepadConnectedEvent;
  43533. private _onGamepadDisconnectedEvent;
  43534. /**
  43535. * Initializes the gamepad manager
  43536. * @param _scene BabylonJS scene
  43537. */
  43538. constructor(_scene?: Scene | undefined);
  43539. /**
  43540. * The gamepads in the game pad manager
  43541. */
  43542. get gamepads(): Gamepad[];
  43543. /**
  43544. * Get the gamepad controllers based on type
  43545. * @param type The type of gamepad controller
  43546. * @returns Nullable gamepad
  43547. */
  43548. getGamepadByType(type?: number): Nullable<Gamepad>;
  43549. /**
  43550. * Disposes the gamepad manager
  43551. */
  43552. dispose(): void;
  43553. private _addNewGamepad;
  43554. private _startMonitoringGamepads;
  43555. private _stopMonitoringGamepads;
  43556. /** @hidden */
  43557. _checkGamepadsStatus(): void;
  43558. private _updateGamepadObjects;
  43559. }
  43560. }
  43561. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43562. import { Nullable } from "babylonjs/types";
  43563. import { Scene } from "babylonjs/scene";
  43564. import { ISceneComponent } from "babylonjs/sceneComponent";
  43565. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43566. module "babylonjs/scene" {
  43567. interface Scene {
  43568. /** @hidden */
  43569. _gamepadManager: Nullable<GamepadManager>;
  43570. /**
  43571. * Gets the gamepad manager associated with the scene
  43572. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43573. */
  43574. gamepadManager: GamepadManager;
  43575. }
  43576. }
  43577. module "babylonjs/Cameras/freeCameraInputsManager" {
  43578. /**
  43579. * Interface representing a free camera inputs manager
  43580. */
  43581. interface FreeCameraInputsManager {
  43582. /**
  43583. * Adds gamepad input support to the FreeCameraInputsManager.
  43584. * @returns the FreeCameraInputsManager
  43585. */
  43586. addGamepad(): FreeCameraInputsManager;
  43587. }
  43588. }
  43589. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43590. /**
  43591. * Interface representing an arc rotate camera inputs manager
  43592. */
  43593. interface ArcRotateCameraInputsManager {
  43594. /**
  43595. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43596. * @returns the camera inputs manager
  43597. */
  43598. addGamepad(): ArcRotateCameraInputsManager;
  43599. }
  43600. }
  43601. /**
  43602. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43603. */
  43604. export class GamepadSystemSceneComponent implements ISceneComponent {
  43605. /**
  43606. * The component name helpfull to identify the component in the list of scene components.
  43607. */
  43608. readonly name: string;
  43609. /**
  43610. * The scene the component belongs to.
  43611. */
  43612. scene: Scene;
  43613. /**
  43614. * Creates a new instance of the component for the given scene
  43615. * @param scene Defines the scene to register the component in
  43616. */
  43617. constructor(scene: Scene);
  43618. /**
  43619. * Registers the component in a given scene
  43620. */
  43621. register(): void;
  43622. /**
  43623. * Rebuilds the elements related to this component in case of
  43624. * context lost for instance.
  43625. */
  43626. rebuild(): void;
  43627. /**
  43628. * Disposes the component and the associated ressources
  43629. */
  43630. dispose(): void;
  43631. private _beforeCameraUpdate;
  43632. }
  43633. }
  43634. declare module "babylonjs/Cameras/universalCamera" {
  43635. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43636. import { Scene } from "babylonjs/scene";
  43637. import { Vector3 } from "babylonjs/Maths/math.vector";
  43638. import "babylonjs/Gamepads/gamepadSceneComponent";
  43639. /**
  43640. * 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,
  43641. * which still works and will still be found in many Playgrounds.
  43642. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43643. */
  43644. export class UniversalCamera extends TouchCamera {
  43645. /**
  43646. * Defines the gamepad rotation sensiblity.
  43647. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43648. */
  43649. get gamepadAngularSensibility(): number;
  43650. set gamepadAngularSensibility(value: number);
  43651. /**
  43652. * Defines the gamepad move sensiblity.
  43653. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43654. */
  43655. get gamepadMoveSensibility(): number;
  43656. set gamepadMoveSensibility(value: number);
  43657. /**
  43658. * 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,
  43659. * which still works and will still be found in many Playgrounds.
  43660. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43661. * @param name Define the name of the camera in the scene
  43662. * @param position Define the start position of the camera in the scene
  43663. * @param scene Define the scene the camera belongs to
  43664. */
  43665. constructor(name: string, position: Vector3, scene: Scene);
  43666. /**
  43667. * Gets the current object class name.
  43668. * @return the class name
  43669. */
  43670. getClassName(): string;
  43671. }
  43672. }
  43673. declare module "babylonjs/Cameras/gamepadCamera" {
  43674. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43675. import { Scene } from "babylonjs/scene";
  43676. import { Vector3 } from "babylonjs/Maths/math.vector";
  43677. /**
  43678. * This represents a FPS type of camera. This is only here for back compat purpose.
  43679. * Please use the UniversalCamera instead as both are identical.
  43680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43681. */
  43682. export class GamepadCamera extends UniversalCamera {
  43683. /**
  43684. * Instantiates a new Gamepad Camera
  43685. * This represents a FPS type of camera. This is only here for back compat purpose.
  43686. * Please use the UniversalCamera instead as both are identical.
  43687. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43688. * @param name Define the name of the camera in the scene
  43689. * @param position Define the start position of the camera in the scene
  43690. * @param scene Define the scene the camera belongs to
  43691. */
  43692. constructor(name: string, position: Vector3, scene: Scene);
  43693. /**
  43694. * Gets the current object class name.
  43695. * @return the class name
  43696. */
  43697. getClassName(): string;
  43698. }
  43699. }
  43700. declare module "babylonjs/Shaders/pass.fragment" {
  43701. /** @hidden */
  43702. export var passPixelShader: {
  43703. name: string;
  43704. shader: string;
  43705. };
  43706. }
  43707. declare module "babylonjs/Shaders/passCube.fragment" {
  43708. /** @hidden */
  43709. export var passCubePixelShader: {
  43710. name: string;
  43711. shader: string;
  43712. };
  43713. }
  43714. declare module "babylonjs/PostProcesses/passPostProcess" {
  43715. import { Nullable } from "babylonjs/types";
  43716. import { Camera } from "babylonjs/Cameras/camera";
  43717. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43718. import { Engine } from "babylonjs/Engines/engine";
  43719. import "babylonjs/Shaders/pass.fragment";
  43720. import "babylonjs/Shaders/passCube.fragment";
  43721. /**
  43722. * PassPostProcess which produces an output the same as it's input
  43723. */
  43724. export class PassPostProcess extends PostProcess {
  43725. /**
  43726. * Creates the PassPostProcess
  43727. * @param name The name of the effect.
  43728. * @param options The required width/height ratio to downsize to before computing the render pass.
  43729. * @param camera The camera to apply the render pass to.
  43730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43731. * @param engine The engine which the post process will be applied. (default: current engine)
  43732. * @param reusable If the post process can be reused on the same frame. (default: false)
  43733. * @param textureType The type of texture to be used when performing the post processing.
  43734. * @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)
  43735. */
  43736. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43737. }
  43738. /**
  43739. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43740. */
  43741. export class PassCubePostProcess extends PostProcess {
  43742. private _face;
  43743. /**
  43744. * Gets or sets the cube face to display.
  43745. * * 0 is +X
  43746. * * 1 is -X
  43747. * * 2 is +Y
  43748. * * 3 is -Y
  43749. * * 4 is +Z
  43750. * * 5 is -Z
  43751. */
  43752. get face(): number;
  43753. set face(value: number);
  43754. /**
  43755. * Creates the PassCubePostProcess
  43756. * @param name The name of the effect.
  43757. * @param options The required width/height ratio to downsize to before computing the render pass.
  43758. * @param camera The camera to apply the render pass to.
  43759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43760. * @param engine The engine which the post process will be applied. (default: current engine)
  43761. * @param reusable If the post process can be reused on the same frame. (default: false)
  43762. * @param textureType The type of texture to be used when performing the post processing.
  43763. * @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)
  43764. */
  43765. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43766. }
  43767. }
  43768. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43769. /** @hidden */
  43770. export var anaglyphPixelShader: {
  43771. name: string;
  43772. shader: string;
  43773. };
  43774. }
  43775. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43776. import { Engine } from "babylonjs/Engines/engine";
  43777. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43778. import { Camera } from "babylonjs/Cameras/camera";
  43779. import "babylonjs/Shaders/anaglyph.fragment";
  43780. /**
  43781. * Postprocess used to generate anaglyphic rendering
  43782. */
  43783. export class AnaglyphPostProcess extends PostProcess {
  43784. private _passedProcess;
  43785. /**
  43786. * Creates a new AnaglyphPostProcess
  43787. * @param name defines postprocess name
  43788. * @param options defines creation options or target ratio scale
  43789. * @param rigCameras defines cameras using this postprocess
  43790. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43791. * @param engine defines hosting engine
  43792. * @param reusable defines if the postprocess will be reused multiple times per frame
  43793. */
  43794. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43795. }
  43796. }
  43797. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43798. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43799. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43800. import { Scene } from "babylonjs/scene";
  43801. import { Vector3 } from "babylonjs/Maths/math.vector";
  43802. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43803. /**
  43804. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43805. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43806. */
  43807. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43808. /**
  43809. * Creates a new AnaglyphArcRotateCamera
  43810. * @param name defines camera name
  43811. * @param alpha defines alpha angle (in radians)
  43812. * @param beta defines beta angle (in radians)
  43813. * @param radius defines radius
  43814. * @param target defines camera target
  43815. * @param interaxialDistance defines distance between each color axis
  43816. * @param scene defines the hosting scene
  43817. */
  43818. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43819. /**
  43820. * Gets camera class name
  43821. * @returns AnaglyphArcRotateCamera
  43822. */
  43823. getClassName(): string;
  43824. }
  43825. }
  43826. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43828. import { Scene } from "babylonjs/scene";
  43829. import { Vector3 } from "babylonjs/Maths/math.vector";
  43830. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43831. /**
  43832. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43833. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43834. */
  43835. export class AnaglyphFreeCamera extends FreeCamera {
  43836. /**
  43837. * Creates a new AnaglyphFreeCamera
  43838. * @param name defines camera name
  43839. * @param position defines initial position
  43840. * @param interaxialDistance defines distance between each color axis
  43841. * @param scene defines the hosting scene
  43842. */
  43843. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43844. /**
  43845. * Gets camera class name
  43846. * @returns AnaglyphFreeCamera
  43847. */
  43848. getClassName(): string;
  43849. }
  43850. }
  43851. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43852. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43853. import { Scene } from "babylonjs/scene";
  43854. import { Vector3 } from "babylonjs/Maths/math.vector";
  43855. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43856. /**
  43857. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43858. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43859. */
  43860. export class AnaglyphGamepadCamera extends GamepadCamera {
  43861. /**
  43862. * Creates a new AnaglyphGamepadCamera
  43863. * @param name defines camera name
  43864. * @param position defines initial position
  43865. * @param interaxialDistance defines distance between each color axis
  43866. * @param scene defines the hosting scene
  43867. */
  43868. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43869. /**
  43870. * Gets camera class name
  43871. * @returns AnaglyphGamepadCamera
  43872. */
  43873. getClassName(): string;
  43874. }
  43875. }
  43876. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43877. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43878. import { Scene } from "babylonjs/scene";
  43879. import { Vector3 } from "babylonjs/Maths/math.vector";
  43880. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43881. /**
  43882. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43883. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43884. */
  43885. export class AnaglyphUniversalCamera extends UniversalCamera {
  43886. /**
  43887. * Creates a new AnaglyphUniversalCamera
  43888. * @param name defines camera name
  43889. * @param position defines initial position
  43890. * @param interaxialDistance defines distance between each color axis
  43891. * @param scene defines the hosting scene
  43892. */
  43893. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43894. /**
  43895. * Gets camera class name
  43896. * @returns AnaglyphUniversalCamera
  43897. */
  43898. getClassName(): string;
  43899. }
  43900. }
  43901. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43902. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43903. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43904. import { Scene } from "babylonjs/scene";
  43905. import { Vector3 } from "babylonjs/Maths/math.vector";
  43906. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43907. /**
  43908. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43909. * @see http://doc.babylonjs.com/features/cameras
  43910. */
  43911. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43912. /**
  43913. * Creates a new StereoscopicArcRotateCamera
  43914. * @param name defines camera name
  43915. * @param alpha defines alpha angle (in radians)
  43916. * @param beta defines beta angle (in radians)
  43917. * @param radius defines radius
  43918. * @param target defines camera target
  43919. * @param interaxialDistance defines distance between each color axis
  43920. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43921. * @param scene defines the hosting scene
  43922. */
  43923. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43924. /**
  43925. * Gets camera class name
  43926. * @returns StereoscopicArcRotateCamera
  43927. */
  43928. getClassName(): string;
  43929. }
  43930. }
  43931. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43932. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43933. import { Scene } from "babylonjs/scene";
  43934. import { Vector3 } from "babylonjs/Maths/math.vector";
  43935. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43936. /**
  43937. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43938. * @see http://doc.babylonjs.com/features/cameras
  43939. */
  43940. export class StereoscopicFreeCamera extends FreeCamera {
  43941. /**
  43942. * Creates a new StereoscopicFreeCamera
  43943. * @param name defines camera name
  43944. * @param position defines initial position
  43945. * @param interaxialDistance defines distance between each color axis
  43946. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43947. * @param scene defines the hosting scene
  43948. */
  43949. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43950. /**
  43951. * Gets camera class name
  43952. * @returns StereoscopicFreeCamera
  43953. */
  43954. getClassName(): string;
  43955. }
  43956. }
  43957. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43958. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43959. import { Scene } from "babylonjs/scene";
  43960. import { Vector3 } from "babylonjs/Maths/math.vector";
  43961. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43962. /**
  43963. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43964. * @see http://doc.babylonjs.com/features/cameras
  43965. */
  43966. export class StereoscopicGamepadCamera extends GamepadCamera {
  43967. /**
  43968. * Creates a new StereoscopicGamepadCamera
  43969. * @param name defines camera name
  43970. * @param position defines initial position
  43971. * @param interaxialDistance defines distance between each color axis
  43972. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43973. * @param scene defines the hosting scene
  43974. */
  43975. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43976. /**
  43977. * Gets camera class name
  43978. * @returns StereoscopicGamepadCamera
  43979. */
  43980. getClassName(): string;
  43981. }
  43982. }
  43983. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43984. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43985. import { Scene } from "babylonjs/scene";
  43986. import { Vector3 } from "babylonjs/Maths/math.vector";
  43987. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43988. /**
  43989. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43990. * @see http://doc.babylonjs.com/features/cameras
  43991. */
  43992. export class StereoscopicUniversalCamera extends UniversalCamera {
  43993. /**
  43994. * Creates a new StereoscopicUniversalCamera
  43995. * @param name defines camera name
  43996. * @param position defines initial position
  43997. * @param interaxialDistance defines distance between each color axis
  43998. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43999. * @param scene defines the hosting scene
  44000. */
  44001. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44002. /**
  44003. * Gets camera class name
  44004. * @returns StereoscopicUniversalCamera
  44005. */
  44006. getClassName(): string;
  44007. }
  44008. }
  44009. declare module "babylonjs/Cameras/Stereoscopic/index" {
  44010. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  44011. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  44012. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  44013. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  44014. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  44015. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  44016. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  44017. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  44018. }
  44019. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  44020. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44021. import { Scene } from "babylonjs/scene";
  44022. import { Vector3 } from "babylonjs/Maths/math.vector";
  44023. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  44024. /**
  44025. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44026. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44027. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44028. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44029. */
  44030. export class VirtualJoysticksCamera extends FreeCamera {
  44031. /**
  44032. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44033. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44034. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44035. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44036. * @param name Define the name of the camera in the scene
  44037. * @param position Define the start position of the camera in the scene
  44038. * @param scene Define the scene the camera belongs to
  44039. */
  44040. constructor(name: string, position: Vector3, scene: Scene);
  44041. /**
  44042. * Gets the current object class name.
  44043. * @return the class name
  44044. */
  44045. getClassName(): string;
  44046. }
  44047. }
  44048. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  44049. import { Matrix } from "babylonjs/Maths/math.vector";
  44050. /**
  44051. * This represents all the required metrics to create a VR camera.
  44052. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44053. */
  44054. export class VRCameraMetrics {
  44055. /**
  44056. * Define the horizontal resolution off the screen.
  44057. */
  44058. hResolution: number;
  44059. /**
  44060. * Define the vertical resolution off the screen.
  44061. */
  44062. vResolution: number;
  44063. /**
  44064. * Define the horizontal screen size.
  44065. */
  44066. hScreenSize: number;
  44067. /**
  44068. * Define the vertical screen size.
  44069. */
  44070. vScreenSize: number;
  44071. /**
  44072. * Define the vertical screen center position.
  44073. */
  44074. vScreenCenter: number;
  44075. /**
  44076. * Define the distance of the eyes to the screen.
  44077. */
  44078. eyeToScreenDistance: number;
  44079. /**
  44080. * Define the distance between both lenses
  44081. */
  44082. lensSeparationDistance: number;
  44083. /**
  44084. * Define the distance between both viewer's eyes.
  44085. */
  44086. interpupillaryDistance: number;
  44087. /**
  44088. * Define the distortion factor of the VR postprocess.
  44089. * Please, touch with care.
  44090. */
  44091. distortionK: number[];
  44092. /**
  44093. * Define the chromatic aberration correction factors for the VR post process.
  44094. */
  44095. chromaAbCorrection: number[];
  44096. /**
  44097. * Define the scale factor of the post process.
  44098. * The smaller the better but the slower.
  44099. */
  44100. postProcessScaleFactor: number;
  44101. /**
  44102. * Define an offset for the lens center.
  44103. */
  44104. lensCenterOffset: number;
  44105. /**
  44106. * Define if the current vr camera should compensate the distortion of the lense or not.
  44107. */
  44108. compensateDistortion: boolean;
  44109. /**
  44110. * Defines if multiview should be enabled when rendering (Default: false)
  44111. */
  44112. multiviewEnabled: boolean;
  44113. /**
  44114. * Gets the rendering aspect ratio based on the provided resolutions.
  44115. */
  44116. get aspectRatio(): number;
  44117. /**
  44118. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44119. */
  44120. get aspectRatioFov(): number;
  44121. /**
  44122. * @hidden
  44123. */
  44124. get leftHMatrix(): Matrix;
  44125. /**
  44126. * @hidden
  44127. */
  44128. get rightHMatrix(): Matrix;
  44129. /**
  44130. * @hidden
  44131. */
  44132. get leftPreViewMatrix(): Matrix;
  44133. /**
  44134. * @hidden
  44135. */
  44136. get rightPreViewMatrix(): Matrix;
  44137. /**
  44138. * Get the default VRMetrics based on the most generic setup.
  44139. * @returns the default vr metrics
  44140. */
  44141. static GetDefault(): VRCameraMetrics;
  44142. }
  44143. }
  44144. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  44145. /** @hidden */
  44146. export var vrDistortionCorrectionPixelShader: {
  44147. name: string;
  44148. shader: string;
  44149. };
  44150. }
  44151. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  44152. import { Camera } from "babylonjs/Cameras/camera";
  44153. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44154. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44155. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  44156. /**
  44157. * VRDistortionCorrectionPostProcess used for mobile VR
  44158. */
  44159. export class VRDistortionCorrectionPostProcess extends PostProcess {
  44160. private _isRightEye;
  44161. private _distortionFactors;
  44162. private _postProcessScaleFactor;
  44163. private _lensCenterOffset;
  44164. private _scaleIn;
  44165. private _scaleFactor;
  44166. private _lensCenter;
  44167. /**
  44168. * Initializes the VRDistortionCorrectionPostProcess
  44169. * @param name The name of the effect.
  44170. * @param camera The camera to apply the render pass to.
  44171. * @param isRightEye If this is for the right eye distortion
  44172. * @param vrMetrics All the required metrics for the VR camera
  44173. */
  44174. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44175. }
  44176. }
  44177. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44178. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44179. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44180. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44181. import { Scene } from "babylonjs/scene";
  44182. import { Vector3 } from "babylonjs/Maths/math.vector";
  44183. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44184. import "babylonjs/Cameras/RigModes/vrRigMode";
  44185. /**
  44186. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44187. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44188. */
  44189. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44190. /**
  44191. * Creates a new VRDeviceOrientationArcRotateCamera
  44192. * @param name defines camera name
  44193. * @param alpha defines the camera rotation along the logitudinal axis
  44194. * @param beta defines the camera rotation along the latitudinal axis
  44195. * @param radius defines the camera distance from its target
  44196. * @param target defines the camera target
  44197. * @param scene defines the scene the camera belongs to
  44198. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44199. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44200. */
  44201. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44202. /**
  44203. * Gets camera class name
  44204. * @returns VRDeviceOrientationArcRotateCamera
  44205. */
  44206. getClassName(): string;
  44207. }
  44208. }
  44209. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44210. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44211. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44212. import { Scene } from "babylonjs/scene";
  44213. import { Vector3 } from "babylonjs/Maths/math.vector";
  44214. import "babylonjs/Cameras/RigModes/vrRigMode";
  44215. /**
  44216. * Camera used to simulate VR rendering (based on FreeCamera)
  44217. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44218. */
  44219. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44220. /**
  44221. * Creates a new VRDeviceOrientationFreeCamera
  44222. * @param name defines camera name
  44223. * @param position defines the start position of the camera
  44224. * @param scene defines the scene the camera belongs to
  44225. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44226. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44227. */
  44228. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44229. /**
  44230. * Gets camera class name
  44231. * @returns VRDeviceOrientationFreeCamera
  44232. */
  44233. getClassName(): string;
  44234. }
  44235. }
  44236. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44237. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44238. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44239. import { Scene } from "babylonjs/scene";
  44240. import { Vector3 } from "babylonjs/Maths/math.vector";
  44241. import "babylonjs/Gamepads/gamepadSceneComponent";
  44242. /**
  44243. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44244. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44245. */
  44246. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44247. /**
  44248. * Creates a new VRDeviceOrientationGamepadCamera
  44249. * @param name defines camera name
  44250. * @param position defines the start position of the camera
  44251. * @param scene defines the scene the camera belongs to
  44252. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44253. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44254. */
  44255. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44256. /**
  44257. * Gets camera class name
  44258. * @returns VRDeviceOrientationGamepadCamera
  44259. */
  44260. getClassName(): string;
  44261. }
  44262. }
  44263. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44266. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44267. /** @hidden */
  44268. export var imageProcessingPixelShader: {
  44269. name: string;
  44270. shader: string;
  44271. };
  44272. }
  44273. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44274. import { Nullable } from "babylonjs/types";
  44275. import { Color4 } from "babylonjs/Maths/math.color";
  44276. import { Camera } from "babylonjs/Cameras/camera";
  44277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44278. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44279. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44280. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44281. import { Engine } from "babylonjs/Engines/engine";
  44282. import "babylonjs/Shaders/imageProcessing.fragment";
  44283. import "babylonjs/Shaders/postprocess.vertex";
  44284. /**
  44285. * ImageProcessingPostProcess
  44286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44287. */
  44288. export class ImageProcessingPostProcess extends PostProcess {
  44289. /**
  44290. * Default configuration related to image processing available in the PBR Material.
  44291. */
  44292. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44293. /**
  44294. * Gets the image processing configuration used either in this material.
  44295. */
  44296. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44297. /**
  44298. * Sets the Default image processing configuration used either in the this material.
  44299. *
  44300. * If sets to null, the scene one is in use.
  44301. */
  44302. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44303. /**
  44304. * Keep track of the image processing observer to allow dispose and replace.
  44305. */
  44306. private _imageProcessingObserver;
  44307. /**
  44308. * Attaches a new image processing configuration to the PBR Material.
  44309. * @param configuration
  44310. */
  44311. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44312. /**
  44313. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44314. */
  44315. get colorCurves(): Nullable<ColorCurves>;
  44316. /**
  44317. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44318. */
  44319. set colorCurves(value: Nullable<ColorCurves>);
  44320. /**
  44321. * Gets wether the color curves effect is enabled.
  44322. */
  44323. get colorCurvesEnabled(): boolean;
  44324. /**
  44325. * Sets wether the color curves effect is enabled.
  44326. */
  44327. set colorCurvesEnabled(value: boolean);
  44328. /**
  44329. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44330. */
  44331. get colorGradingTexture(): Nullable<BaseTexture>;
  44332. /**
  44333. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44334. */
  44335. set colorGradingTexture(value: Nullable<BaseTexture>);
  44336. /**
  44337. * Gets wether the color grading effect is enabled.
  44338. */
  44339. get colorGradingEnabled(): boolean;
  44340. /**
  44341. * Gets wether the color grading effect is enabled.
  44342. */
  44343. set colorGradingEnabled(value: boolean);
  44344. /**
  44345. * Gets exposure used in the effect.
  44346. */
  44347. get exposure(): number;
  44348. /**
  44349. * Sets exposure used in the effect.
  44350. */
  44351. set exposure(value: number);
  44352. /**
  44353. * Gets wether tonemapping is enabled or not.
  44354. */
  44355. get toneMappingEnabled(): boolean;
  44356. /**
  44357. * Sets wether tonemapping is enabled or not
  44358. */
  44359. set toneMappingEnabled(value: boolean);
  44360. /**
  44361. * Gets the type of tone mapping effect.
  44362. */
  44363. get toneMappingType(): number;
  44364. /**
  44365. * Sets the type of tone mapping effect.
  44366. */
  44367. set toneMappingType(value: number);
  44368. /**
  44369. * Gets contrast used in the effect.
  44370. */
  44371. get contrast(): number;
  44372. /**
  44373. * Sets contrast used in the effect.
  44374. */
  44375. set contrast(value: number);
  44376. /**
  44377. * Gets Vignette stretch size.
  44378. */
  44379. get vignetteStretch(): number;
  44380. /**
  44381. * Sets Vignette stretch size.
  44382. */
  44383. set vignetteStretch(value: number);
  44384. /**
  44385. * Gets Vignette centre X Offset.
  44386. */
  44387. get vignetteCentreX(): number;
  44388. /**
  44389. * Sets Vignette centre X Offset.
  44390. */
  44391. set vignetteCentreX(value: number);
  44392. /**
  44393. * Gets Vignette centre Y Offset.
  44394. */
  44395. get vignetteCentreY(): number;
  44396. /**
  44397. * Sets Vignette centre Y Offset.
  44398. */
  44399. set vignetteCentreY(value: number);
  44400. /**
  44401. * Gets Vignette weight or intensity of the vignette effect.
  44402. */
  44403. get vignetteWeight(): number;
  44404. /**
  44405. * Sets Vignette weight or intensity of the vignette effect.
  44406. */
  44407. set vignetteWeight(value: number);
  44408. /**
  44409. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44410. * if vignetteEnabled is set to true.
  44411. */
  44412. get vignetteColor(): Color4;
  44413. /**
  44414. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44415. * if vignetteEnabled is set to true.
  44416. */
  44417. set vignetteColor(value: Color4);
  44418. /**
  44419. * Gets Camera field of view used by the Vignette effect.
  44420. */
  44421. get vignetteCameraFov(): number;
  44422. /**
  44423. * Sets Camera field of view used by the Vignette effect.
  44424. */
  44425. set vignetteCameraFov(value: number);
  44426. /**
  44427. * Gets the vignette blend mode allowing different kind of effect.
  44428. */
  44429. get vignetteBlendMode(): number;
  44430. /**
  44431. * Sets the vignette blend mode allowing different kind of effect.
  44432. */
  44433. set vignetteBlendMode(value: number);
  44434. /**
  44435. * Gets wether the vignette effect is enabled.
  44436. */
  44437. get vignetteEnabled(): boolean;
  44438. /**
  44439. * Sets wether the vignette effect is enabled.
  44440. */
  44441. set vignetteEnabled(value: boolean);
  44442. private _fromLinearSpace;
  44443. /**
  44444. * Gets wether the input of the processing is in Gamma or Linear Space.
  44445. */
  44446. get fromLinearSpace(): boolean;
  44447. /**
  44448. * Sets wether the input of the processing is in Gamma or Linear Space.
  44449. */
  44450. set fromLinearSpace(value: boolean);
  44451. /**
  44452. * Defines cache preventing GC.
  44453. */
  44454. private _defines;
  44455. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44456. /**
  44457. * "ImageProcessingPostProcess"
  44458. * @returns "ImageProcessingPostProcess"
  44459. */
  44460. getClassName(): string;
  44461. protected _updateParameters(): void;
  44462. dispose(camera?: Camera): void;
  44463. }
  44464. }
  44465. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44466. import { Scene } from "babylonjs/scene";
  44467. import { Color3 } from "babylonjs/Maths/math.color";
  44468. import { Mesh } from "babylonjs/Meshes/mesh";
  44469. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44470. import { Nullable } from "babylonjs/types";
  44471. /**
  44472. * Class containing static functions to help procedurally build meshes
  44473. */
  44474. export class GroundBuilder {
  44475. /**
  44476. * Creates a ground mesh
  44477. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44478. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44480. * @param name defines the name of the mesh
  44481. * @param options defines the options used to create the mesh
  44482. * @param scene defines the hosting scene
  44483. * @returns the ground mesh
  44484. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44485. */
  44486. static CreateGround(name: string, options: {
  44487. width?: number;
  44488. height?: number;
  44489. subdivisions?: number;
  44490. subdivisionsX?: number;
  44491. subdivisionsY?: number;
  44492. updatable?: boolean;
  44493. }, scene: any): Mesh;
  44494. /**
  44495. * Creates a tiled ground mesh
  44496. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44497. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44498. * * 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
  44499. * * 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
  44500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44501. * @param name defines the name of the mesh
  44502. * @param options defines the options used to create the mesh
  44503. * @param scene defines the hosting scene
  44504. * @returns the tiled ground mesh
  44505. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44506. */
  44507. static CreateTiledGround(name: string, options: {
  44508. xmin: number;
  44509. zmin: number;
  44510. xmax: number;
  44511. zmax: number;
  44512. subdivisions?: {
  44513. w: number;
  44514. h: number;
  44515. };
  44516. precision?: {
  44517. w: number;
  44518. h: number;
  44519. };
  44520. updatable?: boolean;
  44521. }, scene?: Nullable<Scene>): Mesh;
  44522. /**
  44523. * Creates a ground mesh from a height map
  44524. * * The parameter `url` sets the URL of the height map image resource.
  44525. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44526. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44527. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44528. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44529. * * 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.
  44530. * * 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).
  44531. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44533. * @param name defines the name of the mesh
  44534. * @param url defines the url to the height map
  44535. * @param options defines the options used to create the mesh
  44536. * @param scene defines the hosting scene
  44537. * @returns the ground mesh
  44538. * @see https://doc.babylonjs.com/babylon101/height_map
  44539. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44540. */
  44541. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44542. width?: number;
  44543. height?: number;
  44544. subdivisions?: number;
  44545. minHeight?: number;
  44546. maxHeight?: number;
  44547. colorFilter?: Color3;
  44548. alphaFilter?: number;
  44549. updatable?: boolean;
  44550. onReady?: (mesh: GroundMesh) => void;
  44551. }, scene?: Nullable<Scene>): GroundMesh;
  44552. }
  44553. }
  44554. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44555. import { Vector4 } from "babylonjs/Maths/math.vector";
  44556. import { Mesh } from "babylonjs/Meshes/mesh";
  44557. /**
  44558. * Class containing static functions to help procedurally build meshes
  44559. */
  44560. export class TorusBuilder {
  44561. /**
  44562. * Creates a torus mesh
  44563. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44564. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44565. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44567. * * 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
  44568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44569. * @param name defines the name of the mesh
  44570. * @param options defines the options used to create the mesh
  44571. * @param scene defines the hosting scene
  44572. * @returns the torus mesh
  44573. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44574. */
  44575. static CreateTorus(name: string, options: {
  44576. diameter?: number;
  44577. thickness?: number;
  44578. tessellation?: number;
  44579. updatable?: boolean;
  44580. sideOrientation?: number;
  44581. frontUVs?: Vector4;
  44582. backUVs?: Vector4;
  44583. }, scene: any): Mesh;
  44584. }
  44585. }
  44586. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44587. import { Vector4 } from "babylonjs/Maths/math.vector";
  44588. import { Color4 } from "babylonjs/Maths/math.color";
  44589. import { Mesh } from "babylonjs/Meshes/mesh";
  44590. /**
  44591. * Class containing static functions to help procedurally build meshes
  44592. */
  44593. export class CylinderBuilder {
  44594. /**
  44595. * Creates a cylinder or a cone mesh
  44596. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44597. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44598. * * 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.
  44599. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44600. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44601. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44602. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44603. * * 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).
  44604. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44605. * * 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).
  44606. * * 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
  44607. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44608. * * 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
  44609. * * 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.
  44610. * * If `enclose` is false, a ring surface is one element.
  44611. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44612. * * 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
  44613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44614. * * 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
  44615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44616. * @param name defines the name of the mesh
  44617. * @param options defines the options used to create the mesh
  44618. * @param scene defines the hosting scene
  44619. * @returns the cylinder mesh
  44620. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44621. */
  44622. static CreateCylinder(name: string, options: {
  44623. height?: number;
  44624. diameterTop?: number;
  44625. diameterBottom?: number;
  44626. diameter?: number;
  44627. tessellation?: number;
  44628. subdivisions?: number;
  44629. arc?: number;
  44630. faceColors?: Color4[];
  44631. faceUV?: Vector4[];
  44632. updatable?: boolean;
  44633. hasRings?: boolean;
  44634. enclose?: boolean;
  44635. cap?: number;
  44636. sideOrientation?: number;
  44637. frontUVs?: Vector4;
  44638. backUVs?: Vector4;
  44639. }, scene: any): Mesh;
  44640. }
  44641. }
  44642. declare module "babylonjs/XR/webXRTypes" {
  44643. import { Nullable } from "babylonjs/types";
  44644. import { IDisposable } from "babylonjs/scene";
  44645. /**
  44646. * States of the webXR experience
  44647. */
  44648. export enum WebXRState {
  44649. /**
  44650. * Transitioning to being in XR mode
  44651. */
  44652. ENTERING_XR = 0,
  44653. /**
  44654. * Transitioning to non XR mode
  44655. */
  44656. EXITING_XR = 1,
  44657. /**
  44658. * In XR mode and presenting
  44659. */
  44660. IN_XR = 2,
  44661. /**
  44662. * Not entered XR mode
  44663. */
  44664. NOT_IN_XR = 3
  44665. }
  44666. /**
  44667. * Abstraction of the XR render target
  44668. */
  44669. export interface WebXRRenderTarget extends IDisposable {
  44670. /**
  44671. * xrpresent context of the canvas which can be used to display/mirror xr content
  44672. */
  44673. canvasContext: WebGLRenderingContext;
  44674. /**
  44675. * xr layer for the canvas
  44676. */
  44677. xrLayer: Nullable<XRWebGLLayer>;
  44678. /**
  44679. * Initializes the xr layer for the session
  44680. * @param xrSession xr session
  44681. * @returns a promise that will resolve once the XR Layer has been created
  44682. */
  44683. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44684. }
  44685. }
  44686. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44687. import { Nullable } from "babylonjs/types";
  44688. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44689. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44690. /**
  44691. * COnfiguration object for WebXR output canvas
  44692. */
  44693. export class WebXRManagedOutputCanvasOptions {
  44694. /**
  44695. * An optional canvas in case you wish to create it yourself and provide it here.
  44696. * If not provided, a new canvas will be created
  44697. */
  44698. canvasElement?: HTMLCanvasElement;
  44699. /**
  44700. * Options for this XR Layer output
  44701. */
  44702. canvasOptions?: XRWebGLLayerOptions;
  44703. /**
  44704. * CSS styling for a newly created canvas (if not provided)
  44705. */
  44706. newCanvasCssStyle?: string;
  44707. /**
  44708. * Get the default values of the configuration object
  44709. * @returns default values of this configuration object
  44710. */
  44711. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44712. }
  44713. /**
  44714. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44715. */
  44716. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44717. private _options;
  44718. private _canvas;
  44719. private _engine;
  44720. /**
  44721. * Rendering context of the canvas which can be used to display/mirror xr content
  44722. */
  44723. canvasContext: WebGLRenderingContext;
  44724. /**
  44725. * xr layer for the canvas
  44726. */
  44727. xrLayer: Nullable<XRWebGLLayer>;
  44728. /**
  44729. * Initializes the canvas to be added/removed upon entering/exiting xr
  44730. * @param _xrSessionManager The XR Session manager
  44731. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44732. */
  44733. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44734. /**
  44735. * Disposes of the object
  44736. */
  44737. dispose(): void;
  44738. /**
  44739. * Initializes the xr layer for the session
  44740. * @param xrSession xr session
  44741. * @returns a promise that will resolve once the XR Layer has been created
  44742. */
  44743. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44744. private _addCanvas;
  44745. private _removeCanvas;
  44746. private _setManagedOutputCanvas;
  44747. }
  44748. }
  44749. declare module "babylonjs/XR/webXRSessionManager" {
  44750. import { Observable } from "babylonjs/Misc/observable";
  44751. import { Nullable } from "babylonjs/types";
  44752. import { IDisposable, Scene } from "babylonjs/scene";
  44753. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44754. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44755. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44756. /**
  44757. * Manages an XRSession to work with Babylon's engine
  44758. * @see https://doc.babylonjs.com/how_to/webxr
  44759. */
  44760. export class WebXRSessionManager implements IDisposable {
  44761. /** The scene which the session should be created for */
  44762. scene: Scene;
  44763. private _referenceSpace;
  44764. private _rttProvider;
  44765. private _sessionEnded;
  44766. private _xrNavigator;
  44767. private baseLayer;
  44768. /**
  44769. * The base reference space from which the session started. good if you want to reset your
  44770. * reference space
  44771. */
  44772. baseReferenceSpace: XRReferenceSpace;
  44773. /**
  44774. * Current XR frame
  44775. */
  44776. currentFrame: Nullable<XRFrame>;
  44777. /** WebXR timestamp updated every frame */
  44778. currentTimestamp: number;
  44779. /**
  44780. * Used just in case of a failure to initialize an immersive session.
  44781. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44782. */
  44783. defaultHeightCompensation: number;
  44784. /**
  44785. * Fires every time a new xrFrame arrives which can be used to update the camera
  44786. */
  44787. onXRFrameObservable: Observable<XRFrame>;
  44788. /**
  44789. * Fires when the reference space changed
  44790. */
  44791. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44792. /**
  44793. * Fires when the xr session is ended either by the device or manually done
  44794. */
  44795. onXRSessionEnded: Observable<any>;
  44796. /**
  44797. * Fires when the xr session is ended either by the device or manually done
  44798. */
  44799. onXRSessionInit: Observable<XRSession>;
  44800. /**
  44801. * Underlying xr session
  44802. */
  44803. session: XRSession;
  44804. /**
  44805. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44806. * or get the offset the player is currently at.
  44807. */
  44808. viewerReferenceSpace: XRReferenceSpace;
  44809. /**
  44810. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44811. * @param scene The scene which the session should be created for
  44812. */
  44813. constructor(
  44814. /** The scene which the session should be created for */
  44815. scene: Scene);
  44816. /**
  44817. * The current reference space used in this session. This reference space can constantly change!
  44818. * It is mainly used to offset the camera's position.
  44819. */
  44820. get referenceSpace(): XRReferenceSpace;
  44821. /**
  44822. * Set a new reference space and triggers the observable
  44823. */
  44824. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44825. /**
  44826. * Disposes of the session manager
  44827. */
  44828. dispose(): void;
  44829. /**
  44830. * Stops the xrSession and restores the render loop
  44831. * @returns Promise which resolves after it exits XR
  44832. */
  44833. exitXRAsync(): Promise<void>;
  44834. /**
  44835. * Gets the correct render target texture to be rendered this frame for this eye
  44836. * @param eye the eye for which to get the render target
  44837. * @returns the render target for the specified eye
  44838. */
  44839. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44840. /**
  44841. * Creates a WebXRRenderTarget object for the XR session
  44842. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44843. * @param options optional options to provide when creating a new render target
  44844. * @returns a WebXR render target to which the session can render
  44845. */
  44846. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44847. /**
  44848. * Initializes the manager
  44849. * After initialization enterXR can be called to start an XR session
  44850. * @returns Promise which resolves after it is initialized
  44851. */
  44852. initializeAsync(): Promise<void>;
  44853. /**
  44854. * Initializes an xr session
  44855. * @param xrSessionMode mode to initialize
  44856. * @param xrSessionInit defines optional and required values to pass to the session builder
  44857. * @returns a promise which will resolve once the session has been initialized
  44858. */
  44859. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44860. /**
  44861. * Checks if a session would be supported for the creation options specified
  44862. * @param sessionMode session mode to check if supported eg. immersive-vr
  44863. * @returns A Promise that resolves to true if supported and false if not
  44864. */
  44865. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44866. /**
  44867. * Resets the reference space to the one started the session
  44868. */
  44869. resetReferenceSpace(): void;
  44870. /**
  44871. * Starts rendering to the xr layer
  44872. */
  44873. runXRRenderLoop(): void;
  44874. /**
  44875. * Sets the reference space on the xr session
  44876. * @param referenceSpaceType space to set
  44877. * @returns a promise that will resolve once the reference space has been set
  44878. */
  44879. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44880. /**
  44881. * Updates the render state of the session
  44882. * @param state state to set
  44883. * @returns a promise that resolves once the render state has been updated
  44884. */
  44885. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44886. /**
  44887. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44888. * @param sessionMode defines the session to test
  44889. * @returns a promise with boolean as final value
  44890. */
  44891. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44892. private _createRenderTargetTexture;
  44893. }
  44894. }
  44895. declare module "babylonjs/XR/webXRCamera" {
  44896. import { Scene } from "babylonjs/scene";
  44897. import { Camera } from "babylonjs/Cameras/camera";
  44898. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44899. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44900. /**
  44901. * WebXR Camera which holds the views for the xrSession
  44902. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44903. */
  44904. export class WebXRCamera extends FreeCamera {
  44905. private _xrSessionManager;
  44906. private _firstFrame;
  44907. private _referenceQuaternion;
  44908. private _referencedPosition;
  44909. private _xrInvPositionCache;
  44910. private _xrInvQuaternionCache;
  44911. /**
  44912. * Should position compensation execute on first frame.
  44913. * This is used when copying the position from a native (non XR) camera
  44914. */
  44915. compensateOnFirstFrame: boolean;
  44916. /**
  44917. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44918. * @param name the name of the camera
  44919. * @param scene the scene to add the camera to
  44920. * @param _xrSessionManager a constructed xr session manager
  44921. */
  44922. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44923. /**
  44924. * Return the user's height, unrelated to the current ground.
  44925. * This will be the y position of this camera, when ground level is 0.
  44926. */
  44927. get realWorldHeight(): number;
  44928. /** @hidden */
  44929. _updateForDualEyeDebugging(): void;
  44930. /**
  44931. * Sets this camera's transformation based on a non-vr camera
  44932. * @param otherCamera the non-vr camera to copy the transformation from
  44933. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44934. */
  44935. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44936. /**
  44937. * Gets the current instance class name ("WebXRCamera").
  44938. * @returns the class name
  44939. */
  44940. getClassName(): string;
  44941. private _updateFromXRSession;
  44942. private _updateNumberOfRigCameras;
  44943. private _updateReferenceSpace;
  44944. private _updateReferenceSpaceOffset;
  44945. }
  44946. }
  44947. declare module "babylonjs/XR/webXRFeaturesManager" {
  44948. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44949. import { IDisposable } from "babylonjs/scene";
  44950. /**
  44951. * Defining the interface required for a (webxr) feature
  44952. */
  44953. export interface IWebXRFeature extends IDisposable {
  44954. /**
  44955. * Is this feature attached
  44956. */
  44957. attached: boolean;
  44958. /**
  44959. * Should auto-attach be disabled?
  44960. */
  44961. disableAutoAttach: boolean;
  44962. /**
  44963. * Attach the feature to the session
  44964. * Will usually be called by the features manager
  44965. *
  44966. * @param force should attachment be forced (even when already attached)
  44967. * @returns true if successful.
  44968. */
  44969. attach(force?: boolean): boolean;
  44970. /**
  44971. * Detach the feature from the session
  44972. * Will usually be called by the features manager
  44973. *
  44974. * @returns true if successful.
  44975. */
  44976. detach(): boolean;
  44977. }
  44978. /**
  44979. * A list of the currently available features without referencing them
  44980. */
  44981. export class WebXRFeatureName {
  44982. /**
  44983. * The name of the anchor system feature
  44984. */
  44985. static ANCHOR_SYSTEM: string;
  44986. /**
  44987. * The name of the background remover feature
  44988. */
  44989. static BACKGROUND_REMOVER: string;
  44990. /**
  44991. * The name of the hit test feature
  44992. */
  44993. static HIT_TEST: string;
  44994. /**
  44995. * physics impostors for xr controllers feature
  44996. */
  44997. static PHYSICS_CONTROLLERS: string;
  44998. /**
  44999. * The name of the plane detection feature
  45000. */
  45001. static PLANE_DETECTION: string;
  45002. /**
  45003. * The name of the pointer selection feature
  45004. */
  45005. static POINTER_SELECTION: string;
  45006. /**
  45007. * The name of the teleportation feature
  45008. */
  45009. static TELEPORTATION: string;
  45010. }
  45011. /**
  45012. * Defining the constructor of a feature. Used to register the modules.
  45013. */
  45014. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45015. /**
  45016. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45017. * It is mainly used in AR sessions.
  45018. *
  45019. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45020. */
  45021. export class WebXRFeaturesManager implements IDisposable {
  45022. private _xrSessionManager;
  45023. private static readonly _AvailableFeatures;
  45024. private _features;
  45025. /**
  45026. * constructs a new features manages.
  45027. *
  45028. * @param _xrSessionManager an instance of WebXRSessionManager
  45029. */
  45030. constructor(_xrSessionManager: WebXRSessionManager);
  45031. /**
  45032. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45033. * Mainly used internally.
  45034. *
  45035. * @param featureName the name of the feature to register
  45036. * @param constructorFunction the function used to construct the module
  45037. * @param version the (babylon) version of the module
  45038. * @param stable is that a stable version of this module
  45039. */
  45040. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45041. /**
  45042. * Returns a constructor of a specific feature.
  45043. *
  45044. * @param featureName the name of the feature to construct
  45045. * @param version the version of the feature to load
  45046. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45047. * @param options optional options provided to the module.
  45048. * @returns a function that, when called, will return a new instance of this feature
  45049. */
  45050. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45051. /**
  45052. * Can be used to return the list of features currently registered
  45053. *
  45054. * @returns an Array of available features
  45055. */
  45056. static GetAvailableFeatures(): string[];
  45057. /**
  45058. * Gets the versions available for a specific feature
  45059. * @param featureName the name of the feature
  45060. * @returns an array with the available versions
  45061. */
  45062. static GetAvailableVersions(featureName: string): string[];
  45063. /**
  45064. * Return the latest unstable version of this feature
  45065. * @param featureName the name of the feature to search
  45066. * @returns the version number. if not found will return -1
  45067. */
  45068. static GetLatestVersionOfFeature(featureName: string): number;
  45069. /**
  45070. * Return the latest stable version of this feature
  45071. * @param featureName the name of the feature to search
  45072. * @returns the version number. if not found will return -1
  45073. */
  45074. static GetStableVersionOfFeature(featureName: string): number;
  45075. /**
  45076. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45077. * Can be used during a session to start a feature
  45078. * @param featureName the name of feature to attach
  45079. */
  45080. attachFeature(featureName: string): void;
  45081. /**
  45082. * Can be used inside a session or when the session ends to detach a specific feature
  45083. * @param featureName the name of the feature to detach
  45084. */
  45085. detachFeature(featureName: string): void;
  45086. /**
  45087. * Used to disable an already-enabled feature
  45088. * The feature will be disposed and will be recreated once enabled.
  45089. * @param featureName the feature to disable
  45090. * @returns true if disable was successful
  45091. */
  45092. disableFeature(featureName: string | {
  45093. Name: string;
  45094. }): boolean;
  45095. /**
  45096. * dispose this features manager
  45097. */
  45098. dispose(): void;
  45099. /**
  45100. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  45101. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  45102. *
  45103. * @param featureName the name of the feature to load or the class of the feature
  45104. * @param version optional version to load. if not provided the latest version will be enabled
  45105. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45106. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45107. * @returns a new constructed feature or throws an error if feature not found.
  45108. */
  45109. enableFeature(featureName: string | {
  45110. Name: string;
  45111. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45112. /**
  45113. * get the implementation of an enabled feature.
  45114. * @param featureName the name of the feature to load
  45115. * @returns the feature class, if found
  45116. */
  45117. getEnabledFeature(featureName: string): IWebXRFeature;
  45118. /**
  45119. * Get the list of enabled features
  45120. * @returns an array of enabled features
  45121. */
  45122. getEnabledFeatures(): string[];
  45123. }
  45124. }
  45125. declare module "babylonjs/XR/webXRExperienceHelper" {
  45126. import { Observable } from "babylonjs/Misc/observable";
  45127. import { IDisposable, Scene } from "babylonjs/scene";
  45128. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45129. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45130. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45131. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  45132. /**
  45133. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45134. * @see https://doc.babylonjs.com/how_to/webxr
  45135. */
  45136. export class WebXRExperienceHelper implements IDisposable {
  45137. private scene;
  45138. private _nonVRCamera;
  45139. private _originalSceneAutoClear;
  45140. private _supported;
  45141. /**
  45142. * Camera used to render xr content
  45143. */
  45144. camera: WebXRCamera;
  45145. /** A features manager for this xr session */
  45146. featuresManager: WebXRFeaturesManager;
  45147. /**
  45148. * Observers registered here will be triggered after the camera's initial transformation is set
  45149. * This can be used to set a different ground level or an extra rotation.
  45150. *
  45151. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45152. * to the position set after this observable is done executing.
  45153. */
  45154. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45155. /**
  45156. * Fires when the state of the experience helper has changed
  45157. */
  45158. onStateChangedObservable: Observable<WebXRState>;
  45159. /** Session manager used to keep track of xr session */
  45160. sessionManager: WebXRSessionManager;
  45161. /**
  45162. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45163. */
  45164. state: WebXRState;
  45165. /**
  45166. * Creates a WebXRExperienceHelper
  45167. * @param scene The scene the helper should be created in
  45168. */
  45169. private constructor();
  45170. /**
  45171. * Creates the experience helper
  45172. * @param scene the scene to attach the experience helper to
  45173. * @returns a promise for the experience helper
  45174. */
  45175. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45176. /**
  45177. * Disposes of the experience helper
  45178. */
  45179. dispose(): void;
  45180. /**
  45181. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45182. * @param sessionMode options for the XR session
  45183. * @param referenceSpaceType frame of reference of the XR session
  45184. * @param renderTarget the output canvas that will be used to enter XR mode
  45185. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  45186. * @returns promise that resolves after xr mode has entered
  45187. */
  45188. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  45189. /**
  45190. * Exits XR mode and returns the scene to its original state
  45191. * @returns promise that resolves after xr mode has exited
  45192. */
  45193. exitXRAsync(): Promise<void>;
  45194. private _nonXRToXRCamera;
  45195. private _setState;
  45196. }
  45197. }
  45198. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45199. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45200. import { Observable } from "babylonjs/Misc/observable";
  45201. import { IDisposable } from "babylonjs/scene";
  45202. /**
  45203. * X-Y values for axes in WebXR
  45204. */
  45205. export interface IWebXRMotionControllerAxesValue {
  45206. /**
  45207. * The value of the x axis
  45208. */
  45209. x: number;
  45210. /**
  45211. * The value of the y-axis
  45212. */
  45213. y: number;
  45214. }
  45215. /**
  45216. * changed / previous values for the values of this component
  45217. */
  45218. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45219. /**
  45220. * current (this frame) value
  45221. */
  45222. current: T;
  45223. /**
  45224. * previous (last change) value
  45225. */
  45226. previous: T;
  45227. }
  45228. /**
  45229. * Represents changes in the component between current frame and last values recorded
  45230. */
  45231. export interface IWebXRMotionControllerComponentChanges {
  45232. /**
  45233. * will be populated with previous and current values if axes changed
  45234. */
  45235. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45236. /**
  45237. * will be populated with previous and current values if pressed changed
  45238. */
  45239. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45240. /**
  45241. * will be populated with previous and current values if touched changed
  45242. */
  45243. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45244. /**
  45245. * will be populated with previous and current values if value changed
  45246. */
  45247. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45248. }
  45249. /**
  45250. * This class represents a single component (for example button or thumbstick) of a motion controller
  45251. */
  45252. export class WebXRControllerComponent implements IDisposable {
  45253. /**
  45254. * the id of this component
  45255. */
  45256. id: string;
  45257. /**
  45258. * the type of the component
  45259. */
  45260. type: MotionControllerComponentType;
  45261. private _buttonIndex;
  45262. private _axesIndices;
  45263. private _axes;
  45264. private _changes;
  45265. private _currentValue;
  45266. private _hasChanges;
  45267. private _pressed;
  45268. private _touched;
  45269. /**
  45270. * button component type
  45271. */
  45272. static BUTTON_TYPE: MotionControllerComponentType;
  45273. /**
  45274. * squeeze component type
  45275. */
  45276. static SQUEEZE_TYPE: MotionControllerComponentType;
  45277. /**
  45278. * Thumbstick component type
  45279. */
  45280. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45281. /**
  45282. * Touchpad component type
  45283. */
  45284. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45285. /**
  45286. * trigger component type
  45287. */
  45288. static TRIGGER_TYPE: MotionControllerComponentType;
  45289. /**
  45290. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45291. * the axes data changes
  45292. */
  45293. onAxisValueChangedObservable: Observable<{
  45294. x: number;
  45295. y: number;
  45296. }>;
  45297. /**
  45298. * Observers registered here will be triggered when the state of a button changes
  45299. * State change is either pressed / touched / value
  45300. */
  45301. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45302. /**
  45303. * Creates a new component for a motion controller.
  45304. * It is created by the motion controller itself
  45305. *
  45306. * @param id the id of this component
  45307. * @param type the type of the component
  45308. * @param _buttonIndex index in the buttons array of the gamepad
  45309. * @param _axesIndices indices of the values in the axes array of the gamepad
  45310. */
  45311. constructor(
  45312. /**
  45313. * the id of this component
  45314. */
  45315. id: string,
  45316. /**
  45317. * the type of the component
  45318. */
  45319. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45320. /**
  45321. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45322. */
  45323. get axes(): IWebXRMotionControllerAxesValue;
  45324. /**
  45325. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45326. */
  45327. get changes(): IWebXRMotionControllerComponentChanges;
  45328. /**
  45329. * Return whether or not the component changed the last frame
  45330. */
  45331. get hasChanges(): boolean;
  45332. /**
  45333. * is the button currently pressed
  45334. */
  45335. get pressed(): boolean;
  45336. /**
  45337. * is the button currently touched
  45338. */
  45339. get touched(): boolean;
  45340. /**
  45341. * Get the current value of this component
  45342. */
  45343. get value(): number;
  45344. /**
  45345. * Dispose this component
  45346. */
  45347. dispose(): void;
  45348. /**
  45349. * Are there axes correlating to this component
  45350. * @return true is axes data is available
  45351. */
  45352. isAxes(): boolean;
  45353. /**
  45354. * Is this component a button (hence - pressable)
  45355. * @returns true if can be pressed
  45356. */
  45357. isButton(): boolean;
  45358. /**
  45359. * update this component using the gamepad object it is in. Called on every frame
  45360. * @param nativeController the native gamepad controller object
  45361. */
  45362. update(nativeController: IMinimalMotionControllerObject): void;
  45363. }
  45364. }
  45365. declare module "babylonjs/Loading/sceneLoader" {
  45366. import { Observable } from "babylonjs/Misc/observable";
  45367. import { Nullable } from "babylonjs/types";
  45368. import { Scene } from "babylonjs/scene";
  45369. import { Engine } from "babylonjs/Engines/engine";
  45370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45371. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45372. import { AssetContainer } from "babylonjs/assetContainer";
  45373. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45374. import { Skeleton } from "babylonjs/Bones/skeleton";
  45375. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45376. import { WebRequest } from "babylonjs/Misc/webRequest";
  45377. /**
  45378. * Class used to represent data loading progression
  45379. */
  45380. export class SceneLoaderProgressEvent {
  45381. /** defines if data length to load can be evaluated */
  45382. readonly lengthComputable: boolean;
  45383. /** defines the loaded data length */
  45384. readonly loaded: number;
  45385. /** defines the data length to load */
  45386. readonly total: number;
  45387. /**
  45388. * Create a new progress event
  45389. * @param lengthComputable defines if data length to load can be evaluated
  45390. * @param loaded defines the loaded data length
  45391. * @param total defines the data length to load
  45392. */
  45393. constructor(
  45394. /** defines if data length to load can be evaluated */
  45395. lengthComputable: boolean,
  45396. /** defines the loaded data length */
  45397. loaded: number,
  45398. /** defines the data length to load */
  45399. total: number);
  45400. /**
  45401. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45402. * @param event defines the source event
  45403. * @returns a new SceneLoaderProgressEvent
  45404. */
  45405. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45406. }
  45407. /**
  45408. * Interface used by SceneLoader plugins to define supported file extensions
  45409. */
  45410. export interface ISceneLoaderPluginExtensions {
  45411. /**
  45412. * Defines the list of supported extensions
  45413. */
  45414. [extension: string]: {
  45415. isBinary: boolean;
  45416. };
  45417. }
  45418. /**
  45419. * Interface used by SceneLoader plugin factory
  45420. */
  45421. export interface ISceneLoaderPluginFactory {
  45422. /**
  45423. * Defines the name of the factory
  45424. */
  45425. name: string;
  45426. /**
  45427. * Function called to create a new plugin
  45428. * @return the new plugin
  45429. */
  45430. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45431. /**
  45432. * The callback that returns true if the data can be directly loaded.
  45433. * @param data string containing the file data
  45434. * @returns if the data can be loaded directly
  45435. */
  45436. canDirectLoad?(data: string): boolean;
  45437. }
  45438. /**
  45439. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45440. */
  45441. export interface ISceneLoaderPluginBase {
  45442. /**
  45443. * The friendly name of this plugin.
  45444. */
  45445. name: string;
  45446. /**
  45447. * The file extensions supported by this plugin.
  45448. */
  45449. extensions: string | ISceneLoaderPluginExtensions;
  45450. /**
  45451. * The callback called when loading from a url.
  45452. * @param scene scene loading this url
  45453. * @param url url to load
  45454. * @param onSuccess callback called when the file successfully loads
  45455. * @param onProgress callback called while file is loading (if the server supports this mode)
  45456. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45457. * @param onError callback called when the file fails to load
  45458. * @returns a file request object
  45459. */
  45460. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45461. /**
  45462. * The callback called when loading from a file object.
  45463. * @param scene scene loading this file
  45464. * @param file defines the file to load
  45465. * @param onSuccess defines the callback to call when data is loaded
  45466. * @param onProgress defines the callback to call during loading process
  45467. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45468. * @param onError defines the callback to call when an error occurs
  45469. * @returns a file request object
  45470. */
  45471. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45472. /**
  45473. * The callback that returns true if the data can be directly loaded.
  45474. * @param data string containing the file data
  45475. * @returns if the data can be loaded directly
  45476. */
  45477. canDirectLoad?(data: string): boolean;
  45478. /**
  45479. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45480. * @param scene scene loading this data
  45481. * @param data string containing the data
  45482. * @returns data to pass to the plugin
  45483. */
  45484. directLoad?(scene: Scene, data: string): any;
  45485. /**
  45486. * The callback that allows custom handling of the root url based on the response url.
  45487. * @param rootUrl the original root url
  45488. * @param responseURL the response url if available
  45489. * @returns the new root url
  45490. */
  45491. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45492. }
  45493. /**
  45494. * Interface used to define a SceneLoader plugin
  45495. */
  45496. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45497. /**
  45498. * Import meshes into a scene.
  45499. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45500. * @param scene The scene to import into
  45501. * @param data The data to import
  45502. * @param rootUrl The root url for scene and resources
  45503. * @param meshes The meshes array to import into
  45504. * @param particleSystems The particle systems array to import into
  45505. * @param skeletons The skeletons array to import into
  45506. * @param onError The callback when import fails
  45507. * @returns True if successful or false otherwise
  45508. */
  45509. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45510. /**
  45511. * Load into a scene.
  45512. * @param scene The scene to load into
  45513. * @param data The data to import
  45514. * @param rootUrl The root url for scene and resources
  45515. * @param onError The callback when import fails
  45516. * @returns True if successful or false otherwise
  45517. */
  45518. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45519. /**
  45520. * Load into an asset container.
  45521. * @param scene The scene to load into
  45522. * @param data The data to import
  45523. * @param rootUrl The root url for scene and resources
  45524. * @param onError The callback when import fails
  45525. * @returns The loaded asset container
  45526. */
  45527. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45528. }
  45529. /**
  45530. * Interface used to define an async SceneLoader plugin
  45531. */
  45532. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45533. /**
  45534. * Import meshes into a scene.
  45535. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45536. * @param scene The scene to import into
  45537. * @param data The data to import
  45538. * @param rootUrl The root url for scene and resources
  45539. * @param onProgress The callback when the load progresses
  45540. * @param fileName Defines the name of the file to load
  45541. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45542. */
  45543. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45544. meshes: AbstractMesh[];
  45545. particleSystems: IParticleSystem[];
  45546. skeletons: Skeleton[];
  45547. animationGroups: AnimationGroup[];
  45548. }>;
  45549. /**
  45550. * Load into a scene.
  45551. * @param scene The scene to load into
  45552. * @param data The data to import
  45553. * @param rootUrl The root url for scene and resources
  45554. * @param onProgress The callback when the load progresses
  45555. * @param fileName Defines the name of the file to load
  45556. * @returns Nothing
  45557. */
  45558. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45559. /**
  45560. * Load into an asset container.
  45561. * @param scene The scene to load into
  45562. * @param data The data to import
  45563. * @param rootUrl The root url for scene and resources
  45564. * @param onProgress The callback when the load progresses
  45565. * @param fileName Defines the name of the file to load
  45566. * @returns The loaded asset container
  45567. */
  45568. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45569. }
  45570. /**
  45571. * Mode that determines how to handle old animation groups before loading new ones.
  45572. */
  45573. export enum SceneLoaderAnimationGroupLoadingMode {
  45574. /**
  45575. * Reset all old animations to initial state then dispose them.
  45576. */
  45577. Clean = 0,
  45578. /**
  45579. * Stop all old animations.
  45580. */
  45581. Stop = 1,
  45582. /**
  45583. * Restart old animations from first frame.
  45584. */
  45585. Sync = 2,
  45586. /**
  45587. * Old animations remains untouched.
  45588. */
  45589. NoSync = 3
  45590. }
  45591. /**
  45592. * Class used to load scene from various file formats using registered plugins
  45593. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45594. */
  45595. export class SceneLoader {
  45596. /**
  45597. * No logging while loading
  45598. */
  45599. static readonly NO_LOGGING: number;
  45600. /**
  45601. * Minimal logging while loading
  45602. */
  45603. static readonly MINIMAL_LOGGING: number;
  45604. /**
  45605. * Summary logging while loading
  45606. */
  45607. static readonly SUMMARY_LOGGING: number;
  45608. /**
  45609. * Detailled logging while loading
  45610. */
  45611. static readonly DETAILED_LOGGING: number;
  45612. /**
  45613. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45614. */
  45615. static get ForceFullSceneLoadingForIncremental(): boolean;
  45616. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45617. /**
  45618. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45619. */
  45620. static get ShowLoadingScreen(): boolean;
  45621. static set ShowLoadingScreen(value: boolean);
  45622. /**
  45623. * Defines the current logging level (while loading the scene)
  45624. * @ignorenaming
  45625. */
  45626. static get loggingLevel(): number;
  45627. static set loggingLevel(value: number);
  45628. /**
  45629. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45630. */
  45631. static get CleanBoneMatrixWeights(): boolean;
  45632. static set CleanBoneMatrixWeights(value: boolean);
  45633. /**
  45634. * Event raised when a plugin is used to load a scene
  45635. */
  45636. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45637. private static _registeredPlugins;
  45638. private static _getDefaultPlugin;
  45639. private static _getPluginForExtension;
  45640. private static _getPluginForDirectLoad;
  45641. private static _getPluginForFilename;
  45642. private static _getDirectLoad;
  45643. private static _loadData;
  45644. private static _getFileInfo;
  45645. /**
  45646. * Gets a plugin that can load the given extension
  45647. * @param extension defines the extension to load
  45648. * @returns a plugin or null if none works
  45649. */
  45650. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45651. /**
  45652. * Gets a boolean indicating that the given extension can be loaded
  45653. * @param extension defines the extension to load
  45654. * @returns true if the extension is supported
  45655. */
  45656. static IsPluginForExtensionAvailable(extension: string): boolean;
  45657. /**
  45658. * Adds a new plugin to the list of registered plugins
  45659. * @param plugin defines the plugin to add
  45660. */
  45661. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45662. /**
  45663. * Import meshes into a scene
  45664. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45665. * @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)
  45666. * @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)
  45667. * @param scene the instance of BABYLON.Scene to append to
  45668. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45669. * @param onProgress a callback with a progress event for each file being loaded
  45670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45671. * @param pluginExtension the extension used to determine the plugin
  45672. * @returns The loaded plugin
  45673. */
  45674. 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>;
  45675. /**
  45676. * Import meshes into a scene
  45677. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45678. * @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)
  45679. * @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)
  45680. * @param scene the instance of BABYLON.Scene to append to
  45681. * @param onProgress a callback with a progress event for each file being loaded
  45682. * @param pluginExtension the extension used to determine the plugin
  45683. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45684. */
  45685. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45686. meshes: AbstractMesh[];
  45687. particleSystems: IParticleSystem[];
  45688. skeletons: Skeleton[];
  45689. animationGroups: AnimationGroup[];
  45690. }>;
  45691. /**
  45692. * Load a scene
  45693. * @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)
  45694. * @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)
  45695. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45696. * @param onSuccess a callback with the scene when import succeeds
  45697. * @param onProgress a callback with a progress event for each file being loaded
  45698. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45699. * @param pluginExtension the extension used to determine the plugin
  45700. * @returns The loaded plugin
  45701. */
  45702. 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>;
  45703. /**
  45704. * Load a scene
  45705. * @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)
  45706. * @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)
  45707. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45708. * @param onProgress a callback with a progress event for each file being loaded
  45709. * @param pluginExtension the extension used to determine the plugin
  45710. * @returns The loaded scene
  45711. */
  45712. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45713. /**
  45714. * Append a scene
  45715. * @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)
  45716. * @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)
  45717. * @param scene is the instance of BABYLON.Scene to append to
  45718. * @param onSuccess a callback with the scene when import succeeds
  45719. * @param onProgress a callback with a progress event for each file being loaded
  45720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45721. * @param pluginExtension the extension used to determine the plugin
  45722. * @returns The loaded plugin
  45723. */
  45724. 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>;
  45725. /**
  45726. * Append a scene
  45727. * @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)
  45728. * @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)
  45729. * @param scene is the instance of BABYLON.Scene to append to
  45730. * @param onProgress a callback with a progress event for each file being loaded
  45731. * @param pluginExtension the extension used to determine the plugin
  45732. * @returns The given scene
  45733. */
  45734. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45735. /**
  45736. * Load a scene into an asset container
  45737. * @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)
  45738. * @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)
  45739. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45740. * @param onSuccess a callback with the scene when import succeeds
  45741. * @param onProgress a callback with a progress event for each file being loaded
  45742. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45743. * @param pluginExtension the extension used to determine the plugin
  45744. * @returns The loaded plugin
  45745. */
  45746. 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>;
  45747. /**
  45748. * Load a scene into an asset container
  45749. * @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)
  45750. * @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)
  45751. * @param scene is the instance of Scene to append to
  45752. * @param onProgress a callback with a progress event for each file being loaded
  45753. * @param pluginExtension the extension used to determine the plugin
  45754. * @returns The loaded asset container
  45755. */
  45756. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45757. /**
  45758. * Import animations from a file into a scene
  45759. * @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)
  45760. * @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)
  45761. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45762. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45763. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45764. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45765. * @param onSuccess a callback with the scene when import succeeds
  45766. * @param onProgress a callback with a progress event for each file being loaded
  45767. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45768. */
  45769. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  45770. /**
  45771. * Import animations from a file into a scene
  45772. * @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)
  45773. * @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)
  45774. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45775. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45776. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45777. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45778. * @param onSuccess a callback with the scene when import succeeds
  45779. * @param onProgress a callback with a progress event for each file being loaded
  45780. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45781. * @returns the updated scene with imported animations
  45782. */
  45783. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  45784. }
  45785. }
  45786. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45787. import { IDisposable, Scene } from "babylonjs/scene";
  45788. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45789. import { Observable } from "babylonjs/Misc/observable";
  45790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45791. import { Nullable } from "babylonjs/types";
  45792. /**
  45793. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45794. */
  45795. export type MotionControllerHandedness = "none" | "left" | "right";
  45796. /**
  45797. * The type of components available in motion controllers.
  45798. * This is not the name of the component.
  45799. */
  45800. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45801. /**
  45802. * The state of a controller component
  45803. */
  45804. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45805. /**
  45806. * The schema of motion controller layout.
  45807. * No object will be initialized using this interface
  45808. * This is used just to define the profile.
  45809. */
  45810. export interface IMotionControllerLayout {
  45811. /**
  45812. * Path to load the assets. Usually relative to the base path
  45813. */
  45814. assetPath: string;
  45815. /**
  45816. * Available components (unsorted)
  45817. */
  45818. components: {
  45819. /**
  45820. * A map of component Ids
  45821. */
  45822. [componentId: string]: {
  45823. /**
  45824. * The type of input the component outputs
  45825. */
  45826. type: MotionControllerComponentType;
  45827. /**
  45828. * The indices of this component in the gamepad object
  45829. */
  45830. gamepadIndices: {
  45831. /**
  45832. * Index of button
  45833. */
  45834. button?: number;
  45835. /**
  45836. * If available, index of x-axis
  45837. */
  45838. xAxis?: number;
  45839. /**
  45840. * If available, index of y-axis
  45841. */
  45842. yAxis?: number;
  45843. };
  45844. /**
  45845. * The mesh's root node name
  45846. */
  45847. rootNodeName: string;
  45848. /**
  45849. * Animation definitions for this model
  45850. */
  45851. visualResponses: {
  45852. [stateKey: string]: {
  45853. /**
  45854. * What property will be animated
  45855. */
  45856. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45857. /**
  45858. * What states influence this visual response
  45859. */
  45860. states: MotionControllerComponentStateType[];
  45861. /**
  45862. * Type of animation - movement or visibility
  45863. */
  45864. valueNodeProperty: "transform" | "visibility";
  45865. /**
  45866. * Base node name to move. Its position will be calculated according to the min and max nodes
  45867. */
  45868. valueNodeName?: string;
  45869. /**
  45870. * Minimum movement node
  45871. */
  45872. minNodeName?: string;
  45873. /**
  45874. * Max movement node
  45875. */
  45876. maxNodeName?: string;
  45877. };
  45878. };
  45879. /**
  45880. * If touch enabled, what is the name of node to display user feedback
  45881. */
  45882. touchPointNodeName?: string;
  45883. };
  45884. };
  45885. /**
  45886. * Is it xr standard mapping or not
  45887. */
  45888. gamepadMapping: "" | "xr-standard";
  45889. /**
  45890. * Base root node of this entire model
  45891. */
  45892. rootNodeName: string;
  45893. /**
  45894. * Defines the main button component id
  45895. */
  45896. selectComponentId: string;
  45897. }
  45898. /**
  45899. * A definition for the layout map in the input profile
  45900. */
  45901. export interface IMotionControllerLayoutMap {
  45902. /**
  45903. * Layouts with handedness type as a key
  45904. */
  45905. [handedness: string]: IMotionControllerLayout;
  45906. }
  45907. /**
  45908. * The XR Input profile schema
  45909. * Profiles can be found here:
  45910. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45911. */
  45912. export interface IMotionControllerProfile {
  45913. /**
  45914. * fallback profiles for this profileId
  45915. */
  45916. fallbackProfileIds: string[];
  45917. /**
  45918. * The layout map, with handedness as key
  45919. */
  45920. layouts: IMotionControllerLayoutMap;
  45921. /**
  45922. * The id of this profile
  45923. * correlates to the profile(s) in the xrInput.profiles array
  45924. */
  45925. profileId: string;
  45926. }
  45927. /**
  45928. * A helper-interface for the 3 meshes needed for controller button animation
  45929. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45930. */
  45931. export interface IMotionControllerButtonMeshMap {
  45932. /**
  45933. * the mesh that defines the pressed value mesh position.
  45934. * This is used to find the max-position of this button
  45935. */
  45936. pressedMesh: AbstractMesh;
  45937. /**
  45938. * the mesh that defines the unpressed value mesh position.
  45939. * This is used to find the min (or initial) position of this button
  45940. */
  45941. unpressedMesh: AbstractMesh;
  45942. /**
  45943. * The mesh that will be changed when value changes
  45944. */
  45945. valueMesh: AbstractMesh;
  45946. }
  45947. /**
  45948. * A helper-interface for the 3 meshes needed for controller axis animation.
  45949. * This will be expanded when touchpad animations are fully supported
  45950. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45951. */
  45952. export interface IMotionControllerMeshMap {
  45953. /**
  45954. * the mesh that defines the maximum value mesh position.
  45955. */
  45956. maxMesh?: AbstractMesh;
  45957. /**
  45958. * the mesh that defines the minimum value mesh position.
  45959. */
  45960. minMesh?: AbstractMesh;
  45961. /**
  45962. * The mesh that will be changed when axis value changes
  45963. */
  45964. valueMesh: AbstractMesh;
  45965. }
  45966. /**
  45967. * The elements needed for change-detection of the gamepad objects in motion controllers
  45968. */
  45969. export interface IMinimalMotionControllerObject {
  45970. /**
  45971. * Available axes of this controller
  45972. */
  45973. axes: number[];
  45974. /**
  45975. * An array of available buttons
  45976. */
  45977. buttons: Array<{
  45978. /**
  45979. * Value of the button/trigger
  45980. */
  45981. value: number;
  45982. /**
  45983. * If the button/trigger is currently touched
  45984. */
  45985. touched: boolean;
  45986. /**
  45987. * If the button/trigger is currently pressed
  45988. */
  45989. pressed: boolean;
  45990. }>;
  45991. /**
  45992. * EXPERIMENTAL haptic support.
  45993. */
  45994. hapticActuators?: Array<{
  45995. pulse: (value: number, duration: number) => Promise<boolean>;
  45996. }>;
  45997. }
  45998. /**
  45999. * An Abstract Motion controller
  46000. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46001. * Each component has an observable to check for changes in value and state
  46002. */
  46003. export abstract class WebXRAbstractMotionController implements IDisposable {
  46004. protected scene: Scene;
  46005. protected layout: IMotionControllerLayout;
  46006. /**
  46007. * The gamepad object correlating to this controller
  46008. */
  46009. gamepadObject: IMinimalMotionControllerObject;
  46010. /**
  46011. * handedness (left/right/none) of this controller
  46012. */
  46013. handedness: MotionControllerHandedness;
  46014. private _initComponent;
  46015. private _modelReady;
  46016. /**
  46017. * A map of components (WebXRControllerComponent) in this motion controller
  46018. * Components have a ComponentType and can also have both button and axis definitions
  46019. */
  46020. readonly components: {
  46021. [id: string]: WebXRControllerComponent;
  46022. };
  46023. /**
  46024. * Disable the model's animation. Can be set at any time.
  46025. */
  46026. disableAnimation: boolean;
  46027. /**
  46028. * Observers registered here will be triggered when the model of this controller is done loading
  46029. */
  46030. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46031. /**
  46032. * The profile id of this motion controller
  46033. */
  46034. abstract profileId: string;
  46035. /**
  46036. * The root mesh of the model. It is null if the model was not yet initialized
  46037. */
  46038. rootMesh: Nullable<AbstractMesh>;
  46039. /**
  46040. * constructs a new abstract motion controller
  46041. * @param scene the scene to which the model of the controller will be added
  46042. * @param layout The profile layout to load
  46043. * @param gamepadObject The gamepad object correlating to this controller
  46044. * @param handedness handedness (left/right/none) of this controller
  46045. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46046. */
  46047. constructor(scene: Scene, layout: IMotionControllerLayout,
  46048. /**
  46049. * The gamepad object correlating to this controller
  46050. */
  46051. gamepadObject: IMinimalMotionControllerObject,
  46052. /**
  46053. * handedness (left/right/none) of this controller
  46054. */
  46055. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46056. /**
  46057. * Dispose this controller, the model mesh and all its components
  46058. */
  46059. dispose(): void;
  46060. /**
  46061. * Returns all components of specific type
  46062. * @param type the type to search for
  46063. * @return an array of components with this type
  46064. */
  46065. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46066. /**
  46067. * get a component based an its component id as defined in layout.components
  46068. * @param id the id of the component
  46069. * @returns the component correlates to the id or undefined if not found
  46070. */
  46071. getComponent(id: string): WebXRControllerComponent;
  46072. /**
  46073. * Get the list of components available in this motion controller
  46074. * @returns an array of strings correlating to available components
  46075. */
  46076. getComponentIds(): string[];
  46077. /**
  46078. * Get the first component of specific type
  46079. * @param type type of component to find
  46080. * @return a controller component or null if not found
  46081. */
  46082. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46083. /**
  46084. * Get the main (Select) component of this controller as defined in the layout
  46085. * @returns the main component of this controller
  46086. */
  46087. getMainComponent(): WebXRControllerComponent;
  46088. /**
  46089. * Loads the model correlating to this controller
  46090. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46091. * @returns A promise fulfilled with the result of the model loading
  46092. */
  46093. loadModel(): Promise<boolean>;
  46094. /**
  46095. * Update this model using the current XRFrame
  46096. * @param xrFrame the current xr frame to use and update the model
  46097. */
  46098. updateFromXRFrame(xrFrame: XRFrame): void;
  46099. /**
  46100. * Backwards compatibility due to a deeply-integrated typo
  46101. */
  46102. get handness(): XREye;
  46103. /**
  46104. * Pulse (vibrate) this controller
  46105. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46106. * Consecutive calls to this function will cancel the last pulse call
  46107. *
  46108. * @param value the strength of the pulse in 0.0...1.0 range
  46109. * @param duration Duration of the pulse in milliseconds
  46110. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46111. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  46112. */
  46113. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46114. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46115. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46116. /**
  46117. * Moves the axis on the controller mesh based on its current state
  46118. * @param axis the index of the axis
  46119. * @param axisValue the value of the axis which determines the meshes new position
  46120. * @hidden
  46121. */
  46122. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46123. /**
  46124. * Update the model itself with the current frame data
  46125. * @param xrFrame the frame to use for updating the model mesh
  46126. */
  46127. protected updateModel(xrFrame: XRFrame): void;
  46128. /**
  46129. * Get the filename and path for this controller's model
  46130. * @returns a map of filename and path
  46131. */
  46132. protected abstract _getFilenameAndPath(): {
  46133. filename: string;
  46134. path: string;
  46135. };
  46136. /**
  46137. * This function is called before the mesh is loaded. It checks for loading constraints.
  46138. * For example, this function can check if the GLB loader is available
  46139. * If this function returns false, the generic controller will be loaded instead
  46140. * @returns Is the client ready to load the mesh
  46141. */
  46142. protected abstract _getModelLoadingConstraints(): boolean;
  46143. /**
  46144. * This function will be called after the model was successfully loaded and can be used
  46145. * for mesh transformations before it is available for the user
  46146. * @param meshes the loaded meshes
  46147. */
  46148. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46149. /**
  46150. * Set the root mesh for this controller. Important for the WebXR controller class
  46151. * @param meshes the loaded meshes
  46152. */
  46153. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46154. /**
  46155. * A function executed each frame that updates the mesh (if needed)
  46156. * @param xrFrame the current xrFrame
  46157. */
  46158. protected abstract _updateModel(xrFrame: XRFrame): void;
  46159. private _getGenericFilenameAndPath;
  46160. private _getGenericParentMesh;
  46161. }
  46162. }
  46163. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  46164. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46166. import { Scene } from "babylonjs/scene";
  46167. /**
  46168. * A generic trigger-only motion controller for WebXR
  46169. */
  46170. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46171. /**
  46172. * Static version of the profile id of this controller
  46173. */
  46174. static ProfileId: string;
  46175. profileId: string;
  46176. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46177. protected _getFilenameAndPath(): {
  46178. filename: string;
  46179. path: string;
  46180. };
  46181. protected _getModelLoadingConstraints(): boolean;
  46182. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46183. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46184. protected _updateModel(): void;
  46185. }
  46186. }
  46187. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46188. import { Vector4 } from "babylonjs/Maths/math.vector";
  46189. import { Mesh } from "babylonjs/Meshes/mesh";
  46190. import { Scene } from "babylonjs/scene";
  46191. import { Nullable } from "babylonjs/types";
  46192. /**
  46193. * Class containing static functions to help procedurally build meshes
  46194. */
  46195. export class SphereBuilder {
  46196. /**
  46197. * Creates a sphere mesh
  46198. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46199. * * 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`)
  46200. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46201. * * 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
  46202. * * 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)
  46203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46204. * * 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
  46205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46206. * @param name defines the name of the mesh
  46207. * @param options defines the options used to create the mesh
  46208. * @param scene defines the hosting scene
  46209. * @returns the sphere mesh
  46210. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46211. */
  46212. static CreateSphere(name: string, options: {
  46213. segments?: number;
  46214. diameter?: number;
  46215. diameterX?: number;
  46216. diameterY?: number;
  46217. diameterZ?: number;
  46218. arc?: number;
  46219. slice?: number;
  46220. sideOrientation?: number;
  46221. frontUVs?: Vector4;
  46222. backUVs?: Vector4;
  46223. updatable?: boolean;
  46224. }, scene?: Nullable<Scene>): Mesh;
  46225. }
  46226. }
  46227. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46229. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46230. import { Scene } from "babylonjs/scene";
  46231. /**
  46232. * A profiled motion controller has its profile loaded from an online repository.
  46233. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46234. */
  46235. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46236. private _repositoryUrl;
  46237. private _buttonMeshMapping;
  46238. private _touchDots;
  46239. /**
  46240. * The profile ID of this controller. Will be populated when the controller initializes.
  46241. */
  46242. profileId: string;
  46243. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46244. dispose(): void;
  46245. protected _getFilenameAndPath(): {
  46246. filename: string;
  46247. path: string;
  46248. };
  46249. protected _getModelLoadingConstraints(): boolean;
  46250. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46251. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46252. protected _updateModel(_xrFrame: XRFrame): void;
  46253. }
  46254. }
  46255. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46256. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46257. import { Scene } from "babylonjs/scene";
  46258. /**
  46259. * A construction function type to create a new controller based on an xrInput object
  46260. */
  46261. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46262. /**
  46263. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46264. *
  46265. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46266. * it should be replaced with auto-loaded controllers.
  46267. *
  46268. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46269. */
  46270. export class WebXRMotionControllerManager {
  46271. private static _AvailableControllers;
  46272. private static _Fallbacks;
  46273. private static _ProfileLoadingPromises;
  46274. private static _ProfilesList;
  46275. /**
  46276. * The base URL of the online controller repository. Can be changed at any time.
  46277. */
  46278. static BaseRepositoryUrl: string;
  46279. /**
  46280. * Which repository gets priority - local or online
  46281. */
  46282. static PrioritizeOnlineRepository: boolean;
  46283. /**
  46284. * Use the online repository, or use only locally-defined controllers
  46285. */
  46286. static UseOnlineRepository: boolean;
  46287. /**
  46288. * Clear the cache used for profile loading and reload when requested again
  46289. */
  46290. static ClearProfilesCache(): void;
  46291. /**
  46292. * Register the default fallbacks.
  46293. * This function is called automatically when this file is imported.
  46294. */
  46295. static DefaultFallbacks(): void;
  46296. /**
  46297. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46298. * @param profileId the profile to which a fallback needs to be found
  46299. * @return an array with corresponding fallback profiles
  46300. */
  46301. static FindFallbackWithProfileId(profileId: string): string[];
  46302. /**
  46303. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46304. * The order of search:
  46305. *
  46306. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46307. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46308. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46309. * 4) return the generic trigger controller if none were found
  46310. *
  46311. * @param xrInput the xrInput to which a new controller is initialized
  46312. * @param scene the scene to which the model will be added
  46313. * @param forceProfile force a certain profile for this controller
  46314. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46315. */
  46316. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46317. /**
  46318. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46319. *
  46320. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46321. *
  46322. * @param type the profile type to register
  46323. * @param constructFunction the function to be called when loading this profile
  46324. */
  46325. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46326. /**
  46327. * Register a fallback to a specific profile.
  46328. * @param profileId the profileId that will receive the fallbacks
  46329. * @param fallbacks A list of fallback profiles
  46330. */
  46331. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46332. /**
  46333. * Will update the list of profiles available in the repository
  46334. * @return a promise that resolves to a map of profiles available online
  46335. */
  46336. static UpdateProfilesList(): Promise<{
  46337. [profile: string]: string;
  46338. }>;
  46339. private static _LoadProfileFromRepository;
  46340. private static _LoadProfilesFromAvailableControllers;
  46341. }
  46342. }
  46343. declare module "babylonjs/XR/webXRInputSource" {
  46344. import { Observable } from "babylonjs/Misc/observable";
  46345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46346. import { Ray } from "babylonjs/Culling/ray";
  46347. import { Scene } from "babylonjs/scene";
  46348. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46349. /**
  46350. * Configuration options for the WebXR controller creation
  46351. */
  46352. export interface IWebXRControllerOptions {
  46353. /**
  46354. * Should the controller mesh be animated when a user interacts with it
  46355. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46356. */
  46357. disableMotionControllerAnimation?: boolean;
  46358. /**
  46359. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46360. */
  46361. doNotLoadControllerMesh?: boolean;
  46362. /**
  46363. * Force a specific controller type for this controller.
  46364. * This can be used when creating your own profile or when testing different controllers
  46365. */
  46366. forceControllerProfile?: string;
  46367. /**
  46368. * Defines a rendering group ID for meshes that will be loaded.
  46369. * This is for the default controllers only.
  46370. */
  46371. renderingGroupId?: number;
  46372. }
  46373. /**
  46374. * Represents an XR controller
  46375. */
  46376. export class WebXRInputSource {
  46377. private _scene;
  46378. /** The underlying input source for the controller */
  46379. inputSource: XRInputSource;
  46380. private _options;
  46381. private _tmpQuaternion;
  46382. private _tmpVector;
  46383. private _uniqueId;
  46384. /**
  46385. * 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
  46386. */
  46387. grip?: AbstractMesh;
  46388. /**
  46389. * If available, this is the gamepad object related to this controller.
  46390. * Using this object it is possible to get click events and trackpad changes of the
  46391. * webxr controller that is currently being used.
  46392. */
  46393. motionController?: WebXRAbstractMotionController;
  46394. /**
  46395. * Event that fires when the controller is removed/disposed.
  46396. * The object provided as event data is this controller, after associated assets were disposed.
  46397. * uniqueId is still available.
  46398. */
  46399. onDisposeObservable: Observable<WebXRInputSource>;
  46400. /**
  46401. * Will be triggered when the mesh associated with the motion controller is done loading.
  46402. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46403. * A shortened version of controller -> motion controller -> on mesh loaded.
  46404. */
  46405. onMeshLoadedObservable: Observable<AbstractMesh>;
  46406. /**
  46407. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46408. */
  46409. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46410. /**
  46411. * Pointer which can be used to select objects or attach a visible laser to
  46412. */
  46413. pointer: AbstractMesh;
  46414. /**
  46415. * Creates the controller
  46416. * @see https://doc.babylonjs.com/how_to/webxr
  46417. * @param _scene the scene which the controller should be associated to
  46418. * @param inputSource the underlying input source for the controller
  46419. * @param _options options for this controller creation
  46420. */
  46421. constructor(_scene: Scene,
  46422. /** The underlying input source for the controller */
  46423. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46424. /**
  46425. * Get this controllers unique id
  46426. */
  46427. get uniqueId(): string;
  46428. /**
  46429. * Disposes of the object
  46430. */
  46431. dispose(): void;
  46432. /**
  46433. * Gets a world space ray coming from the pointer or grip
  46434. * @param result the resulting ray
  46435. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46436. */
  46437. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46438. /**
  46439. * Updates the controller pose based on the given XRFrame
  46440. * @param xrFrame xr frame to update the pose with
  46441. * @param referenceSpace reference space to use
  46442. */
  46443. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46444. }
  46445. }
  46446. declare module "babylonjs/XR/webXRInput" {
  46447. import { Observable } from "babylonjs/Misc/observable";
  46448. import { IDisposable } from "babylonjs/scene";
  46449. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  46450. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46451. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46452. /**
  46453. * The schema for initialization options of the XR Input class
  46454. */
  46455. export interface IWebXRInputOptions {
  46456. /**
  46457. * If set to true no model will be automatically loaded
  46458. */
  46459. doNotLoadControllerMeshes?: boolean;
  46460. /**
  46461. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46462. * If not found, the xr input profile data will be used.
  46463. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46464. */
  46465. forceInputProfile?: string;
  46466. /**
  46467. * Do not send a request to the controller repository to load the profile.
  46468. *
  46469. * Instead, use the controllers available in babylon itself.
  46470. */
  46471. disableOnlineControllerRepository?: boolean;
  46472. /**
  46473. * A custom URL for the controllers repository
  46474. */
  46475. customControllersRepositoryURL?: string;
  46476. /**
  46477. * Should the controller model's components not move according to the user input
  46478. */
  46479. disableControllerAnimation?: boolean;
  46480. /**
  46481. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  46482. */
  46483. controllerOptions?: IWebXRControllerOptions;
  46484. }
  46485. /**
  46486. * XR input used to track XR inputs such as controllers/rays
  46487. */
  46488. export class WebXRInput implements IDisposable {
  46489. /**
  46490. * the xr session manager for this session
  46491. */
  46492. xrSessionManager: WebXRSessionManager;
  46493. /**
  46494. * the WebXR camera for this session. Mainly used for teleportation
  46495. */
  46496. xrCamera: WebXRCamera;
  46497. private readonly options;
  46498. /**
  46499. * XR controllers being tracked
  46500. */
  46501. controllers: Array<WebXRInputSource>;
  46502. private _frameObserver;
  46503. private _sessionEndedObserver;
  46504. private _sessionInitObserver;
  46505. /**
  46506. * Event when a controller has been connected/added
  46507. */
  46508. onControllerAddedObservable: Observable<WebXRInputSource>;
  46509. /**
  46510. * Event when a controller has been removed/disconnected
  46511. */
  46512. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46513. /**
  46514. * Initializes the WebXRInput
  46515. * @param xrSessionManager the xr session manager for this session
  46516. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46517. * @param options = initialization options for this xr input
  46518. */
  46519. constructor(
  46520. /**
  46521. * the xr session manager for this session
  46522. */
  46523. xrSessionManager: WebXRSessionManager,
  46524. /**
  46525. * the WebXR camera for this session. Mainly used for teleportation
  46526. */
  46527. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46528. private _onInputSourcesChange;
  46529. private _addAndRemoveControllers;
  46530. /**
  46531. * Disposes of the object
  46532. */
  46533. dispose(): void;
  46534. }
  46535. }
  46536. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46537. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46538. import { Observable, EventState } from "babylonjs/Misc/observable";
  46539. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46540. /**
  46541. * This is the base class for all WebXR features.
  46542. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46543. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46544. */
  46545. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46546. protected _xrSessionManager: WebXRSessionManager;
  46547. private _attached;
  46548. private _removeOnDetach;
  46549. /**
  46550. * Should auto-attach be disabled?
  46551. */
  46552. disableAutoAttach: boolean;
  46553. /**
  46554. * Construct a new (abstract) WebXR feature
  46555. * @param _xrSessionManager the xr session manager for this feature
  46556. */
  46557. constructor(_xrSessionManager: WebXRSessionManager);
  46558. /**
  46559. * Is this feature attached
  46560. */
  46561. get attached(): boolean;
  46562. /**
  46563. * attach this feature
  46564. *
  46565. * @param force should attachment be forced (even when already attached)
  46566. * @returns true if successful, false is failed or already attached
  46567. */
  46568. attach(force?: boolean): boolean;
  46569. /**
  46570. * detach this feature.
  46571. *
  46572. * @returns true if successful, false if failed or already detached
  46573. */
  46574. detach(): boolean;
  46575. /**
  46576. * Dispose this feature and all of the resources attached
  46577. */
  46578. dispose(): void;
  46579. /**
  46580. * This is used to register callbacks that will automatically be removed when detach is called.
  46581. * @param observable the observable to which the observer will be attached
  46582. * @param callback the callback to register
  46583. */
  46584. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46585. /**
  46586. * Code in this function will be executed on each xrFrame received from the browser.
  46587. * This function will not execute after the feature is detached.
  46588. * @param _xrFrame the current frame
  46589. */
  46590. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46591. }
  46592. }
  46593. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46594. import { IDisposable, Scene } from "babylonjs/scene";
  46595. import { Nullable } from "babylonjs/types";
  46596. import { Observable } from "babylonjs/Misc/observable";
  46597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46598. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46599. import { Camera } from "babylonjs/Cameras/camera";
  46600. /**
  46601. * Renders a layer on top of an existing scene
  46602. */
  46603. export class UtilityLayerRenderer implements IDisposable {
  46604. /** the original scene that will be rendered on top of */
  46605. originalScene: Scene;
  46606. private _pointerCaptures;
  46607. private _lastPointerEvents;
  46608. private static _DefaultUtilityLayer;
  46609. private static _DefaultKeepDepthUtilityLayer;
  46610. private _sharedGizmoLight;
  46611. private _renderCamera;
  46612. /**
  46613. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46614. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46615. * @returns the camera that is used when rendering the utility layer
  46616. */
  46617. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46618. /**
  46619. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46620. * @param cam the camera that should be used when rendering the utility layer
  46621. */
  46622. setRenderCamera(cam: Nullable<Camera>): void;
  46623. /**
  46624. * @hidden
  46625. * Light which used by gizmos to get light shading
  46626. */
  46627. _getSharedGizmoLight(): HemisphericLight;
  46628. /**
  46629. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46630. */
  46631. pickUtilitySceneFirst: boolean;
  46632. /**
  46633. * 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)
  46634. */
  46635. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46636. /**
  46637. * 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)
  46638. */
  46639. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46640. /**
  46641. * The scene that is rendered on top of the original scene
  46642. */
  46643. utilityLayerScene: Scene;
  46644. /**
  46645. * If the utility layer should automatically be rendered on top of existing scene
  46646. */
  46647. shouldRender: boolean;
  46648. /**
  46649. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46650. */
  46651. onlyCheckPointerDownEvents: boolean;
  46652. /**
  46653. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46654. */
  46655. processAllEvents: boolean;
  46656. /**
  46657. * Observable raised when the pointer move from the utility layer scene to the main scene
  46658. */
  46659. onPointerOutObservable: Observable<number>;
  46660. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46661. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46662. private _afterRenderObserver;
  46663. private _sceneDisposeObserver;
  46664. private _originalPointerObserver;
  46665. /**
  46666. * Instantiates a UtilityLayerRenderer
  46667. * @param originalScene the original scene that will be rendered on top of
  46668. * @param handleEvents boolean indicating if the utility layer should handle events
  46669. */
  46670. constructor(
  46671. /** the original scene that will be rendered on top of */
  46672. originalScene: Scene, handleEvents?: boolean);
  46673. private _notifyObservers;
  46674. /**
  46675. * Renders the utility layers scene on top of the original scene
  46676. */
  46677. render(): void;
  46678. /**
  46679. * Disposes of the renderer
  46680. */
  46681. dispose(): void;
  46682. private _updateCamera;
  46683. }
  46684. }
  46685. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46686. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46688. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46689. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46690. import { Scene } from "babylonjs/scene";
  46691. import { Nullable } from "babylonjs/types";
  46692. import { Color3 } from "babylonjs/Maths/math.color";
  46693. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46694. /**
  46695. * Options interface for the pointer selection module
  46696. */
  46697. export interface IWebXRControllerPointerSelectionOptions {
  46698. /**
  46699. * if provided, this scene will be used to render meshes.
  46700. */
  46701. customUtilityLayerScene?: Scene;
  46702. /**
  46703. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  46704. * If not disabled, the last picked point will be used to execute a pointer up event
  46705. * If disabled, pointer up event will be triggered right after the pointer down event.
  46706. * Used in screen and gaze target ray mode only
  46707. */
  46708. disablePointerUpOnTouchOut: boolean;
  46709. /**
  46710. * For gaze mode (time to select instead of press)
  46711. */
  46712. forceGazeMode: boolean;
  46713. /**
  46714. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  46715. * to start a new countdown to the pointer down event.
  46716. * Defaults to 1.
  46717. */
  46718. gazeModePointerMovedFactor?: number;
  46719. /**
  46720. * Different button type to use instead of the main component
  46721. */
  46722. overrideButtonId?: string;
  46723. /**
  46724. * use this rendering group id for the meshes (optional)
  46725. */
  46726. renderingGroupId?: number;
  46727. /**
  46728. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46729. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46730. * 3000 means 3 seconds between pointing at something and selecting it
  46731. */
  46732. timeToSelect?: number;
  46733. /**
  46734. * Should meshes created here be added to a utility layer or the main scene
  46735. */
  46736. useUtilityLayer?: boolean;
  46737. /**
  46738. * the xr input to use with this pointer selection
  46739. */
  46740. xrInput: WebXRInput;
  46741. }
  46742. /**
  46743. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46744. */
  46745. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46746. private readonly _options;
  46747. private static _idCounter;
  46748. private _attachController;
  46749. private _controllers;
  46750. private _scene;
  46751. private _tmpVectorForPickCompare;
  46752. /**
  46753. * The module's name
  46754. */
  46755. static readonly Name: string;
  46756. /**
  46757. * The (Babylon) version of this module.
  46758. * This is an integer representing the implementation version.
  46759. * This number does not correspond to the WebXR specs version
  46760. */
  46761. static readonly Version: number;
  46762. /**
  46763. * Disable lighting on the laser pointer (so it will always be visible)
  46764. */
  46765. disablePointerLighting: boolean;
  46766. /**
  46767. * Disable lighting on the selection mesh (so it will always be visible)
  46768. */
  46769. disableSelectionMeshLighting: boolean;
  46770. /**
  46771. * Should the laser pointer be displayed
  46772. */
  46773. displayLaserPointer: boolean;
  46774. /**
  46775. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46776. */
  46777. displaySelectionMesh: boolean;
  46778. /**
  46779. * This color will be set to the laser pointer when selection is triggered
  46780. */
  46781. laserPointerPickedColor: Color3;
  46782. /**
  46783. * Default color of the laser pointer
  46784. */
  46785. lasterPointerDefaultColor: Color3;
  46786. /**
  46787. * default color of the selection ring
  46788. */
  46789. selectionMeshDefaultColor: Color3;
  46790. /**
  46791. * This color will be applied to the selection ring when selection is triggered
  46792. */
  46793. selectionMeshPickedColor: Color3;
  46794. /**
  46795. * Optional filter to be used for ray selection. This predicate shares behavior with
  46796. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46797. */
  46798. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46799. /**
  46800. * constructs a new background remover module
  46801. * @param _xrSessionManager the session manager for this module
  46802. * @param _options read-only options to be used in this module
  46803. */
  46804. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46805. /**
  46806. * attach this feature
  46807. * Will usually be called by the features manager
  46808. *
  46809. * @returns true if successful.
  46810. */
  46811. attach(): boolean;
  46812. /**
  46813. * detach this feature.
  46814. * Will usually be called by the features manager
  46815. *
  46816. * @returns true if successful.
  46817. */
  46818. detach(): boolean;
  46819. /**
  46820. * Will get the mesh under a specific pointer.
  46821. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46822. * @param controllerId the controllerId to check
  46823. * @returns The mesh under pointer or null if no mesh is under the pointer
  46824. */
  46825. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46826. /**
  46827. * Get the xr controller that correlates to the pointer id in the pointer event
  46828. *
  46829. * @param id the pointer id to search for
  46830. * @returns the controller that correlates to this id or null if not found
  46831. */
  46832. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46833. protected _onXRFrame(_xrFrame: XRFrame): void;
  46834. private _attachGazeMode;
  46835. private _attachScreenRayMode;
  46836. private _attachTrackedPointerRayMode;
  46837. private _convertNormalToDirectionOfRay;
  46838. private _detachController;
  46839. private _generateNewMeshPair;
  46840. private _pickingMoved;
  46841. private _updatePointerDistance;
  46842. }
  46843. }
  46844. declare module "babylonjs/XR/webXREnterExitUI" {
  46845. import { Nullable } from "babylonjs/types";
  46846. import { Observable } from "babylonjs/Misc/observable";
  46847. import { IDisposable, Scene } from "babylonjs/scene";
  46848. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46849. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46850. /**
  46851. * Button which can be used to enter a different mode of XR
  46852. */
  46853. export class WebXREnterExitUIButton {
  46854. /** button element */
  46855. element: HTMLElement;
  46856. /** XR initialization options for the button */
  46857. sessionMode: XRSessionMode;
  46858. /** Reference space type */
  46859. referenceSpaceType: XRReferenceSpaceType;
  46860. /**
  46861. * Creates a WebXREnterExitUIButton
  46862. * @param element button element
  46863. * @param sessionMode XR initialization session mode
  46864. * @param referenceSpaceType the type of reference space to be used
  46865. */
  46866. constructor(
  46867. /** button element */
  46868. element: HTMLElement,
  46869. /** XR initialization options for the button */
  46870. sessionMode: XRSessionMode,
  46871. /** Reference space type */
  46872. referenceSpaceType: XRReferenceSpaceType);
  46873. /**
  46874. * Extendable function which can be used to update the button's visuals when the state changes
  46875. * @param activeButton the current active button in the UI
  46876. */
  46877. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46878. }
  46879. /**
  46880. * Options to create the webXR UI
  46881. */
  46882. export class WebXREnterExitUIOptions {
  46883. /**
  46884. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46885. */
  46886. customButtons?: Array<WebXREnterExitUIButton>;
  46887. /**
  46888. * A reference space type to use when creating the default button.
  46889. * Default is local-floor
  46890. */
  46891. referenceSpaceType?: XRReferenceSpaceType;
  46892. /**
  46893. * Context to enter xr with
  46894. */
  46895. renderTarget?: Nullable<WebXRRenderTarget>;
  46896. /**
  46897. * A session mode to use when creating the default button.
  46898. * Default is immersive-vr
  46899. */
  46900. sessionMode?: XRSessionMode;
  46901. /**
  46902. * A list of optional features to init the session with
  46903. */
  46904. optionalFeatures?: string[];
  46905. }
  46906. /**
  46907. * UI to allow the user to enter/exit XR mode
  46908. */
  46909. export class WebXREnterExitUI implements IDisposable {
  46910. private scene;
  46911. /** version of the options passed to this UI */
  46912. options: WebXREnterExitUIOptions;
  46913. private _activeButton;
  46914. private _buttons;
  46915. private _overlay;
  46916. /**
  46917. * Fired every time the active button is changed.
  46918. *
  46919. * When xr is entered via a button that launches xr that button will be the callback parameter
  46920. *
  46921. * When exiting xr the callback parameter will be null)
  46922. */
  46923. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46924. /**
  46925. *
  46926. * @param scene babylon scene object to use
  46927. * @param options (read-only) version of the options passed to this UI
  46928. */
  46929. private constructor();
  46930. /**
  46931. * Creates UI to allow the user to enter/exit XR mode
  46932. * @param scene the scene to add the ui to
  46933. * @param helper the xr experience helper to enter/exit xr with
  46934. * @param options options to configure the UI
  46935. * @returns the created ui
  46936. */
  46937. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46938. /**
  46939. * Disposes of the XR UI component
  46940. */
  46941. dispose(): void;
  46942. private _updateButtons;
  46943. }
  46944. }
  46945. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46946. import { Vector3 } from "babylonjs/Maths/math.vector";
  46947. import { Color4 } from "babylonjs/Maths/math.color";
  46948. import { Nullable } from "babylonjs/types";
  46949. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46950. import { Scene } from "babylonjs/scene";
  46951. /**
  46952. * Class containing static functions to help procedurally build meshes
  46953. */
  46954. export class LinesBuilder {
  46955. /**
  46956. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46957. * * 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
  46958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46959. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46960. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46961. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46963. * * 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
  46964. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46967. * @param name defines the name of the new line system
  46968. * @param options defines the options used to create the line system
  46969. * @param scene defines the hosting scene
  46970. * @returns a new line system mesh
  46971. */
  46972. static CreateLineSystem(name: string, options: {
  46973. lines: Vector3[][];
  46974. updatable?: boolean;
  46975. instance?: Nullable<LinesMesh>;
  46976. colors?: Nullable<Color4[][]>;
  46977. useVertexAlpha?: boolean;
  46978. }, scene: Nullable<Scene>): LinesMesh;
  46979. /**
  46980. * Creates a line mesh
  46981. * 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
  46982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46983. * * The parameter `points` is an array successive Vector3
  46984. * * 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
  46985. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46986. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46987. * * When updating an instance, remember that only point positions can change, not the number of points
  46988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46990. * @param name defines the name of the new line system
  46991. * @param options defines the options used to create the line system
  46992. * @param scene defines the hosting scene
  46993. * @returns a new line mesh
  46994. */
  46995. static CreateLines(name: string, options: {
  46996. points: Vector3[];
  46997. updatable?: boolean;
  46998. instance?: Nullable<LinesMesh>;
  46999. colors?: Color4[];
  47000. useVertexAlpha?: boolean;
  47001. }, scene?: Nullable<Scene>): LinesMesh;
  47002. /**
  47003. * Creates a dashed line mesh
  47004. * * 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
  47005. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47006. * * The parameter `points` is an array successive Vector3
  47007. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47008. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47009. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47010. * * 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
  47011. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47012. * * When updating an instance, remember that only point positions can change, not the number of points
  47013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47014. * @param name defines the name of the mesh
  47015. * @param options defines the options used to create the mesh
  47016. * @param scene defines the hosting scene
  47017. * @returns the dashed line mesh
  47018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47019. */
  47020. static CreateDashedLines(name: string, options: {
  47021. points: Vector3[];
  47022. dashSize?: number;
  47023. gapSize?: number;
  47024. dashNb?: number;
  47025. updatable?: boolean;
  47026. instance?: LinesMesh;
  47027. useVertexAlpha?: boolean;
  47028. }, scene?: Nullable<Scene>): LinesMesh;
  47029. }
  47030. }
  47031. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  47032. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  47033. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47034. import { WebXRInput } from "babylonjs/XR/webXRInput";
  47035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47036. import { Vector3 } from "babylonjs/Maths/math.vector";
  47037. import { Material } from "babylonjs/Materials/material";
  47038. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  47039. import { Scene } from "babylonjs/scene";
  47040. /**
  47041. * The options container for the teleportation module
  47042. */
  47043. export interface IWebXRTeleportationOptions {
  47044. /**
  47045. * if provided, this scene will be used to render meshes.
  47046. */
  47047. customUtilityLayerScene?: Scene;
  47048. /**
  47049. * Values to configure the default target mesh
  47050. */
  47051. defaultTargetMeshOptions?: {
  47052. /**
  47053. * Fill color of the teleportation area
  47054. */
  47055. teleportationFillColor?: string;
  47056. /**
  47057. * Border color for the teleportation area
  47058. */
  47059. teleportationBorderColor?: string;
  47060. /**
  47061. * Disable the mesh's animation sequence
  47062. */
  47063. disableAnimation?: boolean;
  47064. /**
  47065. * Disable lighting on the material or the ring and arrow
  47066. */
  47067. disableLighting?: boolean;
  47068. /**
  47069. * Override the default material of the torus and arrow
  47070. */
  47071. torusArrowMaterial?: Material;
  47072. };
  47073. /**
  47074. * A list of meshes to use as floor meshes.
  47075. * Meshes can be added and removed after initializing the feature using the
  47076. * addFloorMesh and removeFloorMesh functions
  47077. * If empty, rotation will still work
  47078. */
  47079. floorMeshes?: AbstractMesh[];
  47080. /**
  47081. * use this rendering group id for the meshes (optional)
  47082. */
  47083. renderingGroupId?: number;
  47084. /**
  47085. * Should teleportation move only to snap points
  47086. */
  47087. snapPointsOnly?: boolean;
  47088. /**
  47089. * An array of points to which the teleportation will snap to.
  47090. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47091. */
  47092. snapPositions?: Vector3[];
  47093. /**
  47094. * How close should the teleportation ray be in order to snap to position.
  47095. * Default to 0.8 units (meters)
  47096. */
  47097. snapToPositionRadius?: number;
  47098. /**
  47099. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47100. * If you want to support rotation, make sure your mesh has a direction indicator.
  47101. *
  47102. * When left untouched, the default mesh will be initialized.
  47103. */
  47104. teleportationTargetMesh?: AbstractMesh;
  47105. /**
  47106. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47107. */
  47108. timeToTeleport?: number;
  47109. /**
  47110. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47111. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47112. */
  47113. useMainComponentOnly?: boolean;
  47114. /**
  47115. * Should meshes created here be added to a utility layer or the main scene
  47116. */
  47117. useUtilityLayer?: boolean;
  47118. /**
  47119. * Babylon XR Input class for controller
  47120. */
  47121. xrInput: WebXRInput;
  47122. }
  47123. /**
  47124. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47125. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47126. * the input of the attached controllers.
  47127. */
  47128. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47129. private _options;
  47130. private _controllers;
  47131. private _currentTeleportationControllerId;
  47132. private _floorMeshes;
  47133. private _quadraticBezierCurve;
  47134. private _selectionFeature;
  47135. private _snapToPositions;
  47136. private _snappedToPoint;
  47137. private _teleportationRingMaterial?;
  47138. private _tmpRay;
  47139. private _tmpVector;
  47140. /**
  47141. * The module's name
  47142. */
  47143. static readonly Name: string;
  47144. /**
  47145. * The (Babylon) version of this module.
  47146. * This is an integer representing the implementation version.
  47147. * This number does not correspond to the webxr specs version
  47148. */
  47149. static readonly Version: number;
  47150. /**
  47151. * Is movement backwards enabled
  47152. */
  47153. backwardsMovementEnabled: boolean;
  47154. /**
  47155. * Distance to travel when moving backwards
  47156. */
  47157. backwardsTeleportationDistance: number;
  47158. /**
  47159. * The distance from the user to the inspection point in the direction of the controller
  47160. * A higher number will allow the user to move further
  47161. * defaults to 5 (meters, in xr units)
  47162. */
  47163. parabolicCheckRadius: number;
  47164. /**
  47165. * Should the module support parabolic ray on top of direct ray
  47166. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47167. * Very helpful when moving between floors / different heights
  47168. */
  47169. parabolicRayEnabled: boolean;
  47170. /**
  47171. * How much rotation should be applied when rotating right and left
  47172. */
  47173. rotationAngle: number;
  47174. /**
  47175. * Is rotation enabled when moving forward?
  47176. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47177. */
  47178. rotationEnabled: boolean;
  47179. /**
  47180. * constructs a new anchor system
  47181. * @param _xrSessionManager an instance of WebXRSessionManager
  47182. * @param _options configuration object for this feature
  47183. */
  47184. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47185. /**
  47186. * Get the snapPointsOnly flag
  47187. */
  47188. get snapPointsOnly(): boolean;
  47189. /**
  47190. * Sets the snapPointsOnly flag
  47191. * @param snapToPoints should teleportation be exclusively to snap points
  47192. */
  47193. set snapPointsOnly(snapToPoints: boolean);
  47194. /**
  47195. * Add a new mesh to the floor meshes array
  47196. * @param mesh the mesh to use as floor mesh
  47197. */
  47198. addFloorMesh(mesh: AbstractMesh): void;
  47199. /**
  47200. * Add a new snap-to point to fix teleportation to this position
  47201. * @param newSnapPoint The new Snap-To point
  47202. */
  47203. addSnapPoint(newSnapPoint: Vector3): void;
  47204. attach(): boolean;
  47205. detach(): boolean;
  47206. dispose(): void;
  47207. /**
  47208. * Remove a mesh from the floor meshes array
  47209. * @param mesh the mesh to remove
  47210. */
  47211. removeFloorMesh(mesh: AbstractMesh): void;
  47212. /**
  47213. * Remove a mesh from the floor meshes array using its name
  47214. * @param name the mesh name to remove
  47215. */
  47216. removeFloorMeshByName(name: string): void;
  47217. /**
  47218. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  47219. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47220. * @returns was the point found and removed or not
  47221. */
  47222. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47223. /**
  47224. * This function sets a selection feature that will be disabled when
  47225. * the forward ray is shown and will be reattached when hidden.
  47226. * This is used to remove the selection rays when moving.
  47227. * @param selectionFeature the feature to disable when forward movement is enabled
  47228. */
  47229. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47230. protected _onXRFrame(_xrFrame: XRFrame): void;
  47231. private _attachController;
  47232. private _createDefaultTargetMesh;
  47233. private _detachController;
  47234. private _findClosestSnapPointWithRadius;
  47235. private _setTargetMeshPosition;
  47236. private _setTargetMeshVisibility;
  47237. private _showParabolicPath;
  47238. private _teleportForward;
  47239. }
  47240. }
  47241. declare module "babylonjs/XR/webXRDefaultExperience" {
  47242. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47243. import { Scene } from "babylonjs/scene";
  47244. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47245. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47246. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47247. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47249. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47250. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47251. /**
  47252. * Options for the default xr helper
  47253. */
  47254. export class WebXRDefaultExperienceOptions {
  47255. /**
  47256. * Enable or disable default UI to enter XR
  47257. */
  47258. disableDefaultUI?: boolean;
  47259. /**
  47260. * Should teleportation not initialize. defaults to false.
  47261. */
  47262. disableTeleportation?: boolean;
  47263. /**
  47264. * Floor meshes that will be used for teleport
  47265. */
  47266. floorMeshes?: Array<AbstractMesh>;
  47267. /**
  47268. * If set to true, the first frame will not be used to reset position
  47269. * The first frame is mainly used when copying transformation from the old camera
  47270. * Mainly used in AR
  47271. */
  47272. ignoreNativeCameraTransformation?: boolean;
  47273. /**
  47274. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47275. */
  47276. inputOptions?: IWebXRInputOptions;
  47277. /**
  47278. * optional configuration for the output canvas
  47279. */
  47280. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47281. /**
  47282. * optional UI options. This can be used among other to change session mode and reference space type
  47283. */
  47284. uiOptions?: WebXREnterExitUIOptions;
  47285. /**
  47286. * When loading teleportation and pointer select, use stable versions instead of latest.
  47287. */
  47288. useStablePlugins?: boolean;
  47289. /**
  47290. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  47291. */
  47292. renderingGroupId?: number;
  47293. /**
  47294. * A list of optional features to init the session with
  47295. * If set to true, all features we support will be added
  47296. */
  47297. optionalFeatures?: boolean | string[];
  47298. }
  47299. /**
  47300. * Default experience which provides a similar setup to the previous webVRExperience
  47301. */
  47302. export class WebXRDefaultExperience {
  47303. /**
  47304. * Base experience
  47305. */
  47306. baseExperience: WebXRExperienceHelper;
  47307. /**
  47308. * Enables ui for entering/exiting xr
  47309. */
  47310. enterExitUI: WebXREnterExitUI;
  47311. /**
  47312. * Input experience extension
  47313. */
  47314. input: WebXRInput;
  47315. /**
  47316. * Enables laser pointer and selection
  47317. */
  47318. pointerSelection: WebXRControllerPointerSelection;
  47319. /**
  47320. * Default target xr should render to
  47321. */
  47322. renderTarget: WebXRRenderTarget;
  47323. /**
  47324. * Enables teleportation
  47325. */
  47326. teleportation: WebXRMotionControllerTeleportation;
  47327. private constructor();
  47328. /**
  47329. * Creates the default xr experience
  47330. * @param scene scene
  47331. * @param options options for basic configuration
  47332. * @returns resulting WebXRDefaultExperience
  47333. */
  47334. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47335. /**
  47336. * DIsposes of the experience helper
  47337. */
  47338. dispose(): void;
  47339. }
  47340. }
  47341. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47342. import { Observable } from "babylonjs/Misc/observable";
  47343. import { Nullable } from "babylonjs/types";
  47344. import { Camera } from "babylonjs/Cameras/camera";
  47345. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47346. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47347. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47348. import { Scene } from "babylonjs/scene";
  47349. import { Vector3 } from "babylonjs/Maths/math.vector";
  47350. import { Color3 } from "babylonjs/Maths/math.color";
  47351. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47353. import { Mesh } from "babylonjs/Meshes/mesh";
  47354. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47355. import { EasingFunction } from "babylonjs/Animations/easing";
  47356. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47357. import "babylonjs/Meshes/Builders/groundBuilder";
  47358. import "babylonjs/Meshes/Builders/torusBuilder";
  47359. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47360. import "babylonjs/Gamepads/gamepadSceneComponent";
  47361. import "babylonjs/Animations/animatable";
  47362. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47363. /**
  47364. * Options to modify the vr teleportation behavior.
  47365. */
  47366. export interface VRTeleportationOptions {
  47367. /**
  47368. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47369. */
  47370. floorMeshName?: string;
  47371. /**
  47372. * A list of meshes to be used as the teleportation floor. (default: empty)
  47373. */
  47374. floorMeshes?: Mesh[];
  47375. /**
  47376. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47377. */
  47378. teleportationMode?: number;
  47379. /**
  47380. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47381. */
  47382. teleportationTime?: number;
  47383. /**
  47384. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47385. */
  47386. teleportationSpeed?: number;
  47387. /**
  47388. * The easing function used in the animation or null for Linear. (default CircleEase)
  47389. */
  47390. easingFunction?: EasingFunction;
  47391. }
  47392. /**
  47393. * Options to modify the vr experience helper's behavior.
  47394. */
  47395. export interface VRExperienceHelperOptions extends WebVROptions {
  47396. /**
  47397. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47398. */
  47399. createDeviceOrientationCamera?: boolean;
  47400. /**
  47401. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47402. */
  47403. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47404. /**
  47405. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47406. */
  47407. laserToggle?: boolean;
  47408. /**
  47409. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47410. */
  47411. floorMeshes?: Mesh[];
  47412. /**
  47413. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47414. */
  47415. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47416. /**
  47417. * Defines if WebXR should be used instead of WebVR (if available)
  47418. */
  47419. useXR?: boolean;
  47420. }
  47421. /**
  47422. * Event containing information after VR has been entered
  47423. */
  47424. export class OnAfterEnteringVRObservableEvent {
  47425. /**
  47426. * If entering vr was successful
  47427. */
  47428. success: boolean;
  47429. }
  47430. /**
  47431. * Helps to quickly add VR support to an existing scene.
  47432. * See http://doc.babylonjs.com/how_to/webvr_helper
  47433. */
  47434. export class VRExperienceHelper {
  47435. /** Options to modify the vr experience helper's behavior. */
  47436. webVROptions: VRExperienceHelperOptions;
  47437. private _scene;
  47438. private _position;
  47439. private _btnVR;
  47440. private _btnVRDisplayed;
  47441. private _webVRsupported;
  47442. private _webVRready;
  47443. private _webVRrequesting;
  47444. private _webVRpresenting;
  47445. private _hasEnteredVR;
  47446. private _fullscreenVRpresenting;
  47447. private _inputElement;
  47448. private _webVRCamera;
  47449. private _vrDeviceOrientationCamera;
  47450. private _deviceOrientationCamera;
  47451. private _existingCamera;
  47452. private _onKeyDown;
  47453. private _onVrDisplayPresentChange;
  47454. private _onVRDisplayChanged;
  47455. private _onVRRequestPresentStart;
  47456. private _onVRRequestPresentComplete;
  47457. /**
  47458. * 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)
  47459. */
  47460. enableGazeEvenWhenNoPointerLock: boolean;
  47461. /**
  47462. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47463. */
  47464. exitVROnDoubleTap: boolean;
  47465. /**
  47466. * Observable raised right before entering VR.
  47467. */
  47468. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47469. /**
  47470. * Observable raised when entering VR has completed.
  47471. */
  47472. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47473. /**
  47474. * Observable raised when exiting VR.
  47475. */
  47476. onExitingVRObservable: Observable<VRExperienceHelper>;
  47477. /**
  47478. * Observable raised when controller mesh is loaded.
  47479. */
  47480. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47481. /** Return this.onEnteringVRObservable
  47482. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47483. */
  47484. get onEnteringVR(): Observable<VRExperienceHelper>;
  47485. /** Return this.onExitingVRObservable
  47486. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47487. */
  47488. get onExitingVR(): Observable<VRExperienceHelper>;
  47489. /** Return this.onControllerMeshLoadedObservable
  47490. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47491. */
  47492. get onControllerMeshLoaded(): Observable<WebVRController>;
  47493. private _rayLength;
  47494. private _useCustomVRButton;
  47495. private _teleportationRequested;
  47496. private _teleportActive;
  47497. private _floorMeshName;
  47498. private _floorMeshesCollection;
  47499. private _teleportationMode;
  47500. private _teleportationTime;
  47501. private _teleportationSpeed;
  47502. private _teleportationEasing;
  47503. private _rotationAllowed;
  47504. private _teleportBackwardsVector;
  47505. private _teleportationTarget;
  47506. private _isDefaultTeleportationTarget;
  47507. private _postProcessMove;
  47508. private _teleportationFillColor;
  47509. private _teleportationBorderColor;
  47510. private _rotationAngle;
  47511. private _haloCenter;
  47512. private _cameraGazer;
  47513. private _padSensibilityUp;
  47514. private _padSensibilityDown;
  47515. private _leftController;
  47516. private _rightController;
  47517. private _gazeColor;
  47518. private _laserColor;
  47519. private _pickedLaserColor;
  47520. private _pickedGazeColor;
  47521. /**
  47522. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47523. */
  47524. onNewMeshSelected: Observable<AbstractMesh>;
  47525. /**
  47526. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47527. * This observable will provide the mesh and the controller used to select the mesh
  47528. */
  47529. onMeshSelectedWithController: Observable<{
  47530. mesh: AbstractMesh;
  47531. controller: WebVRController;
  47532. }>;
  47533. /**
  47534. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47535. */
  47536. onNewMeshPicked: Observable<PickingInfo>;
  47537. private _circleEase;
  47538. /**
  47539. * Observable raised before camera teleportation
  47540. */
  47541. onBeforeCameraTeleport: Observable<Vector3>;
  47542. /**
  47543. * Observable raised after camera teleportation
  47544. */
  47545. onAfterCameraTeleport: Observable<Vector3>;
  47546. /**
  47547. * Observable raised when current selected mesh gets unselected
  47548. */
  47549. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47550. private _raySelectionPredicate;
  47551. /**
  47552. * To be optionaly changed by user to define custom ray selection
  47553. */
  47554. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47555. /**
  47556. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47557. */
  47558. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47559. /**
  47560. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47561. */
  47562. teleportationEnabled: boolean;
  47563. private _defaultHeight;
  47564. private _teleportationInitialized;
  47565. private _interactionsEnabled;
  47566. private _interactionsRequested;
  47567. private _displayGaze;
  47568. private _displayLaserPointer;
  47569. /**
  47570. * The mesh used to display where the user is going to teleport.
  47571. */
  47572. get teleportationTarget(): Mesh;
  47573. /**
  47574. * Sets the mesh to be used to display where the user is going to teleport.
  47575. */
  47576. set teleportationTarget(value: Mesh);
  47577. /**
  47578. * 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
  47579. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47580. * See http://doc.babylonjs.com/resources/baking_transformations
  47581. */
  47582. get gazeTrackerMesh(): Mesh;
  47583. set gazeTrackerMesh(value: Mesh);
  47584. /**
  47585. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47586. */
  47587. updateGazeTrackerScale: boolean;
  47588. /**
  47589. * If the gaze trackers color should be updated when selecting meshes
  47590. */
  47591. updateGazeTrackerColor: boolean;
  47592. /**
  47593. * If the controller laser color should be updated when selecting meshes
  47594. */
  47595. updateControllerLaserColor: boolean;
  47596. /**
  47597. * The gaze tracking mesh corresponding to the left controller
  47598. */
  47599. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47600. /**
  47601. * The gaze tracking mesh corresponding to the right controller
  47602. */
  47603. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47604. /**
  47605. * If the ray of the gaze should be displayed.
  47606. */
  47607. get displayGaze(): boolean;
  47608. /**
  47609. * Sets if the ray of the gaze should be displayed.
  47610. */
  47611. set displayGaze(value: boolean);
  47612. /**
  47613. * If the ray of the LaserPointer should be displayed.
  47614. */
  47615. get displayLaserPointer(): boolean;
  47616. /**
  47617. * Sets if the ray of the LaserPointer should be displayed.
  47618. */
  47619. set displayLaserPointer(value: boolean);
  47620. /**
  47621. * The deviceOrientationCamera used as the camera when not in VR.
  47622. */
  47623. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47624. /**
  47625. * Based on the current WebVR support, returns the current VR camera used.
  47626. */
  47627. get currentVRCamera(): Nullable<Camera>;
  47628. /**
  47629. * The webVRCamera which is used when in VR.
  47630. */
  47631. get webVRCamera(): WebVRFreeCamera;
  47632. /**
  47633. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47634. */
  47635. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47636. /**
  47637. * The html button that is used to trigger entering into VR.
  47638. */
  47639. get vrButton(): Nullable<HTMLButtonElement>;
  47640. private get _teleportationRequestInitiated();
  47641. /**
  47642. * Defines whether or not Pointer lock should be requested when switching to
  47643. * full screen.
  47644. */
  47645. requestPointerLockOnFullScreen: boolean;
  47646. /**
  47647. * If asking to force XR, this will be populated with the default xr experience
  47648. */
  47649. xr: WebXRDefaultExperience;
  47650. /**
  47651. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47652. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47653. */
  47654. xrTestDone: boolean;
  47655. /**
  47656. * Instantiates a VRExperienceHelper.
  47657. * Helps to quickly add VR support to an existing scene.
  47658. * @param scene The scene the VRExperienceHelper belongs to.
  47659. * @param webVROptions Options to modify the vr experience helper's behavior.
  47660. */
  47661. constructor(scene: Scene,
  47662. /** Options to modify the vr experience helper's behavior. */
  47663. webVROptions?: VRExperienceHelperOptions);
  47664. private completeVRInit;
  47665. private _onDefaultMeshLoaded;
  47666. private _onResize;
  47667. private _onFullscreenChange;
  47668. /**
  47669. * Gets a value indicating if we are currently in VR mode.
  47670. */
  47671. get isInVRMode(): boolean;
  47672. private onVrDisplayPresentChange;
  47673. private onVRDisplayChanged;
  47674. private moveButtonToBottomRight;
  47675. private displayVRButton;
  47676. private updateButtonVisibility;
  47677. private _cachedAngularSensibility;
  47678. /**
  47679. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47680. * Otherwise, will use the fullscreen API.
  47681. */
  47682. enterVR(): void;
  47683. /**
  47684. * Attempt to exit VR, or fullscreen.
  47685. */
  47686. exitVR(): void;
  47687. /**
  47688. * The position of the vr experience helper.
  47689. */
  47690. get position(): Vector3;
  47691. /**
  47692. * Sets the position of the vr experience helper.
  47693. */
  47694. set position(value: Vector3);
  47695. /**
  47696. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47697. */
  47698. enableInteractions(): void;
  47699. private get _noControllerIsActive();
  47700. private beforeRender;
  47701. private _isTeleportationFloor;
  47702. /**
  47703. * Adds a floor mesh to be used for teleportation.
  47704. * @param floorMesh the mesh to be used for teleportation.
  47705. */
  47706. addFloorMesh(floorMesh: Mesh): void;
  47707. /**
  47708. * Removes a floor mesh from being used for teleportation.
  47709. * @param floorMesh the mesh to be removed.
  47710. */
  47711. removeFloorMesh(floorMesh: Mesh): void;
  47712. /**
  47713. * Enables interactions and teleportation using the VR controllers and gaze.
  47714. * @param vrTeleportationOptions options to modify teleportation behavior.
  47715. */
  47716. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47717. private _onNewGamepadConnected;
  47718. private _tryEnableInteractionOnController;
  47719. private _onNewGamepadDisconnected;
  47720. private _enableInteractionOnController;
  47721. private _checkTeleportWithRay;
  47722. private _checkRotate;
  47723. private _checkTeleportBackwards;
  47724. private _enableTeleportationOnController;
  47725. private _createTeleportationCircles;
  47726. private _displayTeleportationTarget;
  47727. private _hideTeleportationTarget;
  47728. private _rotateCamera;
  47729. private _moveTeleportationSelectorTo;
  47730. private _workingVector;
  47731. private _workingQuaternion;
  47732. private _workingMatrix;
  47733. /**
  47734. * Time Constant Teleportation Mode
  47735. */
  47736. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47737. /**
  47738. * Speed Constant Teleportation Mode
  47739. */
  47740. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47741. /**
  47742. * Teleports the users feet to the desired location
  47743. * @param location The location where the user's feet should be placed
  47744. */
  47745. teleportCamera(location: Vector3): void;
  47746. private _convertNormalToDirectionOfRay;
  47747. private _castRayAndSelectObject;
  47748. private _notifySelectedMeshUnselected;
  47749. /**
  47750. * Permanently set new colors for the laser pointer
  47751. * @param color the new laser color
  47752. * @param pickedColor the new laser color when picked mesh detected
  47753. */
  47754. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47755. /**
  47756. * Set lighting enabled / disabled on the laser pointer of both controllers
  47757. * @param enabled should the lighting be enabled on the laser pointer
  47758. */
  47759. setLaserLightingState(enabled?: boolean): void;
  47760. /**
  47761. * Permanently set new colors for the gaze pointer
  47762. * @param color the new gaze color
  47763. * @param pickedColor the new gaze color when picked mesh detected
  47764. */
  47765. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47766. /**
  47767. * Sets the color of the laser ray from the vr controllers.
  47768. * @param color new color for the ray.
  47769. */
  47770. changeLaserColor(color: Color3): void;
  47771. /**
  47772. * Sets the color of the ray from the vr headsets gaze.
  47773. * @param color new color for the ray.
  47774. */
  47775. changeGazeColor(color: Color3): void;
  47776. /**
  47777. * Exits VR and disposes of the vr experience helper
  47778. */
  47779. dispose(): void;
  47780. /**
  47781. * Gets the name of the VRExperienceHelper class
  47782. * @returns "VRExperienceHelper"
  47783. */
  47784. getClassName(): string;
  47785. }
  47786. }
  47787. declare module "babylonjs/Cameras/VR/index" {
  47788. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47789. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47790. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47791. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47792. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47793. export * from "babylonjs/Cameras/VR/webVRCamera";
  47794. }
  47795. declare module "babylonjs/Cameras/RigModes/index" {
  47796. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47797. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47798. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47799. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47800. }
  47801. declare module "babylonjs/Cameras/index" {
  47802. export * from "babylonjs/Cameras/Inputs/index";
  47803. export * from "babylonjs/Cameras/cameraInputsManager";
  47804. export * from "babylonjs/Cameras/camera";
  47805. export * from "babylonjs/Cameras/targetCamera";
  47806. export * from "babylonjs/Cameras/freeCamera";
  47807. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47808. export * from "babylonjs/Cameras/touchCamera";
  47809. export * from "babylonjs/Cameras/arcRotateCamera";
  47810. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47811. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47812. export * from "babylonjs/Cameras/flyCamera";
  47813. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47814. export * from "babylonjs/Cameras/followCamera";
  47815. export * from "babylonjs/Cameras/followCameraInputsManager";
  47816. export * from "babylonjs/Cameras/gamepadCamera";
  47817. export * from "babylonjs/Cameras/Stereoscopic/index";
  47818. export * from "babylonjs/Cameras/universalCamera";
  47819. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47820. export * from "babylonjs/Cameras/VR/index";
  47821. export * from "babylonjs/Cameras/RigModes/index";
  47822. }
  47823. declare module "babylonjs/Collisions/index" {
  47824. export * from "babylonjs/Collisions/collider";
  47825. export * from "babylonjs/Collisions/collisionCoordinator";
  47826. export * from "babylonjs/Collisions/pickingInfo";
  47827. export * from "babylonjs/Collisions/intersectionInfo";
  47828. export * from "babylonjs/Collisions/meshCollisionData";
  47829. }
  47830. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47831. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47832. import { Vector3 } from "babylonjs/Maths/math.vector";
  47833. import { Ray } from "babylonjs/Culling/ray";
  47834. import { Plane } from "babylonjs/Maths/math.plane";
  47835. /**
  47836. * Contains an array of blocks representing the octree
  47837. */
  47838. export interface IOctreeContainer<T> {
  47839. /**
  47840. * Blocks within the octree
  47841. */
  47842. blocks: Array<OctreeBlock<T>>;
  47843. }
  47844. /**
  47845. * Class used to store a cell in an octree
  47846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47847. */
  47848. export class OctreeBlock<T> {
  47849. /**
  47850. * Gets the content of the current block
  47851. */
  47852. entries: T[];
  47853. /**
  47854. * Gets the list of block children
  47855. */
  47856. blocks: Array<OctreeBlock<T>>;
  47857. private _depth;
  47858. private _maxDepth;
  47859. private _capacity;
  47860. private _minPoint;
  47861. private _maxPoint;
  47862. private _boundingVectors;
  47863. private _creationFunc;
  47864. /**
  47865. * Creates a new block
  47866. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47867. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47868. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47869. * @param depth defines the current depth of this block in the octree
  47870. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47871. * @param creationFunc defines a callback to call when an element is added to the block
  47872. */
  47873. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47874. /**
  47875. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47876. */
  47877. get capacity(): number;
  47878. /**
  47879. * Gets the minimum vector (in world space) of the block's bounding box
  47880. */
  47881. get minPoint(): Vector3;
  47882. /**
  47883. * Gets the maximum vector (in world space) of the block's bounding box
  47884. */
  47885. get maxPoint(): Vector3;
  47886. /**
  47887. * Add a new element to this block
  47888. * @param entry defines the element to add
  47889. */
  47890. addEntry(entry: T): void;
  47891. /**
  47892. * Remove an element from this block
  47893. * @param entry defines the element to remove
  47894. */
  47895. removeEntry(entry: T): void;
  47896. /**
  47897. * Add an array of elements to this block
  47898. * @param entries defines the array of elements to add
  47899. */
  47900. addEntries(entries: T[]): void;
  47901. /**
  47902. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47903. * @param frustumPlanes defines the frustum planes to test
  47904. * @param selection defines the array to store current content if selection is positive
  47905. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47906. */
  47907. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47908. /**
  47909. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47910. * @param sphereCenter defines the bounding sphere center
  47911. * @param sphereRadius defines the bounding sphere radius
  47912. * @param selection defines the array to store current content if selection is positive
  47913. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47914. */
  47915. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47916. /**
  47917. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47918. * @param ray defines the ray to test with
  47919. * @param selection defines the array to store current content if selection is positive
  47920. */
  47921. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47922. /**
  47923. * Subdivide the content into child blocks (this block will then be empty)
  47924. */
  47925. createInnerBlocks(): void;
  47926. /**
  47927. * @hidden
  47928. */
  47929. 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;
  47930. }
  47931. }
  47932. declare module "babylonjs/Culling/Octrees/octree" {
  47933. import { SmartArray } from "babylonjs/Misc/smartArray";
  47934. import { Vector3 } from "babylonjs/Maths/math.vector";
  47935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47937. import { Ray } from "babylonjs/Culling/ray";
  47938. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47939. import { Plane } from "babylonjs/Maths/math.plane";
  47940. /**
  47941. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47942. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47943. */
  47944. export class Octree<T> {
  47945. /** 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.) */
  47946. maxDepth: number;
  47947. /**
  47948. * Blocks within the octree containing objects
  47949. */
  47950. blocks: Array<OctreeBlock<T>>;
  47951. /**
  47952. * Content stored in the octree
  47953. */
  47954. dynamicContent: T[];
  47955. private _maxBlockCapacity;
  47956. private _selectionContent;
  47957. private _creationFunc;
  47958. /**
  47959. * Creates a octree
  47960. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47961. * @param creationFunc function to be used to instatiate the octree
  47962. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47963. * @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.)
  47964. */
  47965. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47966. /** 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.) */
  47967. maxDepth?: number);
  47968. /**
  47969. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47970. * @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);
  47971. * @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);
  47972. * @param entries meshes to be added to the octree blocks
  47973. */
  47974. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47975. /**
  47976. * Adds a mesh to the octree
  47977. * @param entry Mesh to add to the octree
  47978. */
  47979. addMesh(entry: T): void;
  47980. /**
  47981. * Remove an element from the octree
  47982. * @param entry defines the element to remove
  47983. */
  47984. removeMesh(entry: T): void;
  47985. /**
  47986. * Selects an array of meshes within the frustum
  47987. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47988. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47989. * @returns array of meshes within the frustum
  47990. */
  47991. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47992. /**
  47993. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47994. * @param sphereCenter defines the bounding sphere center
  47995. * @param sphereRadius defines the bounding sphere radius
  47996. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47997. * @returns an array of objects that intersect the sphere
  47998. */
  47999. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48000. /**
  48001. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48002. * @param ray defines the ray to test with
  48003. * @returns array of intersected objects
  48004. */
  48005. intersectsRay(ray: Ray): SmartArray<T>;
  48006. /**
  48007. * Adds a mesh into the octree block if it intersects the block
  48008. */
  48009. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48010. /**
  48011. * Adds a submesh into the octree block if it intersects the block
  48012. */
  48013. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48014. }
  48015. }
  48016. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  48017. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  48018. import { Scene } from "babylonjs/scene";
  48019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48021. import { Ray } from "babylonjs/Culling/ray";
  48022. import { Octree } from "babylonjs/Culling/Octrees/octree";
  48023. import { Collider } from "babylonjs/Collisions/collider";
  48024. module "babylonjs/scene" {
  48025. interface Scene {
  48026. /**
  48027. * @hidden
  48028. * Backing Filed
  48029. */
  48030. _selectionOctree: Octree<AbstractMesh>;
  48031. /**
  48032. * Gets the octree used to boost mesh selection (picking)
  48033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48034. */
  48035. selectionOctree: Octree<AbstractMesh>;
  48036. /**
  48037. * Creates or updates the octree used to boost selection (picking)
  48038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48039. * @param maxCapacity defines the maximum capacity per leaf
  48040. * @param maxDepth defines the maximum depth of the octree
  48041. * @returns an octree of AbstractMesh
  48042. */
  48043. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48044. }
  48045. }
  48046. module "babylonjs/Meshes/abstractMesh" {
  48047. interface AbstractMesh {
  48048. /**
  48049. * @hidden
  48050. * Backing Field
  48051. */
  48052. _submeshesOctree: Octree<SubMesh>;
  48053. /**
  48054. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48055. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48056. * @param maxCapacity defines the maximum size of each block (64 by default)
  48057. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48058. * @returns the new octree
  48059. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48061. */
  48062. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48063. }
  48064. }
  48065. /**
  48066. * Defines the octree scene component responsible to manage any octrees
  48067. * in a given scene.
  48068. */
  48069. export class OctreeSceneComponent {
  48070. /**
  48071. * The component name help to identify the component in the list of scene components.
  48072. */
  48073. readonly name: string;
  48074. /**
  48075. * The scene the component belongs to.
  48076. */
  48077. scene: Scene;
  48078. /**
  48079. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48080. */
  48081. readonly checksIsEnabled: boolean;
  48082. /**
  48083. * Creates a new instance of the component for the given scene
  48084. * @param scene Defines the scene to register the component in
  48085. */
  48086. constructor(scene: Scene);
  48087. /**
  48088. * Registers the component in a given scene
  48089. */
  48090. register(): void;
  48091. /**
  48092. * Return the list of active meshes
  48093. * @returns the list of active meshes
  48094. */
  48095. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48096. /**
  48097. * Return the list of active sub meshes
  48098. * @param mesh The mesh to get the candidates sub meshes from
  48099. * @returns the list of active sub meshes
  48100. */
  48101. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48102. private _tempRay;
  48103. /**
  48104. * Return the list of sub meshes intersecting with a given local ray
  48105. * @param mesh defines the mesh to find the submesh for
  48106. * @param localRay defines the ray in local space
  48107. * @returns the list of intersecting sub meshes
  48108. */
  48109. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48110. /**
  48111. * Return the list of sub meshes colliding with a collider
  48112. * @param mesh defines the mesh to find the submesh for
  48113. * @param collider defines the collider to evaluate the collision against
  48114. * @returns the list of colliding sub meshes
  48115. */
  48116. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48117. /**
  48118. * Rebuilds the elements related to this component in case of
  48119. * context lost for instance.
  48120. */
  48121. rebuild(): void;
  48122. /**
  48123. * Disposes the component and the associated ressources.
  48124. */
  48125. dispose(): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Culling/Octrees/index" {
  48129. export * from "babylonjs/Culling/Octrees/octree";
  48130. export * from "babylonjs/Culling/Octrees/octreeBlock";
  48131. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  48132. }
  48133. declare module "babylonjs/Culling/index" {
  48134. export * from "babylonjs/Culling/boundingBox";
  48135. export * from "babylonjs/Culling/boundingInfo";
  48136. export * from "babylonjs/Culling/boundingSphere";
  48137. export * from "babylonjs/Culling/Octrees/index";
  48138. export * from "babylonjs/Culling/ray";
  48139. }
  48140. declare module "babylonjs/Gizmos/gizmo" {
  48141. import { Nullable } from "babylonjs/types";
  48142. import { IDisposable } from "babylonjs/scene";
  48143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48144. import { Mesh } from "babylonjs/Meshes/mesh";
  48145. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48146. /**
  48147. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48148. */
  48149. export class Gizmo implements IDisposable {
  48150. /** The utility layer the gizmo will be added to */
  48151. gizmoLayer: UtilityLayerRenderer;
  48152. /**
  48153. * The root mesh of the gizmo
  48154. */
  48155. _rootMesh: Mesh;
  48156. private _attachedMesh;
  48157. /**
  48158. * Ratio for the scale of the gizmo (Default: 1)
  48159. */
  48160. scaleRatio: number;
  48161. /**
  48162. * If a custom mesh has been set (Default: false)
  48163. */
  48164. protected _customMeshSet: boolean;
  48165. /**
  48166. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48167. * * When set, interactions will be enabled
  48168. */
  48169. get attachedMesh(): Nullable<AbstractMesh>;
  48170. set attachedMesh(value: Nullable<AbstractMesh>);
  48171. /**
  48172. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48173. * @param mesh The mesh to replace the default mesh of the gizmo
  48174. */
  48175. setCustomMesh(mesh: Mesh): void;
  48176. /**
  48177. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48178. */
  48179. updateGizmoRotationToMatchAttachedMesh: boolean;
  48180. /**
  48181. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48182. */
  48183. updateGizmoPositionToMatchAttachedMesh: boolean;
  48184. /**
  48185. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48186. */
  48187. updateScale: boolean;
  48188. protected _interactionsEnabled: boolean;
  48189. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48190. private _beforeRenderObserver;
  48191. private _tempVector;
  48192. /**
  48193. * Creates a gizmo
  48194. * @param gizmoLayer The utility layer the gizmo will be added to
  48195. */
  48196. constructor(
  48197. /** The utility layer the gizmo will be added to */
  48198. gizmoLayer?: UtilityLayerRenderer);
  48199. /**
  48200. * Updates the gizmo to match the attached mesh's position/rotation
  48201. */
  48202. protected _update(): void;
  48203. /**
  48204. * Disposes of the gizmo
  48205. */
  48206. dispose(): void;
  48207. }
  48208. }
  48209. declare module "babylonjs/Gizmos/planeDragGizmo" {
  48210. import { Observable } from "babylonjs/Misc/observable";
  48211. import { Nullable } from "babylonjs/types";
  48212. import { Vector3 } from "babylonjs/Maths/math.vector";
  48213. import { Color3 } from "babylonjs/Maths/math.color";
  48214. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48216. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48217. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48218. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48219. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48220. import { Scene } from "babylonjs/scene";
  48221. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48222. /**
  48223. * Single plane drag gizmo
  48224. */
  48225. export class PlaneDragGizmo extends Gizmo {
  48226. /**
  48227. * Drag behavior responsible for the gizmos dragging interactions
  48228. */
  48229. dragBehavior: PointerDragBehavior;
  48230. private _pointerObserver;
  48231. /**
  48232. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48233. */
  48234. snapDistance: number;
  48235. /**
  48236. * Event that fires each time the gizmo snaps to a new location.
  48237. * * snapDistance is the the change in distance
  48238. */
  48239. onSnapObservable: Observable<{
  48240. snapDistance: number;
  48241. }>;
  48242. private _plane;
  48243. private _coloredMaterial;
  48244. private _hoverMaterial;
  48245. private _isEnabled;
  48246. private _parent;
  48247. /** @hidden */
  48248. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48249. /** @hidden */
  48250. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48251. /**
  48252. * Creates a PlaneDragGizmo
  48253. * @param gizmoLayer The utility layer the gizmo will be added to
  48254. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48255. * @param color The color of the gizmo
  48256. */
  48257. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48258. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48259. /**
  48260. * If the gizmo is enabled
  48261. */
  48262. set isEnabled(value: boolean);
  48263. get isEnabled(): boolean;
  48264. /**
  48265. * Disposes of the gizmo
  48266. */
  48267. dispose(): void;
  48268. }
  48269. }
  48270. declare module "babylonjs/Gizmos/positionGizmo" {
  48271. import { Observable } from "babylonjs/Misc/observable";
  48272. import { Nullable } from "babylonjs/types";
  48273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48274. import { Mesh } from "babylonjs/Meshes/mesh";
  48275. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48276. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48277. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48278. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48279. /**
  48280. * Gizmo that enables dragging a mesh along 3 axis
  48281. */
  48282. export class PositionGizmo extends Gizmo {
  48283. /**
  48284. * Internal gizmo used for interactions on the x axis
  48285. */
  48286. xGizmo: AxisDragGizmo;
  48287. /**
  48288. * Internal gizmo used for interactions on the y axis
  48289. */
  48290. yGizmo: AxisDragGizmo;
  48291. /**
  48292. * Internal gizmo used for interactions on the z axis
  48293. */
  48294. zGizmo: AxisDragGizmo;
  48295. /**
  48296. * Internal gizmo used for interactions on the yz plane
  48297. */
  48298. xPlaneGizmo: PlaneDragGizmo;
  48299. /**
  48300. * Internal gizmo used for interactions on the xz plane
  48301. */
  48302. yPlaneGizmo: PlaneDragGizmo;
  48303. /**
  48304. * Internal gizmo used for interactions on the xy plane
  48305. */
  48306. zPlaneGizmo: PlaneDragGizmo;
  48307. /**
  48308. * private variables
  48309. */
  48310. private _meshAttached;
  48311. private _updateGizmoRotationToMatchAttachedMesh;
  48312. private _snapDistance;
  48313. private _scaleRatio;
  48314. /** Fires an event when any of it's sub gizmos are dragged */
  48315. onDragStartObservable: Observable<unknown>;
  48316. /** Fires an event when any of it's sub gizmos are released from dragging */
  48317. onDragEndObservable: Observable<unknown>;
  48318. /**
  48319. * If set to true, planar drag is enabled
  48320. */
  48321. private _planarGizmoEnabled;
  48322. get attachedMesh(): Nullable<AbstractMesh>;
  48323. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48324. /**
  48325. * Creates a PositionGizmo
  48326. * @param gizmoLayer The utility layer the gizmo will be added to
  48327. */
  48328. constructor(gizmoLayer?: UtilityLayerRenderer);
  48329. /**
  48330. * If the planar drag gizmo is enabled
  48331. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48332. */
  48333. set planarGizmoEnabled(value: boolean);
  48334. get planarGizmoEnabled(): boolean;
  48335. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48336. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48337. /**
  48338. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48339. */
  48340. set snapDistance(value: number);
  48341. get snapDistance(): number;
  48342. /**
  48343. * Ratio for the scale of the gizmo (Default: 1)
  48344. */
  48345. set scaleRatio(value: number);
  48346. get scaleRatio(): number;
  48347. /**
  48348. * Disposes of the gizmo
  48349. */
  48350. dispose(): void;
  48351. /**
  48352. * CustomMeshes are not supported by this gizmo
  48353. * @param mesh The mesh to replace the default mesh of the gizmo
  48354. */
  48355. setCustomMesh(mesh: Mesh): void;
  48356. }
  48357. }
  48358. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48359. import { Observable } from "babylonjs/Misc/observable";
  48360. import { Nullable } from "babylonjs/types";
  48361. import { Vector3 } from "babylonjs/Maths/math.vector";
  48362. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48364. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48365. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48366. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48367. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48368. import { Scene } from "babylonjs/scene";
  48369. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48370. import { Color3 } from "babylonjs/Maths/math.color";
  48371. /**
  48372. * Single axis drag gizmo
  48373. */
  48374. export class AxisDragGizmo extends Gizmo {
  48375. /**
  48376. * Drag behavior responsible for the gizmos dragging interactions
  48377. */
  48378. dragBehavior: PointerDragBehavior;
  48379. private _pointerObserver;
  48380. /**
  48381. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48382. */
  48383. snapDistance: number;
  48384. /**
  48385. * Event that fires each time the gizmo snaps to a new location.
  48386. * * snapDistance is the the change in distance
  48387. */
  48388. onSnapObservable: Observable<{
  48389. snapDistance: number;
  48390. }>;
  48391. private _isEnabled;
  48392. private _parent;
  48393. private _arrow;
  48394. private _coloredMaterial;
  48395. private _hoverMaterial;
  48396. /** @hidden */
  48397. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48398. /** @hidden */
  48399. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48400. /**
  48401. * Creates an AxisDragGizmo
  48402. * @param gizmoLayer The utility layer the gizmo will be added to
  48403. * @param dragAxis The axis which the gizmo will be able to drag on
  48404. * @param color The color of the gizmo
  48405. */
  48406. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48407. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48408. /**
  48409. * If the gizmo is enabled
  48410. */
  48411. set isEnabled(value: boolean);
  48412. get isEnabled(): boolean;
  48413. /**
  48414. * Disposes of the gizmo
  48415. */
  48416. dispose(): void;
  48417. }
  48418. }
  48419. declare module "babylonjs/Debug/axesViewer" {
  48420. import { Vector3 } from "babylonjs/Maths/math.vector";
  48421. import { Nullable } from "babylonjs/types";
  48422. import { Scene } from "babylonjs/scene";
  48423. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48424. /**
  48425. * The Axes viewer will show 3 axes in a specific point in space
  48426. */
  48427. export class AxesViewer {
  48428. private _xAxis;
  48429. private _yAxis;
  48430. private _zAxis;
  48431. private _scaleLinesFactor;
  48432. private _instanced;
  48433. /**
  48434. * Gets the hosting scene
  48435. */
  48436. scene: Scene;
  48437. /**
  48438. * Gets or sets a number used to scale line length
  48439. */
  48440. scaleLines: number;
  48441. /** Gets the node hierarchy used to render x-axis */
  48442. get xAxis(): TransformNode;
  48443. /** Gets the node hierarchy used to render y-axis */
  48444. get yAxis(): TransformNode;
  48445. /** Gets the node hierarchy used to render z-axis */
  48446. get zAxis(): TransformNode;
  48447. /**
  48448. * Creates a new AxesViewer
  48449. * @param scene defines the hosting scene
  48450. * @param scaleLines defines a number used to scale line length (1 by default)
  48451. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48452. * @param xAxis defines the node hierarchy used to render the x-axis
  48453. * @param yAxis defines the node hierarchy used to render the y-axis
  48454. * @param zAxis defines the node hierarchy used to render the z-axis
  48455. */
  48456. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48457. /**
  48458. * Force the viewer to update
  48459. * @param position defines the position of the viewer
  48460. * @param xaxis defines the x axis of the viewer
  48461. * @param yaxis defines the y axis of the viewer
  48462. * @param zaxis defines the z axis of the viewer
  48463. */
  48464. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48465. /**
  48466. * Creates an instance of this axes viewer.
  48467. * @returns a new axes viewer with instanced meshes
  48468. */
  48469. createInstance(): AxesViewer;
  48470. /** Releases resources */
  48471. dispose(): void;
  48472. private static _SetRenderingGroupId;
  48473. }
  48474. }
  48475. declare module "babylonjs/Debug/boneAxesViewer" {
  48476. import { Nullable } from "babylonjs/types";
  48477. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48478. import { Vector3 } from "babylonjs/Maths/math.vector";
  48479. import { Mesh } from "babylonjs/Meshes/mesh";
  48480. import { Bone } from "babylonjs/Bones/bone";
  48481. import { Scene } from "babylonjs/scene";
  48482. /**
  48483. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48484. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48485. */
  48486. export class BoneAxesViewer extends AxesViewer {
  48487. /**
  48488. * Gets or sets the target mesh where to display the axes viewer
  48489. */
  48490. mesh: Nullable<Mesh>;
  48491. /**
  48492. * Gets or sets the target bone where to display the axes viewer
  48493. */
  48494. bone: Nullable<Bone>;
  48495. /** Gets current position */
  48496. pos: Vector3;
  48497. /** Gets direction of X axis */
  48498. xaxis: Vector3;
  48499. /** Gets direction of Y axis */
  48500. yaxis: Vector3;
  48501. /** Gets direction of Z axis */
  48502. zaxis: Vector3;
  48503. /**
  48504. * Creates a new BoneAxesViewer
  48505. * @param scene defines the hosting scene
  48506. * @param bone defines the target bone
  48507. * @param mesh defines the target mesh
  48508. * @param scaleLines defines a scaling factor for line length (1 by default)
  48509. */
  48510. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48511. /**
  48512. * Force the viewer to update
  48513. */
  48514. update(): void;
  48515. /** Releases resources */
  48516. dispose(): void;
  48517. }
  48518. }
  48519. declare module "babylonjs/Debug/debugLayer" {
  48520. import { Scene } from "babylonjs/scene";
  48521. /**
  48522. * Interface used to define scene explorer extensibility option
  48523. */
  48524. export interface IExplorerExtensibilityOption {
  48525. /**
  48526. * Define the option label
  48527. */
  48528. label: string;
  48529. /**
  48530. * Defines the action to execute on click
  48531. */
  48532. action: (entity: any) => void;
  48533. }
  48534. /**
  48535. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48536. */
  48537. export interface IExplorerExtensibilityGroup {
  48538. /**
  48539. * Defines a predicate to test if a given type mut be extended
  48540. */
  48541. predicate: (entity: any) => boolean;
  48542. /**
  48543. * Gets the list of options added to a type
  48544. */
  48545. entries: IExplorerExtensibilityOption[];
  48546. }
  48547. /**
  48548. * Interface used to define the options to use to create the Inspector
  48549. */
  48550. export interface IInspectorOptions {
  48551. /**
  48552. * Display in overlay mode (default: false)
  48553. */
  48554. overlay?: boolean;
  48555. /**
  48556. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48557. */
  48558. globalRoot?: HTMLElement;
  48559. /**
  48560. * Display the Scene explorer
  48561. */
  48562. showExplorer?: boolean;
  48563. /**
  48564. * Display the property inspector
  48565. */
  48566. showInspector?: boolean;
  48567. /**
  48568. * Display in embed mode (both panes on the right)
  48569. */
  48570. embedMode?: boolean;
  48571. /**
  48572. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48573. */
  48574. handleResize?: boolean;
  48575. /**
  48576. * Allow the panes to popup (default: true)
  48577. */
  48578. enablePopup?: boolean;
  48579. /**
  48580. * Allow the panes to be closed by users (default: true)
  48581. */
  48582. enableClose?: boolean;
  48583. /**
  48584. * Optional list of extensibility entries
  48585. */
  48586. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48587. /**
  48588. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48589. */
  48590. inspectorURL?: string;
  48591. /**
  48592. * Optional initial tab (default to DebugLayerTab.Properties)
  48593. */
  48594. initialTab?: DebugLayerTab;
  48595. }
  48596. module "babylonjs/scene" {
  48597. interface Scene {
  48598. /**
  48599. * @hidden
  48600. * Backing field
  48601. */
  48602. _debugLayer: DebugLayer;
  48603. /**
  48604. * Gets the debug layer (aka Inspector) associated with the scene
  48605. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48606. */
  48607. debugLayer: DebugLayer;
  48608. }
  48609. }
  48610. /**
  48611. * Enum of inspector action tab
  48612. */
  48613. export enum DebugLayerTab {
  48614. /**
  48615. * Properties tag (default)
  48616. */
  48617. Properties = 0,
  48618. /**
  48619. * Debug tab
  48620. */
  48621. Debug = 1,
  48622. /**
  48623. * Statistics tab
  48624. */
  48625. Statistics = 2,
  48626. /**
  48627. * Tools tab
  48628. */
  48629. Tools = 3,
  48630. /**
  48631. * Settings tab
  48632. */
  48633. Settings = 4
  48634. }
  48635. /**
  48636. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48637. * what is happening in your scene
  48638. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48639. */
  48640. export class DebugLayer {
  48641. /**
  48642. * Define the url to get the inspector script from.
  48643. * By default it uses the babylonjs CDN.
  48644. * @ignoreNaming
  48645. */
  48646. static InspectorURL: string;
  48647. private _scene;
  48648. private BJSINSPECTOR;
  48649. private _onPropertyChangedObservable?;
  48650. /**
  48651. * Observable triggered when a property is changed through the inspector.
  48652. */
  48653. get onPropertyChangedObservable(): any;
  48654. /**
  48655. * Instantiates a new debug layer.
  48656. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48657. * what is happening in your scene
  48658. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48659. * @param scene Defines the scene to inspect
  48660. */
  48661. constructor(scene: Scene);
  48662. /** Creates the inspector window. */
  48663. private _createInspector;
  48664. /**
  48665. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48666. * @param entity defines the entity to select
  48667. * @param lineContainerTitle defines the specific block to highlight
  48668. */
  48669. select(entity: any, lineContainerTitle?: string): void;
  48670. /** Get the inspector from bundle or global */
  48671. private _getGlobalInspector;
  48672. /**
  48673. * Get if the inspector is visible or not.
  48674. * @returns true if visible otherwise, false
  48675. */
  48676. isVisible(): boolean;
  48677. /**
  48678. * Hide the inspector and close its window.
  48679. */
  48680. hide(): void;
  48681. /**
  48682. * Update the scene in the inspector
  48683. */
  48684. setAsActiveScene(): void;
  48685. /**
  48686. * Launch the debugLayer.
  48687. * @param config Define the configuration of the inspector
  48688. * @return a promise fulfilled when the debug layer is visible
  48689. */
  48690. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48691. }
  48692. }
  48693. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48694. import { Nullable } from "babylonjs/types";
  48695. import { Scene } from "babylonjs/scene";
  48696. import { Vector4 } from "babylonjs/Maths/math.vector";
  48697. import { Color4 } from "babylonjs/Maths/math.color";
  48698. import { Mesh } from "babylonjs/Meshes/mesh";
  48699. /**
  48700. * Class containing static functions to help procedurally build meshes
  48701. */
  48702. export class BoxBuilder {
  48703. /**
  48704. * Creates a box mesh
  48705. * * The parameter `size` sets the size (float) of each box side (default 1)
  48706. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48707. * * 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)
  48708. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48710. * * 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
  48711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48712. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48713. * @param name defines the name of the mesh
  48714. * @param options defines the options used to create the mesh
  48715. * @param scene defines the hosting scene
  48716. * @returns the box mesh
  48717. */
  48718. static CreateBox(name: string, options: {
  48719. size?: number;
  48720. width?: number;
  48721. height?: number;
  48722. depth?: number;
  48723. faceUV?: Vector4[];
  48724. faceColors?: Color4[];
  48725. sideOrientation?: number;
  48726. frontUVs?: Vector4;
  48727. backUVs?: Vector4;
  48728. wrap?: boolean;
  48729. topBaseAt?: number;
  48730. bottomBaseAt?: number;
  48731. updatable?: boolean;
  48732. }, scene?: Nullable<Scene>): Mesh;
  48733. }
  48734. }
  48735. declare module "babylonjs/Debug/physicsViewer" {
  48736. import { Nullable } from "babylonjs/types";
  48737. import { Scene } from "babylonjs/scene";
  48738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48739. import { Mesh } from "babylonjs/Meshes/mesh";
  48740. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48741. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48742. /**
  48743. * Used to show the physics impostor around the specific mesh
  48744. */
  48745. export class PhysicsViewer {
  48746. /** @hidden */
  48747. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48748. /** @hidden */
  48749. protected _meshes: Array<Nullable<AbstractMesh>>;
  48750. /** @hidden */
  48751. protected _scene: Nullable<Scene>;
  48752. /** @hidden */
  48753. protected _numMeshes: number;
  48754. /** @hidden */
  48755. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48756. private _renderFunction;
  48757. private _utilityLayer;
  48758. private _debugBoxMesh;
  48759. private _debugSphereMesh;
  48760. private _debugCylinderMesh;
  48761. private _debugMaterial;
  48762. private _debugMeshMeshes;
  48763. /**
  48764. * Creates a new PhysicsViewer
  48765. * @param scene defines the hosting scene
  48766. */
  48767. constructor(scene: Scene);
  48768. /** @hidden */
  48769. protected _updateDebugMeshes(): void;
  48770. /**
  48771. * Renders a specified physic impostor
  48772. * @param impostor defines the impostor to render
  48773. * @param targetMesh defines the mesh represented by the impostor
  48774. * @returns the new debug mesh used to render the impostor
  48775. */
  48776. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48777. /**
  48778. * Hides a specified physic impostor
  48779. * @param impostor defines the impostor to hide
  48780. */
  48781. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48782. private _getDebugMaterial;
  48783. private _getDebugBoxMesh;
  48784. private _getDebugSphereMesh;
  48785. private _getDebugCylinderMesh;
  48786. private _getDebugMeshMesh;
  48787. private _getDebugMesh;
  48788. /** Releases all resources */
  48789. dispose(): void;
  48790. }
  48791. }
  48792. declare module "babylonjs/Debug/rayHelper" {
  48793. import { Nullable } from "babylonjs/types";
  48794. import { Ray } from "babylonjs/Culling/ray";
  48795. import { Vector3 } from "babylonjs/Maths/math.vector";
  48796. import { Color3 } from "babylonjs/Maths/math.color";
  48797. import { Scene } from "babylonjs/scene";
  48798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48799. import "babylonjs/Meshes/Builders/linesBuilder";
  48800. /**
  48801. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48802. * in order to better appreciate the issue one might have.
  48803. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48804. */
  48805. export class RayHelper {
  48806. /**
  48807. * Defines the ray we are currently tryin to visualize.
  48808. */
  48809. ray: Nullable<Ray>;
  48810. private _renderPoints;
  48811. private _renderLine;
  48812. private _renderFunction;
  48813. private _scene;
  48814. private _updateToMeshFunction;
  48815. private _attachedToMesh;
  48816. private _meshSpaceDirection;
  48817. private _meshSpaceOrigin;
  48818. /**
  48819. * Helper function to create a colored helper in a scene in one line.
  48820. * @param ray Defines the ray we are currently tryin to visualize
  48821. * @param scene Defines the scene the ray is used in
  48822. * @param color Defines the color we want to see the ray in
  48823. * @returns The newly created ray helper.
  48824. */
  48825. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48826. /**
  48827. * Instantiate a new ray helper.
  48828. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48829. * in order to better appreciate the issue one might have.
  48830. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48831. * @param ray Defines the ray we are currently tryin to visualize
  48832. */
  48833. constructor(ray: Ray);
  48834. /**
  48835. * Shows the ray we are willing to debug.
  48836. * @param scene Defines the scene the ray needs to be rendered in
  48837. * @param color Defines the color the ray needs to be rendered in
  48838. */
  48839. show(scene: Scene, color?: Color3): void;
  48840. /**
  48841. * Hides the ray we are debugging.
  48842. */
  48843. hide(): void;
  48844. private _render;
  48845. /**
  48846. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48847. * @param mesh Defines the mesh we want the helper attached to
  48848. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48849. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48850. * @param length Defines the length of the ray
  48851. */
  48852. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48853. /**
  48854. * Detach the ray helper from the mesh it has previously been attached to.
  48855. */
  48856. detachFromMesh(): void;
  48857. private _updateToMesh;
  48858. /**
  48859. * Dispose the helper and release its associated resources.
  48860. */
  48861. dispose(): void;
  48862. }
  48863. }
  48864. declare module "babylonjs/Debug/skeletonViewer" {
  48865. import { Color3 } from "babylonjs/Maths/math.color";
  48866. import { Scene } from "babylonjs/scene";
  48867. import { Nullable } from "babylonjs/types";
  48868. import { Skeleton } from "babylonjs/Bones/skeleton";
  48869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48870. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48871. /**
  48872. * Class used to render a debug view of a given skeleton
  48873. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48874. */
  48875. export class SkeletonViewer {
  48876. /** defines the skeleton to render */
  48877. skeleton: Skeleton;
  48878. /** defines the mesh attached to the skeleton */
  48879. mesh: AbstractMesh;
  48880. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48881. autoUpdateBonesMatrices: boolean;
  48882. /** defines the rendering group id to use with the viewer */
  48883. renderingGroupId: number;
  48884. /** Gets or sets the color used to render the skeleton */
  48885. color: Color3;
  48886. private _scene;
  48887. private _debugLines;
  48888. private _debugMesh;
  48889. private _isEnabled;
  48890. private _renderFunction;
  48891. private _utilityLayer;
  48892. /**
  48893. * Returns the mesh used to render the bones
  48894. */
  48895. get debugMesh(): Nullable<LinesMesh>;
  48896. /**
  48897. * Creates a new SkeletonViewer
  48898. * @param skeleton defines the skeleton to render
  48899. * @param mesh defines the mesh attached to the skeleton
  48900. * @param scene defines the hosting scene
  48901. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48902. * @param renderingGroupId defines the rendering group id to use with the viewer
  48903. */
  48904. constructor(
  48905. /** defines the skeleton to render */
  48906. skeleton: Skeleton,
  48907. /** defines the mesh attached to the skeleton */
  48908. mesh: AbstractMesh, scene: Scene,
  48909. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48910. autoUpdateBonesMatrices?: boolean,
  48911. /** defines the rendering group id to use with the viewer */
  48912. renderingGroupId?: number);
  48913. /** Gets or sets a boolean indicating if the viewer is enabled */
  48914. set isEnabled(value: boolean);
  48915. get isEnabled(): boolean;
  48916. private _getBonePosition;
  48917. private _getLinesForBonesWithLength;
  48918. private _getLinesForBonesNoLength;
  48919. /** Update the viewer to sync with current skeleton state */
  48920. update(): void;
  48921. /** Release associated resources */
  48922. dispose(): void;
  48923. }
  48924. }
  48925. declare module "babylonjs/Debug/index" {
  48926. export * from "babylonjs/Debug/axesViewer";
  48927. export * from "babylonjs/Debug/boneAxesViewer";
  48928. export * from "babylonjs/Debug/debugLayer";
  48929. export * from "babylonjs/Debug/physicsViewer";
  48930. export * from "babylonjs/Debug/rayHelper";
  48931. export * from "babylonjs/Debug/skeletonViewer";
  48932. }
  48933. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48934. import { Observable } from "babylonjs/Misc/observable";
  48935. import { Engine } from "babylonjs/Engines/engine";
  48936. import { IDisposable } from "babylonjs/scene";
  48937. import { Nullable } from "babylonjs/types";
  48938. /**
  48939. * This class will take all inputs from Keyboard, Pointer, and
  48940. * any Gamepads and provide a polling system that all devices
  48941. * will use. This class assumes that there will only be one
  48942. * pointer device and one keyboard.
  48943. */
  48944. export class DeviceInputSystem implements IDisposable {
  48945. /** POINTER_DEVICE */
  48946. static readonly POINTER_DEVICE: string;
  48947. /** KEYBOARD_DEVICE */
  48948. static readonly KEYBOARD_DEVICE: string;
  48949. /**
  48950. * Observable to be triggered when a device is connected
  48951. */
  48952. onDeviceConnectedObservable: Observable<string>;
  48953. /**
  48954. * Observable to be triggered when a device is disconnected
  48955. */
  48956. onDeviceDisconnectedObservable: Observable<string>;
  48957. private _inputs;
  48958. private _gamepads;
  48959. private _keyboardActive;
  48960. private _pointerActive;
  48961. private _elementToAttachTo;
  48962. private _keyboardDownEvent;
  48963. private _keyboardUpEvent;
  48964. private _pointerMoveEvent;
  48965. private _pointerDownEvent;
  48966. private _pointerUpEvent;
  48967. private _gamepadConnectedEvent;
  48968. private _gamepadDisconnectedEvent;
  48969. private static _MAX_KEYCODES;
  48970. private static _MAX_POINTER_INPUTS;
  48971. /**
  48972. * Default Constructor
  48973. * @param engine - engine to pull input element from
  48974. */
  48975. constructor(engine: Engine);
  48976. /**
  48977. * Checks for current device input value, given an id and input index
  48978. * @param deviceName Id of connected device
  48979. * @param inputIndex Index of device input
  48980. * @returns Current value of input
  48981. */
  48982. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48983. /**
  48984. * Dispose of all the eventlisteners and clears the observables
  48985. */
  48986. dispose(): void;
  48987. /**
  48988. * Add device and inputs to device map
  48989. * @param deviceName Assigned name of device (may be SN)
  48990. * @param numberOfInputs Number of input entries to create for given device
  48991. */
  48992. private _registerDevice;
  48993. /**
  48994. * Given a specific device name, remove that device from the device map
  48995. * @param deviceName Name of device to be removed
  48996. */
  48997. private _unregisterDevice;
  48998. /**
  48999. * Handle all actions that come from keyboard interaction
  49000. */
  49001. private _handleKeyActions;
  49002. /**
  49003. * Handle all actions that come from pointer interaction
  49004. */
  49005. private _handlePointerActions;
  49006. /**
  49007. * Handle all actions that come from gamepad interaction
  49008. */
  49009. private _handleGamepadActions;
  49010. /**
  49011. * Update all non-event based devices with each frame
  49012. */
  49013. private _updateDevice;
  49014. }
  49015. }
  49016. declare module "babylonjs/DeviceInput/index" {
  49017. export * from "babylonjs/DeviceInput/deviceInputSystem";
  49018. }
  49019. declare module "babylonjs/Engines/nullEngine" {
  49020. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  49021. import { Engine } from "babylonjs/Engines/engine";
  49022. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49023. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49024. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49025. import { Effect } from "babylonjs/Materials/effect";
  49026. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49027. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49028. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  49029. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49030. /**
  49031. * Options to create the null engine
  49032. */
  49033. export class NullEngineOptions {
  49034. /**
  49035. * Render width (Default: 512)
  49036. */
  49037. renderWidth: number;
  49038. /**
  49039. * Render height (Default: 256)
  49040. */
  49041. renderHeight: number;
  49042. /**
  49043. * Texture size (Default: 512)
  49044. */
  49045. textureSize: number;
  49046. /**
  49047. * If delta time between frames should be constant
  49048. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49049. */
  49050. deterministicLockstep: boolean;
  49051. /**
  49052. * Maximum about of steps between frames (Default: 4)
  49053. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49054. */
  49055. lockstepMaxSteps: number;
  49056. }
  49057. /**
  49058. * The null engine class provides support for headless version of babylon.js.
  49059. * This can be used in server side scenario or for testing purposes
  49060. */
  49061. export class NullEngine extends Engine {
  49062. private _options;
  49063. /**
  49064. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49066. * @returns true if engine is in deterministic lock step mode
  49067. */
  49068. isDeterministicLockStep(): boolean;
  49069. /**
  49070. * Gets the max steps when engine is running in deterministic lock step
  49071. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49072. * @returns the max steps
  49073. */
  49074. getLockstepMaxSteps(): number;
  49075. /**
  49076. * Gets the current hardware scaling level.
  49077. * By default the hardware scaling level is computed from the window device ratio.
  49078. * 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.
  49079. * @returns a number indicating the current hardware scaling level
  49080. */
  49081. getHardwareScalingLevel(): number;
  49082. constructor(options?: NullEngineOptions);
  49083. /**
  49084. * Creates a vertex buffer
  49085. * @param vertices the data for the vertex buffer
  49086. * @returns the new WebGL static buffer
  49087. */
  49088. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49089. /**
  49090. * Creates a new index buffer
  49091. * @param indices defines the content of the index buffer
  49092. * @param updatable defines if the index buffer must be updatable
  49093. * @returns a new webGL buffer
  49094. */
  49095. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49096. /**
  49097. * Clear the current render buffer or the current render target (if any is set up)
  49098. * @param color defines the color to use
  49099. * @param backBuffer defines if the back buffer must be cleared
  49100. * @param depth defines if the depth buffer must be cleared
  49101. * @param stencil defines if the stencil buffer must be cleared
  49102. */
  49103. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49104. /**
  49105. * Gets the current render width
  49106. * @param useScreen defines if screen size must be used (or the current render target if any)
  49107. * @returns a number defining the current render width
  49108. */
  49109. getRenderWidth(useScreen?: boolean): number;
  49110. /**
  49111. * Gets the current render height
  49112. * @param useScreen defines if screen size must be used (or the current render target if any)
  49113. * @returns a number defining the current render height
  49114. */
  49115. getRenderHeight(useScreen?: boolean): number;
  49116. /**
  49117. * Set the WebGL's viewport
  49118. * @param viewport defines the viewport element to be used
  49119. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  49120. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  49121. */
  49122. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49123. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49124. /**
  49125. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49126. * @param pipelineContext defines the pipeline context to use
  49127. * @param uniformsNames defines the list of uniform names
  49128. * @returns an array of webGL uniform locations
  49129. */
  49130. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49131. /**
  49132. * Gets the lsit of active attributes for a given webGL program
  49133. * @param pipelineContext defines the pipeline context to use
  49134. * @param attributesNames defines the list of attribute names to get
  49135. * @returns an array of indices indicating the offset of each attribute
  49136. */
  49137. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49138. /**
  49139. * Binds an effect to the webGL context
  49140. * @param effect defines the effect to bind
  49141. */
  49142. bindSamplers(effect: Effect): void;
  49143. /**
  49144. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49145. * @param effect defines the effect to activate
  49146. */
  49147. enableEffect(effect: Effect): void;
  49148. /**
  49149. * Set various states to the webGL context
  49150. * @param culling defines backface culling state
  49151. * @param zOffset defines the value to apply to zOffset (0 by default)
  49152. * @param force defines if states must be applied even if cache is up to date
  49153. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  49154. */
  49155. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49156. /**
  49157. * Set the value of an uniform to an array of int32
  49158. * @param uniform defines the webGL uniform location where to store the value
  49159. * @param array defines the array of int32 to store
  49160. */
  49161. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49162. /**
  49163. * Set the value of an uniform to an array of int32 (stored as vec2)
  49164. * @param uniform defines the webGL uniform location where to store the value
  49165. * @param array defines the array of int32 to store
  49166. */
  49167. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49168. /**
  49169. * Set the value of an uniform to an array of int32 (stored as vec3)
  49170. * @param uniform defines the webGL uniform location where to store the value
  49171. * @param array defines the array of int32 to store
  49172. */
  49173. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49174. /**
  49175. * Set the value of an uniform to an array of int32 (stored as vec4)
  49176. * @param uniform defines the webGL uniform location where to store the value
  49177. * @param array defines the array of int32 to store
  49178. */
  49179. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49180. /**
  49181. * Set the value of an uniform to an array of float32
  49182. * @param uniform defines the webGL uniform location where to store the value
  49183. * @param array defines the array of float32 to store
  49184. */
  49185. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49186. /**
  49187. * Set the value of an uniform to an array of float32 (stored as vec2)
  49188. * @param uniform defines the webGL uniform location where to store the value
  49189. * @param array defines the array of float32 to store
  49190. */
  49191. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49192. /**
  49193. * Set the value of an uniform to an array of float32 (stored as vec3)
  49194. * @param uniform defines the webGL uniform location where to store the value
  49195. * @param array defines the array of float32 to store
  49196. */
  49197. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49198. /**
  49199. * Set the value of an uniform to an array of float32 (stored as vec4)
  49200. * @param uniform defines the webGL uniform location where to store the value
  49201. * @param array defines the array of float32 to store
  49202. */
  49203. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49204. /**
  49205. * Set the value of an uniform to an array of number
  49206. * @param uniform defines the webGL uniform location where to store the value
  49207. * @param array defines the array of number to store
  49208. */
  49209. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49210. /**
  49211. * Set the value of an uniform to an array of number (stored as vec2)
  49212. * @param uniform defines the webGL uniform location where to store the value
  49213. * @param array defines the array of number to store
  49214. */
  49215. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49216. /**
  49217. * Set the value of an uniform to an array of number (stored as vec3)
  49218. * @param uniform defines the webGL uniform location where to store the value
  49219. * @param array defines the array of number to store
  49220. */
  49221. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49222. /**
  49223. * Set the value of an uniform to an array of number (stored as vec4)
  49224. * @param uniform defines the webGL uniform location where to store the value
  49225. * @param array defines the array of number to store
  49226. */
  49227. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49228. /**
  49229. * Set the value of an uniform to an array of float32 (stored as matrices)
  49230. * @param uniform defines the webGL uniform location where to store the value
  49231. * @param matrices defines the array of float32 to store
  49232. */
  49233. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49234. /**
  49235. * Set the value of an uniform to a matrix (3x3)
  49236. * @param uniform defines the webGL uniform location where to store the value
  49237. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49238. */
  49239. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49240. /**
  49241. * Set the value of an uniform to a matrix (2x2)
  49242. * @param uniform defines the webGL uniform location where to store the value
  49243. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49244. */
  49245. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49246. /**
  49247. * Set the value of an uniform to a number (float)
  49248. * @param uniform defines the webGL uniform location where to store the value
  49249. * @param value defines the float number to store
  49250. */
  49251. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49252. /**
  49253. * Set the value of an uniform to a vec2
  49254. * @param uniform defines the webGL uniform location where to store the value
  49255. * @param x defines the 1st component of the value
  49256. * @param y defines the 2nd component of the value
  49257. */
  49258. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49259. /**
  49260. * Set the value of an uniform to a vec3
  49261. * @param uniform defines the webGL uniform location where to store the value
  49262. * @param x defines the 1st component of the value
  49263. * @param y defines the 2nd component of the value
  49264. * @param z defines the 3rd component of the value
  49265. */
  49266. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49267. /**
  49268. * Set the value of an uniform to a boolean
  49269. * @param uniform defines the webGL uniform location where to store the value
  49270. * @param bool defines the boolean to store
  49271. */
  49272. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49273. /**
  49274. * Set the value of an uniform to a vec4
  49275. * @param uniform defines the webGL uniform location where to store the value
  49276. * @param x defines the 1st component of the value
  49277. * @param y defines the 2nd component of the value
  49278. * @param z defines the 3rd component of the value
  49279. * @param w defines the 4th component of the value
  49280. */
  49281. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49282. /**
  49283. * Sets the current alpha mode
  49284. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49285. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49286. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49287. */
  49288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49289. /**
  49290. * Bind webGl buffers directly to the webGL context
  49291. * @param vertexBuffers defines the vertex buffer to bind
  49292. * @param indexBuffer defines the index buffer to bind
  49293. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49294. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49295. * @param effect defines the effect associated with the vertex buffer
  49296. */
  49297. bindBuffers(vertexBuffers: {
  49298. [key: string]: VertexBuffer;
  49299. }, indexBuffer: DataBuffer, effect: Effect): void;
  49300. /**
  49301. * Force the entire cache to be cleared
  49302. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49303. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49304. */
  49305. wipeCaches(bruteForce?: boolean): void;
  49306. /**
  49307. * Send a draw order
  49308. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49309. * @param indexStart defines the starting index
  49310. * @param indexCount defines the number of index to draw
  49311. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49312. */
  49313. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49314. /**
  49315. * Draw a list of indexed primitives
  49316. * @param fillMode defines the primitive to use
  49317. * @param indexStart defines the starting index
  49318. * @param indexCount defines the number of index to draw
  49319. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49320. */
  49321. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49322. /**
  49323. * Draw a list of unindexed primitives
  49324. * @param fillMode defines the primitive to use
  49325. * @param verticesStart defines the index of first vertex to draw
  49326. * @param verticesCount defines the count of vertices to draw
  49327. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49328. */
  49329. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49330. /** @hidden */
  49331. _createTexture(): WebGLTexture;
  49332. /** @hidden */
  49333. _releaseTexture(texture: InternalTexture): void;
  49334. /**
  49335. * Usually called from Texture.ts.
  49336. * Passed information to create a WebGLTexture
  49337. * @param urlArg defines a value which contains one of the following:
  49338. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49339. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49340. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49341. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49342. * @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)
  49343. * @param scene needed for loading to the correct scene
  49344. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49345. * @param onLoad optional callback to be called upon successful completion
  49346. * @param onError optional callback to be called upon failure
  49347. * @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
  49348. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49349. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49350. * @param forcedExtension defines the extension to use to pick the right loader
  49351. * @param mimeType defines an optional mime type
  49352. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49353. */
  49354. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49355. /**
  49356. * Creates a new render target texture
  49357. * @param size defines the size of the texture
  49358. * @param options defines the options used to create the texture
  49359. * @returns a new render target texture stored in an InternalTexture
  49360. */
  49361. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49362. /**
  49363. * Update the sampling mode of a given texture
  49364. * @param samplingMode defines the required sampling mode
  49365. * @param texture defines the texture to update
  49366. */
  49367. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49368. /**
  49369. * Binds the frame buffer to the specified texture.
  49370. * @param texture The texture to render to or null for the default canvas
  49371. * @param faceIndex The face of the texture to render to in case of cube texture
  49372. * @param requiredWidth The width of the target to render to
  49373. * @param requiredHeight The height of the target to render to
  49374. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49375. * @param lodLevel defines le lod level to bind to the frame buffer
  49376. */
  49377. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49378. /**
  49379. * Unbind the current render target texture from the webGL context
  49380. * @param texture defines the render target texture to unbind
  49381. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49382. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49383. */
  49384. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49385. /**
  49386. * Creates a dynamic vertex buffer
  49387. * @param vertices the data for the dynamic vertex buffer
  49388. * @returns the new WebGL dynamic buffer
  49389. */
  49390. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49391. /**
  49392. * Update the content of a dynamic texture
  49393. * @param texture defines the texture to update
  49394. * @param canvas defines the canvas containing the source
  49395. * @param invertY defines if data must be stored with Y axis inverted
  49396. * @param premulAlpha defines if alpha is stored as premultiplied
  49397. * @param format defines the format of the data
  49398. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49399. */
  49400. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49401. /**
  49402. * Gets a boolean indicating if all created effects are ready
  49403. * @returns true if all effects are ready
  49404. */
  49405. areAllEffectsReady(): boolean;
  49406. /**
  49407. * @hidden
  49408. * Get the current error code of the webGL context
  49409. * @returns the error code
  49410. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49411. */
  49412. getError(): number;
  49413. /** @hidden */
  49414. _getUnpackAlignement(): number;
  49415. /** @hidden */
  49416. _unpackFlipY(value: boolean): void;
  49417. /**
  49418. * Update a dynamic index buffer
  49419. * @param indexBuffer defines the target index buffer
  49420. * @param indices defines the data to update
  49421. * @param offset defines the offset in the target index buffer where update should start
  49422. */
  49423. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49424. /**
  49425. * Updates a dynamic vertex buffer.
  49426. * @param vertexBuffer the vertex buffer to update
  49427. * @param vertices the data used to update the vertex buffer
  49428. * @param byteOffset the byte offset of the data (optional)
  49429. * @param byteLength the byte length of the data (optional)
  49430. */
  49431. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49432. /** @hidden */
  49433. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49434. /** @hidden */
  49435. _bindTexture(channel: number, texture: InternalTexture): void;
  49436. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49437. /**
  49438. * 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
  49439. */
  49440. releaseEffects(): void;
  49441. displayLoadingUI(): void;
  49442. hideLoadingUI(): void;
  49443. /** @hidden */
  49444. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49445. /** @hidden */
  49446. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49447. /** @hidden */
  49448. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49449. /** @hidden */
  49450. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49451. }
  49452. }
  49453. declare module "babylonjs/Instrumentation/timeToken" {
  49454. import { Nullable } from "babylonjs/types";
  49455. /**
  49456. * @hidden
  49457. **/
  49458. export class _TimeToken {
  49459. _startTimeQuery: Nullable<WebGLQuery>;
  49460. _endTimeQuery: Nullable<WebGLQuery>;
  49461. _timeElapsedQuery: Nullable<WebGLQuery>;
  49462. _timeElapsedQueryEnded: boolean;
  49463. }
  49464. }
  49465. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49466. import { Nullable, int } from "babylonjs/types";
  49467. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49468. /** @hidden */
  49469. export class _OcclusionDataStorage {
  49470. /** @hidden */
  49471. occlusionInternalRetryCounter: number;
  49472. /** @hidden */
  49473. isOcclusionQueryInProgress: boolean;
  49474. /** @hidden */
  49475. isOccluded: boolean;
  49476. /** @hidden */
  49477. occlusionRetryCount: number;
  49478. /** @hidden */
  49479. occlusionType: number;
  49480. /** @hidden */
  49481. occlusionQueryAlgorithmType: number;
  49482. }
  49483. module "babylonjs/Engines/engine" {
  49484. interface Engine {
  49485. /**
  49486. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49487. * @return the new query
  49488. */
  49489. createQuery(): WebGLQuery;
  49490. /**
  49491. * Delete and release a webGL query
  49492. * @param query defines the query to delete
  49493. * @return the current engine
  49494. */
  49495. deleteQuery(query: WebGLQuery): Engine;
  49496. /**
  49497. * Check if a given query has resolved and got its value
  49498. * @param query defines the query to check
  49499. * @returns true if the query got its value
  49500. */
  49501. isQueryResultAvailable(query: WebGLQuery): boolean;
  49502. /**
  49503. * Gets the value of a given query
  49504. * @param query defines the query to check
  49505. * @returns the value of the query
  49506. */
  49507. getQueryResult(query: WebGLQuery): number;
  49508. /**
  49509. * Initiates an occlusion query
  49510. * @param algorithmType defines the algorithm to use
  49511. * @param query defines the query to use
  49512. * @returns the current engine
  49513. * @see http://doc.babylonjs.com/features/occlusionquery
  49514. */
  49515. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49516. /**
  49517. * Ends an occlusion query
  49518. * @see http://doc.babylonjs.com/features/occlusionquery
  49519. * @param algorithmType defines the algorithm to use
  49520. * @returns the current engine
  49521. */
  49522. endOcclusionQuery(algorithmType: number): Engine;
  49523. /**
  49524. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49525. * Please note that only one query can be issued at a time
  49526. * @returns a time token used to track the time span
  49527. */
  49528. startTimeQuery(): Nullable<_TimeToken>;
  49529. /**
  49530. * Ends a time query
  49531. * @param token defines the token used to measure the time span
  49532. * @returns the time spent (in ns)
  49533. */
  49534. endTimeQuery(token: _TimeToken): int;
  49535. /** @hidden */
  49536. _currentNonTimestampToken: Nullable<_TimeToken>;
  49537. /** @hidden */
  49538. _createTimeQuery(): WebGLQuery;
  49539. /** @hidden */
  49540. _deleteTimeQuery(query: WebGLQuery): void;
  49541. /** @hidden */
  49542. _getGlAlgorithmType(algorithmType: number): number;
  49543. /** @hidden */
  49544. _getTimeQueryResult(query: WebGLQuery): any;
  49545. /** @hidden */
  49546. _getTimeQueryAvailability(query: WebGLQuery): any;
  49547. }
  49548. }
  49549. module "babylonjs/Meshes/abstractMesh" {
  49550. interface AbstractMesh {
  49551. /**
  49552. * Backing filed
  49553. * @hidden
  49554. */
  49555. __occlusionDataStorage: _OcclusionDataStorage;
  49556. /**
  49557. * Access property
  49558. * @hidden
  49559. */
  49560. _occlusionDataStorage: _OcclusionDataStorage;
  49561. /**
  49562. * 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.
  49563. * The default value is -1 which means don't break the query and wait till the result
  49564. * @see http://doc.babylonjs.com/features/occlusionquery
  49565. */
  49566. occlusionRetryCount: number;
  49567. /**
  49568. * 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:
  49569. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49570. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49571. * * 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.
  49572. * @see http://doc.babylonjs.com/features/occlusionquery
  49573. */
  49574. occlusionType: number;
  49575. /**
  49576. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49577. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49578. * * 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.
  49579. * @see http://doc.babylonjs.com/features/occlusionquery
  49580. */
  49581. occlusionQueryAlgorithmType: number;
  49582. /**
  49583. * 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
  49584. * @see http://doc.babylonjs.com/features/occlusionquery
  49585. */
  49586. isOccluded: boolean;
  49587. /**
  49588. * Flag to check the progress status of the query
  49589. * @see http://doc.babylonjs.com/features/occlusionquery
  49590. */
  49591. isOcclusionQueryInProgress: boolean;
  49592. }
  49593. }
  49594. }
  49595. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49596. import { Nullable } from "babylonjs/types";
  49597. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49598. /** @hidden */
  49599. export var _forceTransformFeedbackToBundle: boolean;
  49600. module "babylonjs/Engines/engine" {
  49601. interface Engine {
  49602. /**
  49603. * Creates a webGL transform feedback object
  49604. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49605. * @returns the webGL transform feedback object
  49606. */
  49607. createTransformFeedback(): WebGLTransformFeedback;
  49608. /**
  49609. * Delete a webGL transform feedback object
  49610. * @param value defines the webGL transform feedback object to delete
  49611. */
  49612. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49613. /**
  49614. * Bind a webGL transform feedback object to the webgl context
  49615. * @param value defines the webGL transform feedback object to bind
  49616. */
  49617. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49618. /**
  49619. * Begins a transform feedback operation
  49620. * @param usePoints defines if points or triangles must be used
  49621. */
  49622. beginTransformFeedback(usePoints: boolean): void;
  49623. /**
  49624. * Ends a transform feedback operation
  49625. */
  49626. endTransformFeedback(): void;
  49627. /**
  49628. * Specify the varyings to use with transform feedback
  49629. * @param program defines the associated webGL program
  49630. * @param value defines the list of strings representing the varying names
  49631. */
  49632. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49633. /**
  49634. * Bind a webGL buffer for a transform feedback operation
  49635. * @param value defines the webGL buffer to bind
  49636. */
  49637. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49638. }
  49639. }
  49640. }
  49641. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49642. import { Scene } from "babylonjs/scene";
  49643. import { Engine } from "babylonjs/Engines/engine";
  49644. import { Texture } from "babylonjs/Materials/Textures/texture";
  49645. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49646. import "babylonjs/Engines/Extensions/engine.multiRender";
  49647. /**
  49648. * Creation options of the multi render target texture.
  49649. */
  49650. export interface IMultiRenderTargetOptions {
  49651. /**
  49652. * Define if the texture needs to create mip maps after render.
  49653. */
  49654. generateMipMaps?: boolean;
  49655. /**
  49656. * Define the types of all the draw buffers we want to create
  49657. */
  49658. types?: number[];
  49659. /**
  49660. * Define the sampling modes of all the draw buffers we want to create
  49661. */
  49662. samplingModes?: number[];
  49663. /**
  49664. * Define if a depth buffer is required
  49665. */
  49666. generateDepthBuffer?: boolean;
  49667. /**
  49668. * Define if a stencil buffer is required
  49669. */
  49670. generateStencilBuffer?: boolean;
  49671. /**
  49672. * Define if a depth texture is required instead of a depth buffer
  49673. */
  49674. generateDepthTexture?: boolean;
  49675. /**
  49676. * Define the number of desired draw buffers
  49677. */
  49678. textureCount?: number;
  49679. /**
  49680. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49681. */
  49682. doNotChangeAspectRatio?: boolean;
  49683. /**
  49684. * Define the default type of the buffers we are creating
  49685. */
  49686. defaultType?: number;
  49687. }
  49688. /**
  49689. * A multi render target, like a render target provides the ability to render to a texture.
  49690. * Unlike the render target, it can render to several draw buffers in one draw.
  49691. * This is specially interesting in deferred rendering or for any effects requiring more than
  49692. * just one color from a single pass.
  49693. */
  49694. export class MultiRenderTarget extends RenderTargetTexture {
  49695. private _internalTextures;
  49696. private _textures;
  49697. private _multiRenderTargetOptions;
  49698. /**
  49699. * Get if draw buffers are currently supported by the used hardware and browser.
  49700. */
  49701. get isSupported(): boolean;
  49702. /**
  49703. * Get the list of textures generated by the multi render target.
  49704. */
  49705. get textures(): Texture[];
  49706. /**
  49707. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49708. */
  49709. get depthTexture(): Texture;
  49710. /**
  49711. * Set the wrapping mode on U of all the textures we are rendering to.
  49712. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49713. */
  49714. set wrapU(wrap: number);
  49715. /**
  49716. * Set the wrapping mode on V of all the textures we are rendering to.
  49717. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49718. */
  49719. set wrapV(wrap: number);
  49720. /**
  49721. * Instantiate a new multi render target texture.
  49722. * A multi render target, like a render target provides the ability to render to a texture.
  49723. * Unlike the render target, it can render to several draw buffers in one draw.
  49724. * This is specially interesting in deferred rendering or for any effects requiring more than
  49725. * just one color from a single pass.
  49726. * @param name Define the name of the texture
  49727. * @param size Define the size of the buffers to render to
  49728. * @param count Define the number of target we are rendering into
  49729. * @param scene Define the scene the texture belongs to
  49730. * @param options Define the options used to create the multi render target
  49731. */
  49732. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49733. /** @hidden */
  49734. _rebuild(): void;
  49735. private _createInternalTextures;
  49736. private _createTextures;
  49737. /**
  49738. * Define the number of samples used if MSAA is enabled.
  49739. */
  49740. get samples(): number;
  49741. set samples(value: number);
  49742. /**
  49743. * Resize all the textures in the multi render target.
  49744. * Be carrefull as it will recreate all the data in the new texture.
  49745. * @param size Define the new size
  49746. */
  49747. resize(size: any): void;
  49748. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49749. /**
  49750. * Dispose the render targets and their associated resources
  49751. */
  49752. dispose(): void;
  49753. /**
  49754. * Release all the underlying texture used as draw buffers.
  49755. */
  49756. releaseInternalTextures(): void;
  49757. }
  49758. }
  49759. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49760. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49761. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49762. import { Nullable } from "babylonjs/types";
  49763. module "babylonjs/Engines/thinEngine" {
  49764. interface ThinEngine {
  49765. /**
  49766. * Unbind a list of render target textures from the webGL context
  49767. * This is used only when drawBuffer extension or webGL2 are active
  49768. * @param textures defines the render target textures to unbind
  49769. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49770. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49771. */
  49772. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49773. /**
  49774. * Create a multi render target texture
  49775. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49776. * @param size defines the size of the texture
  49777. * @param options defines the creation options
  49778. * @returns the cube texture as an InternalTexture
  49779. */
  49780. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49781. /**
  49782. * Update the sample count for a given multiple render target texture
  49783. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49784. * @param textures defines the textures to update
  49785. * @param samples defines the sample count to set
  49786. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49787. */
  49788. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49789. }
  49790. }
  49791. }
  49792. declare module "babylonjs/Engines/Extensions/engine.views" {
  49793. import { Camera } from "babylonjs/Cameras/camera";
  49794. import { Nullable } from "babylonjs/types";
  49795. /**
  49796. * Class used to define an additional view for the engine
  49797. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49798. */
  49799. export class EngineView {
  49800. /** Defines the canvas where to render the view */
  49801. target: HTMLCanvasElement;
  49802. /** Defines an optional camera used to render the view (will use active camera else) */
  49803. camera?: Camera;
  49804. }
  49805. module "babylonjs/Engines/engine" {
  49806. interface Engine {
  49807. /**
  49808. * Gets or sets the HTML element to use for attaching events
  49809. */
  49810. inputElement: Nullable<HTMLElement>;
  49811. /**
  49812. * Gets the current engine view
  49813. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49814. */
  49815. activeView: Nullable<EngineView>;
  49816. /** Gets or sets the list of views */
  49817. views: EngineView[];
  49818. /**
  49819. * Register a new child canvas
  49820. * @param canvas defines the canvas to register
  49821. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49822. * @returns the associated view
  49823. */
  49824. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49825. /**
  49826. * Remove a registered child canvas
  49827. * @param canvas defines the canvas to remove
  49828. * @returns the current engine
  49829. */
  49830. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49831. }
  49832. }
  49833. }
  49834. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49835. import { Nullable } from "babylonjs/types";
  49836. module "babylonjs/Engines/engine" {
  49837. interface Engine {
  49838. /** @hidden */
  49839. _excludedCompressedTextures: string[];
  49840. /** @hidden */
  49841. _textureFormatInUse: string;
  49842. /**
  49843. * Gets the list of texture formats supported
  49844. */
  49845. readonly texturesSupported: Array<string>;
  49846. /**
  49847. * Gets the texture format in use
  49848. */
  49849. readonly textureFormatInUse: Nullable<string>;
  49850. /**
  49851. * Set the compressed texture extensions or file names to skip.
  49852. *
  49853. * @param skippedFiles defines the list of those texture files you want to skip
  49854. * Example: [".dds", ".env", "myfile.png"]
  49855. */
  49856. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49857. /**
  49858. * Set the compressed texture format to use, based on the formats you have, and the formats
  49859. * supported by the hardware / browser.
  49860. *
  49861. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49862. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49863. * to API arguments needed to compressed textures. This puts the burden on the container
  49864. * generator to house the arcane code for determining these for current & future formats.
  49865. *
  49866. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49867. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49868. *
  49869. * Note: The result of this call is not taken into account when a texture is base64.
  49870. *
  49871. * @param formatsAvailable defines the list of those format families you have created
  49872. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49873. *
  49874. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49875. * @returns The extension selected.
  49876. */
  49877. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49878. }
  49879. }
  49880. }
  49881. declare module "babylonjs/Engines/Extensions/index" {
  49882. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49883. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49884. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49885. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49886. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49887. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49888. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49889. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49890. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49891. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49892. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49893. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49894. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49895. export * from "babylonjs/Engines/Extensions/engine.views";
  49896. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  49897. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49898. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49899. }
  49900. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49901. import { Nullable } from "babylonjs/types";
  49902. /**
  49903. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49904. */
  49905. export interface CubeMapInfo {
  49906. /**
  49907. * The pixel array for the front face.
  49908. * This is stored in format, left to right, up to down format.
  49909. */
  49910. front: Nullable<ArrayBufferView>;
  49911. /**
  49912. * The pixel array for the back face.
  49913. * This is stored in format, left to right, up to down format.
  49914. */
  49915. back: Nullable<ArrayBufferView>;
  49916. /**
  49917. * The pixel array for the left face.
  49918. * This is stored in format, left to right, up to down format.
  49919. */
  49920. left: Nullable<ArrayBufferView>;
  49921. /**
  49922. * The pixel array for the right face.
  49923. * This is stored in format, left to right, up to down format.
  49924. */
  49925. right: Nullable<ArrayBufferView>;
  49926. /**
  49927. * The pixel array for the up face.
  49928. * This is stored in format, left to right, up to down format.
  49929. */
  49930. up: Nullable<ArrayBufferView>;
  49931. /**
  49932. * The pixel array for the down face.
  49933. * This is stored in format, left to right, up to down format.
  49934. */
  49935. down: Nullable<ArrayBufferView>;
  49936. /**
  49937. * The size of the cubemap stored.
  49938. *
  49939. * Each faces will be size * size pixels.
  49940. */
  49941. size: number;
  49942. /**
  49943. * The format of the texture.
  49944. *
  49945. * RGBA, RGB.
  49946. */
  49947. format: number;
  49948. /**
  49949. * The type of the texture data.
  49950. *
  49951. * UNSIGNED_INT, FLOAT.
  49952. */
  49953. type: number;
  49954. /**
  49955. * Specifies whether the texture is in gamma space.
  49956. */
  49957. gammaSpace: boolean;
  49958. }
  49959. /**
  49960. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49961. */
  49962. export class PanoramaToCubeMapTools {
  49963. private static FACE_LEFT;
  49964. private static FACE_RIGHT;
  49965. private static FACE_FRONT;
  49966. private static FACE_BACK;
  49967. private static FACE_DOWN;
  49968. private static FACE_UP;
  49969. /**
  49970. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49971. *
  49972. * @param float32Array The source data.
  49973. * @param inputWidth The width of the input panorama.
  49974. * @param inputHeight The height of the input panorama.
  49975. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49976. * @return The cubemap data
  49977. */
  49978. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49979. private static CreateCubemapTexture;
  49980. private static CalcProjectionSpherical;
  49981. }
  49982. }
  49983. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49984. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49986. import { Nullable } from "babylonjs/types";
  49987. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49988. /**
  49989. * Helper class dealing with the extraction of spherical polynomial dataArray
  49990. * from a cube map.
  49991. */
  49992. export class CubeMapToSphericalPolynomialTools {
  49993. private static FileFaces;
  49994. /**
  49995. * Converts a texture to the according Spherical Polynomial data.
  49996. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49997. *
  49998. * @param texture The texture to extract the information from.
  49999. * @return The Spherical Polynomial data.
  50000. */
  50001. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50002. /**
  50003. * Converts a cubemap to the according Spherical Polynomial data.
  50004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50005. *
  50006. * @param cubeInfo The Cube map to extract the information from.
  50007. * @return The Spherical Polynomial data.
  50008. */
  50009. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50010. }
  50011. }
  50012. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  50013. import { Nullable } from "babylonjs/types";
  50014. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50015. module "babylonjs/Materials/Textures/baseTexture" {
  50016. interface BaseTexture {
  50017. /**
  50018. * Get the polynomial representation of the texture data.
  50019. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50020. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50021. */
  50022. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50023. }
  50024. }
  50025. }
  50026. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  50027. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50028. /** @hidden */
  50029. export var rgbdEncodePixelShader: {
  50030. name: string;
  50031. shader: string;
  50032. };
  50033. }
  50034. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  50035. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50036. /** @hidden */
  50037. export var rgbdDecodePixelShader: {
  50038. name: string;
  50039. shader: string;
  50040. };
  50041. }
  50042. declare module "babylonjs/Misc/environmentTextureTools" {
  50043. import { Nullable } from "babylonjs/types";
  50044. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50046. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50047. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  50048. import "babylonjs/Engines/Extensions/engine.readTexture";
  50049. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50050. import "babylonjs/Shaders/rgbdEncode.fragment";
  50051. import "babylonjs/Shaders/rgbdDecode.fragment";
  50052. /**
  50053. * Raw texture data and descriptor sufficient for WebGL texture upload
  50054. */
  50055. export interface EnvironmentTextureInfo {
  50056. /**
  50057. * Version of the environment map
  50058. */
  50059. version: number;
  50060. /**
  50061. * Width of image
  50062. */
  50063. width: number;
  50064. /**
  50065. * Irradiance information stored in the file.
  50066. */
  50067. irradiance: any;
  50068. /**
  50069. * Specular information stored in the file.
  50070. */
  50071. specular: any;
  50072. }
  50073. /**
  50074. * Defines One Image in the file. It requires only the position in the file
  50075. * as well as the length.
  50076. */
  50077. interface BufferImageData {
  50078. /**
  50079. * Length of the image data.
  50080. */
  50081. length: number;
  50082. /**
  50083. * Position of the data from the null terminator delimiting the end of the JSON.
  50084. */
  50085. position: number;
  50086. }
  50087. /**
  50088. * Defines the specular data enclosed in the file.
  50089. * This corresponds to the version 1 of the data.
  50090. */
  50091. export interface EnvironmentTextureSpecularInfoV1 {
  50092. /**
  50093. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50094. */
  50095. specularDataPosition?: number;
  50096. /**
  50097. * This contains all the images data needed to reconstruct the cubemap.
  50098. */
  50099. mipmaps: Array<BufferImageData>;
  50100. /**
  50101. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50102. */
  50103. lodGenerationScale: number;
  50104. }
  50105. /**
  50106. * Sets of helpers addressing the serialization and deserialization of environment texture
  50107. * stored in a BabylonJS env file.
  50108. * Those files are usually stored as .env files.
  50109. */
  50110. export class EnvironmentTextureTools {
  50111. /**
  50112. * Magic number identifying the env file.
  50113. */
  50114. private static _MagicBytes;
  50115. /**
  50116. * Gets the environment info from an env file.
  50117. * @param data The array buffer containing the .env bytes.
  50118. * @returns the environment file info (the json header) if successfully parsed.
  50119. */
  50120. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50121. /**
  50122. * Creates an environment texture from a loaded cube texture.
  50123. * @param texture defines the cube texture to convert in env file
  50124. * @return a promise containing the environment data if succesfull.
  50125. */
  50126. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50127. /**
  50128. * Creates a JSON representation of the spherical data.
  50129. * @param texture defines the texture containing the polynomials
  50130. * @return the JSON representation of the spherical info
  50131. */
  50132. private static _CreateEnvTextureIrradiance;
  50133. /**
  50134. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50135. * @param data the image data
  50136. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50137. * @return the views described by info providing access to the underlying buffer
  50138. */
  50139. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50140. /**
  50141. * Uploads the texture info contained in the env file to the GPU.
  50142. * @param texture defines the internal texture to upload to
  50143. * @param data defines the data to load
  50144. * @param info defines the texture info retrieved through the GetEnvInfo method
  50145. * @returns a promise
  50146. */
  50147. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50148. private static _OnImageReadyAsync;
  50149. /**
  50150. * Uploads the levels of image data to the GPU.
  50151. * @param texture defines the internal texture to upload to
  50152. * @param imageData defines the array buffer views of image data [mipmap][face]
  50153. * @returns a promise
  50154. */
  50155. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50156. /**
  50157. * Uploads spherical polynomials information to the texture.
  50158. * @param texture defines the texture we are trying to upload the information to
  50159. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50160. */
  50161. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50162. /** @hidden */
  50163. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50164. }
  50165. }
  50166. declare module "babylonjs/Maths/math.vertexFormat" {
  50167. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50168. /**
  50169. * Contains position and normal vectors for a vertex
  50170. */
  50171. export class PositionNormalVertex {
  50172. /** the position of the vertex (defaut: 0,0,0) */
  50173. position: Vector3;
  50174. /** the normal of the vertex (defaut: 0,1,0) */
  50175. normal: Vector3;
  50176. /**
  50177. * Creates a PositionNormalVertex
  50178. * @param position the position of the vertex (defaut: 0,0,0)
  50179. * @param normal the normal of the vertex (defaut: 0,1,0)
  50180. */
  50181. constructor(
  50182. /** the position of the vertex (defaut: 0,0,0) */
  50183. position?: Vector3,
  50184. /** the normal of the vertex (defaut: 0,1,0) */
  50185. normal?: Vector3);
  50186. /**
  50187. * Clones the PositionNormalVertex
  50188. * @returns the cloned PositionNormalVertex
  50189. */
  50190. clone(): PositionNormalVertex;
  50191. }
  50192. /**
  50193. * Contains position, normal and uv vectors for a vertex
  50194. */
  50195. export class PositionNormalTextureVertex {
  50196. /** the position of the vertex (defaut: 0,0,0) */
  50197. position: Vector3;
  50198. /** the normal of the vertex (defaut: 0,1,0) */
  50199. normal: Vector3;
  50200. /** the uv of the vertex (default: 0,0) */
  50201. uv: Vector2;
  50202. /**
  50203. * Creates a PositionNormalTextureVertex
  50204. * @param position the position of the vertex (defaut: 0,0,0)
  50205. * @param normal the normal of the vertex (defaut: 0,1,0)
  50206. * @param uv the uv of the vertex (default: 0,0)
  50207. */
  50208. constructor(
  50209. /** the position of the vertex (defaut: 0,0,0) */
  50210. position?: Vector3,
  50211. /** the normal of the vertex (defaut: 0,1,0) */
  50212. normal?: Vector3,
  50213. /** the uv of the vertex (default: 0,0) */
  50214. uv?: Vector2);
  50215. /**
  50216. * Clones the PositionNormalTextureVertex
  50217. * @returns the cloned PositionNormalTextureVertex
  50218. */
  50219. clone(): PositionNormalTextureVertex;
  50220. }
  50221. }
  50222. declare module "babylonjs/Maths/math" {
  50223. export * from "babylonjs/Maths/math.axis";
  50224. export * from "babylonjs/Maths/math.color";
  50225. export * from "babylonjs/Maths/math.constants";
  50226. export * from "babylonjs/Maths/math.frustum";
  50227. export * from "babylonjs/Maths/math.path";
  50228. export * from "babylonjs/Maths/math.plane";
  50229. export * from "babylonjs/Maths/math.size";
  50230. export * from "babylonjs/Maths/math.vector";
  50231. export * from "babylonjs/Maths/math.vertexFormat";
  50232. export * from "babylonjs/Maths/math.viewport";
  50233. }
  50234. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50235. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50236. /** @hidden */
  50237. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50238. private _genericAttributeLocation;
  50239. private _varyingLocationCount;
  50240. private _varyingLocationMap;
  50241. private _replacements;
  50242. private _textureCount;
  50243. private _uniforms;
  50244. lineProcessor(line: string): string;
  50245. attributeProcessor(attribute: string): string;
  50246. varyingProcessor(varying: string, isFragment: boolean): string;
  50247. uniformProcessor(uniform: string): string;
  50248. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50249. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50250. }
  50251. }
  50252. declare module "babylonjs/Engines/nativeEngine" {
  50253. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50254. import { Engine } from "babylonjs/Engines/engine";
  50255. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50256. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50258. import { Effect } from "babylonjs/Materials/effect";
  50259. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50260. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50261. import { IColor4Like } from "babylonjs/Maths/math.like";
  50262. import { Scene } from "babylonjs/scene";
  50263. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50264. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50265. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50266. /**
  50267. * Container for accessors for natively-stored mesh data buffers.
  50268. */
  50269. class NativeDataBuffer extends DataBuffer {
  50270. /**
  50271. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50272. */
  50273. nativeIndexBuffer?: any;
  50274. /**
  50275. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50276. */
  50277. nativeVertexBuffer?: any;
  50278. }
  50279. /** @hidden */
  50280. class NativeTexture extends InternalTexture {
  50281. getInternalTexture(): InternalTexture;
  50282. getViewCount(): number;
  50283. }
  50284. /** @hidden */
  50285. export class NativeEngine extends Engine {
  50286. private readonly _native;
  50287. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50288. private readonly INVALID_HANDLE;
  50289. getHardwareScalingLevel(): number;
  50290. constructor();
  50291. dispose(): void;
  50292. /**
  50293. * Can be used to override the current requestAnimationFrame requester.
  50294. * @hidden
  50295. */
  50296. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50297. /**
  50298. * Override default engine behavior.
  50299. * @param color
  50300. * @param backBuffer
  50301. * @param depth
  50302. * @param stencil
  50303. */
  50304. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50305. /**
  50306. * Gets host document
  50307. * @returns the host document object
  50308. */
  50309. getHostDocument(): Nullable<Document>;
  50310. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50311. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50312. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50313. recordVertexArrayObject(vertexBuffers: {
  50314. [key: string]: VertexBuffer;
  50315. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50316. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50317. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50318. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50319. /**
  50320. * Draw a list of indexed primitives
  50321. * @param fillMode defines the primitive to use
  50322. * @param indexStart defines the starting index
  50323. * @param indexCount defines the number of index to draw
  50324. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50325. */
  50326. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50327. /**
  50328. * Draw a list of unindexed primitives
  50329. * @param fillMode defines the primitive to use
  50330. * @param verticesStart defines the index of first vertex to draw
  50331. * @param verticesCount defines the count of vertices to draw
  50332. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50333. */
  50334. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50335. createPipelineContext(): IPipelineContext;
  50336. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50337. /** @hidden */
  50338. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50339. /** @hidden */
  50340. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50341. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50342. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50343. protected _setProgram(program: WebGLProgram): void;
  50344. _releaseEffect(effect: Effect): void;
  50345. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50346. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50347. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50348. bindSamplers(effect: Effect): void;
  50349. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50350. getRenderWidth(useScreen?: boolean): number;
  50351. getRenderHeight(useScreen?: boolean): number;
  50352. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50353. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50354. /**
  50355. * Set the z offset to apply to current rendering
  50356. * @param value defines the offset to apply
  50357. */
  50358. setZOffset(value: number): void;
  50359. /**
  50360. * Gets the current value of the zOffset
  50361. * @returns the current zOffset state
  50362. */
  50363. getZOffset(): number;
  50364. /**
  50365. * Enable or disable depth buffering
  50366. * @param enable defines the state to set
  50367. */
  50368. setDepthBuffer(enable: boolean): void;
  50369. /**
  50370. * Gets a boolean indicating if depth writing is enabled
  50371. * @returns the current depth writing state
  50372. */
  50373. getDepthWrite(): boolean;
  50374. /**
  50375. * Enable or disable depth writing
  50376. * @param enable defines the state to set
  50377. */
  50378. setDepthWrite(enable: boolean): void;
  50379. /**
  50380. * Enable or disable color writing
  50381. * @param enable defines the state to set
  50382. */
  50383. setColorWrite(enable: boolean): void;
  50384. /**
  50385. * Gets a boolean indicating if color writing is enabled
  50386. * @returns the current color writing state
  50387. */
  50388. getColorWrite(): boolean;
  50389. /**
  50390. * Sets alpha constants used by some alpha blending modes
  50391. * @param r defines the red component
  50392. * @param g defines the green component
  50393. * @param b defines the blue component
  50394. * @param a defines the alpha component
  50395. */
  50396. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50397. /**
  50398. * Sets the current alpha mode
  50399. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50400. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50402. */
  50403. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50404. /**
  50405. * Gets the current alpha mode
  50406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50407. * @returns the current alpha mode
  50408. */
  50409. getAlphaMode(): number;
  50410. setInt(uniform: WebGLUniformLocation, int: number): void;
  50411. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50412. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50413. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50414. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50415. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50416. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50417. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50418. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50419. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50420. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50421. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50422. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50423. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50424. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50425. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50426. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50427. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50428. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50429. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50430. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50431. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50432. wipeCaches(bruteForce?: boolean): void;
  50433. _createTexture(): WebGLTexture;
  50434. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50435. /**
  50436. * Usually called from Texture.ts.
  50437. * Passed information to create a WebGLTexture
  50438. * @param url defines a value which contains one of the following:
  50439. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50440. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50441. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50442. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50443. * @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)
  50444. * @param scene needed for loading to the correct scene
  50445. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50446. * @param onLoad optional callback to be called upon successful completion
  50447. * @param onError optional callback to be called upon failure
  50448. * @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
  50449. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50450. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50451. * @param forcedExtension defines the extension to use to pick the right loader
  50452. * @param mimeType defines an optional mime type
  50453. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50454. */
  50455. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  50456. /**
  50457. * Creates a cube texture
  50458. * @param rootUrl defines the url where the files to load is located
  50459. * @param scene defines the current scene
  50460. * @param files defines the list of files to load (1 per face)
  50461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50462. * @param onLoad defines an optional callback raised when the texture is loaded
  50463. * @param onError defines an optional callback raised if there is an issue to load the texture
  50464. * @param format defines the format of the data
  50465. * @param forcedExtension defines the extension to use to pick the right loader
  50466. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50469. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50470. * @returns the cube texture as an InternalTexture
  50471. */
  50472. 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;
  50473. private _getSamplingFilter;
  50474. private static _GetNativeTextureFormat;
  50475. createRenderTargetTexture(size: number | {
  50476. width: number;
  50477. height: number;
  50478. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50479. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50480. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50481. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50482. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50483. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50484. /**
  50485. * Updates a dynamic vertex buffer.
  50486. * @param vertexBuffer the vertex buffer to update
  50487. * @param data the data used to update the vertex buffer
  50488. * @param byteOffset the byte offset of the data (optional)
  50489. * @param byteLength the byte length of the data (optional)
  50490. */
  50491. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50492. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50493. private _updateAnisotropicLevel;
  50494. private _getAddressMode;
  50495. /** @hidden */
  50496. _bindTexture(channel: number, texture: InternalTexture): void;
  50497. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50498. releaseEffects(): void;
  50499. /** @hidden */
  50500. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50501. /** @hidden */
  50502. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50503. /** @hidden */
  50504. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50505. /** @hidden */
  50506. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50507. }
  50508. }
  50509. declare module "babylonjs/Engines/index" {
  50510. export * from "babylonjs/Engines/constants";
  50511. export * from "babylonjs/Engines/engineCapabilities";
  50512. export * from "babylonjs/Engines/instancingAttributeInfo";
  50513. export * from "babylonjs/Engines/thinEngine";
  50514. export * from "babylonjs/Engines/engine";
  50515. export * from "babylonjs/Engines/engineStore";
  50516. export * from "babylonjs/Engines/nullEngine";
  50517. export * from "babylonjs/Engines/Extensions/index";
  50518. export * from "babylonjs/Engines/IPipelineContext";
  50519. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50520. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50521. export * from "babylonjs/Engines/nativeEngine";
  50522. }
  50523. declare module "babylonjs/Events/clipboardEvents" {
  50524. /**
  50525. * Gather the list of clipboard event types as constants.
  50526. */
  50527. export class ClipboardEventTypes {
  50528. /**
  50529. * The clipboard event is fired when a copy command is active (pressed).
  50530. */
  50531. static readonly COPY: number;
  50532. /**
  50533. * The clipboard event is fired when a cut command is active (pressed).
  50534. */
  50535. static readonly CUT: number;
  50536. /**
  50537. * The clipboard event is fired when a paste command is active (pressed).
  50538. */
  50539. static readonly PASTE: number;
  50540. }
  50541. /**
  50542. * This class is used to store clipboard related info for the onClipboardObservable event.
  50543. */
  50544. export class ClipboardInfo {
  50545. /**
  50546. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50547. */
  50548. type: number;
  50549. /**
  50550. * Defines the related dom event
  50551. */
  50552. event: ClipboardEvent;
  50553. /**
  50554. *Creates an instance of ClipboardInfo.
  50555. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50556. * @param event Defines the related dom event
  50557. */
  50558. constructor(
  50559. /**
  50560. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50561. */
  50562. type: number,
  50563. /**
  50564. * Defines the related dom event
  50565. */
  50566. event: ClipboardEvent);
  50567. /**
  50568. * Get the clipboard event's type from the keycode.
  50569. * @param keyCode Defines the keyCode for the current keyboard event.
  50570. * @return {number}
  50571. */
  50572. static GetTypeFromCharacter(keyCode: number): number;
  50573. }
  50574. }
  50575. declare module "babylonjs/Events/index" {
  50576. export * from "babylonjs/Events/keyboardEvents";
  50577. export * from "babylonjs/Events/pointerEvents";
  50578. export * from "babylonjs/Events/clipboardEvents";
  50579. }
  50580. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50581. import { Scene } from "babylonjs/scene";
  50582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50583. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50584. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50585. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50586. /**
  50587. * Google Daydream controller
  50588. */
  50589. export class DaydreamController extends WebVRController {
  50590. /**
  50591. * Base Url for the controller model.
  50592. */
  50593. static MODEL_BASE_URL: string;
  50594. /**
  50595. * File name for the controller model.
  50596. */
  50597. static MODEL_FILENAME: string;
  50598. /**
  50599. * Gamepad Id prefix used to identify Daydream Controller.
  50600. */
  50601. static readonly GAMEPAD_ID_PREFIX: string;
  50602. /**
  50603. * Creates a new DaydreamController from a gamepad
  50604. * @param vrGamepad the gamepad that the controller should be created from
  50605. */
  50606. constructor(vrGamepad: any);
  50607. /**
  50608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50609. * @param scene scene in which to add meshes
  50610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50611. */
  50612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50613. /**
  50614. * Called once for each button that changed state since the last frame
  50615. * @param buttonIdx Which button index changed
  50616. * @param state New state of the button
  50617. * @param changes Which properties on the state changed since last frame
  50618. */
  50619. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50620. }
  50621. }
  50622. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50623. import { Scene } from "babylonjs/scene";
  50624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50625. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50626. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50627. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50628. /**
  50629. * Gear VR Controller
  50630. */
  50631. export class GearVRController extends WebVRController {
  50632. /**
  50633. * Base Url for the controller model.
  50634. */
  50635. static MODEL_BASE_URL: string;
  50636. /**
  50637. * File name for the controller model.
  50638. */
  50639. static MODEL_FILENAME: string;
  50640. /**
  50641. * Gamepad Id prefix used to identify this controller.
  50642. */
  50643. static readonly GAMEPAD_ID_PREFIX: string;
  50644. private readonly _buttonIndexToObservableNameMap;
  50645. /**
  50646. * Creates a new GearVRController from a gamepad
  50647. * @param vrGamepad the gamepad that the controller should be created from
  50648. */
  50649. constructor(vrGamepad: any);
  50650. /**
  50651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50652. * @param scene scene in which to add meshes
  50653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50654. */
  50655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50656. /**
  50657. * Called once for each button that changed state since the last frame
  50658. * @param buttonIdx Which button index changed
  50659. * @param state New state of the button
  50660. * @param changes Which properties on the state changed since last frame
  50661. */
  50662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50663. }
  50664. }
  50665. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50666. import { Scene } from "babylonjs/scene";
  50667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50668. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50669. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50670. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50671. /**
  50672. * Generic Controller
  50673. */
  50674. export class GenericController extends WebVRController {
  50675. /**
  50676. * Base Url for the controller model.
  50677. */
  50678. static readonly MODEL_BASE_URL: string;
  50679. /**
  50680. * File name for the controller model.
  50681. */
  50682. static readonly MODEL_FILENAME: string;
  50683. /**
  50684. * Creates a new GenericController from a gamepad
  50685. * @param vrGamepad the gamepad that the controller should be created from
  50686. */
  50687. constructor(vrGamepad: any);
  50688. /**
  50689. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50690. * @param scene scene in which to add meshes
  50691. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50692. */
  50693. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50694. /**
  50695. * Called once for each button that changed state since the last frame
  50696. * @param buttonIdx Which button index changed
  50697. * @param state New state of the button
  50698. * @param changes Which properties on the state changed since last frame
  50699. */
  50700. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50701. }
  50702. }
  50703. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50704. import { Observable } from "babylonjs/Misc/observable";
  50705. import { Scene } from "babylonjs/scene";
  50706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50707. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50708. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50709. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50710. /**
  50711. * Oculus Touch Controller
  50712. */
  50713. export class OculusTouchController extends WebVRController {
  50714. /**
  50715. * Base Url for the controller model.
  50716. */
  50717. static MODEL_BASE_URL: string;
  50718. /**
  50719. * File name for the left controller model.
  50720. */
  50721. static MODEL_LEFT_FILENAME: string;
  50722. /**
  50723. * File name for the right controller model.
  50724. */
  50725. static MODEL_RIGHT_FILENAME: string;
  50726. /**
  50727. * Base Url for the Quest controller model.
  50728. */
  50729. static QUEST_MODEL_BASE_URL: string;
  50730. /**
  50731. * @hidden
  50732. * If the controllers are running on a device that needs the updated Quest controller models
  50733. */
  50734. static _IsQuest: boolean;
  50735. /**
  50736. * Fired when the secondary trigger on this controller is modified
  50737. */
  50738. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50739. /**
  50740. * Fired when the thumb rest on this controller is modified
  50741. */
  50742. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50743. /**
  50744. * Creates a new OculusTouchController from a gamepad
  50745. * @param vrGamepad the gamepad that the controller should be created from
  50746. */
  50747. constructor(vrGamepad: any);
  50748. /**
  50749. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50750. * @param scene scene in which to add meshes
  50751. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50752. */
  50753. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50754. /**
  50755. * Fired when the A button on this controller is modified
  50756. */
  50757. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50758. /**
  50759. * Fired when the B button on this controller is modified
  50760. */
  50761. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50762. /**
  50763. * Fired when the X button on this controller is modified
  50764. */
  50765. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50766. /**
  50767. * Fired when the Y button on this controller is modified
  50768. */
  50769. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50770. /**
  50771. * Called once for each button that changed state since the last frame
  50772. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50773. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50774. * 2) secondary trigger (same)
  50775. * 3) A (right) X (left), touch, pressed = value
  50776. * 4) B / Y
  50777. * 5) thumb rest
  50778. * @param buttonIdx Which button index changed
  50779. * @param state New state of the button
  50780. * @param changes Which properties on the state changed since last frame
  50781. */
  50782. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50783. }
  50784. }
  50785. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50786. import { Scene } from "babylonjs/scene";
  50787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50788. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50789. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50790. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50791. import { Observable } from "babylonjs/Misc/observable";
  50792. /**
  50793. * Vive Controller
  50794. */
  50795. export class ViveController extends WebVRController {
  50796. /**
  50797. * Base Url for the controller model.
  50798. */
  50799. static MODEL_BASE_URL: string;
  50800. /**
  50801. * File name for the controller model.
  50802. */
  50803. static MODEL_FILENAME: string;
  50804. /**
  50805. * Creates a new ViveController from a gamepad
  50806. * @param vrGamepad the gamepad that the controller should be created from
  50807. */
  50808. constructor(vrGamepad: any);
  50809. /**
  50810. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50811. * @param scene scene in which to add meshes
  50812. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50813. */
  50814. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50815. /**
  50816. * Fired when the left button on this controller is modified
  50817. */
  50818. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50819. /**
  50820. * Fired when the right button on this controller is modified
  50821. */
  50822. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50823. /**
  50824. * Fired when the menu button on this controller is modified
  50825. */
  50826. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50827. /**
  50828. * Called once for each button that changed state since the last frame
  50829. * Vive mapping:
  50830. * 0: touchpad
  50831. * 1: trigger
  50832. * 2: left AND right buttons
  50833. * 3: menu button
  50834. * @param buttonIdx Which button index changed
  50835. * @param state New state of the button
  50836. * @param changes Which properties on the state changed since last frame
  50837. */
  50838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50839. }
  50840. }
  50841. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50842. import { Observable } from "babylonjs/Misc/observable";
  50843. import { Scene } from "babylonjs/scene";
  50844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50845. import { Ray } from "babylonjs/Culling/ray";
  50846. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50847. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50848. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50849. /**
  50850. * Defines the WindowsMotionController object that the state of the windows motion controller
  50851. */
  50852. export class WindowsMotionController extends WebVRController {
  50853. /**
  50854. * The base url used to load the left and right controller models
  50855. */
  50856. static MODEL_BASE_URL: string;
  50857. /**
  50858. * The name of the left controller model file
  50859. */
  50860. static MODEL_LEFT_FILENAME: string;
  50861. /**
  50862. * The name of the right controller model file
  50863. */
  50864. static MODEL_RIGHT_FILENAME: string;
  50865. /**
  50866. * The controller name prefix for this controller type
  50867. */
  50868. static readonly GAMEPAD_ID_PREFIX: string;
  50869. /**
  50870. * The controller id pattern for this controller type
  50871. */
  50872. private static readonly GAMEPAD_ID_PATTERN;
  50873. private _loadedMeshInfo;
  50874. protected readonly _mapping: {
  50875. buttons: string[];
  50876. buttonMeshNames: {
  50877. trigger: string;
  50878. menu: string;
  50879. grip: string;
  50880. thumbstick: string;
  50881. trackpad: string;
  50882. };
  50883. buttonObservableNames: {
  50884. trigger: string;
  50885. menu: string;
  50886. grip: string;
  50887. thumbstick: string;
  50888. trackpad: string;
  50889. };
  50890. axisMeshNames: string[];
  50891. pointingPoseMeshName: string;
  50892. };
  50893. /**
  50894. * Fired when the trackpad on this controller is clicked
  50895. */
  50896. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50897. /**
  50898. * Fired when the trackpad on this controller is modified
  50899. */
  50900. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50901. /**
  50902. * The current x and y values of this controller's trackpad
  50903. */
  50904. trackpad: StickValues;
  50905. /**
  50906. * Creates a new WindowsMotionController from a gamepad
  50907. * @param vrGamepad the gamepad that the controller should be created from
  50908. */
  50909. constructor(vrGamepad: any);
  50910. /**
  50911. * Fired when the trigger on this controller is modified
  50912. */
  50913. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50914. /**
  50915. * Fired when the menu button on this controller is modified
  50916. */
  50917. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50918. /**
  50919. * Fired when the grip button on this controller is modified
  50920. */
  50921. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50922. /**
  50923. * Fired when the thumbstick button on this controller is modified
  50924. */
  50925. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50926. /**
  50927. * Fired when the touchpad button on this controller is modified
  50928. */
  50929. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50930. /**
  50931. * Fired when the touchpad values on this controller are modified
  50932. */
  50933. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50934. protected _updateTrackpad(): void;
  50935. /**
  50936. * Called once per frame by the engine.
  50937. */
  50938. update(): void;
  50939. /**
  50940. * Called once for each button that changed state since the last frame
  50941. * @param buttonIdx Which button index changed
  50942. * @param state New state of the button
  50943. * @param changes Which properties on the state changed since last frame
  50944. */
  50945. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50946. /**
  50947. * Moves the buttons on the controller mesh based on their current state
  50948. * @param buttonName the name of the button to move
  50949. * @param buttonValue the value of the button which determines the buttons new position
  50950. */
  50951. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50952. /**
  50953. * Moves the axis on the controller mesh based on its current state
  50954. * @param axis the index of the axis
  50955. * @param axisValue the value of the axis which determines the meshes new position
  50956. * @hidden
  50957. */
  50958. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50959. /**
  50960. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50961. * @param scene scene in which to add meshes
  50962. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50963. */
  50964. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50965. /**
  50966. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50967. * can be transformed by button presses and axes values, based on this._mapping.
  50968. *
  50969. * @param scene scene in which the meshes exist
  50970. * @param meshes list of meshes that make up the controller model to process
  50971. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50972. */
  50973. private processModel;
  50974. private createMeshInfo;
  50975. /**
  50976. * Gets the ray of the controller in the direction the controller is pointing
  50977. * @param length the length the resulting ray should be
  50978. * @returns a ray in the direction the controller is pointing
  50979. */
  50980. getForwardRay(length?: number): Ray;
  50981. /**
  50982. * Disposes of the controller
  50983. */
  50984. dispose(): void;
  50985. }
  50986. /**
  50987. * This class represents a new windows motion controller in XR.
  50988. */
  50989. export class XRWindowsMotionController extends WindowsMotionController {
  50990. /**
  50991. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50992. */
  50993. protected readonly _mapping: {
  50994. buttons: string[];
  50995. buttonMeshNames: {
  50996. trigger: string;
  50997. menu: string;
  50998. grip: string;
  50999. thumbstick: string;
  51000. trackpad: string;
  51001. };
  51002. buttonObservableNames: {
  51003. trigger: string;
  51004. menu: string;
  51005. grip: string;
  51006. thumbstick: string;
  51007. trackpad: string;
  51008. };
  51009. axisMeshNames: string[];
  51010. pointingPoseMeshName: string;
  51011. };
  51012. /**
  51013. * Construct a new XR-Based windows motion controller
  51014. *
  51015. * @param gamepadInfo the gamepad object from the browser
  51016. */
  51017. constructor(gamepadInfo: any);
  51018. /**
  51019. * holds the thumbstick values (X,Y)
  51020. */
  51021. thumbstickValues: StickValues;
  51022. /**
  51023. * Fired when the thumbstick on this controller is clicked
  51024. */
  51025. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51026. /**
  51027. * Fired when the thumbstick on this controller is modified
  51028. */
  51029. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51030. /**
  51031. * Fired when the touchpad button on this controller is modified
  51032. */
  51033. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51034. /**
  51035. * Fired when the touchpad values on this controller are modified
  51036. */
  51037. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51038. /**
  51039. * Fired when the thumbstick button on this controller is modified
  51040. * here to prevent breaking changes
  51041. */
  51042. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51043. /**
  51044. * updating the thumbstick(!) and not the trackpad.
  51045. * This is named this way due to the difference between WebVR and XR and to avoid
  51046. * changing the parent class.
  51047. */
  51048. protected _updateTrackpad(): void;
  51049. /**
  51050. * Disposes the class with joy
  51051. */
  51052. dispose(): void;
  51053. }
  51054. }
  51055. declare module "babylonjs/Gamepads/Controllers/index" {
  51056. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  51057. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  51058. export * from "babylonjs/Gamepads/Controllers/genericController";
  51059. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  51060. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  51061. export * from "babylonjs/Gamepads/Controllers/viveController";
  51062. export * from "babylonjs/Gamepads/Controllers/webVRController";
  51063. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  51064. }
  51065. declare module "babylonjs/Gamepads/index" {
  51066. export * from "babylonjs/Gamepads/Controllers/index";
  51067. export * from "babylonjs/Gamepads/gamepad";
  51068. export * from "babylonjs/Gamepads/gamepadManager";
  51069. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  51070. export * from "babylonjs/Gamepads/xboxGamepad";
  51071. export * from "babylonjs/Gamepads/dualShockGamepad";
  51072. }
  51073. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  51074. import { Scene } from "babylonjs/scene";
  51075. import { Vector4 } from "babylonjs/Maths/math.vector";
  51076. import { Color4 } from "babylonjs/Maths/math.color";
  51077. import { Mesh } from "babylonjs/Meshes/mesh";
  51078. import { Nullable } from "babylonjs/types";
  51079. /**
  51080. * Class containing static functions to help procedurally build meshes
  51081. */
  51082. export class PolyhedronBuilder {
  51083. /**
  51084. * Creates a polyhedron mesh
  51085. * * 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
  51086. * * The parameter `size` (positive float, default 1) sets the polygon size
  51087. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51088. * * 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`
  51089. * * 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
  51090. * * 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)`)
  51091. * * 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
  51092. * * 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
  51093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51094. * * 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
  51095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51096. * @param name defines the name of the mesh
  51097. * @param options defines the options used to create the mesh
  51098. * @param scene defines the hosting scene
  51099. * @returns the polyhedron mesh
  51100. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51101. */
  51102. static CreatePolyhedron(name: string, options: {
  51103. type?: number;
  51104. size?: number;
  51105. sizeX?: number;
  51106. sizeY?: number;
  51107. sizeZ?: number;
  51108. custom?: any;
  51109. faceUV?: Vector4[];
  51110. faceColors?: Color4[];
  51111. flat?: boolean;
  51112. updatable?: boolean;
  51113. sideOrientation?: number;
  51114. frontUVs?: Vector4;
  51115. backUVs?: Vector4;
  51116. }, scene?: Nullable<Scene>): Mesh;
  51117. }
  51118. }
  51119. declare module "babylonjs/Gizmos/scaleGizmo" {
  51120. import { Observable } from "babylonjs/Misc/observable";
  51121. import { Nullable } from "babylonjs/types";
  51122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51123. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51124. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  51125. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51126. /**
  51127. * Gizmo that enables scaling a mesh along 3 axis
  51128. */
  51129. export class ScaleGizmo extends Gizmo {
  51130. /**
  51131. * Internal gizmo used for interactions on the x axis
  51132. */
  51133. xGizmo: AxisScaleGizmo;
  51134. /**
  51135. * Internal gizmo used for interactions on the y axis
  51136. */
  51137. yGizmo: AxisScaleGizmo;
  51138. /**
  51139. * Internal gizmo used for interactions on the z axis
  51140. */
  51141. zGizmo: AxisScaleGizmo;
  51142. /**
  51143. * Internal gizmo used to scale all axis equally
  51144. */
  51145. uniformScaleGizmo: AxisScaleGizmo;
  51146. private _meshAttached;
  51147. private _updateGizmoRotationToMatchAttachedMesh;
  51148. private _snapDistance;
  51149. private _scaleRatio;
  51150. private _uniformScalingMesh;
  51151. private _octahedron;
  51152. private _sensitivity;
  51153. /** Fires an event when any of it's sub gizmos are dragged */
  51154. onDragStartObservable: Observable<unknown>;
  51155. /** Fires an event when any of it's sub gizmos are released from dragging */
  51156. onDragEndObservable: Observable<unknown>;
  51157. get attachedMesh(): Nullable<AbstractMesh>;
  51158. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51159. /**
  51160. * Creates a ScaleGizmo
  51161. * @param gizmoLayer The utility layer the gizmo will be added to
  51162. */
  51163. constructor(gizmoLayer?: UtilityLayerRenderer);
  51164. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51165. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51166. /**
  51167. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51168. */
  51169. set snapDistance(value: number);
  51170. get snapDistance(): number;
  51171. /**
  51172. * Ratio for the scale of the gizmo (Default: 1)
  51173. */
  51174. set scaleRatio(value: number);
  51175. get scaleRatio(): number;
  51176. /**
  51177. * Sensitivity factor for dragging (Default: 1)
  51178. */
  51179. set sensitivity(value: number);
  51180. get sensitivity(): number;
  51181. /**
  51182. * Disposes of the gizmo
  51183. */
  51184. dispose(): void;
  51185. }
  51186. }
  51187. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  51188. import { Observable } from "babylonjs/Misc/observable";
  51189. import { Nullable } from "babylonjs/types";
  51190. import { Vector3 } from "babylonjs/Maths/math.vector";
  51191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51192. import { Mesh } from "babylonjs/Meshes/mesh";
  51193. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51194. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51195. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51196. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51197. import { Color3 } from "babylonjs/Maths/math.color";
  51198. /**
  51199. * Single axis scale gizmo
  51200. */
  51201. export class AxisScaleGizmo extends Gizmo {
  51202. /**
  51203. * Drag behavior responsible for the gizmos dragging interactions
  51204. */
  51205. dragBehavior: PointerDragBehavior;
  51206. private _pointerObserver;
  51207. /**
  51208. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51209. */
  51210. snapDistance: number;
  51211. /**
  51212. * Event that fires each time the gizmo snaps to a new location.
  51213. * * snapDistance is the the change in distance
  51214. */
  51215. onSnapObservable: Observable<{
  51216. snapDistance: number;
  51217. }>;
  51218. /**
  51219. * If the scaling operation should be done on all axis (default: false)
  51220. */
  51221. uniformScaling: boolean;
  51222. /**
  51223. * Custom sensitivity value for the drag strength
  51224. */
  51225. sensitivity: number;
  51226. private _isEnabled;
  51227. private _parent;
  51228. private _arrow;
  51229. private _coloredMaterial;
  51230. private _hoverMaterial;
  51231. /**
  51232. * Creates an AxisScaleGizmo
  51233. * @param gizmoLayer The utility layer the gizmo will be added to
  51234. * @param dragAxis The axis which the gizmo will be able to scale on
  51235. * @param color The color of the gizmo
  51236. */
  51237. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51238. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51239. /**
  51240. * If the gizmo is enabled
  51241. */
  51242. set isEnabled(value: boolean);
  51243. get isEnabled(): boolean;
  51244. /**
  51245. * Disposes of the gizmo
  51246. */
  51247. dispose(): void;
  51248. /**
  51249. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51250. * @param mesh The mesh to replace the default mesh of the gizmo
  51251. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51252. */
  51253. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51254. }
  51255. }
  51256. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51257. import { Observable } from "babylonjs/Misc/observable";
  51258. import { Nullable } from "babylonjs/types";
  51259. import { Vector3 } from "babylonjs/Maths/math.vector";
  51260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51261. import { Mesh } from "babylonjs/Meshes/mesh";
  51262. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51263. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51264. import { Color3 } from "babylonjs/Maths/math.color";
  51265. import "babylonjs/Meshes/Builders/boxBuilder";
  51266. /**
  51267. * Bounding box gizmo
  51268. */
  51269. export class BoundingBoxGizmo extends Gizmo {
  51270. private _lineBoundingBox;
  51271. private _rotateSpheresParent;
  51272. private _scaleBoxesParent;
  51273. private _boundingDimensions;
  51274. private _renderObserver;
  51275. private _pointerObserver;
  51276. private _scaleDragSpeed;
  51277. private _tmpQuaternion;
  51278. private _tmpVector;
  51279. private _tmpRotationMatrix;
  51280. /**
  51281. * 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)
  51282. */
  51283. ignoreChildren: boolean;
  51284. /**
  51285. * 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)
  51286. */
  51287. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51288. /**
  51289. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51290. */
  51291. rotationSphereSize: number;
  51292. /**
  51293. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51294. */
  51295. scaleBoxSize: number;
  51296. /**
  51297. * 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)
  51298. */
  51299. fixedDragMeshScreenSize: boolean;
  51300. /**
  51301. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51302. */
  51303. fixedDragMeshScreenSizeDistanceFactor: number;
  51304. /**
  51305. * Fired when a rotation sphere or scale box is dragged
  51306. */
  51307. onDragStartObservable: Observable<{}>;
  51308. /**
  51309. * Fired when a scale box is dragged
  51310. */
  51311. onScaleBoxDragObservable: Observable<{}>;
  51312. /**
  51313. * Fired when a scale box drag is ended
  51314. */
  51315. onScaleBoxDragEndObservable: Observable<{}>;
  51316. /**
  51317. * Fired when a rotation sphere is dragged
  51318. */
  51319. onRotationSphereDragObservable: Observable<{}>;
  51320. /**
  51321. * Fired when a rotation sphere drag is ended
  51322. */
  51323. onRotationSphereDragEndObservable: Observable<{}>;
  51324. /**
  51325. * 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)
  51326. */
  51327. scalePivot: Nullable<Vector3>;
  51328. /**
  51329. * Mesh used as a pivot to rotate the attached mesh
  51330. */
  51331. private _anchorMesh;
  51332. private _existingMeshScale;
  51333. private _dragMesh;
  51334. private pointerDragBehavior;
  51335. private coloredMaterial;
  51336. private hoverColoredMaterial;
  51337. /**
  51338. * Sets the color of the bounding box gizmo
  51339. * @param color the color to set
  51340. */
  51341. setColor(color: Color3): void;
  51342. /**
  51343. * Creates an BoundingBoxGizmo
  51344. * @param gizmoLayer The utility layer the gizmo will be added to
  51345. * @param color The color of the gizmo
  51346. */
  51347. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51348. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51349. private _selectNode;
  51350. /**
  51351. * Updates the bounding box information for the Gizmo
  51352. */
  51353. updateBoundingBox(): void;
  51354. private _updateRotationSpheres;
  51355. private _updateScaleBoxes;
  51356. /**
  51357. * Enables rotation on the specified axis and disables rotation on the others
  51358. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51359. */
  51360. setEnabledRotationAxis(axis: string): void;
  51361. /**
  51362. * Enables/disables scaling
  51363. * @param enable if scaling should be enabled
  51364. * @param homogeneousScaling defines if scaling should only be homogeneous
  51365. */
  51366. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51367. private _updateDummy;
  51368. /**
  51369. * Enables a pointer drag behavior on the bounding box of the gizmo
  51370. */
  51371. enableDragBehavior(): void;
  51372. /**
  51373. * Disposes of the gizmo
  51374. */
  51375. dispose(): void;
  51376. /**
  51377. * 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)
  51378. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51379. * @returns the bounding box mesh with the passed in mesh as a child
  51380. */
  51381. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51382. /**
  51383. * CustomMeshes are not supported by this gizmo
  51384. * @param mesh The mesh to replace the default mesh of the gizmo
  51385. */
  51386. setCustomMesh(mesh: Mesh): void;
  51387. }
  51388. }
  51389. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51390. import { Observable } from "babylonjs/Misc/observable";
  51391. import { Nullable } from "babylonjs/types";
  51392. import { Vector3 } from "babylonjs/Maths/math.vector";
  51393. import { Color3 } from "babylonjs/Maths/math.color";
  51394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51395. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51396. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51397. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51398. import "babylonjs/Meshes/Builders/linesBuilder";
  51399. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51400. /**
  51401. * Single plane rotation gizmo
  51402. */
  51403. export class PlaneRotationGizmo extends Gizmo {
  51404. /**
  51405. * Drag behavior responsible for the gizmos dragging interactions
  51406. */
  51407. dragBehavior: PointerDragBehavior;
  51408. private _pointerObserver;
  51409. /**
  51410. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51411. */
  51412. snapDistance: number;
  51413. /**
  51414. * Event that fires each time the gizmo snaps to a new location.
  51415. * * snapDistance is the the change in distance
  51416. */
  51417. onSnapObservable: Observable<{
  51418. snapDistance: number;
  51419. }>;
  51420. private _isEnabled;
  51421. private _parent;
  51422. /**
  51423. * Creates a PlaneRotationGizmo
  51424. * @param gizmoLayer The utility layer the gizmo will be added to
  51425. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51426. * @param color The color of the gizmo
  51427. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51428. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51429. */
  51430. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51431. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51432. /**
  51433. * If the gizmo is enabled
  51434. */
  51435. set isEnabled(value: boolean);
  51436. get isEnabled(): boolean;
  51437. /**
  51438. * Disposes of the gizmo
  51439. */
  51440. dispose(): void;
  51441. }
  51442. }
  51443. declare module "babylonjs/Gizmos/rotationGizmo" {
  51444. import { Observable } from "babylonjs/Misc/observable";
  51445. import { Nullable } from "babylonjs/types";
  51446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51447. import { Mesh } from "babylonjs/Meshes/mesh";
  51448. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51449. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51450. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51451. /**
  51452. * Gizmo that enables rotating a mesh along 3 axis
  51453. */
  51454. export class RotationGizmo extends Gizmo {
  51455. /**
  51456. * Internal gizmo used for interactions on the x axis
  51457. */
  51458. xGizmo: PlaneRotationGizmo;
  51459. /**
  51460. * Internal gizmo used for interactions on the y axis
  51461. */
  51462. yGizmo: PlaneRotationGizmo;
  51463. /**
  51464. * Internal gizmo used for interactions on the z axis
  51465. */
  51466. zGizmo: PlaneRotationGizmo;
  51467. /** Fires an event when any of it's sub gizmos are dragged */
  51468. onDragStartObservable: Observable<unknown>;
  51469. /** Fires an event when any of it's sub gizmos are released from dragging */
  51470. onDragEndObservable: Observable<unknown>;
  51471. private _meshAttached;
  51472. get attachedMesh(): Nullable<AbstractMesh>;
  51473. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51474. /**
  51475. * Creates a RotationGizmo
  51476. * @param gizmoLayer The utility layer the gizmo will be added to
  51477. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51478. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51479. */
  51480. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51481. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51482. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51483. /**
  51484. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51485. */
  51486. set snapDistance(value: number);
  51487. get snapDistance(): number;
  51488. /**
  51489. * Ratio for the scale of the gizmo (Default: 1)
  51490. */
  51491. set scaleRatio(value: number);
  51492. get scaleRatio(): number;
  51493. /**
  51494. * Disposes of the gizmo
  51495. */
  51496. dispose(): void;
  51497. /**
  51498. * CustomMeshes are not supported by this gizmo
  51499. * @param mesh The mesh to replace the default mesh of the gizmo
  51500. */
  51501. setCustomMesh(mesh: Mesh): void;
  51502. }
  51503. }
  51504. declare module "babylonjs/Gizmos/gizmoManager" {
  51505. import { Observable } from "babylonjs/Misc/observable";
  51506. import { Nullable } from "babylonjs/types";
  51507. import { Scene, IDisposable } from "babylonjs/scene";
  51508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51509. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51510. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51511. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51512. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51513. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51514. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51515. /**
  51516. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51517. */
  51518. export class GizmoManager implements IDisposable {
  51519. private scene;
  51520. /**
  51521. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51522. */
  51523. gizmos: {
  51524. positionGizmo: Nullable<PositionGizmo>;
  51525. rotationGizmo: Nullable<RotationGizmo>;
  51526. scaleGizmo: Nullable<ScaleGizmo>;
  51527. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51528. };
  51529. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51530. clearGizmoOnEmptyPointerEvent: boolean;
  51531. /** Fires an event when the manager is attached to a mesh */
  51532. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51533. private _gizmosEnabled;
  51534. private _pointerObserver;
  51535. private _attachedMesh;
  51536. private _boundingBoxColor;
  51537. private _defaultUtilityLayer;
  51538. private _defaultKeepDepthUtilityLayer;
  51539. /**
  51540. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51541. */
  51542. boundingBoxDragBehavior: SixDofDragBehavior;
  51543. /**
  51544. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51545. */
  51546. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51547. /**
  51548. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51549. */
  51550. usePointerToAttachGizmos: boolean;
  51551. /**
  51552. * Utility layer that the bounding box gizmo belongs to
  51553. */
  51554. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51555. /**
  51556. * Utility layer that all gizmos besides bounding box belong to
  51557. */
  51558. get utilityLayer(): UtilityLayerRenderer;
  51559. /**
  51560. * Instatiates a gizmo manager
  51561. * @param scene the scene to overlay the gizmos on top of
  51562. */
  51563. constructor(scene: Scene);
  51564. /**
  51565. * Attaches a set of gizmos to the specified mesh
  51566. * @param mesh The mesh the gizmo's should be attached to
  51567. */
  51568. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51569. /**
  51570. * If the position gizmo is enabled
  51571. */
  51572. set positionGizmoEnabled(value: boolean);
  51573. get positionGizmoEnabled(): boolean;
  51574. /**
  51575. * If the rotation gizmo is enabled
  51576. */
  51577. set rotationGizmoEnabled(value: boolean);
  51578. get rotationGizmoEnabled(): boolean;
  51579. /**
  51580. * If the scale gizmo is enabled
  51581. */
  51582. set scaleGizmoEnabled(value: boolean);
  51583. get scaleGizmoEnabled(): boolean;
  51584. /**
  51585. * If the boundingBox gizmo is enabled
  51586. */
  51587. set boundingBoxGizmoEnabled(value: boolean);
  51588. get boundingBoxGizmoEnabled(): boolean;
  51589. /**
  51590. * Disposes of the gizmo manager
  51591. */
  51592. dispose(): void;
  51593. }
  51594. }
  51595. declare module "babylonjs/Lights/directionalLight" {
  51596. import { Camera } from "babylonjs/Cameras/camera";
  51597. import { Scene } from "babylonjs/scene";
  51598. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51600. import { Light } from "babylonjs/Lights/light";
  51601. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51602. import { Effect } from "babylonjs/Materials/effect";
  51603. /**
  51604. * A directional light is defined by a direction (what a surprise!).
  51605. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51606. * 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.
  51607. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51608. */
  51609. export class DirectionalLight extends ShadowLight {
  51610. private _shadowFrustumSize;
  51611. /**
  51612. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51613. */
  51614. get shadowFrustumSize(): number;
  51615. /**
  51616. * Specifies a fix frustum size for the shadow generation.
  51617. */
  51618. set shadowFrustumSize(value: number);
  51619. private _shadowOrthoScale;
  51620. /**
  51621. * Gets the shadow projection scale against the optimal computed one.
  51622. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51623. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51624. */
  51625. get shadowOrthoScale(): number;
  51626. /**
  51627. * Sets the shadow projection scale against the optimal computed one.
  51628. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51629. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51630. */
  51631. set shadowOrthoScale(value: number);
  51632. /**
  51633. * Automatically compute the projection matrix to best fit (including all the casters)
  51634. * on each frame.
  51635. */
  51636. autoUpdateExtends: boolean;
  51637. /**
  51638. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51639. * on each frame. autoUpdateExtends must be set to true for this to work
  51640. */
  51641. autoCalcShadowZBounds: boolean;
  51642. private _orthoLeft;
  51643. private _orthoRight;
  51644. private _orthoTop;
  51645. private _orthoBottom;
  51646. /**
  51647. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51648. * The directional light is emitted from everywhere in the given direction.
  51649. * It can cast shadows.
  51650. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51651. * @param name The friendly name of the light
  51652. * @param direction The direction of the light
  51653. * @param scene The scene the light belongs to
  51654. */
  51655. constructor(name: string, direction: Vector3, scene: Scene);
  51656. /**
  51657. * Returns the string "DirectionalLight".
  51658. * @return The class name
  51659. */
  51660. getClassName(): string;
  51661. /**
  51662. * Returns the integer 1.
  51663. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51664. */
  51665. getTypeID(): number;
  51666. /**
  51667. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51668. * Returns the DirectionalLight Shadow projection matrix.
  51669. */
  51670. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51671. /**
  51672. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51673. * Returns the DirectionalLight Shadow projection matrix.
  51674. */
  51675. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51676. /**
  51677. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51678. * Returns the DirectionalLight Shadow projection matrix.
  51679. */
  51680. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51681. protected _buildUniformLayout(): void;
  51682. /**
  51683. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51684. * @param effect The effect to update
  51685. * @param lightIndex The index of the light in the effect to update
  51686. * @returns The directional light
  51687. */
  51688. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51689. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51690. /**
  51691. * Gets the minZ used for shadow according to both the scene and the light.
  51692. *
  51693. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51694. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51695. * @param activeCamera The camera we are returning the min for
  51696. * @returns the depth min z
  51697. */
  51698. getDepthMinZ(activeCamera: Camera): number;
  51699. /**
  51700. * Gets the maxZ used for shadow according to both the scene and the light.
  51701. *
  51702. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51703. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51704. * @param activeCamera The camera we are returning the max for
  51705. * @returns the depth max z
  51706. */
  51707. getDepthMaxZ(activeCamera: Camera): number;
  51708. /**
  51709. * Prepares the list of defines specific to the light type.
  51710. * @param defines the list of defines
  51711. * @param lightIndex defines the index of the light for the effect
  51712. */
  51713. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51714. }
  51715. }
  51716. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51717. import { Mesh } from "babylonjs/Meshes/mesh";
  51718. /**
  51719. * Class containing static functions to help procedurally build meshes
  51720. */
  51721. export class HemisphereBuilder {
  51722. /**
  51723. * Creates a hemisphere mesh
  51724. * @param name defines the name of the mesh
  51725. * @param options defines the options used to create the mesh
  51726. * @param scene defines the hosting scene
  51727. * @returns the hemisphere mesh
  51728. */
  51729. static CreateHemisphere(name: string, options: {
  51730. segments?: number;
  51731. diameter?: number;
  51732. sideOrientation?: number;
  51733. }, scene: any): Mesh;
  51734. }
  51735. }
  51736. declare module "babylonjs/Lights/spotLight" {
  51737. import { Nullable } from "babylonjs/types";
  51738. import { Scene } from "babylonjs/scene";
  51739. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51741. import { Effect } from "babylonjs/Materials/effect";
  51742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51743. import { Light } from "babylonjs/Lights/light";
  51744. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51745. /**
  51746. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51747. * These values define a cone of light starting from the position, emitting toward the direction.
  51748. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51749. * and the exponent defines the speed of the decay of the light with distance (reach).
  51750. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51751. */
  51752. export class SpotLight extends ShadowLight {
  51753. private _angle;
  51754. private _innerAngle;
  51755. private _cosHalfAngle;
  51756. private _lightAngleScale;
  51757. private _lightAngleOffset;
  51758. /**
  51759. * Gets the cone angle of the spot light in Radians.
  51760. */
  51761. get angle(): number;
  51762. /**
  51763. * Sets the cone angle of the spot light in Radians.
  51764. */
  51765. set angle(value: number);
  51766. /**
  51767. * Only used in gltf falloff mode, this defines the angle where
  51768. * the directional falloff will start before cutting at angle which could be seen
  51769. * as outer angle.
  51770. */
  51771. get innerAngle(): number;
  51772. /**
  51773. * Only used in gltf falloff mode, this defines the angle where
  51774. * the directional falloff will start before cutting at angle which could be seen
  51775. * as outer angle.
  51776. */
  51777. set innerAngle(value: number);
  51778. private _shadowAngleScale;
  51779. /**
  51780. * Allows scaling the angle of the light for shadow generation only.
  51781. */
  51782. get shadowAngleScale(): number;
  51783. /**
  51784. * Allows scaling the angle of the light for shadow generation only.
  51785. */
  51786. set shadowAngleScale(value: number);
  51787. /**
  51788. * The light decay speed with the distance from the emission spot.
  51789. */
  51790. exponent: number;
  51791. private _projectionTextureMatrix;
  51792. /**
  51793. * Allows reading the projecton texture
  51794. */
  51795. get projectionTextureMatrix(): Matrix;
  51796. protected _projectionTextureLightNear: number;
  51797. /**
  51798. * Gets the near clip of the Spotlight for texture projection.
  51799. */
  51800. get projectionTextureLightNear(): number;
  51801. /**
  51802. * Sets the near clip of the Spotlight for texture projection.
  51803. */
  51804. set projectionTextureLightNear(value: number);
  51805. protected _projectionTextureLightFar: number;
  51806. /**
  51807. * Gets the far clip of the Spotlight for texture projection.
  51808. */
  51809. get projectionTextureLightFar(): number;
  51810. /**
  51811. * Sets the far clip of the Spotlight for texture projection.
  51812. */
  51813. set projectionTextureLightFar(value: number);
  51814. protected _projectionTextureUpDirection: Vector3;
  51815. /**
  51816. * Gets the Up vector of the Spotlight for texture projection.
  51817. */
  51818. get projectionTextureUpDirection(): Vector3;
  51819. /**
  51820. * Sets the Up vector of the Spotlight for texture projection.
  51821. */
  51822. set projectionTextureUpDirection(value: Vector3);
  51823. private _projectionTexture;
  51824. /**
  51825. * Gets the projection texture of the light.
  51826. */
  51827. get projectionTexture(): Nullable<BaseTexture>;
  51828. /**
  51829. * Sets the projection texture of the light.
  51830. */
  51831. set projectionTexture(value: Nullable<BaseTexture>);
  51832. private _projectionTextureViewLightDirty;
  51833. private _projectionTextureProjectionLightDirty;
  51834. private _projectionTextureDirty;
  51835. private _projectionTextureViewTargetVector;
  51836. private _projectionTextureViewLightMatrix;
  51837. private _projectionTextureProjectionLightMatrix;
  51838. private _projectionTextureScalingMatrix;
  51839. /**
  51840. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51841. * It can cast shadows.
  51842. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51843. * @param name The light friendly name
  51844. * @param position The position of the spot light in the scene
  51845. * @param direction The direction of the light in the scene
  51846. * @param angle The cone angle of the light in Radians
  51847. * @param exponent The light decay speed with the distance from the emission spot
  51848. * @param scene The scene the lights belongs to
  51849. */
  51850. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51851. /**
  51852. * Returns the string "SpotLight".
  51853. * @returns the class name
  51854. */
  51855. getClassName(): string;
  51856. /**
  51857. * Returns the integer 2.
  51858. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51859. */
  51860. getTypeID(): number;
  51861. /**
  51862. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51863. */
  51864. protected _setDirection(value: Vector3): void;
  51865. /**
  51866. * Overrides the position setter to recompute the projection texture view light Matrix.
  51867. */
  51868. protected _setPosition(value: Vector3): void;
  51869. /**
  51870. * 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.
  51871. * Returns the SpotLight.
  51872. */
  51873. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51874. protected _computeProjectionTextureViewLightMatrix(): void;
  51875. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51876. /**
  51877. * Main function for light texture projection matrix computing.
  51878. */
  51879. protected _computeProjectionTextureMatrix(): void;
  51880. protected _buildUniformLayout(): void;
  51881. private _computeAngleValues;
  51882. /**
  51883. * Sets the passed Effect "effect" with the Light textures.
  51884. * @param effect The effect to update
  51885. * @param lightIndex The index of the light in the effect to update
  51886. * @returns The light
  51887. */
  51888. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51889. /**
  51890. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51891. * @param effect The effect to update
  51892. * @param lightIndex The index of the light in the effect to update
  51893. * @returns The spot light
  51894. */
  51895. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51896. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51897. /**
  51898. * Disposes the light and the associated resources.
  51899. */
  51900. dispose(): void;
  51901. /**
  51902. * Prepares the list of defines specific to the light type.
  51903. * @param defines the list of defines
  51904. * @param lightIndex defines the index of the light for the effect
  51905. */
  51906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51907. }
  51908. }
  51909. declare module "babylonjs/Gizmos/lightGizmo" {
  51910. import { Nullable } from "babylonjs/types";
  51911. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51912. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51913. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51914. import { Light } from "babylonjs/Lights/light";
  51915. /**
  51916. * Gizmo that enables viewing a light
  51917. */
  51918. export class LightGizmo extends Gizmo {
  51919. private _lightMesh;
  51920. private _material;
  51921. private _cachedPosition;
  51922. private _cachedForward;
  51923. private _attachedMeshParent;
  51924. /**
  51925. * Creates a LightGizmo
  51926. * @param gizmoLayer The utility layer the gizmo will be added to
  51927. */
  51928. constructor(gizmoLayer?: UtilityLayerRenderer);
  51929. private _light;
  51930. /**
  51931. * The light that the gizmo is attached to
  51932. */
  51933. set light(light: Nullable<Light>);
  51934. get light(): Nullable<Light>;
  51935. /**
  51936. * Gets the material used to render the light gizmo
  51937. */
  51938. get material(): StandardMaterial;
  51939. /**
  51940. * @hidden
  51941. * Updates the gizmo to match the attached mesh's position/rotation
  51942. */
  51943. protected _update(): void;
  51944. private static _Scale;
  51945. /**
  51946. * Creates the lines for a light mesh
  51947. */
  51948. private static _CreateLightLines;
  51949. /**
  51950. * Disposes of the light gizmo
  51951. */
  51952. dispose(): void;
  51953. private static _CreateHemisphericLightMesh;
  51954. private static _CreatePointLightMesh;
  51955. private static _CreateSpotLightMesh;
  51956. private static _CreateDirectionalLightMesh;
  51957. }
  51958. }
  51959. declare module "babylonjs/Gizmos/index" {
  51960. export * from "babylonjs/Gizmos/axisDragGizmo";
  51961. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51962. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51963. export * from "babylonjs/Gizmos/gizmo";
  51964. export * from "babylonjs/Gizmos/gizmoManager";
  51965. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51966. export * from "babylonjs/Gizmos/positionGizmo";
  51967. export * from "babylonjs/Gizmos/rotationGizmo";
  51968. export * from "babylonjs/Gizmos/scaleGizmo";
  51969. export * from "babylonjs/Gizmos/lightGizmo";
  51970. export * from "babylonjs/Gizmos/planeDragGizmo";
  51971. }
  51972. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51973. /** @hidden */
  51974. export var backgroundFragmentDeclaration: {
  51975. name: string;
  51976. shader: string;
  51977. };
  51978. }
  51979. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51980. /** @hidden */
  51981. export var backgroundUboDeclaration: {
  51982. name: string;
  51983. shader: string;
  51984. };
  51985. }
  51986. declare module "babylonjs/Shaders/background.fragment" {
  51987. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51988. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51989. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51991. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51992. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51993. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51994. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51995. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51996. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51997. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51998. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52000. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52001. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52002. /** @hidden */
  52003. export var backgroundPixelShader: {
  52004. name: string;
  52005. shader: string;
  52006. };
  52007. }
  52008. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  52009. /** @hidden */
  52010. export var backgroundVertexDeclaration: {
  52011. name: string;
  52012. shader: string;
  52013. };
  52014. }
  52015. declare module "babylonjs/Shaders/background.vertex" {
  52016. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  52017. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  52018. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52019. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52020. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52021. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52022. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52023. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52024. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52025. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52026. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52027. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52028. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52029. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52030. /** @hidden */
  52031. export var backgroundVertexShader: {
  52032. name: string;
  52033. shader: string;
  52034. };
  52035. }
  52036. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  52037. import { Nullable, int, float } from "babylonjs/types";
  52038. import { Scene } from "babylonjs/scene";
  52039. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52040. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52042. import { Mesh } from "babylonjs/Meshes/mesh";
  52043. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52044. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52045. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52046. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52047. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  52048. import { Color3 } from "babylonjs/Maths/math.color";
  52049. import "babylonjs/Shaders/background.fragment";
  52050. import "babylonjs/Shaders/background.vertex";
  52051. /**
  52052. * Background material used to create an efficient environement around your scene.
  52053. */
  52054. export class BackgroundMaterial extends PushMaterial {
  52055. /**
  52056. * Standard reflectance value at parallel view angle.
  52057. */
  52058. static StandardReflectance0: number;
  52059. /**
  52060. * Standard reflectance value at grazing angle.
  52061. */
  52062. static StandardReflectance90: number;
  52063. protected _primaryColor: Color3;
  52064. /**
  52065. * Key light Color (multiply against the environement texture)
  52066. */
  52067. primaryColor: Color3;
  52068. protected __perceptualColor: Nullable<Color3>;
  52069. /**
  52070. * Experimental Internal Use Only.
  52071. *
  52072. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52073. * This acts as a helper to set the primary color to a more "human friendly" value.
  52074. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52075. * output color as close as possible from the chosen value.
  52076. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52077. * part of lighting setup.)
  52078. */
  52079. get _perceptualColor(): Nullable<Color3>;
  52080. set _perceptualColor(value: Nullable<Color3>);
  52081. protected _primaryColorShadowLevel: float;
  52082. /**
  52083. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52084. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52085. */
  52086. get primaryColorShadowLevel(): float;
  52087. set primaryColorShadowLevel(value: float);
  52088. protected _primaryColorHighlightLevel: float;
  52089. /**
  52090. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52091. * The primary color is used at the level chosen to define what the white area would look.
  52092. */
  52093. get primaryColorHighlightLevel(): float;
  52094. set primaryColorHighlightLevel(value: float);
  52095. protected _reflectionTexture: Nullable<BaseTexture>;
  52096. /**
  52097. * Reflection Texture used in the material.
  52098. * Should be author in a specific way for the best result (refer to the documentation).
  52099. */
  52100. reflectionTexture: Nullable<BaseTexture>;
  52101. protected _reflectionBlur: float;
  52102. /**
  52103. * Reflection Texture level of blur.
  52104. *
  52105. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52106. * texture twice.
  52107. */
  52108. reflectionBlur: float;
  52109. protected _diffuseTexture: Nullable<BaseTexture>;
  52110. /**
  52111. * Diffuse Texture used in the material.
  52112. * Should be author in a specific way for the best result (refer to the documentation).
  52113. */
  52114. diffuseTexture: Nullable<BaseTexture>;
  52115. protected _shadowLights: Nullable<IShadowLight[]>;
  52116. /**
  52117. * Specify the list of lights casting shadow on the material.
  52118. * All scene shadow lights will be included if null.
  52119. */
  52120. shadowLights: Nullable<IShadowLight[]>;
  52121. protected _shadowLevel: float;
  52122. /**
  52123. * Helps adjusting the shadow to a softer level if required.
  52124. * 0 means black shadows and 1 means no shadows.
  52125. */
  52126. shadowLevel: float;
  52127. protected _sceneCenter: Vector3;
  52128. /**
  52129. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52130. * It is usually zero but might be interesting to modify according to your setup.
  52131. */
  52132. sceneCenter: Vector3;
  52133. protected _opacityFresnel: boolean;
  52134. /**
  52135. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52136. * This helps ensuring a nice transition when the camera goes under the ground.
  52137. */
  52138. opacityFresnel: boolean;
  52139. protected _reflectionFresnel: boolean;
  52140. /**
  52141. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52142. * This helps adding a mirror texture on the ground.
  52143. */
  52144. reflectionFresnel: boolean;
  52145. protected _reflectionFalloffDistance: number;
  52146. /**
  52147. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52148. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52149. */
  52150. reflectionFalloffDistance: number;
  52151. protected _reflectionAmount: number;
  52152. /**
  52153. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52154. */
  52155. reflectionAmount: number;
  52156. protected _reflectionReflectance0: number;
  52157. /**
  52158. * This specifies the weight of the reflection at grazing angle.
  52159. */
  52160. reflectionReflectance0: number;
  52161. protected _reflectionReflectance90: number;
  52162. /**
  52163. * This specifies the weight of the reflection at a perpendicular point of view.
  52164. */
  52165. reflectionReflectance90: number;
  52166. /**
  52167. * Sets the reflection reflectance fresnel values according to the default standard
  52168. * empirically know to work well :-)
  52169. */
  52170. set reflectionStandardFresnelWeight(value: number);
  52171. protected _useRGBColor: boolean;
  52172. /**
  52173. * Helps to directly use the maps channels instead of their level.
  52174. */
  52175. useRGBColor: boolean;
  52176. protected _enableNoise: boolean;
  52177. /**
  52178. * This helps reducing the banding effect that could occur on the background.
  52179. */
  52180. enableNoise: boolean;
  52181. /**
  52182. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52183. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52184. * Recommended to be keep at 1.0 except for special cases.
  52185. */
  52186. get fovMultiplier(): number;
  52187. set fovMultiplier(value: number);
  52188. private _fovMultiplier;
  52189. /**
  52190. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52191. */
  52192. useEquirectangularFOV: boolean;
  52193. private _maxSimultaneousLights;
  52194. /**
  52195. * Number of Simultaneous lights allowed on the material.
  52196. */
  52197. maxSimultaneousLights: int;
  52198. /**
  52199. * Default configuration related to image processing available in the Background Material.
  52200. */
  52201. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52202. /**
  52203. * Keep track of the image processing observer to allow dispose and replace.
  52204. */
  52205. private _imageProcessingObserver;
  52206. /**
  52207. * Attaches a new image processing configuration to the PBR Material.
  52208. * @param configuration (if null the scene configuration will be use)
  52209. */
  52210. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52211. /**
  52212. * Gets the image processing configuration used either in this material.
  52213. */
  52214. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52215. /**
  52216. * Sets the Default image processing configuration used either in the this material.
  52217. *
  52218. * If sets to null, the scene one is in use.
  52219. */
  52220. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52221. /**
  52222. * Gets wether the color curves effect is enabled.
  52223. */
  52224. get cameraColorCurvesEnabled(): boolean;
  52225. /**
  52226. * Sets wether the color curves effect is enabled.
  52227. */
  52228. set cameraColorCurvesEnabled(value: boolean);
  52229. /**
  52230. * Gets wether the color grading effect is enabled.
  52231. */
  52232. get cameraColorGradingEnabled(): boolean;
  52233. /**
  52234. * Gets wether the color grading effect is enabled.
  52235. */
  52236. set cameraColorGradingEnabled(value: boolean);
  52237. /**
  52238. * Gets wether tonemapping is enabled or not.
  52239. */
  52240. get cameraToneMappingEnabled(): boolean;
  52241. /**
  52242. * Sets wether tonemapping is enabled or not
  52243. */
  52244. set cameraToneMappingEnabled(value: boolean);
  52245. /**
  52246. * The camera exposure used on this material.
  52247. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52248. * This corresponds to a photographic exposure.
  52249. */
  52250. get cameraExposure(): float;
  52251. /**
  52252. * The camera exposure used on this material.
  52253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52254. * This corresponds to a photographic exposure.
  52255. */
  52256. set cameraExposure(value: float);
  52257. /**
  52258. * Gets The camera contrast used on this material.
  52259. */
  52260. get cameraContrast(): float;
  52261. /**
  52262. * Sets The camera contrast used on this material.
  52263. */
  52264. set cameraContrast(value: float);
  52265. /**
  52266. * Gets the Color Grading 2D Lookup Texture.
  52267. */
  52268. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52269. /**
  52270. * Sets the Color Grading 2D Lookup Texture.
  52271. */
  52272. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52273. /**
  52274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52276. * 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;
  52277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52278. */
  52279. get cameraColorCurves(): Nullable<ColorCurves>;
  52280. /**
  52281. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52282. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52283. * 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;
  52284. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52285. */
  52286. set cameraColorCurves(value: Nullable<ColorCurves>);
  52287. /**
  52288. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52289. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52290. */
  52291. switchToBGR: boolean;
  52292. private _renderTargets;
  52293. private _reflectionControls;
  52294. private _white;
  52295. private _primaryShadowColor;
  52296. private _primaryHighlightColor;
  52297. /**
  52298. * Instantiates a Background Material in the given scene
  52299. * @param name The friendly name of the material
  52300. * @param scene The scene to add the material to
  52301. */
  52302. constructor(name: string, scene: Scene);
  52303. /**
  52304. * Gets a boolean indicating that current material needs to register RTT
  52305. */
  52306. get hasRenderTargetTextures(): boolean;
  52307. /**
  52308. * The entire material has been created in order to prevent overdraw.
  52309. * @returns false
  52310. */
  52311. needAlphaTesting(): boolean;
  52312. /**
  52313. * The entire material has been created in order to prevent overdraw.
  52314. * @returns true if blending is enable
  52315. */
  52316. needAlphaBlending(): boolean;
  52317. /**
  52318. * Checks wether the material is ready to be rendered for a given mesh.
  52319. * @param mesh The mesh to render
  52320. * @param subMesh The submesh to check against
  52321. * @param useInstances Specify wether or not the material is used with instances
  52322. * @returns true if all the dependencies are ready (Textures, Effects...)
  52323. */
  52324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52325. /**
  52326. * Compute the primary color according to the chosen perceptual color.
  52327. */
  52328. private _computePrimaryColorFromPerceptualColor;
  52329. /**
  52330. * Compute the highlights and shadow colors according to their chosen levels.
  52331. */
  52332. private _computePrimaryColors;
  52333. /**
  52334. * Build the uniform buffer used in the material.
  52335. */
  52336. buildUniformLayout(): void;
  52337. /**
  52338. * Unbind the material.
  52339. */
  52340. unbind(): void;
  52341. /**
  52342. * Bind only the world matrix to the material.
  52343. * @param world The world matrix to bind.
  52344. */
  52345. bindOnlyWorldMatrix(world: Matrix): void;
  52346. /**
  52347. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52348. * @param world The world matrix to bind.
  52349. * @param subMesh The submesh to bind for.
  52350. */
  52351. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52352. /**
  52353. * Checks to see if a texture is used in the material.
  52354. * @param texture - Base texture to use.
  52355. * @returns - Boolean specifying if a texture is used in the material.
  52356. */
  52357. hasTexture(texture: BaseTexture): boolean;
  52358. /**
  52359. * Dispose the material.
  52360. * @param forceDisposeEffect Force disposal of the associated effect.
  52361. * @param forceDisposeTextures Force disposal of the associated textures.
  52362. */
  52363. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52364. /**
  52365. * Clones the material.
  52366. * @param name The cloned name.
  52367. * @returns The cloned material.
  52368. */
  52369. clone(name: string): BackgroundMaterial;
  52370. /**
  52371. * Serializes the current material to its JSON representation.
  52372. * @returns The JSON representation.
  52373. */
  52374. serialize(): any;
  52375. /**
  52376. * Gets the class name of the material
  52377. * @returns "BackgroundMaterial"
  52378. */
  52379. getClassName(): string;
  52380. /**
  52381. * Parse a JSON input to create back a background material.
  52382. * @param source The JSON data to parse
  52383. * @param scene The scene to create the parsed material in
  52384. * @param rootUrl The root url of the assets the material depends upon
  52385. * @returns the instantiated BackgroundMaterial.
  52386. */
  52387. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52388. }
  52389. }
  52390. declare module "babylonjs/Helpers/environmentHelper" {
  52391. import { Observable } from "babylonjs/Misc/observable";
  52392. import { Nullable } from "babylonjs/types";
  52393. import { Scene } from "babylonjs/scene";
  52394. import { Vector3 } from "babylonjs/Maths/math.vector";
  52395. import { Color3 } from "babylonjs/Maths/math.color";
  52396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52397. import { Mesh } from "babylonjs/Meshes/mesh";
  52398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52399. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52400. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52401. import "babylonjs/Meshes/Builders/planeBuilder";
  52402. import "babylonjs/Meshes/Builders/boxBuilder";
  52403. /**
  52404. * Represents the different options available during the creation of
  52405. * a Environment helper.
  52406. *
  52407. * This can control the default ground, skybox and image processing setup of your scene.
  52408. */
  52409. export interface IEnvironmentHelperOptions {
  52410. /**
  52411. * Specifies whether or not to create a ground.
  52412. * True by default.
  52413. */
  52414. createGround: boolean;
  52415. /**
  52416. * Specifies the ground size.
  52417. * 15 by default.
  52418. */
  52419. groundSize: number;
  52420. /**
  52421. * The texture used on the ground for the main color.
  52422. * Comes from the BabylonJS CDN by default.
  52423. *
  52424. * Remarks: Can be either a texture or a url.
  52425. */
  52426. groundTexture: string | BaseTexture;
  52427. /**
  52428. * The color mixed in the ground texture by default.
  52429. * BabylonJS clearColor by default.
  52430. */
  52431. groundColor: Color3;
  52432. /**
  52433. * Specifies the ground opacity.
  52434. * 1 by default.
  52435. */
  52436. groundOpacity: number;
  52437. /**
  52438. * Enables the ground to receive shadows.
  52439. * True by default.
  52440. */
  52441. enableGroundShadow: boolean;
  52442. /**
  52443. * Helps preventing the shadow to be fully black on the ground.
  52444. * 0.5 by default.
  52445. */
  52446. groundShadowLevel: number;
  52447. /**
  52448. * Creates a mirror texture attach to the ground.
  52449. * false by default.
  52450. */
  52451. enableGroundMirror: boolean;
  52452. /**
  52453. * Specifies the ground mirror size ratio.
  52454. * 0.3 by default as the default kernel is 64.
  52455. */
  52456. groundMirrorSizeRatio: number;
  52457. /**
  52458. * Specifies the ground mirror blur kernel size.
  52459. * 64 by default.
  52460. */
  52461. groundMirrorBlurKernel: number;
  52462. /**
  52463. * Specifies the ground mirror visibility amount.
  52464. * 1 by default
  52465. */
  52466. groundMirrorAmount: number;
  52467. /**
  52468. * Specifies the ground mirror reflectance weight.
  52469. * This uses the standard weight of the background material to setup the fresnel effect
  52470. * of the mirror.
  52471. * 1 by default.
  52472. */
  52473. groundMirrorFresnelWeight: number;
  52474. /**
  52475. * Specifies the ground mirror Falloff distance.
  52476. * This can helps reducing the size of the reflection.
  52477. * 0 by Default.
  52478. */
  52479. groundMirrorFallOffDistance: number;
  52480. /**
  52481. * Specifies the ground mirror texture type.
  52482. * Unsigned Int by Default.
  52483. */
  52484. groundMirrorTextureType: number;
  52485. /**
  52486. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52487. * the shown objects.
  52488. */
  52489. groundYBias: number;
  52490. /**
  52491. * Specifies whether or not to create a skybox.
  52492. * True by default.
  52493. */
  52494. createSkybox: boolean;
  52495. /**
  52496. * Specifies the skybox size.
  52497. * 20 by default.
  52498. */
  52499. skyboxSize: number;
  52500. /**
  52501. * The texture used on the skybox for the main color.
  52502. * Comes from the BabylonJS CDN by default.
  52503. *
  52504. * Remarks: Can be either a texture or a url.
  52505. */
  52506. skyboxTexture: string | BaseTexture;
  52507. /**
  52508. * The color mixed in the skybox texture by default.
  52509. * BabylonJS clearColor by default.
  52510. */
  52511. skyboxColor: Color3;
  52512. /**
  52513. * The background rotation around the Y axis of the scene.
  52514. * This helps aligning the key lights of your scene with the background.
  52515. * 0 by default.
  52516. */
  52517. backgroundYRotation: number;
  52518. /**
  52519. * Compute automatically the size of the elements to best fit with the scene.
  52520. */
  52521. sizeAuto: boolean;
  52522. /**
  52523. * Default position of the rootMesh if autoSize is not true.
  52524. */
  52525. rootPosition: Vector3;
  52526. /**
  52527. * Sets up the image processing in the scene.
  52528. * true by default.
  52529. */
  52530. setupImageProcessing: boolean;
  52531. /**
  52532. * The texture used as your environment texture in the scene.
  52533. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52534. *
  52535. * Remarks: Can be either a texture or a url.
  52536. */
  52537. environmentTexture: string | BaseTexture;
  52538. /**
  52539. * The value of the exposure to apply to the scene.
  52540. * 0.6 by default if setupImageProcessing is true.
  52541. */
  52542. cameraExposure: number;
  52543. /**
  52544. * The value of the contrast to apply to the scene.
  52545. * 1.6 by default if setupImageProcessing is true.
  52546. */
  52547. cameraContrast: number;
  52548. /**
  52549. * Specifies whether or not tonemapping should be enabled in the scene.
  52550. * true by default if setupImageProcessing is true.
  52551. */
  52552. toneMappingEnabled: boolean;
  52553. }
  52554. /**
  52555. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52556. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52557. * It also helps with the default setup of your imageProcessing configuration.
  52558. */
  52559. export class EnvironmentHelper {
  52560. /**
  52561. * Default ground texture URL.
  52562. */
  52563. private static _groundTextureCDNUrl;
  52564. /**
  52565. * Default skybox texture URL.
  52566. */
  52567. private static _skyboxTextureCDNUrl;
  52568. /**
  52569. * Default environment texture URL.
  52570. */
  52571. private static _environmentTextureCDNUrl;
  52572. /**
  52573. * Creates the default options for the helper.
  52574. */
  52575. private static _getDefaultOptions;
  52576. private _rootMesh;
  52577. /**
  52578. * Gets the root mesh created by the helper.
  52579. */
  52580. get rootMesh(): Mesh;
  52581. private _skybox;
  52582. /**
  52583. * Gets the skybox created by the helper.
  52584. */
  52585. get skybox(): Nullable<Mesh>;
  52586. private _skyboxTexture;
  52587. /**
  52588. * Gets the skybox texture created by the helper.
  52589. */
  52590. get skyboxTexture(): Nullable<BaseTexture>;
  52591. private _skyboxMaterial;
  52592. /**
  52593. * Gets the skybox material created by the helper.
  52594. */
  52595. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52596. private _ground;
  52597. /**
  52598. * Gets the ground mesh created by the helper.
  52599. */
  52600. get ground(): Nullable<Mesh>;
  52601. private _groundTexture;
  52602. /**
  52603. * Gets the ground texture created by the helper.
  52604. */
  52605. get groundTexture(): Nullable<BaseTexture>;
  52606. private _groundMirror;
  52607. /**
  52608. * Gets the ground mirror created by the helper.
  52609. */
  52610. get groundMirror(): Nullable<MirrorTexture>;
  52611. /**
  52612. * Gets the ground mirror render list to helps pushing the meshes
  52613. * you wish in the ground reflection.
  52614. */
  52615. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52616. private _groundMaterial;
  52617. /**
  52618. * Gets the ground material created by the helper.
  52619. */
  52620. get groundMaterial(): Nullable<BackgroundMaterial>;
  52621. /**
  52622. * Stores the creation options.
  52623. */
  52624. private readonly _scene;
  52625. private _options;
  52626. /**
  52627. * This observable will be notified with any error during the creation of the environment,
  52628. * mainly texture creation errors.
  52629. */
  52630. onErrorObservable: Observable<{
  52631. message?: string;
  52632. exception?: any;
  52633. }>;
  52634. /**
  52635. * constructor
  52636. * @param options Defines the options we want to customize the helper
  52637. * @param scene The scene to add the material to
  52638. */
  52639. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52640. /**
  52641. * Updates the background according to the new options
  52642. * @param options
  52643. */
  52644. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52645. /**
  52646. * Sets the primary color of all the available elements.
  52647. * @param color the main color to affect to the ground and the background
  52648. */
  52649. setMainColor(color: Color3): void;
  52650. /**
  52651. * Setup the image processing according to the specified options.
  52652. */
  52653. private _setupImageProcessing;
  52654. /**
  52655. * Setup the environment texture according to the specified options.
  52656. */
  52657. private _setupEnvironmentTexture;
  52658. /**
  52659. * Setup the background according to the specified options.
  52660. */
  52661. private _setupBackground;
  52662. /**
  52663. * Get the scene sizes according to the setup.
  52664. */
  52665. private _getSceneSize;
  52666. /**
  52667. * Setup the ground according to the specified options.
  52668. */
  52669. private _setupGround;
  52670. /**
  52671. * Setup the ground material according to the specified options.
  52672. */
  52673. private _setupGroundMaterial;
  52674. /**
  52675. * Setup the ground diffuse texture according to the specified options.
  52676. */
  52677. private _setupGroundDiffuseTexture;
  52678. /**
  52679. * Setup the ground mirror texture according to the specified options.
  52680. */
  52681. private _setupGroundMirrorTexture;
  52682. /**
  52683. * Setup the ground to receive the mirror texture.
  52684. */
  52685. private _setupMirrorInGroundMaterial;
  52686. /**
  52687. * Setup the skybox according to the specified options.
  52688. */
  52689. private _setupSkybox;
  52690. /**
  52691. * Setup the skybox material according to the specified options.
  52692. */
  52693. private _setupSkyboxMaterial;
  52694. /**
  52695. * Setup the skybox reflection texture according to the specified options.
  52696. */
  52697. private _setupSkyboxReflectionTexture;
  52698. private _errorHandler;
  52699. /**
  52700. * Dispose all the elements created by the Helper.
  52701. */
  52702. dispose(): void;
  52703. }
  52704. }
  52705. declare module "babylonjs/Helpers/photoDome" {
  52706. import { Observable } from "babylonjs/Misc/observable";
  52707. import { Nullable } from "babylonjs/types";
  52708. import { Scene } from "babylonjs/scene";
  52709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52710. import { Mesh } from "babylonjs/Meshes/mesh";
  52711. import { Texture } from "babylonjs/Materials/Textures/texture";
  52712. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52713. import "babylonjs/Meshes/Builders/sphereBuilder";
  52714. /**
  52715. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52716. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52717. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52718. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52719. */
  52720. export class PhotoDome extends TransformNode {
  52721. /**
  52722. * Define the image as a Monoscopic panoramic 360 image.
  52723. */
  52724. static readonly MODE_MONOSCOPIC: number;
  52725. /**
  52726. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52727. */
  52728. static readonly MODE_TOPBOTTOM: number;
  52729. /**
  52730. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52731. */
  52732. static readonly MODE_SIDEBYSIDE: number;
  52733. private _useDirectMapping;
  52734. /**
  52735. * The texture being displayed on the sphere
  52736. */
  52737. protected _photoTexture: Texture;
  52738. /**
  52739. * Gets or sets the texture being displayed on the sphere
  52740. */
  52741. get photoTexture(): Texture;
  52742. set photoTexture(value: Texture);
  52743. /**
  52744. * Observable raised when an error occured while loading the 360 image
  52745. */
  52746. onLoadErrorObservable: Observable<string>;
  52747. /**
  52748. * The skybox material
  52749. */
  52750. protected _material: BackgroundMaterial;
  52751. /**
  52752. * The surface used for the skybox
  52753. */
  52754. protected _mesh: Mesh;
  52755. /**
  52756. * Gets the mesh used for the skybox.
  52757. */
  52758. get mesh(): Mesh;
  52759. /**
  52760. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52761. * Also see the options.resolution property.
  52762. */
  52763. get fovMultiplier(): number;
  52764. set fovMultiplier(value: number);
  52765. private _imageMode;
  52766. /**
  52767. * Gets or set the current video mode for the video. It can be:
  52768. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52769. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52770. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52771. */
  52772. get imageMode(): number;
  52773. set imageMode(value: number);
  52774. /**
  52775. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52776. * @param name Element's name, child elements will append suffixes for their own names.
  52777. * @param urlsOfPhoto defines the url of the photo to display
  52778. * @param options defines an object containing optional or exposed sub element properties
  52779. * @param onError defines a callback called when an error occured while loading the texture
  52780. */
  52781. constructor(name: string, urlOfPhoto: string, options: {
  52782. resolution?: number;
  52783. size?: number;
  52784. useDirectMapping?: boolean;
  52785. faceForward?: boolean;
  52786. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52787. private _onBeforeCameraRenderObserver;
  52788. private _changeImageMode;
  52789. /**
  52790. * Releases resources associated with this node.
  52791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52793. */
  52794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52795. }
  52796. }
  52797. declare module "babylonjs/Misc/rgbdTextureTools" {
  52798. import "babylonjs/Shaders/rgbdDecode.fragment";
  52799. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52800. import { Texture } from "babylonjs/Materials/Textures/texture";
  52801. /**
  52802. * Class used to host RGBD texture specific utilities
  52803. */
  52804. export class RGBDTextureTools {
  52805. /**
  52806. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52807. * @param texture the texture to expand.
  52808. */
  52809. static ExpandRGBDTexture(texture: Texture): void;
  52810. }
  52811. }
  52812. declare module "babylonjs/Misc/brdfTextureTools" {
  52813. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52814. import { Scene } from "babylonjs/scene";
  52815. /**
  52816. * Class used to host texture specific utilities
  52817. */
  52818. export class BRDFTextureTools {
  52819. /**
  52820. * Prevents texture cache collision
  52821. */
  52822. private static _instanceNumber;
  52823. /**
  52824. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52825. * @param scene defines the hosting scene
  52826. * @returns the environment BRDF texture
  52827. */
  52828. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52829. private static _environmentBRDFBase64Texture;
  52830. }
  52831. }
  52832. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52833. import { Nullable } from "babylonjs/types";
  52834. import { Color3 } from "babylonjs/Maths/math.color";
  52835. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52836. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52837. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52838. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52839. import { Engine } from "babylonjs/Engines/engine";
  52840. import { Scene } from "babylonjs/scene";
  52841. /**
  52842. * @hidden
  52843. */
  52844. export interface IMaterialClearCoatDefines {
  52845. CLEARCOAT: boolean;
  52846. CLEARCOAT_DEFAULTIOR: boolean;
  52847. CLEARCOAT_TEXTURE: boolean;
  52848. CLEARCOAT_TEXTUREDIRECTUV: number;
  52849. CLEARCOAT_BUMP: boolean;
  52850. CLEARCOAT_BUMPDIRECTUV: number;
  52851. CLEARCOAT_TINT: boolean;
  52852. CLEARCOAT_TINT_TEXTURE: boolean;
  52853. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52854. /** @hidden */
  52855. _areTexturesDirty: boolean;
  52856. }
  52857. /**
  52858. * Define the code related to the clear coat parameters of the pbr material.
  52859. */
  52860. export class PBRClearCoatConfiguration {
  52861. /**
  52862. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52863. * The default fits with a polyurethane material.
  52864. */
  52865. private static readonly _DefaultIndexOfRefraction;
  52866. private _isEnabled;
  52867. /**
  52868. * Defines if the clear coat is enabled in the material.
  52869. */
  52870. isEnabled: boolean;
  52871. /**
  52872. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52873. */
  52874. intensity: number;
  52875. /**
  52876. * Defines the clear coat layer roughness.
  52877. */
  52878. roughness: number;
  52879. private _indexOfRefraction;
  52880. /**
  52881. * Defines the index of refraction of the clear coat.
  52882. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52883. * The default fits with a polyurethane material.
  52884. * Changing the default value is more performance intensive.
  52885. */
  52886. indexOfRefraction: number;
  52887. private _texture;
  52888. /**
  52889. * Stores the clear coat values in a texture.
  52890. */
  52891. texture: Nullable<BaseTexture>;
  52892. private _bumpTexture;
  52893. /**
  52894. * Define the clear coat specific bump texture.
  52895. */
  52896. bumpTexture: Nullable<BaseTexture>;
  52897. private _isTintEnabled;
  52898. /**
  52899. * Defines if the clear coat tint is enabled in the material.
  52900. */
  52901. isTintEnabled: boolean;
  52902. /**
  52903. * Defines the clear coat tint of the material.
  52904. * This is only use if tint is enabled
  52905. */
  52906. tintColor: Color3;
  52907. /**
  52908. * Defines the distance at which the tint color should be found in the
  52909. * clear coat media.
  52910. * This is only use if tint is enabled
  52911. */
  52912. tintColorAtDistance: number;
  52913. /**
  52914. * Defines the clear coat layer thickness.
  52915. * This is only use if tint is enabled
  52916. */
  52917. tintThickness: number;
  52918. private _tintTexture;
  52919. /**
  52920. * Stores the clear tint values in a texture.
  52921. * rgb is tint
  52922. * a is a thickness factor
  52923. */
  52924. tintTexture: Nullable<BaseTexture>;
  52925. /** @hidden */
  52926. private _internalMarkAllSubMeshesAsTexturesDirty;
  52927. /** @hidden */
  52928. _markAllSubMeshesAsTexturesDirty(): void;
  52929. /**
  52930. * Instantiate a new istance of clear coat configuration.
  52931. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52932. */
  52933. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52934. /**
  52935. * Gets wehter the submesh is ready to be used or not.
  52936. * @param defines the list of "defines" to update.
  52937. * @param scene defines the scene the material belongs to.
  52938. * @param engine defines the engine the material belongs to.
  52939. * @param disableBumpMap defines wether the material disables bump or not.
  52940. * @returns - boolean indicating that the submesh is ready or not.
  52941. */
  52942. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52943. /**
  52944. * Checks to see if a texture is used in the material.
  52945. * @param defines the list of "defines" to update.
  52946. * @param scene defines the scene to the material belongs to.
  52947. */
  52948. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52949. /**
  52950. * Binds the material data.
  52951. * @param uniformBuffer defines the Uniform buffer to fill in.
  52952. * @param scene defines the scene the material belongs to.
  52953. * @param engine defines the engine the material belongs to.
  52954. * @param disableBumpMap defines wether the material disables bump or not.
  52955. * @param isFrozen defines wether the material is frozen or not.
  52956. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52957. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52958. */
  52959. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52960. /**
  52961. * Checks to see if a texture is used in the material.
  52962. * @param texture - Base texture to use.
  52963. * @returns - Boolean specifying if a texture is used in the material.
  52964. */
  52965. hasTexture(texture: BaseTexture): boolean;
  52966. /**
  52967. * Returns an array of the actively used textures.
  52968. * @param activeTextures Array of BaseTextures
  52969. */
  52970. getActiveTextures(activeTextures: BaseTexture[]): void;
  52971. /**
  52972. * Returns the animatable textures.
  52973. * @param animatables Array of animatable textures.
  52974. */
  52975. getAnimatables(animatables: IAnimatable[]): void;
  52976. /**
  52977. * Disposes the resources of the material.
  52978. * @param forceDisposeTextures - Forces the disposal of all textures.
  52979. */
  52980. dispose(forceDisposeTextures?: boolean): void;
  52981. /**
  52982. * Get the current class name of the texture useful for serialization or dynamic coding.
  52983. * @returns "PBRClearCoatConfiguration"
  52984. */
  52985. getClassName(): string;
  52986. /**
  52987. * Add fallbacks to the effect fallbacks list.
  52988. * @param defines defines the Base texture to use.
  52989. * @param fallbacks defines the current fallback list.
  52990. * @param currentRank defines the current fallback rank.
  52991. * @returns the new fallback rank.
  52992. */
  52993. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52994. /**
  52995. * Add the required uniforms to the current list.
  52996. * @param uniforms defines the current uniform list.
  52997. */
  52998. static AddUniforms(uniforms: string[]): void;
  52999. /**
  53000. * Add the required samplers to the current list.
  53001. * @param samplers defines the current sampler list.
  53002. */
  53003. static AddSamplers(samplers: string[]): void;
  53004. /**
  53005. * Add the required uniforms to the current buffer.
  53006. * @param uniformBuffer defines the current uniform buffer.
  53007. */
  53008. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53009. /**
  53010. * Makes a duplicate of the current configuration into another one.
  53011. * @param clearCoatConfiguration define the config where to copy the info
  53012. */
  53013. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53014. /**
  53015. * Serializes this clear coat configuration.
  53016. * @returns - An object with the serialized config.
  53017. */
  53018. serialize(): any;
  53019. /**
  53020. * Parses a anisotropy Configuration from a serialized object.
  53021. * @param source - Serialized object.
  53022. * @param scene Defines the scene we are parsing for
  53023. * @param rootUrl Defines the rootUrl to load from
  53024. */
  53025. parse(source: any, scene: Scene, rootUrl: string): void;
  53026. }
  53027. }
  53028. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  53029. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53031. import { Vector2 } from "babylonjs/Maths/math.vector";
  53032. import { Scene } from "babylonjs/scene";
  53033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53034. import { Nullable } from "babylonjs/types";
  53035. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53036. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53037. /**
  53038. * @hidden
  53039. */
  53040. export interface IMaterialAnisotropicDefines {
  53041. ANISOTROPIC: boolean;
  53042. ANISOTROPIC_TEXTURE: boolean;
  53043. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53044. MAINUV1: boolean;
  53045. _areTexturesDirty: boolean;
  53046. _needUVs: boolean;
  53047. }
  53048. /**
  53049. * Define the code related to the anisotropic parameters of the pbr material.
  53050. */
  53051. export class PBRAnisotropicConfiguration {
  53052. private _isEnabled;
  53053. /**
  53054. * Defines if the anisotropy is enabled in the material.
  53055. */
  53056. isEnabled: boolean;
  53057. /**
  53058. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53059. */
  53060. intensity: number;
  53061. /**
  53062. * Defines if the effect is along the tangents, bitangents or in between.
  53063. * By default, the effect is "strectching" the highlights along the tangents.
  53064. */
  53065. direction: Vector2;
  53066. private _texture;
  53067. /**
  53068. * Stores the anisotropy values in a texture.
  53069. * rg is direction (like normal from -1 to 1)
  53070. * b is a intensity
  53071. */
  53072. texture: Nullable<BaseTexture>;
  53073. /** @hidden */
  53074. private _internalMarkAllSubMeshesAsTexturesDirty;
  53075. /** @hidden */
  53076. _markAllSubMeshesAsTexturesDirty(): void;
  53077. /**
  53078. * Instantiate a new istance of anisotropy configuration.
  53079. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53080. */
  53081. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53082. /**
  53083. * Specifies that the submesh is ready to be used.
  53084. * @param defines the list of "defines" to update.
  53085. * @param scene defines the scene the material belongs to.
  53086. * @returns - boolean indicating that the submesh is ready or not.
  53087. */
  53088. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53089. /**
  53090. * Checks to see if a texture is used in the material.
  53091. * @param defines the list of "defines" to update.
  53092. * @param mesh the mesh we are preparing the defines for.
  53093. * @param scene defines the scene the material belongs to.
  53094. */
  53095. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53096. /**
  53097. * Binds the material data.
  53098. * @param uniformBuffer defines the Uniform buffer to fill in.
  53099. * @param scene defines the scene the material belongs to.
  53100. * @param isFrozen defines wether the material is frozen or not.
  53101. */
  53102. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53103. /**
  53104. * Checks to see if a texture is used in the material.
  53105. * @param texture - Base texture to use.
  53106. * @returns - Boolean specifying if a texture is used in the material.
  53107. */
  53108. hasTexture(texture: BaseTexture): boolean;
  53109. /**
  53110. * Returns an array of the actively used textures.
  53111. * @param activeTextures Array of BaseTextures
  53112. */
  53113. getActiveTextures(activeTextures: BaseTexture[]): void;
  53114. /**
  53115. * Returns the animatable textures.
  53116. * @param animatables Array of animatable textures.
  53117. */
  53118. getAnimatables(animatables: IAnimatable[]): void;
  53119. /**
  53120. * Disposes the resources of the material.
  53121. * @param forceDisposeTextures - Forces the disposal of all textures.
  53122. */
  53123. dispose(forceDisposeTextures?: boolean): void;
  53124. /**
  53125. * Get the current class name of the texture useful for serialization or dynamic coding.
  53126. * @returns "PBRAnisotropicConfiguration"
  53127. */
  53128. getClassName(): string;
  53129. /**
  53130. * Add fallbacks to the effect fallbacks list.
  53131. * @param defines defines the Base texture to use.
  53132. * @param fallbacks defines the current fallback list.
  53133. * @param currentRank defines the current fallback rank.
  53134. * @returns the new fallback rank.
  53135. */
  53136. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53137. /**
  53138. * Add the required uniforms to the current list.
  53139. * @param uniforms defines the current uniform list.
  53140. */
  53141. static AddUniforms(uniforms: string[]): void;
  53142. /**
  53143. * Add the required uniforms to the current buffer.
  53144. * @param uniformBuffer defines the current uniform buffer.
  53145. */
  53146. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53147. /**
  53148. * Add the required samplers to the current list.
  53149. * @param samplers defines the current sampler list.
  53150. */
  53151. static AddSamplers(samplers: string[]): void;
  53152. /**
  53153. * Makes a duplicate of the current configuration into another one.
  53154. * @param anisotropicConfiguration define the config where to copy the info
  53155. */
  53156. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53157. /**
  53158. * Serializes this anisotropy configuration.
  53159. * @returns - An object with the serialized config.
  53160. */
  53161. serialize(): any;
  53162. /**
  53163. * Parses a anisotropy Configuration from a serialized object.
  53164. * @param source - Serialized object.
  53165. * @param scene Defines the scene we are parsing for
  53166. * @param rootUrl Defines the rootUrl to load from
  53167. */
  53168. parse(source: any, scene: Scene, rootUrl: string): void;
  53169. }
  53170. }
  53171. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  53172. import { Scene } from "babylonjs/scene";
  53173. /**
  53174. * @hidden
  53175. */
  53176. export interface IMaterialBRDFDefines {
  53177. BRDF_V_HEIGHT_CORRELATED: boolean;
  53178. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53179. SPHERICAL_HARMONICS: boolean;
  53180. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53181. /** @hidden */
  53182. _areMiscDirty: boolean;
  53183. }
  53184. /**
  53185. * Define the code related to the BRDF parameters of the pbr material.
  53186. */
  53187. export class PBRBRDFConfiguration {
  53188. /**
  53189. * Default value used for the energy conservation.
  53190. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53191. */
  53192. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53193. /**
  53194. * Default value used for the Smith Visibility Height Correlated mode.
  53195. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53196. */
  53197. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53198. /**
  53199. * Default value used for the IBL diffuse part.
  53200. * This can help switching back to the polynomials mode globally which is a tiny bit
  53201. * less GPU intensive at the drawback of a lower quality.
  53202. */
  53203. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53204. /**
  53205. * Default value used for activating energy conservation for the specular workflow.
  53206. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53207. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53208. */
  53209. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53210. private _useEnergyConservation;
  53211. /**
  53212. * Defines if the material uses energy conservation.
  53213. */
  53214. useEnergyConservation: boolean;
  53215. private _useSmithVisibilityHeightCorrelated;
  53216. /**
  53217. * LEGACY Mode set to false
  53218. * Defines if the material uses height smith correlated visibility term.
  53219. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53220. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53221. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53222. * Not relying on height correlated will also disable energy conservation.
  53223. */
  53224. useSmithVisibilityHeightCorrelated: boolean;
  53225. private _useSphericalHarmonics;
  53226. /**
  53227. * LEGACY Mode set to false
  53228. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53229. * diffuse part of the IBL.
  53230. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53231. * to the ground truth.
  53232. */
  53233. useSphericalHarmonics: boolean;
  53234. private _useSpecularGlossinessInputEnergyConservation;
  53235. /**
  53236. * Defines if the material uses energy conservation, when the specular workflow is active.
  53237. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53238. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53239. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53240. */
  53241. useSpecularGlossinessInputEnergyConservation: boolean;
  53242. /** @hidden */
  53243. private _internalMarkAllSubMeshesAsMiscDirty;
  53244. /** @hidden */
  53245. _markAllSubMeshesAsMiscDirty(): void;
  53246. /**
  53247. * Instantiate a new istance of clear coat configuration.
  53248. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53249. */
  53250. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53251. /**
  53252. * Checks to see if a texture is used in the material.
  53253. * @param defines the list of "defines" to update.
  53254. */
  53255. prepareDefines(defines: IMaterialBRDFDefines): void;
  53256. /**
  53257. * Get the current class name of the texture useful for serialization or dynamic coding.
  53258. * @returns "PBRClearCoatConfiguration"
  53259. */
  53260. getClassName(): string;
  53261. /**
  53262. * Makes a duplicate of the current configuration into another one.
  53263. * @param brdfConfiguration define the config where to copy the info
  53264. */
  53265. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53266. /**
  53267. * Serializes this BRDF configuration.
  53268. * @returns - An object with the serialized config.
  53269. */
  53270. serialize(): any;
  53271. /**
  53272. * Parses a anisotropy Configuration from a serialized object.
  53273. * @param source - Serialized object.
  53274. * @param scene Defines the scene we are parsing for
  53275. * @param rootUrl Defines the rootUrl to load from
  53276. */
  53277. parse(source: any, scene: Scene, rootUrl: string): void;
  53278. }
  53279. }
  53280. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53281. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53282. import { Color3 } from "babylonjs/Maths/math.color";
  53283. import { Scene } from "babylonjs/scene";
  53284. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53285. import { Nullable } from "babylonjs/types";
  53286. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53287. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53288. /**
  53289. * @hidden
  53290. */
  53291. export interface IMaterialSheenDefines {
  53292. SHEEN: boolean;
  53293. SHEEN_TEXTURE: boolean;
  53294. SHEEN_TEXTUREDIRECTUV: number;
  53295. SHEEN_LINKWITHALBEDO: boolean;
  53296. SHEEN_ROUGHNESS: boolean;
  53297. SHEEN_ALBEDOSCALING: boolean;
  53298. /** @hidden */
  53299. _areTexturesDirty: boolean;
  53300. }
  53301. /**
  53302. * Define the code related to the Sheen parameters of the pbr material.
  53303. */
  53304. export class PBRSheenConfiguration {
  53305. private _isEnabled;
  53306. /**
  53307. * Defines if the material uses sheen.
  53308. */
  53309. isEnabled: boolean;
  53310. private _linkSheenWithAlbedo;
  53311. /**
  53312. * Defines if the sheen is linked to the sheen color.
  53313. */
  53314. linkSheenWithAlbedo: boolean;
  53315. /**
  53316. * Defines the sheen intensity.
  53317. */
  53318. intensity: number;
  53319. /**
  53320. * Defines the sheen color.
  53321. */
  53322. color: Color3;
  53323. private _texture;
  53324. /**
  53325. * Stores the sheen tint values in a texture.
  53326. * rgb is tint
  53327. * a is a intensity
  53328. */
  53329. texture: Nullable<BaseTexture>;
  53330. private _roughness;
  53331. /**
  53332. * Defines the sheen roughness.
  53333. * It is not taken into account if linkSheenWithAlbedo is true.
  53334. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53335. */
  53336. roughness: Nullable<number>;
  53337. private _albedoScaling;
  53338. /**
  53339. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53340. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53341. * making it easier to setup and tweak the effect
  53342. */
  53343. albedoScaling: boolean;
  53344. /** @hidden */
  53345. private _internalMarkAllSubMeshesAsTexturesDirty;
  53346. /** @hidden */
  53347. _markAllSubMeshesAsTexturesDirty(): void;
  53348. /**
  53349. * Instantiate a new istance of clear coat configuration.
  53350. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53351. */
  53352. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53353. /**
  53354. * Specifies that the submesh is ready to be used.
  53355. * @param defines the list of "defines" to update.
  53356. * @param scene defines the scene the material belongs to.
  53357. * @returns - boolean indicating that the submesh is ready or not.
  53358. */
  53359. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53360. /**
  53361. * Checks to see if a texture is used in the material.
  53362. * @param defines the list of "defines" to update.
  53363. * @param scene defines the scene the material belongs to.
  53364. */
  53365. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53366. /**
  53367. * Binds the material data.
  53368. * @param uniformBuffer defines the Uniform buffer to fill in.
  53369. * @param scene defines the scene the material belongs to.
  53370. * @param isFrozen defines wether the material is frozen or not.
  53371. */
  53372. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53373. /**
  53374. * Checks to see if a texture is used in the material.
  53375. * @param texture - Base texture to use.
  53376. * @returns - Boolean specifying if a texture is used in the material.
  53377. */
  53378. hasTexture(texture: BaseTexture): boolean;
  53379. /**
  53380. * Returns an array of the actively used textures.
  53381. * @param activeTextures Array of BaseTextures
  53382. */
  53383. getActiveTextures(activeTextures: BaseTexture[]): void;
  53384. /**
  53385. * Returns the animatable textures.
  53386. * @param animatables Array of animatable textures.
  53387. */
  53388. getAnimatables(animatables: IAnimatable[]): void;
  53389. /**
  53390. * Disposes the resources of the material.
  53391. * @param forceDisposeTextures - Forces the disposal of all textures.
  53392. */
  53393. dispose(forceDisposeTextures?: boolean): void;
  53394. /**
  53395. * Get the current class name of the texture useful for serialization or dynamic coding.
  53396. * @returns "PBRSheenConfiguration"
  53397. */
  53398. getClassName(): string;
  53399. /**
  53400. * Add fallbacks to the effect fallbacks list.
  53401. * @param defines defines the Base texture to use.
  53402. * @param fallbacks defines the current fallback list.
  53403. * @param currentRank defines the current fallback rank.
  53404. * @returns the new fallback rank.
  53405. */
  53406. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53407. /**
  53408. * Add the required uniforms to the current list.
  53409. * @param uniforms defines the current uniform list.
  53410. */
  53411. static AddUniforms(uniforms: string[]): void;
  53412. /**
  53413. * Add the required uniforms to the current buffer.
  53414. * @param uniformBuffer defines the current uniform buffer.
  53415. */
  53416. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53417. /**
  53418. * Add the required samplers to the current list.
  53419. * @param samplers defines the current sampler list.
  53420. */
  53421. static AddSamplers(samplers: string[]): void;
  53422. /**
  53423. * Makes a duplicate of the current configuration into another one.
  53424. * @param sheenConfiguration define the config where to copy the info
  53425. */
  53426. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53427. /**
  53428. * Serializes this BRDF configuration.
  53429. * @returns - An object with the serialized config.
  53430. */
  53431. serialize(): any;
  53432. /**
  53433. * Parses a anisotropy Configuration from a serialized object.
  53434. * @param source - Serialized object.
  53435. * @param scene Defines the scene we are parsing for
  53436. * @param rootUrl Defines the rootUrl to load from
  53437. */
  53438. parse(source: any, scene: Scene, rootUrl: string): void;
  53439. }
  53440. }
  53441. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53442. import { Nullable } from "babylonjs/types";
  53443. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53444. import { Color3 } from "babylonjs/Maths/math.color";
  53445. import { SmartArray } from "babylonjs/Misc/smartArray";
  53446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53447. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53448. import { Effect } from "babylonjs/Materials/effect";
  53449. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53450. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53451. import { Engine } from "babylonjs/Engines/engine";
  53452. import { Scene } from "babylonjs/scene";
  53453. /**
  53454. * @hidden
  53455. */
  53456. export interface IMaterialSubSurfaceDefines {
  53457. SUBSURFACE: boolean;
  53458. SS_REFRACTION: boolean;
  53459. SS_TRANSLUCENCY: boolean;
  53460. SS_SCATERRING: boolean;
  53461. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53462. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53463. SS_REFRACTIONMAP_3D: boolean;
  53464. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53465. SS_LODINREFRACTIONALPHA: boolean;
  53466. SS_GAMMAREFRACTION: boolean;
  53467. SS_RGBDREFRACTION: boolean;
  53468. SS_LINEARSPECULARREFRACTION: boolean;
  53469. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53470. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53471. /** @hidden */
  53472. _areTexturesDirty: boolean;
  53473. }
  53474. /**
  53475. * Define the code related to the sub surface parameters of the pbr material.
  53476. */
  53477. export class PBRSubSurfaceConfiguration {
  53478. private _isRefractionEnabled;
  53479. /**
  53480. * Defines if the refraction is enabled in the material.
  53481. */
  53482. isRefractionEnabled: boolean;
  53483. private _isTranslucencyEnabled;
  53484. /**
  53485. * Defines if the translucency is enabled in the material.
  53486. */
  53487. isTranslucencyEnabled: boolean;
  53488. private _isScatteringEnabled;
  53489. /**
  53490. * Defines the refraction intensity of the material.
  53491. * The refraction when enabled replaces the Diffuse part of the material.
  53492. * The intensity helps transitionning between diffuse and refraction.
  53493. */
  53494. refractionIntensity: number;
  53495. /**
  53496. * Defines the translucency intensity of the material.
  53497. * When translucency has been enabled, this defines how much of the "translucency"
  53498. * is addded to the diffuse part of the material.
  53499. */
  53500. translucencyIntensity: number;
  53501. /**
  53502. * Defines the scattering intensity of the material.
  53503. * When scattering has been enabled, this defines how much of the "scattered light"
  53504. * is addded to the diffuse part of the material.
  53505. */
  53506. scatteringIntensity: number;
  53507. private _thicknessTexture;
  53508. /**
  53509. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53510. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53511. * 0 would mean minimumThickness
  53512. * 1 would mean maximumThickness
  53513. * The other channels might be use as a mask to vary the different effects intensity.
  53514. */
  53515. thicknessTexture: Nullable<BaseTexture>;
  53516. private _refractionTexture;
  53517. /**
  53518. * Defines the texture to use for refraction.
  53519. */
  53520. refractionTexture: Nullable<BaseTexture>;
  53521. private _indexOfRefraction;
  53522. /**
  53523. * Defines the index of refraction used in the material.
  53524. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53525. */
  53526. indexOfRefraction: number;
  53527. private _invertRefractionY;
  53528. /**
  53529. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53530. */
  53531. invertRefractionY: boolean;
  53532. private _linkRefractionWithTransparency;
  53533. /**
  53534. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53535. * Materials half opaque for instance using refraction could benefit from this control.
  53536. */
  53537. linkRefractionWithTransparency: boolean;
  53538. /**
  53539. * Defines the minimum thickness stored in the thickness map.
  53540. * If no thickness map is defined, this value will be used to simulate thickness.
  53541. */
  53542. minimumThickness: number;
  53543. /**
  53544. * Defines the maximum thickness stored in the thickness map.
  53545. */
  53546. maximumThickness: number;
  53547. /**
  53548. * Defines the volume tint of the material.
  53549. * This is used for both translucency and scattering.
  53550. */
  53551. tintColor: Color3;
  53552. /**
  53553. * Defines the distance at which the tint color should be found in the media.
  53554. * This is used for refraction only.
  53555. */
  53556. tintColorAtDistance: number;
  53557. /**
  53558. * Defines how far each channel transmit through the media.
  53559. * It is defined as a color to simplify it selection.
  53560. */
  53561. diffusionDistance: Color3;
  53562. private _useMaskFromThicknessTexture;
  53563. /**
  53564. * Stores the intensity of the different subsurface effects in the thickness texture.
  53565. * * the green channel is the translucency intensity.
  53566. * * the blue channel is the scattering intensity.
  53567. * * the alpha channel is the refraction intensity.
  53568. */
  53569. useMaskFromThicknessTexture: boolean;
  53570. /** @hidden */
  53571. private _internalMarkAllSubMeshesAsTexturesDirty;
  53572. /** @hidden */
  53573. _markAllSubMeshesAsTexturesDirty(): void;
  53574. /**
  53575. * Instantiate a new istance of sub surface configuration.
  53576. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53577. */
  53578. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53579. /**
  53580. * Gets wehter the submesh is ready to be used or not.
  53581. * @param defines the list of "defines" to update.
  53582. * @param scene defines the scene the material belongs to.
  53583. * @returns - boolean indicating that the submesh is ready or not.
  53584. */
  53585. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53586. /**
  53587. * Checks to see if a texture is used in the material.
  53588. * @param defines the list of "defines" to update.
  53589. * @param scene defines the scene to the material belongs to.
  53590. */
  53591. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53592. /**
  53593. * Binds the material data.
  53594. * @param uniformBuffer defines the Uniform buffer to fill in.
  53595. * @param scene defines the scene the material belongs to.
  53596. * @param engine defines the engine the material belongs to.
  53597. * @param isFrozen defines wether the material is frozen or not.
  53598. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53599. */
  53600. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53601. /**
  53602. * Unbinds the material from the mesh.
  53603. * @param activeEffect defines the effect that should be unbound from.
  53604. * @returns true if unbound, otherwise false
  53605. */
  53606. unbind(activeEffect: Effect): boolean;
  53607. /**
  53608. * Returns the texture used for refraction or null if none is used.
  53609. * @param scene defines the scene the material belongs to.
  53610. * @returns - Refraction texture if present. If no refraction texture and refraction
  53611. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53612. */
  53613. private _getRefractionTexture;
  53614. /**
  53615. * Returns true if alpha blending should be disabled.
  53616. */
  53617. get disableAlphaBlending(): boolean;
  53618. /**
  53619. * Fills the list of render target textures.
  53620. * @param renderTargets the list of render targets to update
  53621. */
  53622. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53623. /**
  53624. * Checks to see if a texture is used in the material.
  53625. * @param texture - Base texture to use.
  53626. * @returns - Boolean specifying if a texture is used in the material.
  53627. */
  53628. hasTexture(texture: BaseTexture): boolean;
  53629. /**
  53630. * Gets a boolean indicating that current material needs to register RTT
  53631. * @returns true if this uses a render target otherwise false.
  53632. */
  53633. hasRenderTargetTextures(): boolean;
  53634. /**
  53635. * Returns an array of the actively used textures.
  53636. * @param activeTextures Array of BaseTextures
  53637. */
  53638. getActiveTextures(activeTextures: BaseTexture[]): void;
  53639. /**
  53640. * Returns the animatable textures.
  53641. * @param animatables Array of animatable textures.
  53642. */
  53643. getAnimatables(animatables: IAnimatable[]): void;
  53644. /**
  53645. * Disposes the resources of the material.
  53646. * @param forceDisposeTextures - Forces the disposal of all textures.
  53647. */
  53648. dispose(forceDisposeTextures?: boolean): void;
  53649. /**
  53650. * Get the current class name of the texture useful for serialization or dynamic coding.
  53651. * @returns "PBRSubSurfaceConfiguration"
  53652. */
  53653. getClassName(): string;
  53654. /**
  53655. * Add fallbacks to the effect fallbacks list.
  53656. * @param defines defines the Base texture to use.
  53657. * @param fallbacks defines the current fallback list.
  53658. * @param currentRank defines the current fallback rank.
  53659. * @returns the new fallback rank.
  53660. */
  53661. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53662. /**
  53663. * Add the required uniforms to the current list.
  53664. * @param uniforms defines the current uniform list.
  53665. */
  53666. static AddUniforms(uniforms: string[]): void;
  53667. /**
  53668. * Add the required samplers to the current list.
  53669. * @param samplers defines the current sampler list.
  53670. */
  53671. static AddSamplers(samplers: string[]): void;
  53672. /**
  53673. * Add the required uniforms to the current buffer.
  53674. * @param uniformBuffer defines the current uniform buffer.
  53675. */
  53676. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53677. /**
  53678. * Makes a duplicate of the current configuration into another one.
  53679. * @param configuration define the config where to copy the info
  53680. */
  53681. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53682. /**
  53683. * Serializes this Sub Surface configuration.
  53684. * @returns - An object with the serialized config.
  53685. */
  53686. serialize(): any;
  53687. /**
  53688. * Parses a anisotropy Configuration from a serialized object.
  53689. * @param source - Serialized object.
  53690. * @param scene Defines the scene we are parsing for
  53691. * @param rootUrl Defines the rootUrl to load from
  53692. */
  53693. parse(source: any, scene: Scene, rootUrl: string): void;
  53694. }
  53695. }
  53696. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53697. /** @hidden */
  53698. export var pbrFragmentDeclaration: {
  53699. name: string;
  53700. shader: string;
  53701. };
  53702. }
  53703. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53704. /** @hidden */
  53705. export var pbrUboDeclaration: {
  53706. name: string;
  53707. shader: string;
  53708. };
  53709. }
  53710. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53711. /** @hidden */
  53712. export var pbrFragmentExtraDeclaration: {
  53713. name: string;
  53714. shader: string;
  53715. };
  53716. }
  53717. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53718. /** @hidden */
  53719. export var pbrFragmentSamplersDeclaration: {
  53720. name: string;
  53721. shader: string;
  53722. };
  53723. }
  53724. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53725. /** @hidden */
  53726. export var pbrHelperFunctions: {
  53727. name: string;
  53728. shader: string;
  53729. };
  53730. }
  53731. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53732. /** @hidden */
  53733. export var harmonicsFunctions: {
  53734. name: string;
  53735. shader: string;
  53736. };
  53737. }
  53738. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53739. /** @hidden */
  53740. export var pbrDirectLightingSetupFunctions: {
  53741. name: string;
  53742. shader: string;
  53743. };
  53744. }
  53745. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53746. /** @hidden */
  53747. export var pbrDirectLightingFalloffFunctions: {
  53748. name: string;
  53749. shader: string;
  53750. };
  53751. }
  53752. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53753. /** @hidden */
  53754. export var pbrBRDFFunctions: {
  53755. name: string;
  53756. shader: string;
  53757. };
  53758. }
  53759. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53760. /** @hidden */
  53761. export var pbrDirectLightingFunctions: {
  53762. name: string;
  53763. shader: string;
  53764. };
  53765. }
  53766. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53767. /** @hidden */
  53768. export var pbrIBLFunctions: {
  53769. name: string;
  53770. shader: string;
  53771. };
  53772. }
  53773. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53774. /** @hidden */
  53775. export var pbrBlockAlbedoOpacity: {
  53776. name: string;
  53777. shader: string;
  53778. };
  53779. }
  53780. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53781. /** @hidden */
  53782. export var pbrBlockReflectivity: {
  53783. name: string;
  53784. shader: string;
  53785. };
  53786. }
  53787. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53788. /** @hidden */
  53789. export var pbrBlockAmbientOcclusion: {
  53790. name: string;
  53791. shader: string;
  53792. };
  53793. }
  53794. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53795. /** @hidden */
  53796. export var pbrBlockAlphaFresnel: {
  53797. name: string;
  53798. shader: string;
  53799. };
  53800. }
  53801. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53802. /** @hidden */
  53803. export var pbrBlockAnisotropic: {
  53804. name: string;
  53805. shader: string;
  53806. };
  53807. }
  53808. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53809. /** @hidden */
  53810. export var pbrBlockReflection: {
  53811. name: string;
  53812. shader: string;
  53813. };
  53814. }
  53815. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53816. /** @hidden */
  53817. export var pbrBlockSheen: {
  53818. name: string;
  53819. shader: string;
  53820. };
  53821. }
  53822. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53823. /** @hidden */
  53824. export var pbrBlockClearcoat: {
  53825. name: string;
  53826. shader: string;
  53827. };
  53828. }
  53829. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53830. /** @hidden */
  53831. export var pbrBlockSubSurface: {
  53832. name: string;
  53833. shader: string;
  53834. };
  53835. }
  53836. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53837. /** @hidden */
  53838. export var pbrBlockNormalGeometric: {
  53839. name: string;
  53840. shader: string;
  53841. };
  53842. }
  53843. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53844. /** @hidden */
  53845. export var pbrBlockNormalFinal: {
  53846. name: string;
  53847. shader: string;
  53848. };
  53849. }
  53850. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53851. /** @hidden */
  53852. export var pbrBlockGeometryInfo: {
  53853. name: string;
  53854. shader: string;
  53855. };
  53856. }
  53857. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53858. /** @hidden */
  53859. export var pbrBlockReflectance0: {
  53860. name: string;
  53861. shader: string;
  53862. };
  53863. }
  53864. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53865. /** @hidden */
  53866. export var pbrBlockReflectance: {
  53867. name: string;
  53868. shader: string;
  53869. };
  53870. }
  53871. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53872. /** @hidden */
  53873. export var pbrBlockDirectLighting: {
  53874. name: string;
  53875. shader: string;
  53876. };
  53877. }
  53878. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53879. /** @hidden */
  53880. export var pbrBlockFinalLitComponents: {
  53881. name: string;
  53882. shader: string;
  53883. };
  53884. }
  53885. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53886. /** @hidden */
  53887. export var pbrBlockFinalUnlitComponents: {
  53888. name: string;
  53889. shader: string;
  53890. };
  53891. }
  53892. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53893. /** @hidden */
  53894. export var pbrBlockFinalColorComposition: {
  53895. name: string;
  53896. shader: string;
  53897. };
  53898. }
  53899. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53900. /** @hidden */
  53901. export var pbrBlockImageProcessing: {
  53902. name: string;
  53903. shader: string;
  53904. };
  53905. }
  53906. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53907. /** @hidden */
  53908. export var pbrDebug: {
  53909. name: string;
  53910. shader: string;
  53911. };
  53912. }
  53913. declare module "babylonjs/Shaders/pbr.fragment" {
  53914. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53915. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53916. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53917. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53918. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53919. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53920. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53921. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53922. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53923. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53924. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53925. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53926. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53927. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53928. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53929. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53930. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53931. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53932. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53933. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53934. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  53935. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53936. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53937. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53938. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53939. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53940. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53941. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53942. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53943. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53944. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53945. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53946. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53947. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53948. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53949. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53950. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53951. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53952. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53953. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53954. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53955. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53956. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53957. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53958. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53959. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53960. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53961. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53962. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53963. /** @hidden */
  53964. export var pbrPixelShader: {
  53965. name: string;
  53966. shader: string;
  53967. };
  53968. }
  53969. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53970. /** @hidden */
  53971. export var pbrVertexDeclaration: {
  53972. name: string;
  53973. shader: string;
  53974. };
  53975. }
  53976. declare module "babylonjs/Shaders/pbr.vertex" {
  53977. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53978. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53979. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53980. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53981. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53982. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53983. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53984. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53985. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53986. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53987. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53990. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53994. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53995. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53996. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53997. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53998. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53999. /** @hidden */
  54000. export var pbrVertexShader: {
  54001. name: string;
  54002. shader: string;
  54003. };
  54004. }
  54005. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  54006. import { Nullable } from "babylonjs/types";
  54007. import { Scene } from "babylonjs/scene";
  54008. import { Matrix } from "babylonjs/Maths/math.vector";
  54009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54011. import { Mesh } from "babylonjs/Meshes/mesh";
  54012. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  54013. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  54014. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  54015. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  54016. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  54017. import { Color3 } from "babylonjs/Maths/math.color";
  54018. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54019. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  54020. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54021. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54023. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  54024. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54025. import "babylonjs/Shaders/pbr.fragment";
  54026. import "babylonjs/Shaders/pbr.vertex";
  54027. /**
  54028. * Manages the defines for the PBR Material.
  54029. * @hidden
  54030. */
  54031. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54032. PBR: boolean;
  54033. MAINUV1: boolean;
  54034. MAINUV2: boolean;
  54035. UV1: boolean;
  54036. UV2: boolean;
  54037. ALBEDO: boolean;
  54038. GAMMAALBEDO: boolean;
  54039. ALBEDODIRECTUV: number;
  54040. VERTEXCOLOR: boolean;
  54041. AMBIENT: boolean;
  54042. AMBIENTDIRECTUV: number;
  54043. AMBIENTINGRAYSCALE: boolean;
  54044. OPACITY: boolean;
  54045. VERTEXALPHA: boolean;
  54046. OPACITYDIRECTUV: number;
  54047. OPACITYRGB: boolean;
  54048. ALPHATEST: boolean;
  54049. DEPTHPREPASS: boolean;
  54050. ALPHABLEND: boolean;
  54051. ALPHAFROMALBEDO: boolean;
  54052. ALPHATESTVALUE: string;
  54053. SPECULAROVERALPHA: boolean;
  54054. RADIANCEOVERALPHA: boolean;
  54055. ALPHAFRESNEL: boolean;
  54056. LINEARALPHAFRESNEL: boolean;
  54057. PREMULTIPLYALPHA: boolean;
  54058. EMISSIVE: boolean;
  54059. EMISSIVEDIRECTUV: number;
  54060. REFLECTIVITY: boolean;
  54061. REFLECTIVITYDIRECTUV: number;
  54062. SPECULARTERM: boolean;
  54063. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54064. MICROSURFACEAUTOMATIC: boolean;
  54065. LODBASEDMICROSFURACE: boolean;
  54066. MICROSURFACEMAP: boolean;
  54067. MICROSURFACEMAPDIRECTUV: number;
  54068. METALLICWORKFLOW: boolean;
  54069. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54070. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54071. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54072. AOSTOREINMETALMAPRED: boolean;
  54073. METALLICF0FACTORFROMMETALLICMAP: boolean;
  54074. ENVIRONMENTBRDF: boolean;
  54075. ENVIRONMENTBRDF_RGBD: boolean;
  54076. NORMAL: boolean;
  54077. TANGENT: boolean;
  54078. BUMP: boolean;
  54079. BUMPDIRECTUV: number;
  54080. OBJECTSPACE_NORMALMAP: boolean;
  54081. PARALLAX: boolean;
  54082. PARALLAXOCCLUSION: boolean;
  54083. NORMALXYSCALE: boolean;
  54084. LIGHTMAP: boolean;
  54085. LIGHTMAPDIRECTUV: number;
  54086. USELIGHTMAPASSHADOWMAP: boolean;
  54087. GAMMALIGHTMAP: boolean;
  54088. RGBDLIGHTMAP: boolean;
  54089. REFLECTION: boolean;
  54090. REFLECTIONMAP_3D: boolean;
  54091. REFLECTIONMAP_SPHERICAL: boolean;
  54092. REFLECTIONMAP_PLANAR: boolean;
  54093. REFLECTIONMAP_CUBIC: boolean;
  54094. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54095. REFLECTIONMAP_PROJECTION: boolean;
  54096. REFLECTIONMAP_SKYBOX: boolean;
  54097. REFLECTIONMAP_EXPLICIT: boolean;
  54098. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54099. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54100. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54101. INVERTCUBICMAP: boolean;
  54102. USESPHERICALFROMREFLECTIONMAP: boolean;
  54103. USEIRRADIANCEMAP: boolean;
  54104. SPHERICAL_HARMONICS: boolean;
  54105. USESPHERICALINVERTEX: boolean;
  54106. REFLECTIONMAP_OPPOSITEZ: boolean;
  54107. LODINREFLECTIONALPHA: boolean;
  54108. GAMMAREFLECTION: boolean;
  54109. RGBDREFLECTION: boolean;
  54110. LINEARSPECULARREFLECTION: boolean;
  54111. RADIANCEOCCLUSION: boolean;
  54112. HORIZONOCCLUSION: boolean;
  54113. INSTANCES: boolean;
  54114. NUM_BONE_INFLUENCERS: number;
  54115. BonesPerMesh: number;
  54116. BONETEXTURE: boolean;
  54117. NONUNIFORMSCALING: boolean;
  54118. MORPHTARGETS: boolean;
  54119. MORPHTARGETS_NORMAL: boolean;
  54120. MORPHTARGETS_TANGENT: boolean;
  54121. MORPHTARGETS_UV: boolean;
  54122. NUM_MORPH_INFLUENCERS: number;
  54123. IMAGEPROCESSING: boolean;
  54124. VIGNETTE: boolean;
  54125. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54126. VIGNETTEBLENDMODEOPAQUE: boolean;
  54127. TONEMAPPING: boolean;
  54128. TONEMAPPING_ACES: boolean;
  54129. CONTRAST: boolean;
  54130. COLORCURVES: boolean;
  54131. COLORGRADING: boolean;
  54132. COLORGRADING3D: boolean;
  54133. SAMPLER3DGREENDEPTH: boolean;
  54134. SAMPLER3DBGRMAP: boolean;
  54135. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54136. EXPOSURE: boolean;
  54137. MULTIVIEW: boolean;
  54138. USEPHYSICALLIGHTFALLOFF: boolean;
  54139. USEGLTFLIGHTFALLOFF: boolean;
  54140. TWOSIDEDLIGHTING: boolean;
  54141. SHADOWFLOAT: boolean;
  54142. CLIPPLANE: boolean;
  54143. CLIPPLANE2: boolean;
  54144. CLIPPLANE3: boolean;
  54145. CLIPPLANE4: boolean;
  54146. CLIPPLANE5: boolean;
  54147. CLIPPLANE6: boolean;
  54148. POINTSIZE: boolean;
  54149. FOG: boolean;
  54150. LOGARITHMICDEPTH: boolean;
  54151. FORCENORMALFORWARD: boolean;
  54152. SPECULARAA: boolean;
  54153. CLEARCOAT: boolean;
  54154. CLEARCOAT_DEFAULTIOR: boolean;
  54155. CLEARCOAT_TEXTURE: boolean;
  54156. CLEARCOAT_TEXTUREDIRECTUV: number;
  54157. CLEARCOAT_BUMP: boolean;
  54158. CLEARCOAT_BUMPDIRECTUV: number;
  54159. CLEARCOAT_TINT: boolean;
  54160. CLEARCOAT_TINT_TEXTURE: boolean;
  54161. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54162. ANISOTROPIC: boolean;
  54163. ANISOTROPIC_TEXTURE: boolean;
  54164. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54165. BRDF_V_HEIGHT_CORRELATED: boolean;
  54166. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54167. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54168. SHEEN: boolean;
  54169. SHEEN_TEXTURE: boolean;
  54170. SHEEN_TEXTUREDIRECTUV: number;
  54171. SHEEN_LINKWITHALBEDO: boolean;
  54172. SHEEN_ROUGHNESS: boolean;
  54173. SHEEN_ALBEDOSCALING: boolean;
  54174. SUBSURFACE: boolean;
  54175. SS_REFRACTION: boolean;
  54176. SS_TRANSLUCENCY: boolean;
  54177. SS_SCATERRING: boolean;
  54178. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54179. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54180. SS_REFRACTIONMAP_3D: boolean;
  54181. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54182. SS_LODINREFRACTIONALPHA: boolean;
  54183. SS_GAMMAREFRACTION: boolean;
  54184. SS_RGBDREFRACTION: boolean;
  54185. SS_LINEARSPECULARREFRACTION: boolean;
  54186. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54187. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54188. UNLIT: boolean;
  54189. DEBUGMODE: number;
  54190. /**
  54191. * Initializes the PBR Material defines.
  54192. */
  54193. constructor();
  54194. /**
  54195. * Resets the PBR Material defines.
  54196. */
  54197. reset(): void;
  54198. }
  54199. /**
  54200. * The Physically based material base class of BJS.
  54201. *
  54202. * This offers the main features of a standard PBR material.
  54203. * For more information, please refer to the documentation :
  54204. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54205. */
  54206. export abstract class PBRBaseMaterial extends PushMaterial {
  54207. /**
  54208. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54209. */
  54210. static readonly PBRMATERIAL_OPAQUE: number;
  54211. /**
  54212. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54213. */
  54214. static readonly PBRMATERIAL_ALPHATEST: number;
  54215. /**
  54216. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54217. */
  54218. static readonly PBRMATERIAL_ALPHABLEND: number;
  54219. /**
  54220. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54221. * They are also discarded below the alpha cutoff threshold to improve performances.
  54222. */
  54223. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54224. /**
  54225. * Defines the default value of how much AO map is occluding the analytical lights
  54226. * (point spot...).
  54227. */
  54228. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54229. /**
  54230. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54231. */
  54232. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54233. /**
  54234. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54235. * to enhance interoperability with other engines.
  54236. */
  54237. static readonly LIGHTFALLOFF_GLTF: number;
  54238. /**
  54239. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54240. * to enhance interoperability with other materials.
  54241. */
  54242. static readonly LIGHTFALLOFF_STANDARD: number;
  54243. /**
  54244. * Intensity of the direct lights e.g. the four lights available in your scene.
  54245. * This impacts both the direct diffuse and specular highlights.
  54246. */
  54247. protected _directIntensity: number;
  54248. /**
  54249. * Intensity of the emissive part of the material.
  54250. * This helps controlling the emissive effect without modifying the emissive color.
  54251. */
  54252. protected _emissiveIntensity: number;
  54253. /**
  54254. * Intensity of the environment e.g. how much the environment will light the object
  54255. * either through harmonics for rough material or through the refelction for shiny ones.
  54256. */
  54257. protected _environmentIntensity: number;
  54258. /**
  54259. * This is a special control allowing the reduction of the specular highlights coming from the
  54260. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54261. */
  54262. protected _specularIntensity: number;
  54263. /**
  54264. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54265. */
  54266. private _lightingInfos;
  54267. /**
  54268. * Debug Control allowing disabling the bump map on this material.
  54269. */
  54270. protected _disableBumpMap: boolean;
  54271. /**
  54272. * AKA Diffuse Texture in standard nomenclature.
  54273. */
  54274. protected _albedoTexture: Nullable<BaseTexture>;
  54275. /**
  54276. * AKA Occlusion Texture in other nomenclature.
  54277. */
  54278. protected _ambientTexture: Nullable<BaseTexture>;
  54279. /**
  54280. * AKA Occlusion Texture Intensity in other nomenclature.
  54281. */
  54282. protected _ambientTextureStrength: number;
  54283. /**
  54284. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54285. * 1 means it completely occludes it
  54286. * 0 mean it has no impact
  54287. */
  54288. protected _ambientTextureImpactOnAnalyticalLights: number;
  54289. /**
  54290. * Stores the alpha values in a texture.
  54291. */
  54292. protected _opacityTexture: Nullable<BaseTexture>;
  54293. /**
  54294. * Stores the reflection values in a texture.
  54295. */
  54296. protected _reflectionTexture: Nullable<BaseTexture>;
  54297. /**
  54298. * Stores the emissive values in a texture.
  54299. */
  54300. protected _emissiveTexture: Nullable<BaseTexture>;
  54301. /**
  54302. * AKA Specular texture in other nomenclature.
  54303. */
  54304. protected _reflectivityTexture: Nullable<BaseTexture>;
  54305. /**
  54306. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54307. */
  54308. protected _metallicTexture: Nullable<BaseTexture>;
  54309. /**
  54310. * Specifies the metallic scalar of the metallic/roughness workflow.
  54311. * Can also be used to scale the metalness values of the metallic texture.
  54312. */
  54313. protected _metallic: Nullable<number>;
  54314. /**
  54315. * Specifies the roughness scalar of the metallic/roughness workflow.
  54316. * Can also be used to scale the roughness values of the metallic texture.
  54317. */
  54318. protected _roughness: Nullable<number>;
  54319. /**
  54320. * Specifies the an F0 factor to help configuring the material F0.
  54321. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54322. * to 0.5 the previously hard coded value stays the same.
  54323. * Can also be used to scale the F0 values of the metallic texture.
  54324. */
  54325. protected _metallicF0Factor: number;
  54326. /**
  54327. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54328. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54329. * your expectation as it multiplies with the texture data.
  54330. */
  54331. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54332. /**
  54333. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54334. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54335. */
  54336. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54337. /**
  54338. * Stores surface normal data used to displace a mesh in a texture.
  54339. */
  54340. protected _bumpTexture: Nullable<BaseTexture>;
  54341. /**
  54342. * Stores the pre-calculated light information of a mesh in a texture.
  54343. */
  54344. protected _lightmapTexture: Nullable<BaseTexture>;
  54345. /**
  54346. * The color of a material in ambient lighting.
  54347. */
  54348. protected _ambientColor: Color3;
  54349. /**
  54350. * AKA Diffuse Color in other nomenclature.
  54351. */
  54352. protected _albedoColor: Color3;
  54353. /**
  54354. * AKA Specular Color in other nomenclature.
  54355. */
  54356. protected _reflectivityColor: Color3;
  54357. /**
  54358. * The color applied when light is reflected from a material.
  54359. */
  54360. protected _reflectionColor: Color3;
  54361. /**
  54362. * The color applied when light is emitted from a material.
  54363. */
  54364. protected _emissiveColor: Color3;
  54365. /**
  54366. * AKA Glossiness in other nomenclature.
  54367. */
  54368. protected _microSurface: number;
  54369. /**
  54370. * Specifies that the material will use the light map as a show map.
  54371. */
  54372. protected _useLightmapAsShadowmap: boolean;
  54373. /**
  54374. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54375. * makes the reflect vector face the model (under horizon).
  54376. */
  54377. protected _useHorizonOcclusion: boolean;
  54378. /**
  54379. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54380. * too much the area relying on ambient texture to define their ambient occlusion.
  54381. */
  54382. protected _useRadianceOcclusion: boolean;
  54383. /**
  54384. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54385. */
  54386. protected _useAlphaFromAlbedoTexture: boolean;
  54387. /**
  54388. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54389. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54390. */
  54391. protected _useSpecularOverAlpha: boolean;
  54392. /**
  54393. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54394. */
  54395. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54396. /**
  54397. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54398. */
  54399. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54400. /**
  54401. * Specifies if the metallic texture contains the roughness information in its green channel.
  54402. */
  54403. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54404. /**
  54405. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54406. */
  54407. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54408. /**
  54409. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54410. */
  54411. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54412. /**
  54413. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54414. */
  54415. protected _useAmbientInGrayScale: boolean;
  54416. /**
  54417. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54418. * The material will try to infer what glossiness each pixel should be.
  54419. */
  54420. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54421. /**
  54422. * Defines the falloff type used in this material.
  54423. * It by default is Physical.
  54424. */
  54425. protected _lightFalloff: number;
  54426. /**
  54427. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54428. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54429. */
  54430. protected _useRadianceOverAlpha: boolean;
  54431. /**
  54432. * Allows using an object space normal map (instead of tangent space).
  54433. */
  54434. protected _useObjectSpaceNormalMap: boolean;
  54435. /**
  54436. * Allows using the bump map in parallax mode.
  54437. */
  54438. protected _useParallax: boolean;
  54439. /**
  54440. * Allows using the bump map in parallax occlusion mode.
  54441. */
  54442. protected _useParallaxOcclusion: boolean;
  54443. /**
  54444. * Controls the scale bias of the parallax mode.
  54445. */
  54446. protected _parallaxScaleBias: number;
  54447. /**
  54448. * If sets to true, disables all the lights affecting the material.
  54449. */
  54450. protected _disableLighting: boolean;
  54451. /**
  54452. * Number of Simultaneous lights allowed on the material.
  54453. */
  54454. protected _maxSimultaneousLights: number;
  54455. /**
  54456. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54457. */
  54458. protected _invertNormalMapX: boolean;
  54459. /**
  54460. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54461. */
  54462. protected _invertNormalMapY: boolean;
  54463. /**
  54464. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54465. */
  54466. protected _twoSidedLighting: boolean;
  54467. /**
  54468. * Defines the alpha limits in alpha test mode.
  54469. */
  54470. protected _alphaCutOff: number;
  54471. /**
  54472. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54473. */
  54474. protected _forceAlphaTest: boolean;
  54475. /**
  54476. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54477. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54478. */
  54479. protected _useAlphaFresnel: boolean;
  54480. /**
  54481. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54482. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54483. */
  54484. protected _useLinearAlphaFresnel: boolean;
  54485. /**
  54486. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54487. * from cos thetav and roughness:
  54488. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54489. */
  54490. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54491. /**
  54492. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54493. */
  54494. protected _forceIrradianceInFragment: boolean;
  54495. /**
  54496. * Force normal to face away from face.
  54497. */
  54498. protected _forceNormalForward: boolean;
  54499. /**
  54500. * Enables specular anti aliasing in the PBR shader.
  54501. * It will both interacts on the Geometry for analytical and IBL lighting.
  54502. * It also prefilter the roughness map based on the bump values.
  54503. */
  54504. protected _enableSpecularAntiAliasing: boolean;
  54505. /**
  54506. * Default configuration related to image processing available in the PBR Material.
  54507. */
  54508. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54509. /**
  54510. * Keep track of the image processing observer to allow dispose and replace.
  54511. */
  54512. private _imageProcessingObserver;
  54513. /**
  54514. * Attaches a new image processing configuration to the PBR Material.
  54515. * @param configuration
  54516. */
  54517. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54518. /**
  54519. * Stores the available render targets.
  54520. */
  54521. private _renderTargets;
  54522. /**
  54523. * Sets the global ambient color for the material used in lighting calculations.
  54524. */
  54525. private _globalAmbientColor;
  54526. /**
  54527. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54528. */
  54529. private _useLogarithmicDepth;
  54530. /**
  54531. * If set to true, no lighting calculations will be applied.
  54532. */
  54533. private _unlit;
  54534. private _debugMode;
  54535. /**
  54536. * @hidden
  54537. * This is reserved for the inspector.
  54538. * Defines the material debug mode.
  54539. * It helps seeing only some components of the material while troubleshooting.
  54540. */
  54541. debugMode: number;
  54542. /**
  54543. * @hidden
  54544. * This is reserved for the inspector.
  54545. * Specify from where on screen the debug mode should start.
  54546. * The value goes from -1 (full screen) to 1 (not visible)
  54547. * It helps with side by side comparison against the final render
  54548. * This defaults to -1
  54549. */
  54550. private debugLimit;
  54551. /**
  54552. * @hidden
  54553. * This is reserved for the inspector.
  54554. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54555. * You can use the factor to better multiply the final value.
  54556. */
  54557. private debugFactor;
  54558. /**
  54559. * Defines the clear coat layer parameters for the material.
  54560. */
  54561. readonly clearCoat: PBRClearCoatConfiguration;
  54562. /**
  54563. * Defines the anisotropic parameters for the material.
  54564. */
  54565. readonly anisotropy: PBRAnisotropicConfiguration;
  54566. /**
  54567. * Defines the BRDF parameters for the material.
  54568. */
  54569. readonly brdf: PBRBRDFConfiguration;
  54570. /**
  54571. * Defines the Sheen parameters for the material.
  54572. */
  54573. readonly sheen: PBRSheenConfiguration;
  54574. /**
  54575. * Defines the SubSurface parameters for the material.
  54576. */
  54577. readonly subSurface: PBRSubSurfaceConfiguration;
  54578. protected _rebuildInParallel: boolean;
  54579. /**
  54580. * Instantiates a new PBRMaterial instance.
  54581. *
  54582. * @param name The material name
  54583. * @param scene The scene the material will be use in.
  54584. */
  54585. constructor(name: string, scene: Scene);
  54586. /**
  54587. * Gets a boolean indicating that current material needs to register RTT
  54588. */
  54589. get hasRenderTargetTextures(): boolean;
  54590. /**
  54591. * Gets the name of the material class.
  54592. */
  54593. getClassName(): string;
  54594. /**
  54595. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54596. */
  54597. get useLogarithmicDepth(): boolean;
  54598. /**
  54599. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54600. */
  54601. set useLogarithmicDepth(value: boolean);
  54602. /**
  54603. * Returns true if alpha blending should be disabled.
  54604. */
  54605. protected get _disableAlphaBlending(): boolean;
  54606. /**
  54607. * Specifies whether or not this material should be rendered in alpha blend mode.
  54608. */
  54609. needAlphaBlending(): boolean;
  54610. /**
  54611. * Specifies whether or not this material should be rendered in alpha test mode.
  54612. */
  54613. needAlphaTesting(): boolean;
  54614. /**
  54615. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54616. */
  54617. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54618. /**
  54619. * Gets the texture used for the alpha test.
  54620. */
  54621. getAlphaTestTexture(): Nullable<BaseTexture>;
  54622. /**
  54623. * Specifies that the submesh is ready to be used.
  54624. * @param mesh - BJS mesh.
  54625. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54626. * @param useInstances - Specifies that instances should be used.
  54627. * @returns - boolean indicating that the submesh is ready or not.
  54628. */
  54629. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54630. /**
  54631. * Specifies if the material uses metallic roughness workflow.
  54632. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54633. */
  54634. isMetallicWorkflow(): boolean;
  54635. private _prepareEffect;
  54636. private _prepareDefines;
  54637. /**
  54638. * Force shader compilation
  54639. */
  54640. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54641. /**
  54642. * Initializes the uniform buffer layout for the shader.
  54643. */
  54644. buildUniformLayout(): void;
  54645. /**
  54646. * Unbinds the material from the mesh
  54647. */
  54648. unbind(): void;
  54649. /**
  54650. * Binds the submesh data.
  54651. * @param world - The world matrix.
  54652. * @param mesh - The BJS mesh.
  54653. * @param subMesh - A submesh of the BJS mesh.
  54654. */
  54655. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54656. /**
  54657. * Returns the animatable textures.
  54658. * @returns - Array of animatable textures.
  54659. */
  54660. getAnimatables(): IAnimatable[];
  54661. /**
  54662. * Returns the texture used for reflections.
  54663. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54664. */
  54665. private _getReflectionTexture;
  54666. /**
  54667. * Returns an array of the actively used textures.
  54668. * @returns - Array of BaseTextures
  54669. */
  54670. getActiveTextures(): BaseTexture[];
  54671. /**
  54672. * Checks to see if a texture is used in the material.
  54673. * @param texture - Base texture to use.
  54674. * @returns - Boolean specifying if a texture is used in the material.
  54675. */
  54676. hasTexture(texture: BaseTexture): boolean;
  54677. /**
  54678. * Disposes the resources of the material.
  54679. * @param forceDisposeEffect - Forces the disposal of effects.
  54680. * @param forceDisposeTextures - Forces the disposal of all textures.
  54681. */
  54682. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54683. }
  54684. }
  54685. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54686. import { Nullable } from "babylonjs/types";
  54687. import { Scene } from "babylonjs/scene";
  54688. import { Color3 } from "babylonjs/Maths/math.color";
  54689. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54690. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54691. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54692. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54693. /**
  54694. * The Physically based material of BJS.
  54695. *
  54696. * This offers the main features of a standard PBR material.
  54697. * For more information, please refer to the documentation :
  54698. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54699. */
  54700. export class PBRMaterial extends PBRBaseMaterial {
  54701. /**
  54702. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54703. */
  54704. static readonly PBRMATERIAL_OPAQUE: number;
  54705. /**
  54706. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54707. */
  54708. static readonly PBRMATERIAL_ALPHATEST: number;
  54709. /**
  54710. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54711. */
  54712. static readonly PBRMATERIAL_ALPHABLEND: number;
  54713. /**
  54714. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54715. * They are also discarded below the alpha cutoff threshold to improve performances.
  54716. */
  54717. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54718. /**
  54719. * Defines the default value of how much AO map is occluding the analytical lights
  54720. * (point spot...).
  54721. */
  54722. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54723. /**
  54724. * Intensity of the direct lights e.g. the four lights available in your scene.
  54725. * This impacts both the direct diffuse and specular highlights.
  54726. */
  54727. directIntensity: number;
  54728. /**
  54729. * Intensity of the emissive part of the material.
  54730. * This helps controlling the emissive effect without modifying the emissive color.
  54731. */
  54732. emissiveIntensity: number;
  54733. /**
  54734. * Intensity of the environment e.g. how much the environment will light the object
  54735. * either through harmonics for rough material or through the refelction for shiny ones.
  54736. */
  54737. environmentIntensity: number;
  54738. /**
  54739. * This is a special control allowing the reduction of the specular highlights coming from the
  54740. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54741. */
  54742. specularIntensity: number;
  54743. /**
  54744. * Debug Control allowing disabling the bump map on this material.
  54745. */
  54746. disableBumpMap: boolean;
  54747. /**
  54748. * AKA Diffuse Texture in standard nomenclature.
  54749. */
  54750. albedoTexture: BaseTexture;
  54751. /**
  54752. * AKA Occlusion Texture in other nomenclature.
  54753. */
  54754. ambientTexture: BaseTexture;
  54755. /**
  54756. * AKA Occlusion Texture Intensity in other nomenclature.
  54757. */
  54758. ambientTextureStrength: number;
  54759. /**
  54760. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54761. * 1 means it completely occludes it
  54762. * 0 mean it has no impact
  54763. */
  54764. ambientTextureImpactOnAnalyticalLights: number;
  54765. /**
  54766. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54767. */
  54768. opacityTexture: BaseTexture;
  54769. /**
  54770. * Stores the reflection values in a texture.
  54771. */
  54772. reflectionTexture: Nullable<BaseTexture>;
  54773. /**
  54774. * Stores the emissive values in a texture.
  54775. */
  54776. emissiveTexture: BaseTexture;
  54777. /**
  54778. * AKA Specular texture in other nomenclature.
  54779. */
  54780. reflectivityTexture: BaseTexture;
  54781. /**
  54782. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54783. */
  54784. metallicTexture: BaseTexture;
  54785. /**
  54786. * Specifies the metallic scalar of the metallic/roughness workflow.
  54787. * Can also be used to scale the metalness values of the metallic texture.
  54788. */
  54789. metallic: Nullable<number>;
  54790. /**
  54791. * Specifies the roughness scalar of the metallic/roughness workflow.
  54792. * Can also be used to scale the roughness values of the metallic texture.
  54793. */
  54794. roughness: Nullable<number>;
  54795. /**
  54796. * Specifies the an F0 factor to help configuring the material F0.
  54797. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54798. * to 0.5 the previously hard coded value stays the same.
  54799. * Can also be used to scale the F0 values of the metallic texture.
  54800. */
  54801. metallicF0Factor: number;
  54802. /**
  54803. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54804. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54805. * your expectation as it multiplies with the texture data.
  54806. */
  54807. useMetallicF0FactorFromMetallicTexture: boolean;
  54808. /**
  54809. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54810. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54811. */
  54812. microSurfaceTexture: BaseTexture;
  54813. /**
  54814. * Stores surface normal data used to displace a mesh in a texture.
  54815. */
  54816. bumpTexture: BaseTexture;
  54817. /**
  54818. * Stores the pre-calculated light information of a mesh in a texture.
  54819. */
  54820. lightmapTexture: BaseTexture;
  54821. /**
  54822. * Stores the refracted light information in a texture.
  54823. */
  54824. get refractionTexture(): Nullable<BaseTexture>;
  54825. set refractionTexture(value: Nullable<BaseTexture>);
  54826. /**
  54827. * The color of a material in ambient lighting.
  54828. */
  54829. ambientColor: Color3;
  54830. /**
  54831. * AKA Diffuse Color in other nomenclature.
  54832. */
  54833. albedoColor: Color3;
  54834. /**
  54835. * AKA Specular Color in other nomenclature.
  54836. */
  54837. reflectivityColor: Color3;
  54838. /**
  54839. * The color reflected from the material.
  54840. */
  54841. reflectionColor: Color3;
  54842. /**
  54843. * The color emitted from the material.
  54844. */
  54845. emissiveColor: Color3;
  54846. /**
  54847. * AKA Glossiness in other nomenclature.
  54848. */
  54849. microSurface: number;
  54850. /**
  54851. * source material index of refraction (IOR)' / 'destination material IOR.
  54852. */
  54853. get indexOfRefraction(): number;
  54854. set indexOfRefraction(value: number);
  54855. /**
  54856. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54857. */
  54858. get invertRefractionY(): boolean;
  54859. set invertRefractionY(value: boolean);
  54860. /**
  54861. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54862. * Materials half opaque for instance using refraction could benefit from this control.
  54863. */
  54864. get linkRefractionWithTransparency(): boolean;
  54865. set linkRefractionWithTransparency(value: boolean);
  54866. /**
  54867. * If true, the light map contains occlusion information instead of lighting info.
  54868. */
  54869. useLightmapAsShadowmap: boolean;
  54870. /**
  54871. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54872. */
  54873. useAlphaFromAlbedoTexture: boolean;
  54874. /**
  54875. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54876. */
  54877. forceAlphaTest: boolean;
  54878. /**
  54879. * Defines the alpha limits in alpha test mode.
  54880. */
  54881. alphaCutOff: number;
  54882. /**
  54883. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54884. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54885. */
  54886. useSpecularOverAlpha: boolean;
  54887. /**
  54888. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54889. */
  54890. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54891. /**
  54892. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54893. */
  54894. useRoughnessFromMetallicTextureAlpha: boolean;
  54895. /**
  54896. * Specifies if the metallic texture contains the roughness information in its green channel.
  54897. */
  54898. useRoughnessFromMetallicTextureGreen: boolean;
  54899. /**
  54900. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54901. */
  54902. useMetallnessFromMetallicTextureBlue: boolean;
  54903. /**
  54904. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54905. */
  54906. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54907. /**
  54908. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54909. */
  54910. useAmbientInGrayScale: boolean;
  54911. /**
  54912. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54913. * The material will try to infer what glossiness each pixel should be.
  54914. */
  54915. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54916. /**
  54917. * BJS is using an harcoded light falloff based on a manually sets up range.
  54918. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54919. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54920. */
  54921. get usePhysicalLightFalloff(): boolean;
  54922. /**
  54923. * BJS is using an harcoded light falloff based on a manually sets up range.
  54924. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54925. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54926. */
  54927. set usePhysicalLightFalloff(value: boolean);
  54928. /**
  54929. * In order to support the falloff compatibility with gltf, a special mode has been added
  54930. * to reproduce the gltf light falloff.
  54931. */
  54932. get useGLTFLightFalloff(): boolean;
  54933. /**
  54934. * In order to support the falloff compatibility with gltf, a special mode has been added
  54935. * to reproduce the gltf light falloff.
  54936. */
  54937. set useGLTFLightFalloff(value: boolean);
  54938. /**
  54939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54941. */
  54942. useRadianceOverAlpha: boolean;
  54943. /**
  54944. * Allows using an object space normal map (instead of tangent space).
  54945. */
  54946. useObjectSpaceNormalMap: boolean;
  54947. /**
  54948. * Allows using the bump map in parallax mode.
  54949. */
  54950. useParallax: boolean;
  54951. /**
  54952. * Allows using the bump map in parallax occlusion mode.
  54953. */
  54954. useParallaxOcclusion: boolean;
  54955. /**
  54956. * Controls the scale bias of the parallax mode.
  54957. */
  54958. parallaxScaleBias: number;
  54959. /**
  54960. * If sets to true, disables all the lights affecting the material.
  54961. */
  54962. disableLighting: boolean;
  54963. /**
  54964. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54965. */
  54966. forceIrradianceInFragment: boolean;
  54967. /**
  54968. * Number of Simultaneous lights allowed on the material.
  54969. */
  54970. maxSimultaneousLights: number;
  54971. /**
  54972. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54973. */
  54974. invertNormalMapX: boolean;
  54975. /**
  54976. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54977. */
  54978. invertNormalMapY: boolean;
  54979. /**
  54980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54981. */
  54982. twoSidedLighting: boolean;
  54983. /**
  54984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54985. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54986. */
  54987. useAlphaFresnel: boolean;
  54988. /**
  54989. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54990. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54991. */
  54992. useLinearAlphaFresnel: boolean;
  54993. /**
  54994. * Let user defines the brdf lookup texture used for IBL.
  54995. * A default 8bit version is embedded but you could point at :
  54996. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54997. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54998. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54999. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55000. */
  55001. environmentBRDFTexture: Nullable<BaseTexture>;
  55002. /**
  55003. * Force normal to face away from face.
  55004. */
  55005. forceNormalForward: boolean;
  55006. /**
  55007. * Enables specular anti aliasing in the PBR shader.
  55008. * It will both interacts on the Geometry for analytical and IBL lighting.
  55009. * It also prefilter the roughness map based on the bump values.
  55010. */
  55011. enableSpecularAntiAliasing: boolean;
  55012. /**
  55013. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55014. * makes the reflect vector face the model (under horizon).
  55015. */
  55016. useHorizonOcclusion: boolean;
  55017. /**
  55018. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55019. * too much the area relying on ambient texture to define their ambient occlusion.
  55020. */
  55021. useRadianceOcclusion: boolean;
  55022. /**
  55023. * If set to true, no lighting calculations will be applied.
  55024. */
  55025. unlit: boolean;
  55026. /**
  55027. * Gets the image processing configuration used either in this material.
  55028. */
  55029. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55030. /**
  55031. * Sets the Default image processing configuration used either in the this material.
  55032. *
  55033. * If sets to null, the scene one is in use.
  55034. */
  55035. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55036. /**
  55037. * Gets wether the color curves effect is enabled.
  55038. */
  55039. get cameraColorCurvesEnabled(): boolean;
  55040. /**
  55041. * Sets wether the color curves effect is enabled.
  55042. */
  55043. set cameraColorCurvesEnabled(value: boolean);
  55044. /**
  55045. * Gets wether the color grading effect is enabled.
  55046. */
  55047. get cameraColorGradingEnabled(): boolean;
  55048. /**
  55049. * Gets wether the color grading effect is enabled.
  55050. */
  55051. set cameraColorGradingEnabled(value: boolean);
  55052. /**
  55053. * Gets wether tonemapping is enabled or not.
  55054. */
  55055. get cameraToneMappingEnabled(): boolean;
  55056. /**
  55057. * Sets wether tonemapping is enabled or not
  55058. */
  55059. set cameraToneMappingEnabled(value: boolean);
  55060. /**
  55061. * The camera exposure used on this material.
  55062. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55063. * This corresponds to a photographic exposure.
  55064. */
  55065. get cameraExposure(): number;
  55066. /**
  55067. * The camera exposure used on this material.
  55068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55069. * This corresponds to a photographic exposure.
  55070. */
  55071. set cameraExposure(value: number);
  55072. /**
  55073. * Gets The camera contrast used on this material.
  55074. */
  55075. get cameraContrast(): number;
  55076. /**
  55077. * Sets The camera contrast used on this material.
  55078. */
  55079. set cameraContrast(value: number);
  55080. /**
  55081. * Gets the Color Grading 2D Lookup Texture.
  55082. */
  55083. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55084. /**
  55085. * Sets the Color Grading 2D Lookup Texture.
  55086. */
  55087. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55088. /**
  55089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55091. * 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;
  55092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55093. */
  55094. get cameraColorCurves(): Nullable<ColorCurves>;
  55095. /**
  55096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55098. * 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;
  55099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55100. */
  55101. set cameraColorCurves(value: Nullable<ColorCurves>);
  55102. /**
  55103. * Instantiates a new PBRMaterial instance.
  55104. *
  55105. * @param name The material name
  55106. * @param scene The scene the material will be use in.
  55107. */
  55108. constructor(name: string, scene: Scene);
  55109. /**
  55110. * Returns the name of this material class.
  55111. */
  55112. getClassName(): string;
  55113. /**
  55114. * Makes a duplicate of the current material.
  55115. * @param name - name to use for the new material.
  55116. */
  55117. clone(name: string): PBRMaterial;
  55118. /**
  55119. * Serializes this PBR Material.
  55120. * @returns - An object with the serialized material.
  55121. */
  55122. serialize(): any;
  55123. /**
  55124. * Parses a PBR Material from a serialized object.
  55125. * @param source - Serialized object.
  55126. * @param scene - BJS scene instance.
  55127. * @param rootUrl - url for the scene object
  55128. * @returns - PBRMaterial
  55129. */
  55130. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55131. }
  55132. }
  55133. declare module "babylonjs/Misc/dds" {
  55134. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55135. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55136. import { Nullable } from "babylonjs/types";
  55137. import { Scene } from "babylonjs/scene";
  55138. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  55139. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55140. /**
  55141. * Direct draw surface info
  55142. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55143. */
  55144. export interface DDSInfo {
  55145. /**
  55146. * Width of the texture
  55147. */
  55148. width: number;
  55149. /**
  55150. * Width of the texture
  55151. */
  55152. height: number;
  55153. /**
  55154. * Number of Mipmaps for the texture
  55155. * @see https://en.wikipedia.org/wiki/Mipmap
  55156. */
  55157. mipmapCount: number;
  55158. /**
  55159. * If the textures format is a known fourCC format
  55160. * @see https://www.fourcc.org/
  55161. */
  55162. isFourCC: boolean;
  55163. /**
  55164. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55165. */
  55166. isRGB: boolean;
  55167. /**
  55168. * If the texture is a lumincance format
  55169. */
  55170. isLuminance: boolean;
  55171. /**
  55172. * If this is a cube texture
  55173. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55174. */
  55175. isCube: boolean;
  55176. /**
  55177. * If the texture is a compressed format eg. FOURCC_DXT1
  55178. */
  55179. isCompressed: boolean;
  55180. /**
  55181. * The dxgiFormat of the texture
  55182. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55183. */
  55184. dxgiFormat: number;
  55185. /**
  55186. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55187. */
  55188. textureType: number;
  55189. /**
  55190. * Sphericle polynomial created for the dds texture
  55191. */
  55192. sphericalPolynomial?: SphericalPolynomial;
  55193. }
  55194. /**
  55195. * Class used to provide DDS decompression tools
  55196. */
  55197. export class DDSTools {
  55198. /**
  55199. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55200. */
  55201. static StoreLODInAlphaChannel: boolean;
  55202. /**
  55203. * Gets DDS information from an array buffer
  55204. * @param data defines the array buffer view to read data from
  55205. * @returns the DDS information
  55206. */
  55207. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55208. private static _FloatView;
  55209. private static _Int32View;
  55210. private static _ToHalfFloat;
  55211. private static _FromHalfFloat;
  55212. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55213. private static _GetHalfFloatRGBAArrayBuffer;
  55214. private static _GetFloatRGBAArrayBuffer;
  55215. private static _GetFloatAsUIntRGBAArrayBuffer;
  55216. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55217. private static _GetRGBAArrayBuffer;
  55218. private static _ExtractLongWordOrder;
  55219. private static _GetRGBArrayBuffer;
  55220. private static _GetLuminanceArrayBuffer;
  55221. /**
  55222. * Uploads DDS Levels to a Babylon Texture
  55223. * @hidden
  55224. */
  55225. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55226. }
  55227. module "babylonjs/Engines/thinEngine" {
  55228. interface ThinEngine {
  55229. /**
  55230. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55231. * @param rootUrl defines the url where the file to load is located
  55232. * @param scene defines the current scene
  55233. * @param lodScale defines scale to apply to the mip map selection
  55234. * @param lodOffset defines offset to apply to the mip map selection
  55235. * @param onLoad defines an optional callback raised when the texture is loaded
  55236. * @param onError defines an optional callback raised if there is an issue to load the texture
  55237. * @param format defines the format of the data
  55238. * @param forcedExtension defines the extension to use to pick the right loader
  55239. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55240. * @returns the cube texture as an InternalTexture
  55241. */
  55242. 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;
  55243. }
  55244. }
  55245. }
  55246. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55247. import { Nullable } from "babylonjs/types";
  55248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55249. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55250. /**
  55251. * Implementation of the DDS Texture Loader.
  55252. * @hidden
  55253. */
  55254. export class _DDSTextureLoader implements IInternalTextureLoader {
  55255. /**
  55256. * Defines wether the loader supports cascade loading the different faces.
  55257. */
  55258. readonly supportCascades: boolean;
  55259. /**
  55260. * This returns if the loader support the current file information.
  55261. * @param extension defines the file extension of the file being loaded
  55262. * @returns true if the loader can load the specified file
  55263. */
  55264. canLoad(extension: string): boolean;
  55265. /**
  55266. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55267. * @param data contains the texture data
  55268. * @param texture defines the BabylonJS internal texture
  55269. * @param createPolynomials will be true if polynomials have been requested
  55270. * @param onLoad defines the callback to trigger once the texture is ready
  55271. * @param onError defines the callback to trigger in case of error
  55272. */
  55273. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55274. /**
  55275. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55276. * @param data contains the texture data
  55277. * @param texture defines the BabylonJS internal texture
  55278. * @param callback defines the method to call once ready to upload
  55279. */
  55280. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55281. }
  55282. }
  55283. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55284. import { Nullable } from "babylonjs/types";
  55285. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55286. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55287. /**
  55288. * Implementation of the ENV Texture Loader.
  55289. * @hidden
  55290. */
  55291. export class _ENVTextureLoader implements IInternalTextureLoader {
  55292. /**
  55293. * Defines wether the loader supports cascade loading the different faces.
  55294. */
  55295. readonly supportCascades: boolean;
  55296. /**
  55297. * This returns if the loader support the current file information.
  55298. * @param extension defines the file extension of the file being loaded
  55299. * @returns true if the loader can load the specified file
  55300. */
  55301. canLoad(extension: string): boolean;
  55302. /**
  55303. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55304. * @param data contains the texture data
  55305. * @param texture defines the BabylonJS internal texture
  55306. * @param createPolynomials will be true if polynomials have been requested
  55307. * @param onLoad defines the callback to trigger once the texture is ready
  55308. * @param onError defines the callback to trigger in case of error
  55309. */
  55310. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55311. /**
  55312. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55313. * @param data contains the texture data
  55314. * @param texture defines the BabylonJS internal texture
  55315. * @param callback defines the method to call once ready to upload
  55316. */
  55317. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55318. }
  55319. }
  55320. declare module "babylonjs/Misc/khronosTextureContainer" {
  55321. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55322. /**
  55323. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55324. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55325. */
  55326. export class KhronosTextureContainer {
  55327. /** contents of the KTX container file */
  55328. data: ArrayBufferView;
  55329. private static HEADER_LEN;
  55330. private static COMPRESSED_2D;
  55331. private static COMPRESSED_3D;
  55332. private static TEX_2D;
  55333. private static TEX_3D;
  55334. /**
  55335. * Gets the openGL type
  55336. */
  55337. glType: number;
  55338. /**
  55339. * Gets the openGL type size
  55340. */
  55341. glTypeSize: number;
  55342. /**
  55343. * Gets the openGL format
  55344. */
  55345. glFormat: number;
  55346. /**
  55347. * Gets the openGL internal format
  55348. */
  55349. glInternalFormat: number;
  55350. /**
  55351. * Gets the base internal format
  55352. */
  55353. glBaseInternalFormat: number;
  55354. /**
  55355. * Gets image width in pixel
  55356. */
  55357. pixelWidth: number;
  55358. /**
  55359. * Gets image height in pixel
  55360. */
  55361. pixelHeight: number;
  55362. /**
  55363. * Gets image depth in pixels
  55364. */
  55365. pixelDepth: number;
  55366. /**
  55367. * Gets the number of array elements
  55368. */
  55369. numberOfArrayElements: number;
  55370. /**
  55371. * Gets the number of faces
  55372. */
  55373. numberOfFaces: number;
  55374. /**
  55375. * Gets the number of mipmap levels
  55376. */
  55377. numberOfMipmapLevels: number;
  55378. /**
  55379. * Gets the bytes of key value data
  55380. */
  55381. bytesOfKeyValueData: number;
  55382. /**
  55383. * Gets the load type
  55384. */
  55385. loadType: number;
  55386. /**
  55387. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55388. */
  55389. isInvalid: boolean;
  55390. /**
  55391. * Creates a new KhronosTextureContainer
  55392. * @param data contents of the KTX container file
  55393. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55394. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55395. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55396. */
  55397. constructor(
  55398. /** contents of the KTX container file */
  55399. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55400. /**
  55401. * Uploads KTX content to a Babylon Texture.
  55402. * It is assumed that the texture has already been created & is currently bound
  55403. * @hidden
  55404. */
  55405. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55406. private _upload2DCompressedLevels;
  55407. /**
  55408. * Checks if the given data starts with a KTX file identifier.
  55409. * @param data the data to check
  55410. * @returns true if the data is a KTX file or false otherwise
  55411. */
  55412. static IsValid(data: ArrayBufferView): boolean;
  55413. }
  55414. }
  55415. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55416. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55417. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55418. /**
  55419. * Class for loading KTX2 files
  55420. * !!! Experimental Extension Subject to Changes !!!
  55421. * @hidden
  55422. */
  55423. export class KhronosTextureContainer2 {
  55424. private static _ModulePromise;
  55425. private static _TranscodeFormat;
  55426. constructor(engine: ThinEngine);
  55427. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55428. private _determineTranscodeFormat;
  55429. /**
  55430. * Checks if the given data starts with a KTX2 file identifier.
  55431. * @param data the data to check
  55432. * @returns true if the data is a KTX2 file or false otherwise
  55433. */
  55434. static IsValid(data: ArrayBufferView): boolean;
  55435. }
  55436. }
  55437. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55438. import { Nullable } from "babylonjs/types";
  55439. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55440. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55441. /**
  55442. * Implementation of the KTX Texture Loader.
  55443. * @hidden
  55444. */
  55445. export class _KTXTextureLoader implements IInternalTextureLoader {
  55446. /**
  55447. * Defines wether the loader supports cascade loading the different faces.
  55448. */
  55449. readonly supportCascades: boolean;
  55450. /**
  55451. * This returns if the loader support the current file information.
  55452. * @param extension defines the file extension of the file being loaded
  55453. * @returns true if the loader can load the specified file
  55454. */
  55455. canLoad(extension: string): boolean;
  55456. /**
  55457. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55458. * @param data contains the texture data
  55459. * @param texture defines the BabylonJS internal texture
  55460. * @param createPolynomials will be true if polynomials have been requested
  55461. * @param onLoad defines the callback to trigger once the texture is ready
  55462. * @param onError defines the callback to trigger in case of error
  55463. */
  55464. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55465. /**
  55466. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55467. * @param data contains the texture data
  55468. * @param texture defines the BabylonJS internal texture
  55469. * @param callback defines the method to call once ready to upload
  55470. */
  55471. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55472. }
  55473. }
  55474. declare module "babylonjs/Helpers/sceneHelpers" {
  55475. import { Nullable } from "babylonjs/types";
  55476. import { Mesh } from "babylonjs/Meshes/mesh";
  55477. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55478. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55479. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55480. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55481. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55482. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55483. import "babylonjs/Meshes/Builders/boxBuilder";
  55484. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55485. /** @hidden */
  55486. export var _forceSceneHelpersToBundle: boolean;
  55487. module "babylonjs/scene" {
  55488. interface Scene {
  55489. /**
  55490. * Creates a default light for the scene.
  55491. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55492. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55493. */
  55494. createDefaultLight(replace?: boolean): void;
  55495. /**
  55496. * Creates a default camera for the scene.
  55497. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55498. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55499. * @param replace has default false, when true replaces the active camera in the scene
  55500. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55501. */
  55502. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55503. /**
  55504. * Creates a default camera and a default light.
  55505. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55506. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55507. * @param replace has the default false, when true replaces the active camera/light in the scene
  55508. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55509. */
  55510. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55511. /**
  55512. * Creates a new sky box
  55513. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55514. * @param environmentTexture defines the texture to use as environment texture
  55515. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55516. * @param scale defines the overall scale of the skybox
  55517. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55518. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55519. * @returns a new mesh holding the sky box
  55520. */
  55521. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55522. /**
  55523. * Creates a new environment
  55524. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55525. * @param options defines the options you can use to configure the environment
  55526. * @returns the new EnvironmentHelper
  55527. */
  55528. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55529. /**
  55530. * Creates a new VREXperienceHelper
  55531. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55532. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55533. * @returns a new VREXperienceHelper
  55534. */
  55535. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55536. /**
  55537. * Creates a new WebXRDefaultExperience
  55538. * @see http://doc.babylonjs.com/how_to/webxr
  55539. * @param options experience options
  55540. * @returns a promise for a new WebXRDefaultExperience
  55541. */
  55542. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55543. }
  55544. }
  55545. }
  55546. declare module "babylonjs/Helpers/videoDome" {
  55547. import { Scene } from "babylonjs/scene";
  55548. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55549. import { Mesh } from "babylonjs/Meshes/mesh";
  55550. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55551. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55552. import "babylonjs/Meshes/Builders/sphereBuilder";
  55553. /**
  55554. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55555. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55556. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55557. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55558. */
  55559. export class VideoDome extends TransformNode {
  55560. /**
  55561. * Define the video source as a Monoscopic panoramic 360 video.
  55562. */
  55563. static readonly MODE_MONOSCOPIC: number;
  55564. /**
  55565. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55566. */
  55567. static readonly MODE_TOPBOTTOM: number;
  55568. /**
  55569. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55570. */
  55571. static readonly MODE_SIDEBYSIDE: number;
  55572. private _halfDome;
  55573. private _useDirectMapping;
  55574. /**
  55575. * The video texture being displayed on the sphere
  55576. */
  55577. protected _videoTexture: VideoTexture;
  55578. /**
  55579. * Gets the video texture being displayed on the sphere
  55580. */
  55581. get videoTexture(): VideoTexture;
  55582. /**
  55583. * The skybox material
  55584. */
  55585. protected _material: BackgroundMaterial;
  55586. /**
  55587. * The surface used for the skybox
  55588. */
  55589. protected _mesh: Mesh;
  55590. /**
  55591. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55592. */
  55593. private _halfDomeMask;
  55594. /**
  55595. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55596. * Also see the options.resolution property.
  55597. */
  55598. get fovMultiplier(): number;
  55599. set fovMultiplier(value: number);
  55600. private _videoMode;
  55601. /**
  55602. * Gets or set the current video mode for the video. It can be:
  55603. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55604. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55605. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55606. */
  55607. get videoMode(): number;
  55608. set videoMode(value: number);
  55609. /**
  55610. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55611. *
  55612. */
  55613. get halfDome(): boolean;
  55614. /**
  55615. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55616. */
  55617. set halfDome(enabled: boolean);
  55618. /**
  55619. * Oberserver used in Stereoscopic VR Mode.
  55620. */
  55621. private _onBeforeCameraRenderObserver;
  55622. /**
  55623. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55624. * @param name Element's name, child elements will append suffixes for their own names.
  55625. * @param urlsOrVideo defines the url(s) or the video element to use
  55626. * @param options An object containing optional or exposed sub element properties
  55627. */
  55628. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55629. resolution?: number;
  55630. clickToPlay?: boolean;
  55631. autoPlay?: boolean;
  55632. loop?: boolean;
  55633. size?: number;
  55634. poster?: string;
  55635. faceForward?: boolean;
  55636. useDirectMapping?: boolean;
  55637. halfDomeMode?: boolean;
  55638. }, scene: Scene);
  55639. private _changeVideoMode;
  55640. /**
  55641. * Releases resources associated with this node.
  55642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55644. */
  55645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55646. }
  55647. }
  55648. declare module "babylonjs/Helpers/index" {
  55649. export * from "babylonjs/Helpers/environmentHelper";
  55650. export * from "babylonjs/Helpers/photoDome";
  55651. export * from "babylonjs/Helpers/sceneHelpers";
  55652. export * from "babylonjs/Helpers/videoDome";
  55653. }
  55654. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55655. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55656. import { IDisposable } from "babylonjs/scene";
  55657. import { Engine } from "babylonjs/Engines/engine";
  55658. /**
  55659. * This class can be used to get instrumentation data from a Babylon engine
  55660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55661. */
  55662. export class EngineInstrumentation implements IDisposable {
  55663. /**
  55664. * Define the instrumented engine.
  55665. */
  55666. engine: Engine;
  55667. private _captureGPUFrameTime;
  55668. private _gpuFrameTimeToken;
  55669. private _gpuFrameTime;
  55670. private _captureShaderCompilationTime;
  55671. private _shaderCompilationTime;
  55672. private _onBeginFrameObserver;
  55673. private _onEndFrameObserver;
  55674. private _onBeforeShaderCompilationObserver;
  55675. private _onAfterShaderCompilationObserver;
  55676. /**
  55677. * Gets the perf counter used for GPU frame time
  55678. */
  55679. get gpuFrameTimeCounter(): PerfCounter;
  55680. /**
  55681. * Gets the GPU frame time capture status
  55682. */
  55683. get captureGPUFrameTime(): boolean;
  55684. /**
  55685. * Enable or disable the GPU frame time capture
  55686. */
  55687. set captureGPUFrameTime(value: boolean);
  55688. /**
  55689. * Gets the perf counter used for shader compilation time
  55690. */
  55691. get shaderCompilationTimeCounter(): PerfCounter;
  55692. /**
  55693. * Gets the shader compilation time capture status
  55694. */
  55695. get captureShaderCompilationTime(): boolean;
  55696. /**
  55697. * Enable or disable the shader compilation time capture
  55698. */
  55699. set captureShaderCompilationTime(value: boolean);
  55700. /**
  55701. * Instantiates a new engine instrumentation.
  55702. * This class can be used to get instrumentation data from a Babylon engine
  55703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55704. * @param engine Defines the engine to instrument
  55705. */
  55706. constructor(
  55707. /**
  55708. * Define the instrumented engine.
  55709. */
  55710. engine: Engine);
  55711. /**
  55712. * Dispose and release associated resources.
  55713. */
  55714. dispose(): void;
  55715. }
  55716. }
  55717. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55718. import { Scene, IDisposable } from "babylonjs/scene";
  55719. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55720. /**
  55721. * This class can be used to get instrumentation data from a Babylon engine
  55722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55723. */
  55724. export class SceneInstrumentation implements IDisposable {
  55725. /**
  55726. * Defines the scene to instrument
  55727. */
  55728. scene: Scene;
  55729. private _captureActiveMeshesEvaluationTime;
  55730. private _activeMeshesEvaluationTime;
  55731. private _captureRenderTargetsRenderTime;
  55732. private _renderTargetsRenderTime;
  55733. private _captureFrameTime;
  55734. private _frameTime;
  55735. private _captureRenderTime;
  55736. private _renderTime;
  55737. private _captureInterFrameTime;
  55738. private _interFrameTime;
  55739. private _captureParticlesRenderTime;
  55740. private _particlesRenderTime;
  55741. private _captureSpritesRenderTime;
  55742. private _spritesRenderTime;
  55743. private _capturePhysicsTime;
  55744. private _physicsTime;
  55745. private _captureAnimationsTime;
  55746. private _animationsTime;
  55747. private _captureCameraRenderTime;
  55748. private _cameraRenderTime;
  55749. private _onBeforeActiveMeshesEvaluationObserver;
  55750. private _onAfterActiveMeshesEvaluationObserver;
  55751. private _onBeforeRenderTargetsRenderObserver;
  55752. private _onAfterRenderTargetsRenderObserver;
  55753. private _onAfterRenderObserver;
  55754. private _onBeforeDrawPhaseObserver;
  55755. private _onAfterDrawPhaseObserver;
  55756. private _onBeforeAnimationsObserver;
  55757. private _onBeforeParticlesRenderingObserver;
  55758. private _onAfterParticlesRenderingObserver;
  55759. private _onBeforeSpritesRenderingObserver;
  55760. private _onAfterSpritesRenderingObserver;
  55761. private _onBeforePhysicsObserver;
  55762. private _onAfterPhysicsObserver;
  55763. private _onAfterAnimationsObserver;
  55764. private _onBeforeCameraRenderObserver;
  55765. private _onAfterCameraRenderObserver;
  55766. /**
  55767. * Gets the perf counter used for active meshes evaluation time
  55768. */
  55769. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55770. /**
  55771. * Gets the active meshes evaluation time capture status
  55772. */
  55773. get captureActiveMeshesEvaluationTime(): boolean;
  55774. /**
  55775. * Enable or disable the active meshes evaluation time capture
  55776. */
  55777. set captureActiveMeshesEvaluationTime(value: boolean);
  55778. /**
  55779. * Gets the perf counter used for render targets render time
  55780. */
  55781. get renderTargetsRenderTimeCounter(): PerfCounter;
  55782. /**
  55783. * Gets the render targets render time capture status
  55784. */
  55785. get captureRenderTargetsRenderTime(): boolean;
  55786. /**
  55787. * Enable or disable the render targets render time capture
  55788. */
  55789. set captureRenderTargetsRenderTime(value: boolean);
  55790. /**
  55791. * Gets the perf counter used for particles render time
  55792. */
  55793. get particlesRenderTimeCounter(): PerfCounter;
  55794. /**
  55795. * Gets the particles render time capture status
  55796. */
  55797. get captureParticlesRenderTime(): boolean;
  55798. /**
  55799. * Enable or disable the particles render time capture
  55800. */
  55801. set captureParticlesRenderTime(value: boolean);
  55802. /**
  55803. * Gets the perf counter used for sprites render time
  55804. */
  55805. get spritesRenderTimeCounter(): PerfCounter;
  55806. /**
  55807. * Gets the sprites render time capture status
  55808. */
  55809. get captureSpritesRenderTime(): boolean;
  55810. /**
  55811. * Enable or disable the sprites render time capture
  55812. */
  55813. set captureSpritesRenderTime(value: boolean);
  55814. /**
  55815. * Gets the perf counter used for physics time
  55816. */
  55817. get physicsTimeCounter(): PerfCounter;
  55818. /**
  55819. * Gets the physics time capture status
  55820. */
  55821. get capturePhysicsTime(): boolean;
  55822. /**
  55823. * Enable or disable the physics time capture
  55824. */
  55825. set capturePhysicsTime(value: boolean);
  55826. /**
  55827. * Gets the perf counter used for animations time
  55828. */
  55829. get animationsTimeCounter(): PerfCounter;
  55830. /**
  55831. * Gets the animations time capture status
  55832. */
  55833. get captureAnimationsTime(): boolean;
  55834. /**
  55835. * Enable or disable the animations time capture
  55836. */
  55837. set captureAnimationsTime(value: boolean);
  55838. /**
  55839. * Gets the perf counter used for frame time capture
  55840. */
  55841. get frameTimeCounter(): PerfCounter;
  55842. /**
  55843. * Gets the frame time capture status
  55844. */
  55845. get captureFrameTime(): boolean;
  55846. /**
  55847. * Enable or disable the frame time capture
  55848. */
  55849. set captureFrameTime(value: boolean);
  55850. /**
  55851. * Gets the perf counter used for inter-frames time capture
  55852. */
  55853. get interFrameTimeCounter(): PerfCounter;
  55854. /**
  55855. * Gets the inter-frames time capture status
  55856. */
  55857. get captureInterFrameTime(): boolean;
  55858. /**
  55859. * Enable or disable the inter-frames time capture
  55860. */
  55861. set captureInterFrameTime(value: boolean);
  55862. /**
  55863. * Gets the perf counter used for render time capture
  55864. */
  55865. get renderTimeCounter(): PerfCounter;
  55866. /**
  55867. * Gets the render time capture status
  55868. */
  55869. get captureRenderTime(): boolean;
  55870. /**
  55871. * Enable or disable the render time capture
  55872. */
  55873. set captureRenderTime(value: boolean);
  55874. /**
  55875. * Gets the perf counter used for camera render time capture
  55876. */
  55877. get cameraRenderTimeCounter(): PerfCounter;
  55878. /**
  55879. * Gets the camera render time capture status
  55880. */
  55881. get captureCameraRenderTime(): boolean;
  55882. /**
  55883. * Enable or disable the camera render time capture
  55884. */
  55885. set captureCameraRenderTime(value: boolean);
  55886. /**
  55887. * Gets the perf counter used for draw calls
  55888. */
  55889. get drawCallsCounter(): PerfCounter;
  55890. /**
  55891. * Instantiates a new scene instrumentation.
  55892. * This class can be used to get instrumentation data from a Babylon engine
  55893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55894. * @param scene Defines the scene to instrument
  55895. */
  55896. constructor(
  55897. /**
  55898. * Defines the scene to instrument
  55899. */
  55900. scene: Scene);
  55901. /**
  55902. * Dispose and release associated resources.
  55903. */
  55904. dispose(): void;
  55905. }
  55906. }
  55907. declare module "babylonjs/Instrumentation/index" {
  55908. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55909. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55910. export * from "babylonjs/Instrumentation/timeToken";
  55911. }
  55912. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55913. /** @hidden */
  55914. export var glowMapGenerationPixelShader: {
  55915. name: string;
  55916. shader: string;
  55917. };
  55918. }
  55919. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55920. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55923. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55924. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55925. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55926. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55927. /** @hidden */
  55928. export var glowMapGenerationVertexShader: {
  55929. name: string;
  55930. shader: string;
  55931. };
  55932. }
  55933. declare module "babylonjs/Layers/effectLayer" {
  55934. import { Observable } from "babylonjs/Misc/observable";
  55935. import { Nullable } from "babylonjs/types";
  55936. import { Camera } from "babylonjs/Cameras/camera";
  55937. import { Scene } from "babylonjs/scene";
  55938. import { ISize } from "babylonjs/Maths/math.size";
  55939. import { Color4 } from "babylonjs/Maths/math.color";
  55940. import { Engine } from "babylonjs/Engines/engine";
  55941. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55943. import { Mesh } from "babylonjs/Meshes/mesh";
  55944. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55947. import { Effect } from "babylonjs/Materials/effect";
  55948. import { Material } from "babylonjs/Materials/material";
  55949. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55950. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55951. /**
  55952. * Effect layer options. This helps customizing the behaviour
  55953. * of the effect layer.
  55954. */
  55955. export interface IEffectLayerOptions {
  55956. /**
  55957. * Multiplication factor apply to the canvas size to compute the render target size
  55958. * used to generated the objects (the smaller the faster).
  55959. */
  55960. mainTextureRatio: number;
  55961. /**
  55962. * Enforces a fixed size texture to ensure effect stability across devices.
  55963. */
  55964. mainTextureFixedSize?: number;
  55965. /**
  55966. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55967. */
  55968. alphaBlendingMode: number;
  55969. /**
  55970. * The camera attached to the layer.
  55971. */
  55972. camera: Nullable<Camera>;
  55973. /**
  55974. * The rendering group to draw the layer in.
  55975. */
  55976. renderingGroupId: number;
  55977. }
  55978. /**
  55979. * The effect layer Helps adding post process effect blended with the main pass.
  55980. *
  55981. * This can be for instance use to generate glow or higlight effects on the scene.
  55982. *
  55983. * The effect layer class can not be used directly and is intented to inherited from to be
  55984. * customized per effects.
  55985. */
  55986. export abstract class EffectLayer {
  55987. private _vertexBuffers;
  55988. private _indexBuffer;
  55989. private _cachedDefines;
  55990. private _effectLayerMapGenerationEffect;
  55991. private _effectLayerOptions;
  55992. private _mergeEffect;
  55993. protected _scene: Scene;
  55994. protected _engine: Engine;
  55995. protected _maxSize: number;
  55996. protected _mainTextureDesiredSize: ISize;
  55997. protected _mainTexture: RenderTargetTexture;
  55998. protected _shouldRender: boolean;
  55999. protected _postProcesses: PostProcess[];
  56000. protected _textures: BaseTexture[];
  56001. protected _emissiveTextureAndColor: {
  56002. texture: Nullable<BaseTexture>;
  56003. color: Color4;
  56004. };
  56005. /**
  56006. * The name of the layer
  56007. */
  56008. name: string;
  56009. /**
  56010. * The clear color of the texture used to generate the glow map.
  56011. */
  56012. neutralColor: Color4;
  56013. /**
  56014. * Specifies whether the highlight layer is enabled or not.
  56015. */
  56016. isEnabled: boolean;
  56017. /**
  56018. * Gets the camera attached to the layer.
  56019. */
  56020. get camera(): Nullable<Camera>;
  56021. /**
  56022. * Gets the rendering group id the layer should render in.
  56023. */
  56024. get renderingGroupId(): number;
  56025. set renderingGroupId(renderingGroupId: number);
  56026. /**
  56027. * An event triggered when the effect layer has been disposed.
  56028. */
  56029. onDisposeObservable: Observable<EffectLayer>;
  56030. /**
  56031. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56032. */
  56033. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56034. /**
  56035. * An event triggered when the generated texture is being merged in the scene.
  56036. */
  56037. onBeforeComposeObservable: Observable<EffectLayer>;
  56038. /**
  56039. * An event triggered when the mesh is rendered into the effect render target.
  56040. */
  56041. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56042. /**
  56043. * An event triggered after the mesh has been rendered into the effect render target.
  56044. */
  56045. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56046. /**
  56047. * An event triggered when the generated texture has been merged in the scene.
  56048. */
  56049. onAfterComposeObservable: Observable<EffectLayer>;
  56050. /**
  56051. * An event triggered when the efffect layer changes its size.
  56052. */
  56053. onSizeChangedObservable: Observable<EffectLayer>;
  56054. /** @hidden */
  56055. static _SceneComponentInitialization: (scene: Scene) => void;
  56056. /**
  56057. * Instantiates a new effect Layer and references it in the scene.
  56058. * @param name The name of the layer
  56059. * @param scene The scene to use the layer in
  56060. */
  56061. constructor(
  56062. /** The Friendly of the effect in the scene */
  56063. name: string, scene: Scene);
  56064. /**
  56065. * Get the effect name of the layer.
  56066. * @return The effect name
  56067. */
  56068. abstract getEffectName(): string;
  56069. /**
  56070. * Checks for the readiness of the element composing the layer.
  56071. * @param subMesh the mesh to check for
  56072. * @param useInstances specify whether or not to use instances to render the mesh
  56073. * @return true if ready otherwise, false
  56074. */
  56075. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56076. /**
  56077. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56078. * @returns true if the effect requires stencil during the main canvas render pass.
  56079. */
  56080. abstract needStencil(): boolean;
  56081. /**
  56082. * Create the merge effect. This is the shader use to blit the information back
  56083. * to the main canvas at the end of the scene rendering.
  56084. * @returns The effect containing the shader used to merge the effect on the main canvas
  56085. */
  56086. protected abstract _createMergeEffect(): Effect;
  56087. /**
  56088. * Creates the render target textures and post processes used in the effect layer.
  56089. */
  56090. protected abstract _createTextureAndPostProcesses(): void;
  56091. /**
  56092. * Implementation specific of rendering the generating effect on the main canvas.
  56093. * @param effect The effect used to render through
  56094. */
  56095. protected abstract _internalRender(effect: Effect): void;
  56096. /**
  56097. * Sets the required values for both the emissive texture and and the main color.
  56098. */
  56099. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56100. /**
  56101. * Free any resources and references associated to a mesh.
  56102. * Internal use
  56103. * @param mesh The mesh to free.
  56104. */
  56105. abstract _disposeMesh(mesh: Mesh): void;
  56106. /**
  56107. * Serializes this layer (Glow or Highlight for example)
  56108. * @returns a serialized layer object
  56109. */
  56110. abstract serialize?(): any;
  56111. /**
  56112. * Initializes the effect layer with the required options.
  56113. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56114. */
  56115. protected _init(options: Partial<IEffectLayerOptions>): void;
  56116. /**
  56117. * Generates the index buffer of the full screen quad blending to the main canvas.
  56118. */
  56119. private _generateIndexBuffer;
  56120. /**
  56121. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56122. */
  56123. private _generateVertexBuffer;
  56124. /**
  56125. * Sets the main texture desired size which is the closest power of two
  56126. * of the engine canvas size.
  56127. */
  56128. private _setMainTextureSize;
  56129. /**
  56130. * Creates the main texture for the effect layer.
  56131. */
  56132. protected _createMainTexture(): void;
  56133. /**
  56134. * Adds specific effects defines.
  56135. * @param defines The defines to add specifics to.
  56136. */
  56137. protected _addCustomEffectDefines(defines: string[]): void;
  56138. /**
  56139. * Checks for the readiness of the element composing the layer.
  56140. * @param subMesh the mesh to check for
  56141. * @param useInstances specify whether or not to use instances to render the mesh
  56142. * @param emissiveTexture the associated emissive texture used to generate the glow
  56143. * @return true if ready otherwise, false
  56144. */
  56145. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56146. /**
  56147. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56148. */
  56149. render(): void;
  56150. /**
  56151. * Determine if a given mesh will be used in the current effect.
  56152. * @param mesh mesh to test
  56153. * @returns true if the mesh will be used
  56154. */
  56155. hasMesh(mesh: AbstractMesh): boolean;
  56156. /**
  56157. * Returns true if the layer contains information to display, otherwise false.
  56158. * @returns true if the glow layer should be rendered
  56159. */
  56160. shouldRender(): boolean;
  56161. /**
  56162. * Returns true if the mesh should render, otherwise false.
  56163. * @param mesh The mesh to render
  56164. * @returns true if it should render otherwise false
  56165. */
  56166. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56167. /**
  56168. * Returns true if the mesh can be rendered, otherwise false.
  56169. * @param mesh The mesh to render
  56170. * @param material The material used on the mesh
  56171. * @returns true if it can be rendered otherwise false
  56172. */
  56173. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56174. /**
  56175. * Returns true if the mesh should render, otherwise false.
  56176. * @param mesh The mesh to render
  56177. * @returns true if it should render otherwise false
  56178. */
  56179. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56180. /**
  56181. * Renders the submesh passed in parameter to the generation map.
  56182. */
  56183. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56184. /**
  56185. * Defines whether the current material of the mesh should be use to render the effect.
  56186. * @param mesh defines the current mesh to render
  56187. */
  56188. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56189. /**
  56190. * Rebuild the required buffers.
  56191. * @hidden Internal use only.
  56192. */
  56193. _rebuild(): void;
  56194. /**
  56195. * Dispose only the render target textures and post process.
  56196. */
  56197. private _disposeTextureAndPostProcesses;
  56198. /**
  56199. * Dispose the highlight layer and free resources.
  56200. */
  56201. dispose(): void;
  56202. /**
  56203. * Gets the class name of the effect layer
  56204. * @returns the string with the class name of the effect layer
  56205. */
  56206. getClassName(): string;
  56207. /**
  56208. * Creates an effect layer from parsed effect layer data
  56209. * @param parsedEffectLayer defines effect layer data
  56210. * @param scene defines the current scene
  56211. * @param rootUrl defines the root URL containing the effect layer information
  56212. * @returns a parsed effect Layer
  56213. */
  56214. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56215. }
  56216. }
  56217. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  56218. import { Scene } from "babylonjs/scene";
  56219. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56220. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56221. import { AbstractScene } from "babylonjs/abstractScene";
  56222. module "babylonjs/abstractScene" {
  56223. interface AbstractScene {
  56224. /**
  56225. * The list of effect layers (highlights/glow) added to the scene
  56226. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56227. * @see http://doc.babylonjs.com/how_to/glow_layer
  56228. */
  56229. effectLayers: Array<EffectLayer>;
  56230. /**
  56231. * Removes the given effect layer from this scene.
  56232. * @param toRemove defines the effect layer to remove
  56233. * @returns the index of the removed effect layer
  56234. */
  56235. removeEffectLayer(toRemove: EffectLayer): number;
  56236. /**
  56237. * Adds the given effect layer to this scene
  56238. * @param newEffectLayer defines the effect layer to add
  56239. */
  56240. addEffectLayer(newEffectLayer: EffectLayer): void;
  56241. }
  56242. }
  56243. /**
  56244. * Defines the layer scene component responsible to manage any effect layers
  56245. * in a given scene.
  56246. */
  56247. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56248. /**
  56249. * The component name helpfull to identify the component in the list of scene components.
  56250. */
  56251. readonly name: string;
  56252. /**
  56253. * The scene the component belongs to.
  56254. */
  56255. scene: Scene;
  56256. private _engine;
  56257. private _renderEffects;
  56258. private _needStencil;
  56259. private _previousStencilState;
  56260. /**
  56261. * Creates a new instance of the component for the given scene
  56262. * @param scene Defines the scene to register the component in
  56263. */
  56264. constructor(scene: Scene);
  56265. /**
  56266. * Registers the component in a given scene
  56267. */
  56268. register(): void;
  56269. /**
  56270. * Rebuilds the elements related to this component in case of
  56271. * context lost for instance.
  56272. */
  56273. rebuild(): void;
  56274. /**
  56275. * Serializes the component data to the specified json object
  56276. * @param serializationObject The object to serialize to
  56277. */
  56278. serialize(serializationObject: any): void;
  56279. /**
  56280. * Adds all the elements from the container to the scene
  56281. * @param container the container holding the elements
  56282. */
  56283. addFromContainer(container: AbstractScene): void;
  56284. /**
  56285. * Removes all the elements in the container from the scene
  56286. * @param container contains the elements to remove
  56287. * @param dispose if the removed element should be disposed (default: false)
  56288. */
  56289. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56290. /**
  56291. * Disposes the component and the associated ressources.
  56292. */
  56293. dispose(): void;
  56294. private _isReadyForMesh;
  56295. private _renderMainTexture;
  56296. private _setStencil;
  56297. private _setStencilBack;
  56298. private _draw;
  56299. private _drawCamera;
  56300. private _drawRenderingGroup;
  56301. }
  56302. }
  56303. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56304. /** @hidden */
  56305. export var glowMapMergePixelShader: {
  56306. name: string;
  56307. shader: string;
  56308. };
  56309. }
  56310. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56311. /** @hidden */
  56312. export var glowMapMergeVertexShader: {
  56313. name: string;
  56314. shader: string;
  56315. };
  56316. }
  56317. declare module "babylonjs/Layers/glowLayer" {
  56318. import { Nullable } from "babylonjs/types";
  56319. import { Camera } from "babylonjs/Cameras/camera";
  56320. import { Scene } from "babylonjs/scene";
  56321. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56323. import { Mesh } from "babylonjs/Meshes/mesh";
  56324. import { Texture } from "babylonjs/Materials/Textures/texture";
  56325. import { Effect } from "babylonjs/Materials/effect";
  56326. import { Material } from "babylonjs/Materials/material";
  56327. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56328. import { Color4 } from "babylonjs/Maths/math.color";
  56329. import "babylonjs/Shaders/glowMapMerge.fragment";
  56330. import "babylonjs/Shaders/glowMapMerge.vertex";
  56331. import "babylonjs/Layers/effectLayerSceneComponent";
  56332. module "babylonjs/abstractScene" {
  56333. interface AbstractScene {
  56334. /**
  56335. * Return a the first highlight layer of the scene with a given name.
  56336. * @param name The name of the highlight layer to look for.
  56337. * @return The highlight layer if found otherwise null.
  56338. */
  56339. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56340. }
  56341. }
  56342. /**
  56343. * Glow layer options. This helps customizing the behaviour
  56344. * of the glow layer.
  56345. */
  56346. export interface IGlowLayerOptions {
  56347. /**
  56348. * Multiplication factor apply to the canvas size to compute the render target size
  56349. * used to generated the glowing objects (the smaller the faster).
  56350. */
  56351. mainTextureRatio: number;
  56352. /**
  56353. * Enforces a fixed size texture to ensure resize independant blur.
  56354. */
  56355. mainTextureFixedSize?: number;
  56356. /**
  56357. * How big is the kernel of the blur texture.
  56358. */
  56359. blurKernelSize: number;
  56360. /**
  56361. * The camera attached to the layer.
  56362. */
  56363. camera: Nullable<Camera>;
  56364. /**
  56365. * Enable MSAA by chosing the number of samples.
  56366. */
  56367. mainTextureSamples?: number;
  56368. /**
  56369. * The rendering group to draw the layer in.
  56370. */
  56371. renderingGroupId: number;
  56372. }
  56373. /**
  56374. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56375. *
  56376. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56377. *
  56378. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56379. */
  56380. export class GlowLayer extends EffectLayer {
  56381. /**
  56382. * Effect Name of the layer.
  56383. */
  56384. static readonly EffectName: string;
  56385. /**
  56386. * The default blur kernel size used for the glow.
  56387. */
  56388. static DefaultBlurKernelSize: number;
  56389. /**
  56390. * The default texture size ratio used for the glow.
  56391. */
  56392. static DefaultTextureRatio: number;
  56393. /**
  56394. * Sets the kernel size of the blur.
  56395. */
  56396. set blurKernelSize(value: number);
  56397. /**
  56398. * Gets the kernel size of the blur.
  56399. */
  56400. get blurKernelSize(): number;
  56401. /**
  56402. * Sets the glow intensity.
  56403. */
  56404. set intensity(value: number);
  56405. /**
  56406. * Gets the glow intensity.
  56407. */
  56408. get intensity(): number;
  56409. private _options;
  56410. private _intensity;
  56411. private _horizontalBlurPostprocess1;
  56412. private _verticalBlurPostprocess1;
  56413. private _horizontalBlurPostprocess2;
  56414. private _verticalBlurPostprocess2;
  56415. private _blurTexture1;
  56416. private _blurTexture2;
  56417. private _postProcesses1;
  56418. private _postProcesses2;
  56419. private _includedOnlyMeshes;
  56420. private _excludedMeshes;
  56421. private _meshesUsingTheirOwnMaterials;
  56422. /**
  56423. * Callback used to let the user override the color selection on a per mesh basis
  56424. */
  56425. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56426. /**
  56427. * Callback used to let the user override the texture selection on a per mesh basis
  56428. */
  56429. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56430. /**
  56431. * Instantiates a new glow Layer and references it to the scene.
  56432. * @param name The name of the layer
  56433. * @param scene The scene to use the layer in
  56434. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56435. */
  56436. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56437. /**
  56438. * Get the effect name of the layer.
  56439. * @return The effect name
  56440. */
  56441. getEffectName(): string;
  56442. /**
  56443. * Create the merge effect. This is the shader use to blit the information back
  56444. * to the main canvas at the end of the scene rendering.
  56445. */
  56446. protected _createMergeEffect(): Effect;
  56447. /**
  56448. * Creates the render target textures and post processes used in the glow layer.
  56449. */
  56450. protected _createTextureAndPostProcesses(): void;
  56451. /**
  56452. * Checks for the readiness of the element composing the layer.
  56453. * @param subMesh the mesh to check for
  56454. * @param useInstances specify wether or not to use instances to render the mesh
  56455. * @param emissiveTexture the associated emissive texture used to generate the glow
  56456. * @return true if ready otherwise, false
  56457. */
  56458. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56459. /**
  56460. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56461. */
  56462. needStencil(): boolean;
  56463. /**
  56464. * Returns true if the mesh can be rendered, otherwise false.
  56465. * @param mesh The mesh to render
  56466. * @param material The material used on the mesh
  56467. * @returns true if it can be rendered otherwise false
  56468. */
  56469. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56470. /**
  56471. * Implementation specific of rendering the generating effect on the main canvas.
  56472. * @param effect The effect used to render through
  56473. */
  56474. protected _internalRender(effect: Effect): void;
  56475. /**
  56476. * Sets the required values for both the emissive texture and and the main color.
  56477. */
  56478. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56479. /**
  56480. * Returns true if the mesh should render, otherwise false.
  56481. * @param mesh The mesh to render
  56482. * @returns true if it should render otherwise false
  56483. */
  56484. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56485. /**
  56486. * Adds specific effects defines.
  56487. * @param defines The defines to add specifics to.
  56488. */
  56489. protected _addCustomEffectDefines(defines: string[]): void;
  56490. /**
  56491. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56492. * @param mesh The mesh to exclude from the glow layer
  56493. */
  56494. addExcludedMesh(mesh: Mesh): void;
  56495. /**
  56496. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56497. * @param mesh The mesh to remove
  56498. */
  56499. removeExcludedMesh(mesh: Mesh): void;
  56500. /**
  56501. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56502. * @param mesh The mesh to include in the glow layer
  56503. */
  56504. addIncludedOnlyMesh(mesh: Mesh): void;
  56505. /**
  56506. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56507. * @param mesh The mesh to remove
  56508. */
  56509. removeIncludedOnlyMesh(mesh: Mesh): void;
  56510. /**
  56511. * Determine if a given mesh will be used in the glow layer
  56512. * @param mesh The mesh to test
  56513. * @returns true if the mesh will be highlighted by the current glow layer
  56514. */
  56515. hasMesh(mesh: AbstractMesh): boolean;
  56516. /**
  56517. * Defines whether the current material of the mesh should be use to render the effect.
  56518. * @param mesh defines the current mesh to render
  56519. */
  56520. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56521. /**
  56522. * Add a mesh to be rendered through its own material and not with emissive only.
  56523. * @param mesh The mesh for which we need to use its material
  56524. */
  56525. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56526. /**
  56527. * Remove a mesh from being rendered through its own material and not with emissive only.
  56528. * @param mesh The mesh for which we need to not use its material
  56529. */
  56530. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56531. /**
  56532. * Free any resources and references associated to a mesh.
  56533. * Internal use
  56534. * @param mesh The mesh to free.
  56535. * @hidden
  56536. */
  56537. _disposeMesh(mesh: Mesh): void;
  56538. /**
  56539. * Gets the class name of the effect layer
  56540. * @returns the string with the class name of the effect layer
  56541. */
  56542. getClassName(): string;
  56543. /**
  56544. * Serializes this glow layer
  56545. * @returns a serialized glow layer object
  56546. */
  56547. serialize(): any;
  56548. /**
  56549. * Creates a Glow Layer from parsed glow layer data
  56550. * @param parsedGlowLayer defines glow layer data
  56551. * @param scene defines the current scene
  56552. * @param rootUrl defines the root URL containing the glow layer information
  56553. * @returns a parsed Glow Layer
  56554. */
  56555. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56556. }
  56557. }
  56558. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56559. /** @hidden */
  56560. export var glowBlurPostProcessPixelShader: {
  56561. name: string;
  56562. shader: string;
  56563. };
  56564. }
  56565. declare module "babylonjs/Layers/highlightLayer" {
  56566. import { Observable } from "babylonjs/Misc/observable";
  56567. import { Nullable } from "babylonjs/types";
  56568. import { Camera } from "babylonjs/Cameras/camera";
  56569. import { Scene } from "babylonjs/scene";
  56570. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56572. import { Mesh } from "babylonjs/Meshes/mesh";
  56573. import { Effect } from "babylonjs/Materials/effect";
  56574. import { Material } from "babylonjs/Materials/material";
  56575. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56576. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56577. import "babylonjs/Shaders/glowMapMerge.fragment";
  56578. import "babylonjs/Shaders/glowMapMerge.vertex";
  56579. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56580. module "babylonjs/abstractScene" {
  56581. interface AbstractScene {
  56582. /**
  56583. * Return a the first highlight layer of the scene with a given name.
  56584. * @param name The name of the highlight layer to look for.
  56585. * @return The highlight layer if found otherwise null.
  56586. */
  56587. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56588. }
  56589. }
  56590. /**
  56591. * Highlight layer options. This helps customizing the behaviour
  56592. * of the highlight layer.
  56593. */
  56594. export interface IHighlightLayerOptions {
  56595. /**
  56596. * Multiplication factor apply to the canvas size to compute the render target size
  56597. * used to generated the glowing objects (the smaller the faster).
  56598. */
  56599. mainTextureRatio: number;
  56600. /**
  56601. * Enforces a fixed size texture to ensure resize independant blur.
  56602. */
  56603. mainTextureFixedSize?: number;
  56604. /**
  56605. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56606. * of the picture to blur (the smaller the faster).
  56607. */
  56608. blurTextureSizeRatio: number;
  56609. /**
  56610. * How big in texel of the blur texture is the vertical blur.
  56611. */
  56612. blurVerticalSize: number;
  56613. /**
  56614. * How big in texel of the blur texture is the horizontal blur.
  56615. */
  56616. blurHorizontalSize: number;
  56617. /**
  56618. * Alpha blending mode used to apply the blur. Default is combine.
  56619. */
  56620. alphaBlendingMode: number;
  56621. /**
  56622. * The camera attached to the layer.
  56623. */
  56624. camera: Nullable<Camera>;
  56625. /**
  56626. * Should we display highlight as a solid stroke?
  56627. */
  56628. isStroke?: boolean;
  56629. /**
  56630. * The rendering group to draw the layer in.
  56631. */
  56632. renderingGroupId: number;
  56633. }
  56634. /**
  56635. * The highlight layer Helps adding a glow effect around a mesh.
  56636. *
  56637. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56638. * glowy meshes to your scene.
  56639. *
  56640. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56641. */
  56642. export class HighlightLayer extends EffectLayer {
  56643. name: string;
  56644. /**
  56645. * Effect Name of the highlight layer.
  56646. */
  56647. static readonly EffectName: string;
  56648. /**
  56649. * The neutral color used during the preparation of the glow effect.
  56650. * This is black by default as the blend operation is a blend operation.
  56651. */
  56652. static NeutralColor: Color4;
  56653. /**
  56654. * Stencil value used for glowing meshes.
  56655. */
  56656. static GlowingMeshStencilReference: number;
  56657. /**
  56658. * Stencil value used for the other meshes in the scene.
  56659. */
  56660. static NormalMeshStencilReference: number;
  56661. /**
  56662. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56663. */
  56664. innerGlow: boolean;
  56665. /**
  56666. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56667. */
  56668. outerGlow: boolean;
  56669. /**
  56670. * Specifies the horizontal size of the blur.
  56671. */
  56672. set blurHorizontalSize(value: number);
  56673. /**
  56674. * Specifies the vertical size of the blur.
  56675. */
  56676. set blurVerticalSize(value: number);
  56677. /**
  56678. * Gets the horizontal size of the blur.
  56679. */
  56680. get blurHorizontalSize(): number;
  56681. /**
  56682. * Gets the vertical size of the blur.
  56683. */
  56684. get blurVerticalSize(): number;
  56685. /**
  56686. * An event triggered when the highlight layer is being blurred.
  56687. */
  56688. onBeforeBlurObservable: Observable<HighlightLayer>;
  56689. /**
  56690. * An event triggered when the highlight layer has been blurred.
  56691. */
  56692. onAfterBlurObservable: Observable<HighlightLayer>;
  56693. private _instanceGlowingMeshStencilReference;
  56694. private _options;
  56695. private _downSamplePostprocess;
  56696. private _horizontalBlurPostprocess;
  56697. private _verticalBlurPostprocess;
  56698. private _blurTexture;
  56699. private _meshes;
  56700. private _excludedMeshes;
  56701. /**
  56702. * Instantiates a new highlight Layer and references it to the scene..
  56703. * @param name The name of the layer
  56704. * @param scene The scene to use the layer in
  56705. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56706. */
  56707. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56708. /**
  56709. * Get the effect name of the layer.
  56710. * @return The effect name
  56711. */
  56712. getEffectName(): string;
  56713. /**
  56714. * Create the merge effect. This is the shader use to blit the information back
  56715. * to the main canvas at the end of the scene rendering.
  56716. */
  56717. protected _createMergeEffect(): Effect;
  56718. /**
  56719. * Creates the render target textures and post processes used in the highlight layer.
  56720. */
  56721. protected _createTextureAndPostProcesses(): void;
  56722. /**
  56723. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56724. */
  56725. needStencil(): boolean;
  56726. /**
  56727. * Checks for the readiness of the element composing the layer.
  56728. * @param subMesh the mesh to check for
  56729. * @param useInstances specify wether or not to use instances to render the mesh
  56730. * @param emissiveTexture the associated emissive texture used to generate the glow
  56731. * @return true if ready otherwise, false
  56732. */
  56733. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56734. /**
  56735. * Implementation specific of rendering the generating effect on the main canvas.
  56736. * @param effect The effect used to render through
  56737. */
  56738. protected _internalRender(effect: Effect): void;
  56739. /**
  56740. * Returns true if the layer contains information to display, otherwise false.
  56741. */
  56742. shouldRender(): boolean;
  56743. /**
  56744. * Returns true if the mesh should render, otherwise false.
  56745. * @param mesh The mesh to render
  56746. * @returns true if it should render otherwise false
  56747. */
  56748. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56749. /**
  56750. * Adds specific effects defines.
  56751. * @param defines The defines to add specifics to.
  56752. */
  56753. protected _addCustomEffectDefines(defines: string[]): void;
  56754. /**
  56755. * Sets the required values for both the emissive texture and and the main color.
  56756. */
  56757. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56758. /**
  56759. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56760. * @param mesh The mesh to exclude from the highlight layer
  56761. */
  56762. addExcludedMesh(mesh: Mesh): void;
  56763. /**
  56764. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56765. * @param mesh The mesh to highlight
  56766. */
  56767. removeExcludedMesh(mesh: Mesh): void;
  56768. /**
  56769. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56770. * @param mesh mesh to test
  56771. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56772. */
  56773. hasMesh(mesh: AbstractMesh): boolean;
  56774. /**
  56775. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56776. * @param mesh The mesh to highlight
  56777. * @param color The color of the highlight
  56778. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56779. */
  56780. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56781. /**
  56782. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56783. * @param mesh The mesh to highlight
  56784. */
  56785. removeMesh(mesh: Mesh): void;
  56786. /**
  56787. * Remove all the meshes currently referenced in the highlight layer
  56788. */
  56789. removeAllMeshes(): void;
  56790. /**
  56791. * Force the stencil to the normal expected value for none glowing parts
  56792. */
  56793. private _defaultStencilReference;
  56794. /**
  56795. * Free any resources and references associated to a mesh.
  56796. * Internal use
  56797. * @param mesh The mesh to free.
  56798. * @hidden
  56799. */
  56800. _disposeMesh(mesh: Mesh): void;
  56801. /**
  56802. * Dispose the highlight layer and free resources.
  56803. */
  56804. dispose(): void;
  56805. /**
  56806. * Gets the class name of the effect layer
  56807. * @returns the string with the class name of the effect layer
  56808. */
  56809. getClassName(): string;
  56810. /**
  56811. * Serializes this Highlight layer
  56812. * @returns a serialized Highlight layer object
  56813. */
  56814. serialize(): any;
  56815. /**
  56816. * Creates a Highlight layer from parsed Highlight layer data
  56817. * @param parsedHightlightLayer defines the Highlight layer data
  56818. * @param scene defines the current scene
  56819. * @param rootUrl defines the root URL containing the Highlight layer information
  56820. * @returns a parsed Highlight layer
  56821. */
  56822. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56823. }
  56824. }
  56825. declare module "babylonjs/Layers/layerSceneComponent" {
  56826. import { Scene } from "babylonjs/scene";
  56827. import { ISceneComponent } from "babylonjs/sceneComponent";
  56828. import { Layer } from "babylonjs/Layers/layer";
  56829. import { AbstractScene } from "babylonjs/abstractScene";
  56830. module "babylonjs/abstractScene" {
  56831. interface AbstractScene {
  56832. /**
  56833. * The list of layers (background and foreground) of the scene
  56834. */
  56835. layers: Array<Layer>;
  56836. }
  56837. }
  56838. /**
  56839. * Defines the layer scene component responsible to manage any layers
  56840. * in a given scene.
  56841. */
  56842. export class LayerSceneComponent implements ISceneComponent {
  56843. /**
  56844. * The component name helpfull to identify the component in the list of scene components.
  56845. */
  56846. readonly name: string;
  56847. /**
  56848. * The scene the component belongs to.
  56849. */
  56850. scene: Scene;
  56851. private _engine;
  56852. /**
  56853. * Creates a new instance of the component for the given scene
  56854. * @param scene Defines the scene to register the component in
  56855. */
  56856. constructor(scene: Scene);
  56857. /**
  56858. * Registers the component in a given scene
  56859. */
  56860. register(): void;
  56861. /**
  56862. * Rebuilds the elements related to this component in case of
  56863. * context lost for instance.
  56864. */
  56865. rebuild(): void;
  56866. /**
  56867. * Disposes the component and the associated ressources.
  56868. */
  56869. dispose(): void;
  56870. private _draw;
  56871. private _drawCameraPredicate;
  56872. private _drawCameraBackground;
  56873. private _drawCameraForeground;
  56874. private _drawRenderTargetPredicate;
  56875. private _drawRenderTargetBackground;
  56876. private _drawRenderTargetForeground;
  56877. /**
  56878. * Adds all the elements from the container to the scene
  56879. * @param container the container holding the elements
  56880. */
  56881. addFromContainer(container: AbstractScene): void;
  56882. /**
  56883. * Removes all the elements in the container from the scene
  56884. * @param container contains the elements to remove
  56885. * @param dispose if the removed element should be disposed (default: false)
  56886. */
  56887. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56888. }
  56889. }
  56890. declare module "babylonjs/Shaders/layer.fragment" {
  56891. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56892. /** @hidden */
  56893. export var layerPixelShader: {
  56894. name: string;
  56895. shader: string;
  56896. };
  56897. }
  56898. declare module "babylonjs/Shaders/layer.vertex" {
  56899. /** @hidden */
  56900. export var layerVertexShader: {
  56901. name: string;
  56902. shader: string;
  56903. };
  56904. }
  56905. declare module "babylonjs/Layers/layer" {
  56906. import { Observable } from "babylonjs/Misc/observable";
  56907. import { Nullable } from "babylonjs/types";
  56908. import { Scene } from "babylonjs/scene";
  56909. import { Vector2 } from "babylonjs/Maths/math.vector";
  56910. import { Color4 } from "babylonjs/Maths/math.color";
  56911. import { Texture } from "babylonjs/Materials/Textures/texture";
  56912. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56913. import "babylonjs/Shaders/layer.fragment";
  56914. import "babylonjs/Shaders/layer.vertex";
  56915. /**
  56916. * This represents a full screen 2d layer.
  56917. * This can be useful to display a picture in the background of your scene for instance.
  56918. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56919. */
  56920. export class Layer {
  56921. /**
  56922. * Define the name of the layer.
  56923. */
  56924. name: string;
  56925. /**
  56926. * Define the texture the layer should display.
  56927. */
  56928. texture: Nullable<Texture>;
  56929. /**
  56930. * Is the layer in background or foreground.
  56931. */
  56932. isBackground: boolean;
  56933. /**
  56934. * Define the color of the layer (instead of texture).
  56935. */
  56936. color: Color4;
  56937. /**
  56938. * Define the scale of the layer in order to zoom in out of the texture.
  56939. */
  56940. scale: Vector2;
  56941. /**
  56942. * Define an offset for the layer in order to shift the texture.
  56943. */
  56944. offset: Vector2;
  56945. /**
  56946. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56947. */
  56948. alphaBlendingMode: number;
  56949. /**
  56950. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56951. * Alpha test will not mix with the background color in case of transparency.
  56952. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56953. */
  56954. alphaTest: boolean;
  56955. /**
  56956. * Define a mask to restrict the layer to only some of the scene cameras.
  56957. */
  56958. layerMask: number;
  56959. /**
  56960. * Define the list of render target the layer is visible into.
  56961. */
  56962. renderTargetTextures: RenderTargetTexture[];
  56963. /**
  56964. * Define if the layer is only used in renderTarget or if it also
  56965. * renders in the main frame buffer of the canvas.
  56966. */
  56967. renderOnlyInRenderTargetTextures: boolean;
  56968. private _scene;
  56969. private _vertexBuffers;
  56970. private _indexBuffer;
  56971. private _effect;
  56972. private _previousDefines;
  56973. /**
  56974. * An event triggered when the layer is disposed.
  56975. */
  56976. onDisposeObservable: Observable<Layer>;
  56977. private _onDisposeObserver;
  56978. /**
  56979. * Back compatibility with callback before the onDisposeObservable existed.
  56980. * The set callback will be triggered when the layer has been disposed.
  56981. */
  56982. set onDispose(callback: () => void);
  56983. /**
  56984. * An event triggered before rendering the scene
  56985. */
  56986. onBeforeRenderObservable: Observable<Layer>;
  56987. private _onBeforeRenderObserver;
  56988. /**
  56989. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56990. * The set callback will be triggered just before rendering the layer.
  56991. */
  56992. set onBeforeRender(callback: () => void);
  56993. /**
  56994. * An event triggered after rendering the scene
  56995. */
  56996. onAfterRenderObservable: Observable<Layer>;
  56997. private _onAfterRenderObserver;
  56998. /**
  56999. * Back compatibility with callback before the onAfterRenderObservable existed.
  57000. * The set callback will be triggered just after rendering the layer.
  57001. */
  57002. set onAfterRender(callback: () => void);
  57003. /**
  57004. * Instantiates a new layer.
  57005. * This represents a full screen 2d layer.
  57006. * This can be useful to display a picture in the background of your scene for instance.
  57007. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57008. * @param name Define the name of the layer in the scene
  57009. * @param imgUrl Define the url of the texture to display in the layer
  57010. * @param scene Define the scene the layer belongs to
  57011. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57012. * @param color Defines a color for the layer
  57013. */
  57014. constructor(
  57015. /**
  57016. * Define the name of the layer.
  57017. */
  57018. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57019. private _createIndexBuffer;
  57020. /** @hidden */
  57021. _rebuild(): void;
  57022. /**
  57023. * Renders the layer in the scene.
  57024. */
  57025. render(): void;
  57026. /**
  57027. * Disposes and releases the associated ressources.
  57028. */
  57029. dispose(): void;
  57030. }
  57031. }
  57032. declare module "babylonjs/Layers/index" {
  57033. export * from "babylonjs/Layers/effectLayer";
  57034. export * from "babylonjs/Layers/effectLayerSceneComponent";
  57035. export * from "babylonjs/Layers/glowLayer";
  57036. export * from "babylonjs/Layers/highlightLayer";
  57037. export * from "babylonjs/Layers/layer";
  57038. export * from "babylonjs/Layers/layerSceneComponent";
  57039. }
  57040. declare module "babylonjs/Shaders/lensFlare.fragment" {
  57041. /** @hidden */
  57042. export var lensFlarePixelShader: {
  57043. name: string;
  57044. shader: string;
  57045. };
  57046. }
  57047. declare module "babylonjs/Shaders/lensFlare.vertex" {
  57048. /** @hidden */
  57049. export var lensFlareVertexShader: {
  57050. name: string;
  57051. shader: string;
  57052. };
  57053. }
  57054. declare module "babylonjs/LensFlares/lensFlareSystem" {
  57055. import { Scene } from "babylonjs/scene";
  57056. import { Vector3 } from "babylonjs/Maths/math.vector";
  57057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57058. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  57059. import "babylonjs/Shaders/lensFlare.fragment";
  57060. import "babylonjs/Shaders/lensFlare.vertex";
  57061. import { Viewport } from "babylonjs/Maths/math.viewport";
  57062. /**
  57063. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57064. * It is usually composed of several `lensFlare`.
  57065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57066. */
  57067. export class LensFlareSystem {
  57068. /**
  57069. * Define the name of the lens flare system
  57070. */
  57071. name: string;
  57072. /**
  57073. * List of lens flares used in this system.
  57074. */
  57075. lensFlares: LensFlare[];
  57076. /**
  57077. * Define a limit from the border the lens flare can be visible.
  57078. */
  57079. borderLimit: number;
  57080. /**
  57081. * Define a viewport border we do not want to see the lens flare in.
  57082. */
  57083. viewportBorder: number;
  57084. /**
  57085. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57086. */
  57087. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57088. /**
  57089. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57090. */
  57091. layerMask: number;
  57092. /**
  57093. * Define the id of the lens flare system in the scene.
  57094. * (equal to name by default)
  57095. */
  57096. id: string;
  57097. private _scene;
  57098. private _emitter;
  57099. private _vertexBuffers;
  57100. private _indexBuffer;
  57101. private _effect;
  57102. private _positionX;
  57103. private _positionY;
  57104. private _isEnabled;
  57105. /** @hidden */
  57106. static _SceneComponentInitialization: (scene: Scene) => void;
  57107. /**
  57108. * Instantiates a lens flare system.
  57109. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57110. * It is usually composed of several `lensFlare`.
  57111. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57112. * @param name Define the name of the lens flare system in the scene
  57113. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57114. * @param scene Define the scene the lens flare system belongs to
  57115. */
  57116. constructor(
  57117. /**
  57118. * Define the name of the lens flare system
  57119. */
  57120. name: string, emitter: any, scene: Scene);
  57121. /**
  57122. * Define if the lens flare system is enabled.
  57123. */
  57124. get isEnabled(): boolean;
  57125. set isEnabled(value: boolean);
  57126. /**
  57127. * Get the scene the effects belongs to.
  57128. * @returns the scene holding the lens flare system
  57129. */
  57130. getScene(): Scene;
  57131. /**
  57132. * Get the emitter of the lens flare system.
  57133. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57134. * @returns the emitter of the lens flare system
  57135. */
  57136. getEmitter(): any;
  57137. /**
  57138. * Set the emitter of the lens flare system.
  57139. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57140. * @param newEmitter Define the new emitter of the system
  57141. */
  57142. setEmitter(newEmitter: any): void;
  57143. /**
  57144. * Get the lens flare system emitter position.
  57145. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57146. * @returns the position
  57147. */
  57148. getEmitterPosition(): Vector3;
  57149. /**
  57150. * @hidden
  57151. */
  57152. computeEffectivePosition(globalViewport: Viewport): boolean;
  57153. /** @hidden */
  57154. _isVisible(): boolean;
  57155. /**
  57156. * @hidden
  57157. */
  57158. render(): boolean;
  57159. /**
  57160. * Dispose and release the lens flare with its associated resources.
  57161. */
  57162. dispose(): void;
  57163. /**
  57164. * Parse a lens flare system from a JSON repressentation
  57165. * @param parsedLensFlareSystem Define the JSON to parse
  57166. * @param scene Define the scene the parsed system should be instantiated in
  57167. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57168. * @returns the parsed system
  57169. */
  57170. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57171. /**
  57172. * Serialize the current Lens Flare System into a JSON representation.
  57173. * @returns the serialized JSON
  57174. */
  57175. serialize(): any;
  57176. }
  57177. }
  57178. declare module "babylonjs/LensFlares/lensFlare" {
  57179. import { Nullable } from "babylonjs/types";
  57180. import { Color3 } from "babylonjs/Maths/math.color";
  57181. import { Texture } from "babylonjs/Materials/Textures/texture";
  57182. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57183. /**
  57184. * This represents one of the lens effect in a `lensFlareSystem`.
  57185. * It controls one of the indiviual texture used in the effect.
  57186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57187. */
  57188. export class LensFlare {
  57189. /**
  57190. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57191. */
  57192. size: number;
  57193. /**
  57194. * 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.
  57195. */
  57196. position: number;
  57197. /**
  57198. * Define the lens color.
  57199. */
  57200. color: Color3;
  57201. /**
  57202. * Define the lens texture.
  57203. */
  57204. texture: Nullable<Texture>;
  57205. /**
  57206. * Define the alpha mode to render this particular lens.
  57207. */
  57208. alphaMode: number;
  57209. private _system;
  57210. /**
  57211. * Creates a new Lens Flare.
  57212. * This represents one of the lens effect in a `lensFlareSystem`.
  57213. * It controls one of the indiviual texture used in the effect.
  57214. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57215. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57216. * @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.
  57217. * @param color Define the lens color
  57218. * @param imgUrl Define the lens texture url
  57219. * @param system Define the `lensFlareSystem` this flare is part of
  57220. * @returns The newly created Lens Flare
  57221. */
  57222. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57223. /**
  57224. * Instantiates a new Lens Flare.
  57225. * This represents one of the lens effect in a `lensFlareSystem`.
  57226. * It controls one of the indiviual texture used in the effect.
  57227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57228. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57229. * @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.
  57230. * @param color Define the lens color
  57231. * @param imgUrl Define the lens texture url
  57232. * @param system Define the `lensFlareSystem` this flare is part of
  57233. */
  57234. constructor(
  57235. /**
  57236. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57237. */
  57238. size: number,
  57239. /**
  57240. * 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.
  57241. */
  57242. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57243. /**
  57244. * Dispose and release the lens flare with its associated resources.
  57245. */
  57246. dispose(): void;
  57247. }
  57248. }
  57249. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57250. import { Nullable } from "babylonjs/types";
  57251. import { Scene } from "babylonjs/scene";
  57252. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57253. import { AbstractScene } from "babylonjs/abstractScene";
  57254. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57255. module "babylonjs/abstractScene" {
  57256. interface AbstractScene {
  57257. /**
  57258. * The list of lens flare system added to the scene
  57259. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57260. */
  57261. lensFlareSystems: Array<LensFlareSystem>;
  57262. /**
  57263. * Removes the given lens flare system from this scene.
  57264. * @param toRemove The lens flare system to remove
  57265. * @returns The index of the removed lens flare system
  57266. */
  57267. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57268. /**
  57269. * Adds the given lens flare system to this scene
  57270. * @param newLensFlareSystem The lens flare system to add
  57271. */
  57272. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57273. /**
  57274. * Gets a lens flare system using its name
  57275. * @param name defines the name to look for
  57276. * @returns the lens flare system or null if not found
  57277. */
  57278. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57279. /**
  57280. * Gets a lens flare system using its id
  57281. * @param id defines the id to look for
  57282. * @returns the lens flare system or null if not found
  57283. */
  57284. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57285. }
  57286. }
  57287. /**
  57288. * Defines the lens flare scene component responsible to manage any lens flares
  57289. * in a given scene.
  57290. */
  57291. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57292. /**
  57293. * The component name helpfull to identify the component in the list of scene components.
  57294. */
  57295. readonly name: string;
  57296. /**
  57297. * The scene the component belongs to.
  57298. */
  57299. scene: Scene;
  57300. /**
  57301. * Creates a new instance of the component for the given scene
  57302. * @param scene Defines the scene to register the component in
  57303. */
  57304. constructor(scene: Scene);
  57305. /**
  57306. * Registers the component in a given scene
  57307. */
  57308. register(): void;
  57309. /**
  57310. * Rebuilds the elements related to this component in case of
  57311. * context lost for instance.
  57312. */
  57313. rebuild(): void;
  57314. /**
  57315. * Adds all the elements from the container to the scene
  57316. * @param container the container holding the elements
  57317. */
  57318. addFromContainer(container: AbstractScene): void;
  57319. /**
  57320. * Removes all the elements in the container from the scene
  57321. * @param container contains the elements to remove
  57322. * @param dispose if the removed element should be disposed (default: false)
  57323. */
  57324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57325. /**
  57326. * Serializes the component data to the specified json object
  57327. * @param serializationObject The object to serialize to
  57328. */
  57329. serialize(serializationObject: any): void;
  57330. /**
  57331. * Disposes the component and the associated ressources.
  57332. */
  57333. dispose(): void;
  57334. private _draw;
  57335. }
  57336. }
  57337. declare module "babylonjs/LensFlares/index" {
  57338. export * from "babylonjs/LensFlares/lensFlare";
  57339. export * from "babylonjs/LensFlares/lensFlareSystem";
  57340. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57341. }
  57342. declare module "babylonjs/Shaders/depth.fragment" {
  57343. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57344. /** @hidden */
  57345. export var depthPixelShader: {
  57346. name: string;
  57347. shader: string;
  57348. };
  57349. }
  57350. declare module "babylonjs/Shaders/depth.vertex" {
  57351. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57352. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57353. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57354. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57355. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57356. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57357. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57358. /** @hidden */
  57359. export var depthVertexShader: {
  57360. name: string;
  57361. shader: string;
  57362. };
  57363. }
  57364. declare module "babylonjs/Rendering/depthRenderer" {
  57365. import { Nullable } from "babylonjs/types";
  57366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57367. import { Scene } from "babylonjs/scene";
  57368. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57369. import { Camera } from "babylonjs/Cameras/camera";
  57370. import "babylonjs/Shaders/depth.fragment";
  57371. import "babylonjs/Shaders/depth.vertex";
  57372. /**
  57373. * This represents a depth renderer in Babylon.
  57374. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57375. */
  57376. export class DepthRenderer {
  57377. private _scene;
  57378. private _depthMap;
  57379. private _effect;
  57380. private readonly _storeNonLinearDepth;
  57381. private readonly _clearColor;
  57382. /** Get if the depth renderer is using packed depth or not */
  57383. readonly isPacked: boolean;
  57384. private _cachedDefines;
  57385. private _camera;
  57386. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57387. enabled: boolean;
  57388. /**
  57389. * Specifiess that the depth renderer will only be used within
  57390. * the camera it is created for.
  57391. * This can help forcing its rendering during the camera processing.
  57392. */
  57393. useOnlyInActiveCamera: boolean;
  57394. /** @hidden */
  57395. static _SceneComponentInitialization: (scene: Scene) => void;
  57396. /**
  57397. * Instantiates a depth renderer
  57398. * @param scene The scene the renderer belongs to
  57399. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57400. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57401. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57402. */
  57403. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57404. /**
  57405. * Creates the depth rendering effect and checks if the effect is ready.
  57406. * @param subMesh The submesh to be used to render the depth map of
  57407. * @param useInstances If multiple world instances should be used
  57408. * @returns if the depth renderer is ready to render the depth map
  57409. */
  57410. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57411. /**
  57412. * Gets the texture which the depth map will be written to.
  57413. * @returns The depth map texture
  57414. */
  57415. getDepthMap(): RenderTargetTexture;
  57416. /**
  57417. * Disposes of the depth renderer.
  57418. */
  57419. dispose(): void;
  57420. }
  57421. }
  57422. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57423. /** @hidden */
  57424. export var minmaxReduxPixelShader: {
  57425. name: string;
  57426. shader: string;
  57427. };
  57428. }
  57429. declare module "babylonjs/Misc/minMaxReducer" {
  57430. import { Nullable } from "babylonjs/types";
  57431. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57432. import { Camera } from "babylonjs/Cameras/camera";
  57433. import { Observer } from "babylonjs/Misc/observable";
  57434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57435. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57436. import { Observable } from "babylonjs/Misc/observable";
  57437. import "babylonjs/Shaders/minmaxRedux.fragment";
  57438. /**
  57439. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57440. * and maximum values from all values of the texture.
  57441. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57442. * The source values are read from the red channel of the texture.
  57443. */
  57444. export class MinMaxReducer {
  57445. /**
  57446. * Observable triggered when the computation has been performed
  57447. */
  57448. onAfterReductionPerformed: Observable<{
  57449. min: number;
  57450. max: number;
  57451. }>;
  57452. protected _camera: Camera;
  57453. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57454. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57455. protected _postProcessManager: PostProcessManager;
  57456. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57457. protected _forceFullscreenViewport: boolean;
  57458. /**
  57459. * Creates a min/max reducer
  57460. * @param camera The camera to use for the post processes
  57461. */
  57462. constructor(camera: Camera);
  57463. /**
  57464. * Gets the texture used to read the values from.
  57465. */
  57466. get sourceTexture(): Nullable<RenderTargetTexture>;
  57467. /**
  57468. * Sets the source texture to read the values from.
  57469. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57470. * because in such textures '1' value must not be taken into account to compute the maximum
  57471. * as this value is used to clear the texture.
  57472. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57473. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57474. * @param depthRedux Indicates if the texture is a depth texture or not
  57475. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57476. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57477. */
  57478. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57479. /**
  57480. * Defines the refresh rate of the computation.
  57481. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57482. */
  57483. get refreshRate(): number;
  57484. set refreshRate(value: number);
  57485. protected _activated: boolean;
  57486. /**
  57487. * Gets the activation status of the reducer
  57488. */
  57489. get activated(): boolean;
  57490. /**
  57491. * Activates the reduction computation.
  57492. * When activated, the observers registered in onAfterReductionPerformed are
  57493. * called after the compuation is performed
  57494. */
  57495. activate(): void;
  57496. /**
  57497. * Deactivates the reduction computation.
  57498. */
  57499. deactivate(): void;
  57500. /**
  57501. * Disposes the min/max reducer
  57502. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57503. */
  57504. dispose(disposeAll?: boolean): void;
  57505. }
  57506. }
  57507. declare module "babylonjs/Misc/depthReducer" {
  57508. import { Nullable } from "babylonjs/types";
  57509. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57510. import { Camera } from "babylonjs/Cameras/camera";
  57511. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57512. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57513. /**
  57514. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57515. */
  57516. export class DepthReducer extends MinMaxReducer {
  57517. private _depthRenderer;
  57518. private _depthRendererId;
  57519. /**
  57520. * Gets the depth renderer used for the computation.
  57521. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57522. */
  57523. get depthRenderer(): Nullable<DepthRenderer>;
  57524. /**
  57525. * Creates a depth reducer
  57526. * @param camera The camera used to render the depth texture
  57527. */
  57528. constructor(camera: Camera);
  57529. /**
  57530. * Sets the depth renderer to use to generate the depth map
  57531. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57532. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57533. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57534. */
  57535. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57536. /** @hidden */
  57537. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57538. /**
  57539. * Activates the reduction computation.
  57540. * When activated, the observers registered in onAfterReductionPerformed are
  57541. * called after the compuation is performed
  57542. */
  57543. activate(): void;
  57544. /**
  57545. * Deactivates the reduction computation.
  57546. */
  57547. deactivate(): void;
  57548. /**
  57549. * Disposes the depth reducer
  57550. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57551. */
  57552. dispose(disposeAll?: boolean): void;
  57553. }
  57554. }
  57555. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57556. import { Nullable } from "babylonjs/types";
  57557. import { Scene } from "babylonjs/scene";
  57558. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57559. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57561. import { Effect } from "babylonjs/Materials/effect";
  57562. import "babylonjs/Shaders/shadowMap.fragment";
  57563. import "babylonjs/Shaders/shadowMap.vertex";
  57564. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57565. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57566. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57567. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57568. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57569. /**
  57570. * A CSM implementation allowing casting shadows on large scenes.
  57571. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57572. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57573. */
  57574. export class CascadedShadowGenerator extends ShadowGenerator {
  57575. private static readonly frustumCornersNDCSpace;
  57576. /**
  57577. * Name of the CSM class
  57578. */
  57579. static CLASSNAME: string;
  57580. /**
  57581. * Defines the default number of cascades used by the CSM.
  57582. */
  57583. static readonly DEFAULT_CASCADES_COUNT: number;
  57584. /**
  57585. * Defines the minimum number of cascades used by the CSM.
  57586. */
  57587. static readonly MIN_CASCADES_COUNT: number;
  57588. /**
  57589. * Defines the maximum number of cascades used by the CSM.
  57590. */
  57591. static readonly MAX_CASCADES_COUNT: number;
  57592. protected _validateFilter(filter: number): number;
  57593. /**
  57594. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57595. */
  57596. penumbraDarkness: number;
  57597. private _numCascades;
  57598. /**
  57599. * Gets or set the number of cascades used by the CSM.
  57600. */
  57601. get numCascades(): number;
  57602. set numCascades(value: number);
  57603. /**
  57604. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57605. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57606. */
  57607. stabilizeCascades: boolean;
  57608. private _freezeShadowCastersBoundingInfo;
  57609. private _freezeShadowCastersBoundingInfoObservable;
  57610. /**
  57611. * Enables or disables the shadow casters bounding info computation.
  57612. * If your shadow casters don't move, you can disable this feature.
  57613. * If it is enabled, the bounding box computation is done every frame.
  57614. */
  57615. get freezeShadowCastersBoundingInfo(): boolean;
  57616. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57617. private _scbiMin;
  57618. private _scbiMax;
  57619. protected _computeShadowCastersBoundingInfo(): void;
  57620. protected _shadowCastersBoundingInfo: BoundingInfo;
  57621. /**
  57622. * Gets or sets the shadow casters bounding info.
  57623. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57624. * so that the system won't overwrite the bounds you provide
  57625. */
  57626. get shadowCastersBoundingInfo(): BoundingInfo;
  57627. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57628. protected _breaksAreDirty: boolean;
  57629. protected _minDistance: number;
  57630. protected _maxDistance: number;
  57631. /**
  57632. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57633. *
  57634. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57635. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57636. * @param min minimal distance for the breaks (default to 0.)
  57637. * @param max maximal distance for the breaks (default to 1.)
  57638. */
  57639. setMinMaxDistance(min: number, max: number): void;
  57640. /** Gets the minimal distance used in the cascade break computation */
  57641. get minDistance(): number;
  57642. /** Gets the maximal distance used in the cascade break computation */
  57643. get maxDistance(): number;
  57644. /**
  57645. * Gets the class name of that object
  57646. * @returns "CascadedShadowGenerator"
  57647. */
  57648. getClassName(): string;
  57649. private _cascadeMinExtents;
  57650. private _cascadeMaxExtents;
  57651. /**
  57652. * Gets a cascade minimum extents
  57653. * @param cascadeIndex index of the cascade
  57654. * @returns the minimum cascade extents
  57655. */
  57656. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57657. /**
  57658. * Gets a cascade maximum extents
  57659. * @param cascadeIndex index of the cascade
  57660. * @returns the maximum cascade extents
  57661. */
  57662. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57663. private _cascades;
  57664. private _currentLayer;
  57665. private _viewSpaceFrustumsZ;
  57666. private _viewMatrices;
  57667. private _projectionMatrices;
  57668. private _transformMatrices;
  57669. private _transformMatricesAsArray;
  57670. private _frustumLengths;
  57671. private _lightSizeUVCorrection;
  57672. private _depthCorrection;
  57673. private _frustumCornersWorldSpace;
  57674. private _frustumCenter;
  57675. private _shadowCameraPos;
  57676. private _shadowMaxZ;
  57677. /**
  57678. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57679. * It defaults to camera.maxZ
  57680. */
  57681. get shadowMaxZ(): number;
  57682. /**
  57683. * Sets the shadow max z distance.
  57684. */
  57685. set shadowMaxZ(value: number);
  57686. protected _debug: boolean;
  57687. /**
  57688. * Gets or sets the debug flag.
  57689. * When enabled, the cascades are materialized by different colors on the screen.
  57690. */
  57691. get debug(): boolean;
  57692. set debug(dbg: boolean);
  57693. private _depthClamp;
  57694. /**
  57695. * Gets or sets the depth clamping value.
  57696. *
  57697. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57698. * to account for the shadow casters far away.
  57699. *
  57700. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57701. */
  57702. get depthClamp(): boolean;
  57703. set depthClamp(value: boolean);
  57704. private _cascadeBlendPercentage;
  57705. /**
  57706. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57707. * It defaults to 0.1 (10% blending).
  57708. */
  57709. get cascadeBlendPercentage(): number;
  57710. set cascadeBlendPercentage(value: number);
  57711. private _lambda;
  57712. /**
  57713. * Gets or set the lambda parameter.
  57714. * This parameter is used to split the camera frustum and create the cascades.
  57715. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  57716. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57717. */
  57718. get lambda(): number;
  57719. set lambda(value: number);
  57720. /**
  57721. * Gets the view matrix corresponding to a given cascade
  57722. * @param cascadeNum cascade to retrieve the view matrix from
  57723. * @returns the cascade view matrix
  57724. */
  57725. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57726. /**
  57727. * Gets the projection matrix corresponding to a given cascade
  57728. * @param cascadeNum cascade to retrieve the projection matrix from
  57729. * @returns the cascade projection matrix
  57730. */
  57731. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57732. /**
  57733. * Gets the transformation matrix corresponding to a given cascade
  57734. * @param cascadeNum cascade to retrieve the transformation matrix from
  57735. * @returns the cascade transformation matrix
  57736. */
  57737. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57738. private _depthRenderer;
  57739. /**
  57740. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57741. *
  57742. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57743. *
  57744. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57745. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57746. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  57747. */
  57748. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57749. private _depthReducer;
  57750. private _autoCalcDepthBounds;
  57751. /**
  57752. * Gets or sets the autoCalcDepthBounds property.
  57753. *
  57754. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57755. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57756. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57757. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57758. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57759. */
  57760. get autoCalcDepthBounds(): boolean;
  57761. set autoCalcDepthBounds(value: boolean);
  57762. /**
  57763. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57764. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57765. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57766. * for setting the refresh rate on the renderer yourself!
  57767. */
  57768. get autoCalcDepthBoundsRefreshRate(): number;
  57769. set autoCalcDepthBoundsRefreshRate(value: number);
  57770. /**
  57771. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57772. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57773. * you change the camera near/far planes!
  57774. */
  57775. splitFrustum(): void;
  57776. private _splitFrustum;
  57777. private _computeMatrices;
  57778. private _computeFrustumInWorldSpace;
  57779. private _computeCascadeFrustum;
  57780. /**
  57781. * Support test.
  57782. */
  57783. static get IsSupported(): boolean;
  57784. /** @hidden */
  57785. static _SceneComponentInitialization: (scene: Scene) => void;
  57786. /**
  57787. * Creates a Cascaded Shadow Generator object.
  57788. * A ShadowGenerator is the required tool to use the shadows.
  57789. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57790. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57791. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57792. * @param light The directional light object generating the shadows.
  57793. * @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.
  57794. */
  57795. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57796. protected _initializeGenerator(): void;
  57797. protected _createTargetRenderTexture(): void;
  57798. protected _initializeShadowMap(): void;
  57799. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57800. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57801. /**
  57802. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57803. * @param defines Defines of the material we want to update
  57804. * @param lightIndex Index of the light in the enabled light list of the material
  57805. */
  57806. prepareDefines(defines: any, lightIndex: number): void;
  57807. /**
  57808. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57809. * defined in the generator but impacting the effect).
  57810. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57811. * @param effect The effect we are binfing the information for
  57812. */
  57813. bindShadowLight(lightIndex: string, effect: Effect): void;
  57814. /**
  57815. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57816. * (eq to view projection * shadow projection matrices)
  57817. * @returns The transform matrix used to create the shadow map
  57818. */
  57819. getTransformMatrix(): Matrix;
  57820. /**
  57821. * Disposes the ShadowGenerator.
  57822. * Returns nothing.
  57823. */
  57824. dispose(): void;
  57825. /**
  57826. * Serializes the shadow generator setup to a json object.
  57827. * @returns The serialized JSON object
  57828. */
  57829. serialize(): any;
  57830. /**
  57831. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57832. * @param parsedShadowGenerator The JSON object to parse
  57833. * @param scene The scene to create the shadow map for
  57834. * @returns The parsed shadow generator
  57835. */
  57836. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57837. }
  57838. }
  57839. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57840. import { Scene } from "babylonjs/scene";
  57841. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57842. import { AbstractScene } from "babylonjs/abstractScene";
  57843. /**
  57844. * Defines the shadow generator component responsible to manage any shadow generators
  57845. * in a given scene.
  57846. */
  57847. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57848. /**
  57849. * The component name helpfull to identify the component in the list of scene components.
  57850. */
  57851. readonly name: string;
  57852. /**
  57853. * The scene the component belongs to.
  57854. */
  57855. scene: Scene;
  57856. /**
  57857. * Creates a new instance of the component for the given scene
  57858. * @param scene Defines the scene to register the component in
  57859. */
  57860. constructor(scene: Scene);
  57861. /**
  57862. * Registers the component in a given scene
  57863. */
  57864. register(): void;
  57865. /**
  57866. * Rebuilds the elements related to this component in case of
  57867. * context lost for instance.
  57868. */
  57869. rebuild(): void;
  57870. /**
  57871. * Serializes the component data to the specified json object
  57872. * @param serializationObject The object to serialize to
  57873. */
  57874. serialize(serializationObject: any): void;
  57875. /**
  57876. * Adds all the elements from the container to the scene
  57877. * @param container the container holding the elements
  57878. */
  57879. addFromContainer(container: AbstractScene): void;
  57880. /**
  57881. * Removes all the elements in the container from the scene
  57882. * @param container contains the elements to remove
  57883. * @param dispose if the removed element should be disposed (default: false)
  57884. */
  57885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57886. /**
  57887. * Rebuilds the elements related to this component in case of
  57888. * context lost for instance.
  57889. */
  57890. dispose(): void;
  57891. private _gatherRenderTargets;
  57892. }
  57893. }
  57894. declare module "babylonjs/Lights/Shadows/index" {
  57895. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57896. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57897. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57898. }
  57899. declare module "babylonjs/Lights/pointLight" {
  57900. import { Scene } from "babylonjs/scene";
  57901. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57903. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57904. import { Effect } from "babylonjs/Materials/effect";
  57905. /**
  57906. * A point light is a light defined by an unique point in world space.
  57907. * The light is emitted in every direction from this point.
  57908. * A good example of a point light is a standard light bulb.
  57909. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57910. */
  57911. export class PointLight extends ShadowLight {
  57912. private _shadowAngle;
  57913. /**
  57914. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57915. * This specifies what angle the shadow will use to be created.
  57916. *
  57917. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57918. */
  57919. get shadowAngle(): number;
  57920. /**
  57921. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57922. * This specifies what angle the shadow will use to be created.
  57923. *
  57924. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57925. */
  57926. set shadowAngle(value: number);
  57927. /**
  57928. * Gets the direction if it has been set.
  57929. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57930. */
  57931. get direction(): Vector3;
  57932. /**
  57933. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57934. */
  57935. set direction(value: Vector3);
  57936. /**
  57937. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57938. * A PointLight emits the light in every direction.
  57939. * It can cast shadows.
  57940. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57941. * ```javascript
  57942. * var pointLight = new PointLight("pl", camera.position, scene);
  57943. * ```
  57944. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57945. * @param name The light friendly name
  57946. * @param position The position of the point light in the scene
  57947. * @param scene The scene the lights belongs to
  57948. */
  57949. constructor(name: string, position: Vector3, scene: Scene);
  57950. /**
  57951. * Returns the string "PointLight"
  57952. * @returns the class name
  57953. */
  57954. getClassName(): string;
  57955. /**
  57956. * Returns the integer 0.
  57957. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57958. */
  57959. getTypeID(): number;
  57960. /**
  57961. * Specifies wether or not the shadowmap should be a cube texture.
  57962. * @returns true if the shadowmap needs to be a cube texture.
  57963. */
  57964. needCube(): boolean;
  57965. /**
  57966. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57967. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57968. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57969. */
  57970. getShadowDirection(faceIndex?: number): Vector3;
  57971. /**
  57972. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57973. * - fov = PI / 2
  57974. * - aspect ratio : 1.0
  57975. * - z-near and far equal to the active camera minZ and maxZ.
  57976. * Returns the PointLight.
  57977. */
  57978. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57979. protected _buildUniformLayout(): void;
  57980. /**
  57981. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57982. * @param effect The effect to update
  57983. * @param lightIndex The index of the light in the effect to update
  57984. * @returns The point light
  57985. */
  57986. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57987. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57988. /**
  57989. * Prepares the list of defines specific to the light type.
  57990. * @param defines the list of defines
  57991. * @param lightIndex defines the index of the light for the effect
  57992. */
  57993. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57994. }
  57995. }
  57996. declare module "babylonjs/Lights/index" {
  57997. export * from "babylonjs/Lights/light";
  57998. export * from "babylonjs/Lights/shadowLight";
  57999. export * from "babylonjs/Lights/Shadows/index";
  58000. export * from "babylonjs/Lights/directionalLight";
  58001. export * from "babylonjs/Lights/hemisphericLight";
  58002. export * from "babylonjs/Lights/pointLight";
  58003. export * from "babylonjs/Lights/spotLight";
  58004. }
  58005. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  58006. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58007. /**
  58008. * Header information of HDR texture files.
  58009. */
  58010. export interface HDRInfo {
  58011. /**
  58012. * The height of the texture in pixels.
  58013. */
  58014. height: number;
  58015. /**
  58016. * The width of the texture in pixels.
  58017. */
  58018. width: number;
  58019. /**
  58020. * The index of the beginning of the data in the binary file.
  58021. */
  58022. dataPosition: number;
  58023. }
  58024. /**
  58025. * This groups tools to convert HDR texture to native colors array.
  58026. */
  58027. export class HDRTools {
  58028. private static Ldexp;
  58029. private static Rgbe2float;
  58030. private static readStringLine;
  58031. /**
  58032. * Reads header information from an RGBE texture stored in a native array.
  58033. * More information on this format are available here:
  58034. * https://en.wikipedia.org/wiki/RGBE_image_format
  58035. *
  58036. * @param uint8array The binary file stored in native array.
  58037. * @return The header information.
  58038. */
  58039. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58040. /**
  58041. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58042. * This RGBE texture needs to store the information as a panorama.
  58043. *
  58044. * More information on this format are available here:
  58045. * https://en.wikipedia.org/wiki/RGBE_image_format
  58046. *
  58047. * @param buffer The binary file stored in an array buffer.
  58048. * @param size The expected size of the extracted cubemap.
  58049. * @return The Cube Map information.
  58050. */
  58051. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58052. /**
  58053. * Returns the pixels data extracted from an RGBE texture.
  58054. * This pixels will be stored left to right up to down in the R G B order in one array.
  58055. *
  58056. * More information on this format are available here:
  58057. * https://en.wikipedia.org/wiki/RGBE_image_format
  58058. *
  58059. * @param uint8array The binary file stored in an array buffer.
  58060. * @param hdrInfo The header information of the file.
  58061. * @return The pixels data in RGB right to left up to down order.
  58062. */
  58063. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58064. private static RGBE_ReadPixels_RLE;
  58065. }
  58066. }
  58067. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  58068. import { Nullable } from "babylonjs/types";
  58069. import { Scene } from "babylonjs/scene";
  58070. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58072. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58073. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58074. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58075. /**
  58076. * This represents a texture coming from an HDR input.
  58077. *
  58078. * The only supported format is currently panorama picture stored in RGBE format.
  58079. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58080. */
  58081. export class HDRCubeTexture extends BaseTexture {
  58082. private static _facesMapping;
  58083. private _generateHarmonics;
  58084. private _noMipmap;
  58085. private _textureMatrix;
  58086. private _size;
  58087. private _onLoad;
  58088. private _onError;
  58089. /**
  58090. * The texture URL.
  58091. */
  58092. url: string;
  58093. /**
  58094. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58095. */
  58096. coordinatesMode: number;
  58097. protected _isBlocking: boolean;
  58098. /**
  58099. * Sets wether or not the texture is blocking during loading.
  58100. */
  58101. set isBlocking(value: boolean);
  58102. /**
  58103. * Gets wether or not the texture is blocking during loading.
  58104. */
  58105. get isBlocking(): boolean;
  58106. protected _rotationY: number;
  58107. /**
  58108. * Sets texture matrix rotation angle around Y axis in radians.
  58109. */
  58110. set rotationY(value: number);
  58111. /**
  58112. * Gets texture matrix rotation angle around Y axis radians.
  58113. */
  58114. get rotationY(): number;
  58115. /**
  58116. * Gets or sets the center of the bounding box associated with the cube texture
  58117. * It must define where the camera used to render the texture was set
  58118. */
  58119. boundingBoxPosition: Vector3;
  58120. private _boundingBoxSize;
  58121. /**
  58122. * Gets or sets the size of the bounding box associated with the cube texture
  58123. * When defined, the cubemap will switch to local mode
  58124. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58125. * @example https://www.babylonjs-playground.com/#RNASML
  58126. */
  58127. set boundingBoxSize(value: Vector3);
  58128. get boundingBoxSize(): Vector3;
  58129. /**
  58130. * Instantiates an HDRTexture from the following parameters.
  58131. *
  58132. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58133. * @param sceneOrEngine The scene or engine the texture will be used in
  58134. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58135. * @param noMipmap Forces to not generate the mipmap if true
  58136. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58137. * @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)
  58138. * @param reserved Reserved flag for internal use.
  58139. */
  58140. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58141. /**
  58142. * Get the current class name of the texture useful for serialization or dynamic coding.
  58143. * @returns "HDRCubeTexture"
  58144. */
  58145. getClassName(): string;
  58146. /**
  58147. * Occurs when the file is raw .hdr file.
  58148. */
  58149. private loadTexture;
  58150. clone(): HDRCubeTexture;
  58151. delayLoad(): void;
  58152. /**
  58153. * Get the texture reflection matrix used to rotate/transform the reflection.
  58154. * @returns the reflection matrix
  58155. */
  58156. getReflectionTextureMatrix(): Matrix;
  58157. /**
  58158. * Set the texture reflection matrix used to rotate/transform the reflection.
  58159. * @param value Define the reflection matrix to set
  58160. */
  58161. setReflectionTextureMatrix(value: Matrix): void;
  58162. /**
  58163. * Parses a JSON representation of an HDR Texture in order to create the texture
  58164. * @param parsedTexture Define the JSON representation
  58165. * @param scene Define the scene the texture should be created in
  58166. * @param rootUrl Define the root url in case we need to load relative dependencies
  58167. * @returns the newly created texture after parsing
  58168. */
  58169. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58170. serialize(): any;
  58171. }
  58172. }
  58173. declare module "babylonjs/Physics/physicsEngine" {
  58174. import { Nullable } from "babylonjs/types";
  58175. import { Vector3 } from "babylonjs/Maths/math.vector";
  58176. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58177. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  58178. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  58179. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58180. /**
  58181. * Class used to control physics engine
  58182. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58183. */
  58184. export class PhysicsEngine implements IPhysicsEngine {
  58185. private _physicsPlugin;
  58186. /**
  58187. * Global value used to control the smallest number supported by the simulation
  58188. */
  58189. static Epsilon: number;
  58190. private _impostors;
  58191. private _joints;
  58192. private _subTimeStep;
  58193. /**
  58194. * Gets the gravity vector used by the simulation
  58195. */
  58196. gravity: Vector3;
  58197. /**
  58198. * Factory used to create the default physics plugin.
  58199. * @returns The default physics plugin
  58200. */
  58201. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58202. /**
  58203. * Creates a new Physics Engine
  58204. * @param gravity defines the gravity vector used by the simulation
  58205. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58206. */
  58207. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58208. /**
  58209. * Sets the gravity vector used by the simulation
  58210. * @param gravity defines the gravity vector to use
  58211. */
  58212. setGravity(gravity: Vector3): void;
  58213. /**
  58214. * Set the time step of the physics engine.
  58215. * Default is 1/60.
  58216. * To slow it down, enter 1/600 for example.
  58217. * To speed it up, 1/30
  58218. * @param newTimeStep defines the new timestep to apply to this world.
  58219. */
  58220. setTimeStep(newTimeStep?: number): void;
  58221. /**
  58222. * Get the time step of the physics engine.
  58223. * @returns the current time step
  58224. */
  58225. getTimeStep(): number;
  58226. /**
  58227. * Set the sub time step of the physics engine.
  58228. * Default is 0 meaning there is no sub steps
  58229. * To increase physics resolution precision, set a small value (like 1 ms)
  58230. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58231. */
  58232. setSubTimeStep(subTimeStep?: number): void;
  58233. /**
  58234. * Get the sub time step of the physics engine.
  58235. * @returns the current sub time step
  58236. */
  58237. getSubTimeStep(): number;
  58238. /**
  58239. * Release all resources
  58240. */
  58241. dispose(): void;
  58242. /**
  58243. * Gets the name of the current physics plugin
  58244. * @returns the name of the plugin
  58245. */
  58246. getPhysicsPluginName(): string;
  58247. /**
  58248. * Adding a new impostor for the impostor tracking.
  58249. * This will be done by the impostor itself.
  58250. * @param impostor the impostor to add
  58251. */
  58252. addImpostor(impostor: PhysicsImpostor): void;
  58253. /**
  58254. * Remove an impostor from the engine.
  58255. * This impostor and its mesh will not longer be updated by the physics engine.
  58256. * @param impostor the impostor to remove
  58257. */
  58258. removeImpostor(impostor: PhysicsImpostor): void;
  58259. /**
  58260. * Add a joint to the physics engine
  58261. * @param mainImpostor defines the main impostor to which the joint is added.
  58262. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58263. * @param joint defines the joint that will connect both impostors.
  58264. */
  58265. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58266. /**
  58267. * Removes a joint from the simulation
  58268. * @param mainImpostor defines the impostor used with the joint
  58269. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58270. * @param joint defines the joint to remove
  58271. */
  58272. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58273. /**
  58274. * Called by the scene. No need to call it.
  58275. * @param delta defines the timespam between frames
  58276. */
  58277. _step(delta: number): void;
  58278. /**
  58279. * Gets the current plugin used to run the simulation
  58280. * @returns current plugin
  58281. */
  58282. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58283. /**
  58284. * Gets the list of physic impostors
  58285. * @returns an array of PhysicsImpostor
  58286. */
  58287. getImpostors(): Array<PhysicsImpostor>;
  58288. /**
  58289. * Gets the impostor for a physics enabled object
  58290. * @param object defines the object impersonated by the impostor
  58291. * @returns the PhysicsImpostor or null if not found
  58292. */
  58293. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58294. /**
  58295. * Gets the impostor for a physics body object
  58296. * @param body defines physics body used by the impostor
  58297. * @returns the PhysicsImpostor or null if not found
  58298. */
  58299. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58300. /**
  58301. * Does a raycast in the physics world
  58302. * @param from when should the ray start?
  58303. * @param to when should the ray end?
  58304. * @returns PhysicsRaycastResult
  58305. */
  58306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58307. }
  58308. }
  58309. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58310. import { Nullable } from "babylonjs/types";
  58311. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58313. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58314. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58315. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58316. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58317. /** @hidden */
  58318. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58319. private _useDeltaForWorldStep;
  58320. world: any;
  58321. name: string;
  58322. private _physicsMaterials;
  58323. private _fixedTimeStep;
  58324. private _cannonRaycastResult;
  58325. private _raycastResult;
  58326. private _physicsBodysToRemoveAfterStep;
  58327. BJSCANNON: any;
  58328. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58329. setGravity(gravity: Vector3): void;
  58330. setTimeStep(timeStep: number): void;
  58331. getTimeStep(): number;
  58332. executeStep(delta: number): void;
  58333. private _removeMarkedPhysicsBodiesFromWorld;
  58334. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58335. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58336. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58337. private _processChildMeshes;
  58338. removePhysicsBody(impostor: PhysicsImpostor): void;
  58339. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58340. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58341. private _addMaterial;
  58342. private _checkWithEpsilon;
  58343. private _createShape;
  58344. private _createHeightmap;
  58345. private _minus90X;
  58346. private _plus90X;
  58347. private _tmpPosition;
  58348. private _tmpDeltaPosition;
  58349. private _tmpUnityRotation;
  58350. private _updatePhysicsBodyTransformation;
  58351. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58352. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58353. isSupported(): boolean;
  58354. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58357. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58358. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58359. getBodyMass(impostor: PhysicsImpostor): number;
  58360. getBodyFriction(impostor: PhysicsImpostor): number;
  58361. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58362. getBodyRestitution(impostor: PhysicsImpostor): number;
  58363. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58364. sleepBody(impostor: PhysicsImpostor): void;
  58365. wakeUpBody(impostor: PhysicsImpostor): void;
  58366. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58367. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58368. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58370. getRadius(impostor: PhysicsImpostor): number;
  58371. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58372. dispose(): void;
  58373. private _extendNamespace;
  58374. /**
  58375. * Does a raycast in the physics world
  58376. * @param from when should the ray start?
  58377. * @param to when should the ray end?
  58378. * @returns PhysicsRaycastResult
  58379. */
  58380. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58381. }
  58382. }
  58383. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58384. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58385. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58386. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58388. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58389. import { Nullable } from "babylonjs/types";
  58390. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58391. /** @hidden */
  58392. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58393. private _useDeltaForWorldStep;
  58394. world: any;
  58395. name: string;
  58396. BJSOIMO: any;
  58397. private _raycastResult;
  58398. private _fixedTimeStep;
  58399. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58400. setGravity(gravity: Vector3): void;
  58401. setTimeStep(timeStep: number): void;
  58402. getTimeStep(): number;
  58403. private _tmpImpostorsArray;
  58404. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58405. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58406. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58407. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58408. private _tmpPositionVector;
  58409. removePhysicsBody(impostor: PhysicsImpostor): void;
  58410. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58411. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58412. isSupported(): boolean;
  58413. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58414. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58415. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58416. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58417. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58418. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58419. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58420. getBodyMass(impostor: PhysicsImpostor): number;
  58421. getBodyFriction(impostor: PhysicsImpostor): number;
  58422. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58423. getBodyRestitution(impostor: PhysicsImpostor): number;
  58424. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58425. sleepBody(impostor: PhysicsImpostor): void;
  58426. wakeUpBody(impostor: PhysicsImpostor): void;
  58427. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58428. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58429. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58430. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58431. getRadius(impostor: PhysicsImpostor): number;
  58432. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58433. dispose(): void;
  58434. /**
  58435. * Does a raycast in the physics world
  58436. * @param from when should the ray start?
  58437. * @param to when should the ray end?
  58438. * @returns PhysicsRaycastResult
  58439. */
  58440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58441. }
  58442. }
  58443. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58444. import { Nullable } from "babylonjs/types";
  58445. import { Scene } from "babylonjs/scene";
  58446. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58447. import { Color4 } from "babylonjs/Maths/math.color";
  58448. import { Mesh } from "babylonjs/Meshes/mesh";
  58449. /**
  58450. * Class containing static functions to help procedurally build meshes
  58451. */
  58452. export class RibbonBuilder {
  58453. /**
  58454. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58455. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58456. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58457. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58458. * * 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
  58459. * * 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
  58460. * * 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
  58461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58462. * * 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
  58463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58464. * * 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
  58465. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58466. * * 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
  58467. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58469. * @param name defines the name of the mesh
  58470. * @param options defines the options used to create the mesh
  58471. * @param scene defines the hosting scene
  58472. * @returns the ribbon mesh
  58473. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58475. */
  58476. static CreateRibbon(name: string, options: {
  58477. pathArray: Vector3[][];
  58478. closeArray?: boolean;
  58479. closePath?: boolean;
  58480. offset?: number;
  58481. updatable?: boolean;
  58482. sideOrientation?: number;
  58483. frontUVs?: Vector4;
  58484. backUVs?: Vector4;
  58485. instance?: Mesh;
  58486. invertUV?: boolean;
  58487. uvs?: Vector2[];
  58488. colors?: Color4[];
  58489. }, scene?: Nullable<Scene>): Mesh;
  58490. }
  58491. }
  58492. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58493. import { Nullable } from "babylonjs/types";
  58494. import { Scene } from "babylonjs/scene";
  58495. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58496. import { Mesh } from "babylonjs/Meshes/mesh";
  58497. /**
  58498. * Class containing static functions to help procedurally build meshes
  58499. */
  58500. export class ShapeBuilder {
  58501. /**
  58502. * 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.
  58503. * * 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.
  58504. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58505. * * 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.
  58506. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58507. * * 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
  58508. * * 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
  58509. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58511. * * 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
  58512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58514. * @param name defines the name of the mesh
  58515. * @param options defines the options used to create the mesh
  58516. * @param scene defines the hosting scene
  58517. * @returns the extruded shape mesh
  58518. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58519. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58520. */
  58521. static ExtrudeShape(name: string, options: {
  58522. shape: Vector3[];
  58523. path: Vector3[];
  58524. scale?: number;
  58525. rotation?: number;
  58526. cap?: number;
  58527. updatable?: boolean;
  58528. sideOrientation?: number;
  58529. frontUVs?: Vector4;
  58530. backUVs?: Vector4;
  58531. instance?: Mesh;
  58532. invertUV?: boolean;
  58533. }, scene?: Nullable<Scene>): Mesh;
  58534. /**
  58535. * Creates an custom extruded shape mesh.
  58536. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58537. * * 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.
  58538. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58539. * * 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
  58540. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58541. * * 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
  58542. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58543. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58544. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58545. * * 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
  58546. * * 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
  58547. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58549. * * 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
  58550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58552. * @param name defines the name of the mesh
  58553. * @param options defines the options used to create the mesh
  58554. * @param scene defines the hosting scene
  58555. * @returns the custom extruded shape mesh
  58556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58557. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58559. */
  58560. static ExtrudeShapeCustom(name: string, options: {
  58561. shape: Vector3[];
  58562. path: Vector3[];
  58563. scaleFunction?: any;
  58564. rotationFunction?: any;
  58565. ribbonCloseArray?: boolean;
  58566. ribbonClosePath?: boolean;
  58567. cap?: number;
  58568. updatable?: boolean;
  58569. sideOrientation?: number;
  58570. frontUVs?: Vector4;
  58571. backUVs?: Vector4;
  58572. instance?: Mesh;
  58573. invertUV?: boolean;
  58574. }, scene?: Nullable<Scene>): Mesh;
  58575. private static _ExtrudeShapeGeneric;
  58576. }
  58577. }
  58578. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58579. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58580. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58581. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58582. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58583. import { Nullable } from "babylonjs/types";
  58584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58585. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58586. /**
  58587. * AmmoJS Physics plugin
  58588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58589. * @see https://github.com/kripken/ammo.js/
  58590. */
  58591. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58592. private _useDeltaForWorldStep;
  58593. /**
  58594. * Reference to the Ammo library
  58595. */
  58596. bjsAMMO: any;
  58597. /**
  58598. * Created ammoJS world which physics bodies are added to
  58599. */
  58600. world: any;
  58601. /**
  58602. * Name of the plugin
  58603. */
  58604. name: string;
  58605. private _timeStep;
  58606. private _fixedTimeStep;
  58607. private _maxSteps;
  58608. private _tmpQuaternion;
  58609. private _tmpAmmoTransform;
  58610. private _tmpAmmoQuaternion;
  58611. private _tmpAmmoConcreteContactResultCallback;
  58612. private _collisionConfiguration;
  58613. private _dispatcher;
  58614. private _overlappingPairCache;
  58615. private _solver;
  58616. private _softBodySolver;
  58617. private _tmpAmmoVectorA;
  58618. private _tmpAmmoVectorB;
  58619. private _tmpAmmoVectorC;
  58620. private _tmpAmmoVectorD;
  58621. private _tmpContactCallbackResult;
  58622. private _tmpAmmoVectorRCA;
  58623. private _tmpAmmoVectorRCB;
  58624. private _raycastResult;
  58625. private static readonly DISABLE_COLLISION_FLAG;
  58626. private static readonly KINEMATIC_FLAG;
  58627. private static readonly DISABLE_DEACTIVATION_FLAG;
  58628. /**
  58629. * Initializes the ammoJS plugin
  58630. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58631. * @param ammoInjection can be used to inject your own ammo reference
  58632. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58633. */
  58634. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58635. /**
  58636. * Sets the gravity of the physics world (m/(s^2))
  58637. * @param gravity Gravity to set
  58638. */
  58639. setGravity(gravity: Vector3): void;
  58640. /**
  58641. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58642. * @param timeStep timestep to use in seconds
  58643. */
  58644. setTimeStep(timeStep: number): void;
  58645. /**
  58646. * 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)
  58647. * @param fixedTimeStep fixedTimeStep to use in seconds
  58648. */
  58649. setFixedTimeStep(fixedTimeStep: number): void;
  58650. /**
  58651. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58652. * @param maxSteps the maximum number of steps by the physics engine per frame
  58653. */
  58654. setMaxSteps(maxSteps: number): void;
  58655. /**
  58656. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58657. * @returns the current timestep in seconds
  58658. */
  58659. getTimeStep(): number;
  58660. /**
  58661. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58662. */
  58663. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58664. private _isImpostorInContact;
  58665. private _isImpostorPairInContact;
  58666. private _stepSimulation;
  58667. /**
  58668. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58669. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58670. * After the step the babylon meshes are set to the position of the physics imposters
  58671. * @param delta amount of time to step forward
  58672. * @param impostors array of imposters to update before/after the step
  58673. */
  58674. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58675. /**
  58676. * Update babylon mesh to match physics world object
  58677. * @param impostor imposter to match
  58678. */
  58679. private _afterSoftStep;
  58680. /**
  58681. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58682. * @param impostor imposter to match
  58683. */
  58684. private _ropeStep;
  58685. /**
  58686. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58687. * @param impostor imposter to match
  58688. */
  58689. private _softbodyOrClothStep;
  58690. private _tmpMatrix;
  58691. /**
  58692. * Applies an impulse on the imposter
  58693. * @param impostor imposter to apply impulse to
  58694. * @param force amount of force to be applied to the imposter
  58695. * @param contactPoint the location to apply the impulse on the imposter
  58696. */
  58697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58698. /**
  58699. * Applies a force on the imposter
  58700. * @param impostor imposter to apply force
  58701. * @param force amount of force to be applied to the imposter
  58702. * @param contactPoint the location to apply the force on the imposter
  58703. */
  58704. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58705. /**
  58706. * Creates a physics body using the plugin
  58707. * @param impostor the imposter to create the physics body on
  58708. */
  58709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58710. /**
  58711. * Removes the physics body from the imposter and disposes of the body's memory
  58712. * @param impostor imposter to remove the physics body from
  58713. */
  58714. removePhysicsBody(impostor: PhysicsImpostor): void;
  58715. /**
  58716. * Generates a joint
  58717. * @param impostorJoint the imposter joint to create the joint with
  58718. */
  58719. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58720. /**
  58721. * Removes a joint
  58722. * @param impostorJoint the imposter joint to remove the joint from
  58723. */
  58724. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58725. private _addMeshVerts;
  58726. /**
  58727. * Initialise the soft body vertices to match its object's (mesh) vertices
  58728. * Softbody vertices (nodes) are in world space and to match this
  58729. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58730. * @param impostor to create the softbody for
  58731. */
  58732. private _softVertexData;
  58733. /**
  58734. * Create an impostor's soft body
  58735. * @param impostor to create the softbody for
  58736. */
  58737. private _createSoftbody;
  58738. /**
  58739. * Create cloth for an impostor
  58740. * @param impostor to create the softbody for
  58741. */
  58742. private _createCloth;
  58743. /**
  58744. * Create rope for an impostor
  58745. * @param impostor to create the softbody for
  58746. */
  58747. private _createRope;
  58748. /**
  58749. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58750. * @param impostor to create the custom physics shape for
  58751. */
  58752. private _createCustom;
  58753. private _addHullVerts;
  58754. private _createShape;
  58755. /**
  58756. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58757. * @param impostor imposter containing the physics body and babylon object
  58758. */
  58759. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58760. /**
  58761. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58762. * @param impostor imposter containing the physics body and babylon object
  58763. * @param newPosition new position
  58764. * @param newRotation new rotation
  58765. */
  58766. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58767. /**
  58768. * If this plugin is supported
  58769. * @returns true if its supported
  58770. */
  58771. isSupported(): boolean;
  58772. /**
  58773. * Sets the linear velocity of the physics body
  58774. * @param impostor imposter to set the velocity on
  58775. * @param velocity velocity to set
  58776. */
  58777. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58778. /**
  58779. * Sets the angular velocity of the physics body
  58780. * @param impostor imposter to set the velocity on
  58781. * @param velocity velocity to set
  58782. */
  58783. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58784. /**
  58785. * gets the linear velocity
  58786. * @param impostor imposter to get linear velocity from
  58787. * @returns linear velocity
  58788. */
  58789. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58790. /**
  58791. * gets the angular velocity
  58792. * @param impostor imposter to get angular velocity from
  58793. * @returns angular velocity
  58794. */
  58795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58796. /**
  58797. * Sets the mass of physics body
  58798. * @param impostor imposter to set the mass on
  58799. * @param mass mass to set
  58800. */
  58801. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58802. /**
  58803. * Gets the mass of the physics body
  58804. * @param impostor imposter to get the mass from
  58805. * @returns mass
  58806. */
  58807. getBodyMass(impostor: PhysicsImpostor): number;
  58808. /**
  58809. * Gets friction of the impostor
  58810. * @param impostor impostor to get friction from
  58811. * @returns friction value
  58812. */
  58813. getBodyFriction(impostor: PhysicsImpostor): number;
  58814. /**
  58815. * Sets friction of the impostor
  58816. * @param impostor impostor to set friction on
  58817. * @param friction friction value
  58818. */
  58819. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58820. /**
  58821. * Gets restitution of the impostor
  58822. * @param impostor impostor to get restitution from
  58823. * @returns restitution value
  58824. */
  58825. getBodyRestitution(impostor: PhysicsImpostor): number;
  58826. /**
  58827. * Sets resitution of the impostor
  58828. * @param impostor impostor to set resitution on
  58829. * @param restitution resitution value
  58830. */
  58831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58832. /**
  58833. * Gets pressure inside the impostor
  58834. * @param impostor impostor to get pressure from
  58835. * @returns pressure value
  58836. */
  58837. getBodyPressure(impostor: PhysicsImpostor): number;
  58838. /**
  58839. * Sets pressure inside a soft body impostor
  58840. * Cloth and rope must remain 0 pressure
  58841. * @param impostor impostor to set pressure on
  58842. * @param pressure pressure value
  58843. */
  58844. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58845. /**
  58846. * Gets stiffness of the impostor
  58847. * @param impostor impostor to get stiffness from
  58848. * @returns pressure value
  58849. */
  58850. getBodyStiffness(impostor: PhysicsImpostor): number;
  58851. /**
  58852. * Sets stiffness of the impostor
  58853. * @param impostor impostor to set stiffness on
  58854. * @param stiffness stiffness value from 0 to 1
  58855. */
  58856. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58857. /**
  58858. * Gets velocityIterations of the impostor
  58859. * @param impostor impostor to get velocity iterations from
  58860. * @returns velocityIterations value
  58861. */
  58862. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58863. /**
  58864. * Sets velocityIterations of the impostor
  58865. * @param impostor impostor to set velocity iterations on
  58866. * @param velocityIterations velocityIterations value
  58867. */
  58868. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58869. /**
  58870. * Gets positionIterations of the impostor
  58871. * @param impostor impostor to get position iterations from
  58872. * @returns positionIterations value
  58873. */
  58874. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58875. /**
  58876. * Sets positionIterations of the impostor
  58877. * @param impostor impostor to set position on
  58878. * @param positionIterations positionIterations value
  58879. */
  58880. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58881. /**
  58882. * Append an anchor to a cloth object
  58883. * @param impostor is the cloth impostor to add anchor to
  58884. * @param otherImpostor is the rigid impostor to anchor to
  58885. * @param width ratio across width from 0 to 1
  58886. * @param height ratio up height from 0 to 1
  58887. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58888. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58889. */
  58890. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58891. /**
  58892. * Append an hook to a rope object
  58893. * @param impostor is the rope impostor to add hook to
  58894. * @param otherImpostor is the rigid impostor to hook to
  58895. * @param length ratio along the rope from 0 to 1
  58896. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58897. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58898. */
  58899. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58900. /**
  58901. * Sleeps the physics body and stops it from being active
  58902. * @param impostor impostor to sleep
  58903. */
  58904. sleepBody(impostor: PhysicsImpostor): void;
  58905. /**
  58906. * Activates the physics body
  58907. * @param impostor impostor to activate
  58908. */
  58909. wakeUpBody(impostor: PhysicsImpostor): void;
  58910. /**
  58911. * Updates the distance parameters of the joint
  58912. * @param joint joint to update
  58913. * @param maxDistance maximum distance of the joint
  58914. * @param minDistance minimum distance of the joint
  58915. */
  58916. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58917. /**
  58918. * Sets a motor on the joint
  58919. * @param joint joint to set motor on
  58920. * @param speed speed of the motor
  58921. * @param maxForce maximum force of the motor
  58922. * @param motorIndex index of the motor
  58923. */
  58924. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58925. /**
  58926. * Sets the motors limit
  58927. * @param joint joint to set limit on
  58928. * @param upperLimit upper limit
  58929. * @param lowerLimit lower limit
  58930. */
  58931. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58932. /**
  58933. * Syncs the position and rotation of a mesh with the impostor
  58934. * @param mesh mesh to sync
  58935. * @param impostor impostor to update the mesh with
  58936. */
  58937. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58938. /**
  58939. * Gets the radius of the impostor
  58940. * @param impostor impostor to get radius from
  58941. * @returns the radius
  58942. */
  58943. getRadius(impostor: PhysicsImpostor): number;
  58944. /**
  58945. * Gets the box size of the impostor
  58946. * @param impostor impostor to get box size from
  58947. * @param result the resulting box size
  58948. */
  58949. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58950. /**
  58951. * Disposes of the impostor
  58952. */
  58953. dispose(): void;
  58954. /**
  58955. * Does a raycast in the physics world
  58956. * @param from when should the ray start?
  58957. * @param to when should the ray end?
  58958. * @returns PhysicsRaycastResult
  58959. */
  58960. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58961. }
  58962. }
  58963. declare module "babylonjs/Probes/reflectionProbe" {
  58964. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58965. import { Vector3 } from "babylonjs/Maths/math.vector";
  58966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58967. import { Nullable } from "babylonjs/types";
  58968. import { Scene } from "babylonjs/scene";
  58969. module "babylonjs/abstractScene" {
  58970. interface AbstractScene {
  58971. /**
  58972. * The list of reflection probes added to the scene
  58973. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58974. */
  58975. reflectionProbes: Array<ReflectionProbe>;
  58976. /**
  58977. * Removes the given reflection probe from this scene.
  58978. * @param toRemove The reflection probe to remove
  58979. * @returns The index of the removed reflection probe
  58980. */
  58981. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58982. /**
  58983. * Adds the given reflection probe to this scene.
  58984. * @param newReflectionProbe The reflection probe to add
  58985. */
  58986. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58987. }
  58988. }
  58989. /**
  58990. * Class used to generate realtime reflection / refraction cube textures
  58991. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58992. */
  58993. export class ReflectionProbe {
  58994. /** defines the name of the probe */
  58995. name: string;
  58996. private _scene;
  58997. private _renderTargetTexture;
  58998. private _projectionMatrix;
  58999. private _viewMatrix;
  59000. private _target;
  59001. private _add;
  59002. private _attachedMesh;
  59003. private _invertYAxis;
  59004. /** Gets or sets probe position (center of the cube map) */
  59005. position: Vector3;
  59006. /**
  59007. * Creates a new reflection probe
  59008. * @param name defines the name of the probe
  59009. * @param size defines the texture resolution (for each face)
  59010. * @param scene defines the hosting scene
  59011. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59012. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59013. */
  59014. constructor(
  59015. /** defines the name of the probe */
  59016. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59017. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59018. get samples(): number;
  59019. set samples(value: number);
  59020. /** Gets or sets the refresh rate to use (on every frame by default) */
  59021. get refreshRate(): number;
  59022. set refreshRate(value: number);
  59023. /**
  59024. * Gets the hosting scene
  59025. * @returns a Scene
  59026. */
  59027. getScene(): Scene;
  59028. /** Gets the internal CubeTexture used to render to */
  59029. get cubeTexture(): RenderTargetTexture;
  59030. /** Gets the list of meshes to render */
  59031. get renderList(): Nullable<AbstractMesh[]>;
  59032. /**
  59033. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59034. * @param mesh defines the mesh to attach to
  59035. */
  59036. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59037. /**
  59038. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59039. * @param renderingGroupId The rendering group id corresponding to its index
  59040. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59041. */
  59042. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59043. /**
  59044. * Clean all associated resources
  59045. */
  59046. dispose(): void;
  59047. /**
  59048. * Converts the reflection probe information to a readable string for debug purpose.
  59049. * @param fullDetails Supports for multiple levels of logging within scene loading
  59050. * @returns the human readable reflection probe info
  59051. */
  59052. toString(fullDetails?: boolean): string;
  59053. /**
  59054. * Get the class name of the relfection probe.
  59055. * @returns "ReflectionProbe"
  59056. */
  59057. getClassName(): string;
  59058. /**
  59059. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59060. * @returns The JSON representation of the texture
  59061. */
  59062. serialize(): any;
  59063. /**
  59064. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59065. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59066. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59067. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59068. * @returns The parsed reflection probe if successful
  59069. */
  59070. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59071. }
  59072. }
  59073. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  59074. /** @hidden */
  59075. export var _BabylonLoaderRegistered: boolean;
  59076. /**
  59077. * Helps setting up some configuration for the babylon file loader.
  59078. */
  59079. export class BabylonFileLoaderConfiguration {
  59080. /**
  59081. * The loader does not allow injecting custom physix engine into the plugins.
  59082. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59083. * So you could set this variable to your engine import to make it work.
  59084. */
  59085. static LoaderInjectedPhysicsEngine: any;
  59086. }
  59087. }
  59088. declare module "babylonjs/Loading/Plugins/index" {
  59089. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  59090. }
  59091. declare module "babylonjs/Loading/index" {
  59092. export * from "babylonjs/Loading/loadingScreen";
  59093. export * from "babylonjs/Loading/Plugins/index";
  59094. export * from "babylonjs/Loading/sceneLoader";
  59095. export * from "babylonjs/Loading/sceneLoaderFlags";
  59096. }
  59097. declare module "babylonjs/Materials/Background/index" {
  59098. export * from "babylonjs/Materials/Background/backgroundMaterial";
  59099. }
  59100. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  59101. import { Scene } from "babylonjs/scene";
  59102. import { Color3 } from "babylonjs/Maths/math.color";
  59103. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59105. /**
  59106. * The Physically based simple base material of BJS.
  59107. *
  59108. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59109. * It is used as the base class for both the specGloss and metalRough conventions.
  59110. */
  59111. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59112. /**
  59113. * Number of Simultaneous lights allowed on the material.
  59114. */
  59115. maxSimultaneousLights: number;
  59116. /**
  59117. * If sets to true, disables all the lights affecting the material.
  59118. */
  59119. disableLighting: boolean;
  59120. /**
  59121. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59122. */
  59123. environmentTexture: BaseTexture;
  59124. /**
  59125. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59126. */
  59127. invertNormalMapX: boolean;
  59128. /**
  59129. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59130. */
  59131. invertNormalMapY: boolean;
  59132. /**
  59133. * Normal map used in the model.
  59134. */
  59135. normalTexture: BaseTexture;
  59136. /**
  59137. * Emissivie color used to self-illuminate the model.
  59138. */
  59139. emissiveColor: Color3;
  59140. /**
  59141. * Emissivie texture used to self-illuminate the model.
  59142. */
  59143. emissiveTexture: BaseTexture;
  59144. /**
  59145. * Occlusion Channel Strenght.
  59146. */
  59147. occlusionStrength: number;
  59148. /**
  59149. * Occlusion Texture of the material (adding extra occlusion effects).
  59150. */
  59151. occlusionTexture: BaseTexture;
  59152. /**
  59153. * Defines the alpha limits in alpha test mode.
  59154. */
  59155. alphaCutOff: number;
  59156. /**
  59157. * Gets the current double sided mode.
  59158. */
  59159. get doubleSided(): boolean;
  59160. /**
  59161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59162. */
  59163. set doubleSided(value: boolean);
  59164. /**
  59165. * Stores the pre-calculated light information of a mesh in a texture.
  59166. */
  59167. lightmapTexture: BaseTexture;
  59168. /**
  59169. * If true, the light map contains occlusion information instead of lighting info.
  59170. */
  59171. useLightmapAsShadowmap: boolean;
  59172. /**
  59173. * Instantiates a new PBRMaterial instance.
  59174. *
  59175. * @param name The material name
  59176. * @param scene The scene the material will be use in.
  59177. */
  59178. constructor(name: string, scene: Scene);
  59179. getClassName(): string;
  59180. }
  59181. }
  59182. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  59183. import { Scene } from "babylonjs/scene";
  59184. import { Color3 } from "babylonjs/Maths/math.color";
  59185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59186. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59187. /**
  59188. * The PBR material of BJS following the metal roughness convention.
  59189. *
  59190. * This fits to the PBR convention in the GLTF definition:
  59191. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59192. */
  59193. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59194. /**
  59195. * The base color has two different interpretations depending on the value of metalness.
  59196. * When the material is a metal, the base color is the specific measured reflectance value
  59197. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59198. * of the material.
  59199. */
  59200. baseColor: Color3;
  59201. /**
  59202. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59203. * well as opacity information in the alpha channel.
  59204. */
  59205. baseTexture: BaseTexture;
  59206. /**
  59207. * Specifies the metallic scalar value of the material.
  59208. * Can also be used to scale the metalness values of the metallic texture.
  59209. */
  59210. metallic: number;
  59211. /**
  59212. * Specifies the roughness scalar value of the material.
  59213. * Can also be used to scale the roughness values of the metallic texture.
  59214. */
  59215. roughness: number;
  59216. /**
  59217. * Texture containing both the metallic value in the B channel and the
  59218. * roughness value in the G channel to keep better precision.
  59219. */
  59220. metallicRoughnessTexture: BaseTexture;
  59221. /**
  59222. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59223. *
  59224. * @param name The material name
  59225. * @param scene The scene the material will be use in.
  59226. */
  59227. constructor(name: string, scene: Scene);
  59228. /**
  59229. * Return the currrent class name of the material.
  59230. */
  59231. getClassName(): string;
  59232. /**
  59233. * Makes a duplicate of the current material.
  59234. * @param name - name to use for the new material.
  59235. */
  59236. clone(name: string): PBRMetallicRoughnessMaterial;
  59237. /**
  59238. * Serialize the material to a parsable JSON object.
  59239. */
  59240. serialize(): any;
  59241. /**
  59242. * Parses a JSON object correponding to the serialize function.
  59243. */
  59244. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59245. }
  59246. }
  59247. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59248. import { Scene } from "babylonjs/scene";
  59249. import { Color3 } from "babylonjs/Maths/math.color";
  59250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59251. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59252. /**
  59253. * The PBR material of BJS following the specular glossiness convention.
  59254. *
  59255. * This fits to the PBR convention in the GLTF definition:
  59256. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59257. */
  59258. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59259. /**
  59260. * Specifies the diffuse color of the material.
  59261. */
  59262. diffuseColor: Color3;
  59263. /**
  59264. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59265. * channel.
  59266. */
  59267. diffuseTexture: BaseTexture;
  59268. /**
  59269. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59270. */
  59271. specularColor: Color3;
  59272. /**
  59273. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59274. */
  59275. glossiness: number;
  59276. /**
  59277. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59278. */
  59279. specularGlossinessTexture: BaseTexture;
  59280. /**
  59281. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59282. *
  59283. * @param name The material name
  59284. * @param scene The scene the material will be use in.
  59285. */
  59286. constructor(name: string, scene: Scene);
  59287. /**
  59288. * Return the currrent class name of the material.
  59289. */
  59290. getClassName(): string;
  59291. /**
  59292. * Makes a duplicate of the current material.
  59293. * @param name - name to use for the new material.
  59294. */
  59295. clone(name: string): PBRSpecularGlossinessMaterial;
  59296. /**
  59297. * Serialize the material to a parsable JSON object.
  59298. */
  59299. serialize(): any;
  59300. /**
  59301. * Parses a JSON object correponding to the serialize function.
  59302. */
  59303. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59304. }
  59305. }
  59306. declare module "babylonjs/Materials/PBR/index" {
  59307. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59308. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59309. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59310. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59311. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59312. }
  59313. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59314. import { Nullable } from "babylonjs/types";
  59315. import { Scene } from "babylonjs/scene";
  59316. import { Matrix } from "babylonjs/Maths/math.vector";
  59317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59318. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59319. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59320. /**
  59321. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59322. * It can help converting any input color in a desired output one. This can then be used to create effects
  59323. * from sepia, black and white to sixties or futuristic rendering...
  59324. *
  59325. * The only supported format is currently 3dl.
  59326. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59327. */
  59328. export class ColorGradingTexture extends BaseTexture {
  59329. /**
  59330. * The texture URL.
  59331. */
  59332. url: string;
  59333. /**
  59334. * Empty line regex stored for GC.
  59335. */
  59336. private static _noneEmptyLineRegex;
  59337. private _textureMatrix;
  59338. private _onLoad;
  59339. /**
  59340. * Instantiates a ColorGradingTexture from the following parameters.
  59341. *
  59342. * @param url The location of the color gradind data (currently only supporting 3dl)
  59343. * @param sceneOrEngine The scene or engine the texture will be used in
  59344. * @param onLoad defines a callback triggered when the texture has been loaded
  59345. */
  59346. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59347. /**
  59348. * Fires the onload event from the constructor if requested.
  59349. */
  59350. private _triggerOnLoad;
  59351. /**
  59352. * Returns the texture matrix used in most of the material.
  59353. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59354. */
  59355. getTextureMatrix(): Matrix;
  59356. /**
  59357. * Occurs when the file being loaded is a .3dl LUT file.
  59358. */
  59359. private load3dlTexture;
  59360. /**
  59361. * Starts the loading process of the texture.
  59362. */
  59363. private loadTexture;
  59364. /**
  59365. * Clones the color gradind texture.
  59366. */
  59367. clone(): ColorGradingTexture;
  59368. /**
  59369. * Called during delayed load for textures.
  59370. */
  59371. delayLoad(): void;
  59372. /**
  59373. * Parses a color grading texture serialized by Babylon.
  59374. * @param parsedTexture The texture information being parsedTexture
  59375. * @param scene The scene to load the texture in
  59376. * @param rootUrl The root url of the data assets to load
  59377. * @return A color gradind texture
  59378. */
  59379. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59380. /**
  59381. * Serializes the LUT texture to json format.
  59382. */
  59383. serialize(): any;
  59384. }
  59385. }
  59386. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59388. import { Scene } from "babylonjs/scene";
  59389. import { Nullable } from "babylonjs/types";
  59390. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59391. /**
  59392. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59393. */
  59394. export class EquiRectangularCubeTexture extends BaseTexture {
  59395. /** The six faces of the cube. */
  59396. private static _FacesMapping;
  59397. private _noMipmap;
  59398. private _onLoad;
  59399. private _onError;
  59400. /** The size of the cubemap. */
  59401. private _size;
  59402. /** The buffer of the image. */
  59403. private _buffer;
  59404. /** The width of the input image. */
  59405. private _width;
  59406. /** The height of the input image. */
  59407. private _height;
  59408. /** The URL to the image. */
  59409. url: string;
  59410. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59411. coordinatesMode: number;
  59412. /**
  59413. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59414. * @param url The location of the image
  59415. * @param scene The scene the texture will be used in
  59416. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59417. * @param noMipmap Forces to not generate the mipmap if true
  59418. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59419. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59420. * @param onLoad — defines a callback called when texture is loaded
  59421. * @param onError — defines a callback called if there is an error
  59422. */
  59423. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59424. /**
  59425. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59426. */
  59427. private loadImage;
  59428. /**
  59429. * Convert the image buffer into a cubemap and create a CubeTexture.
  59430. */
  59431. private loadTexture;
  59432. /**
  59433. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59434. * @param buffer The ArrayBuffer that should be converted.
  59435. * @returns The buffer as Float32Array.
  59436. */
  59437. private getFloat32ArrayFromArrayBuffer;
  59438. /**
  59439. * Get the current class name of the texture useful for serialization or dynamic coding.
  59440. * @returns "EquiRectangularCubeTexture"
  59441. */
  59442. getClassName(): string;
  59443. /**
  59444. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59445. * @returns A clone of the current EquiRectangularCubeTexture.
  59446. */
  59447. clone(): EquiRectangularCubeTexture;
  59448. }
  59449. }
  59450. declare module "babylonjs/Misc/tga" {
  59451. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59452. /**
  59453. * Based on jsTGALoader - Javascript loader for TGA file
  59454. * By Vincent Thibault
  59455. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59456. */
  59457. export class TGATools {
  59458. private static _TYPE_INDEXED;
  59459. private static _TYPE_RGB;
  59460. private static _TYPE_GREY;
  59461. private static _TYPE_RLE_INDEXED;
  59462. private static _TYPE_RLE_RGB;
  59463. private static _TYPE_RLE_GREY;
  59464. private static _ORIGIN_MASK;
  59465. private static _ORIGIN_SHIFT;
  59466. private static _ORIGIN_BL;
  59467. private static _ORIGIN_BR;
  59468. private static _ORIGIN_UL;
  59469. private static _ORIGIN_UR;
  59470. /**
  59471. * Gets the header of a TGA file
  59472. * @param data defines the TGA data
  59473. * @returns the header
  59474. */
  59475. static GetTGAHeader(data: Uint8Array): any;
  59476. /**
  59477. * Uploads TGA content to a Babylon Texture
  59478. * @hidden
  59479. */
  59480. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59481. /** @hidden */
  59482. 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;
  59483. /** @hidden */
  59484. 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;
  59485. /** @hidden */
  59486. 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;
  59487. /** @hidden */
  59488. 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;
  59489. /** @hidden */
  59490. 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;
  59491. /** @hidden */
  59492. 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;
  59493. }
  59494. }
  59495. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59496. import { Nullable } from "babylonjs/types";
  59497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59498. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59499. /**
  59500. * Implementation of the TGA Texture Loader.
  59501. * @hidden
  59502. */
  59503. export class _TGATextureLoader implements IInternalTextureLoader {
  59504. /**
  59505. * Defines wether the loader supports cascade loading the different faces.
  59506. */
  59507. readonly supportCascades: boolean;
  59508. /**
  59509. * This returns if the loader support the current file information.
  59510. * @param extension defines the file extension of the file being loaded
  59511. * @returns true if the loader can load the specified file
  59512. */
  59513. canLoad(extension: string): boolean;
  59514. /**
  59515. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59516. * @param data contains the texture data
  59517. * @param texture defines the BabylonJS internal texture
  59518. * @param createPolynomials will be true if polynomials have been requested
  59519. * @param onLoad defines the callback to trigger once the texture is ready
  59520. * @param onError defines the callback to trigger in case of error
  59521. */
  59522. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59523. /**
  59524. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59525. * @param data contains the texture data
  59526. * @param texture defines the BabylonJS internal texture
  59527. * @param callback defines the method to call once ready to upload
  59528. */
  59529. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59530. }
  59531. }
  59532. declare module "babylonjs/Misc/basis" {
  59533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59534. /**
  59535. * Info about the .basis files
  59536. */
  59537. class BasisFileInfo {
  59538. /**
  59539. * If the file has alpha
  59540. */
  59541. hasAlpha: boolean;
  59542. /**
  59543. * Info about each image of the basis file
  59544. */
  59545. images: Array<{
  59546. levels: Array<{
  59547. width: number;
  59548. height: number;
  59549. transcodedPixels: ArrayBufferView;
  59550. }>;
  59551. }>;
  59552. }
  59553. /**
  59554. * Result of transcoding a basis file
  59555. */
  59556. class TranscodeResult {
  59557. /**
  59558. * Info about the .basis file
  59559. */
  59560. fileInfo: BasisFileInfo;
  59561. /**
  59562. * Format to use when loading the file
  59563. */
  59564. format: number;
  59565. }
  59566. /**
  59567. * Configuration options for the Basis transcoder
  59568. */
  59569. export class BasisTranscodeConfiguration {
  59570. /**
  59571. * Supported compression formats used to determine the supported output format of the transcoder
  59572. */
  59573. supportedCompressionFormats?: {
  59574. /**
  59575. * etc1 compression format
  59576. */
  59577. etc1?: boolean;
  59578. /**
  59579. * s3tc compression format
  59580. */
  59581. s3tc?: boolean;
  59582. /**
  59583. * pvrtc compression format
  59584. */
  59585. pvrtc?: boolean;
  59586. /**
  59587. * etc2 compression format
  59588. */
  59589. etc2?: boolean;
  59590. };
  59591. /**
  59592. * If mipmap levels should be loaded for transcoded images (Default: true)
  59593. */
  59594. loadMipmapLevels?: boolean;
  59595. /**
  59596. * Index of a single image to load (Default: all images)
  59597. */
  59598. loadSingleImage?: number;
  59599. }
  59600. /**
  59601. * Used to load .Basis files
  59602. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59603. */
  59604. export class BasisTools {
  59605. private static _IgnoreSupportedFormats;
  59606. /**
  59607. * URL to use when loading the basis transcoder
  59608. */
  59609. static JSModuleURL: string;
  59610. /**
  59611. * URL to use when loading the wasm module for the transcoder
  59612. */
  59613. static WasmModuleURL: string;
  59614. /**
  59615. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59616. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59617. * @returns internal format corresponding to the Basis format
  59618. */
  59619. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59620. private static _WorkerPromise;
  59621. private static _Worker;
  59622. private static _actionId;
  59623. private static _CreateWorkerAsync;
  59624. /**
  59625. * Transcodes a loaded image file to compressed pixel data
  59626. * @param data image data to transcode
  59627. * @param config configuration options for the transcoding
  59628. * @returns a promise resulting in the transcoded image
  59629. */
  59630. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59631. /**
  59632. * Loads a texture from the transcode result
  59633. * @param texture texture load to
  59634. * @param transcodeResult the result of transcoding the basis file to load from
  59635. */
  59636. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59637. }
  59638. }
  59639. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59640. import { Nullable } from "babylonjs/types";
  59641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59642. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59643. /**
  59644. * Loader for .basis file format
  59645. */
  59646. export class _BasisTextureLoader implements IInternalTextureLoader {
  59647. /**
  59648. * Defines whether the loader supports cascade loading the different faces.
  59649. */
  59650. readonly supportCascades: boolean;
  59651. /**
  59652. * This returns if the loader support the current file information.
  59653. * @param extension defines the file extension of the file being loaded
  59654. * @returns true if the loader can load the specified file
  59655. */
  59656. canLoad(extension: string): boolean;
  59657. /**
  59658. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59659. * @param data contains the texture data
  59660. * @param texture defines the BabylonJS internal texture
  59661. * @param createPolynomials will be true if polynomials have been requested
  59662. * @param onLoad defines the callback to trigger once the texture is ready
  59663. * @param onError defines the callback to trigger in case of error
  59664. */
  59665. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59666. /**
  59667. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59668. * @param data contains the texture data
  59669. * @param texture defines the BabylonJS internal texture
  59670. * @param callback defines the method to call once ready to upload
  59671. */
  59672. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59673. }
  59674. }
  59675. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59676. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59677. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59678. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59679. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59680. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59681. }
  59682. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59683. import { Scene } from "babylonjs/scene";
  59684. import { Texture } from "babylonjs/Materials/Textures/texture";
  59685. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59686. /**
  59687. * 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.
  59688. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59689. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59690. */
  59691. export class CustomProceduralTexture extends ProceduralTexture {
  59692. private _animate;
  59693. private _time;
  59694. private _config;
  59695. private _texturePath;
  59696. /**
  59697. * Instantiates a new Custom Procedural Texture.
  59698. * 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.
  59699. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59700. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59701. * @param name Define the name of the texture
  59702. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59703. * @param size Define the size of the texture to create
  59704. * @param scene Define the scene the texture belongs to
  59705. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59706. * @param generateMipMaps Define if the texture should creates mip maps or not
  59707. */
  59708. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59709. private _loadJson;
  59710. /**
  59711. * Is the texture ready to be used ? (rendered at least once)
  59712. * @returns true if ready, otherwise, false.
  59713. */
  59714. isReady(): boolean;
  59715. /**
  59716. * Render the texture to its associated render target.
  59717. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59718. */
  59719. render(useCameraPostProcess?: boolean): void;
  59720. /**
  59721. * Update the list of dependant textures samplers in the shader.
  59722. */
  59723. updateTextures(): void;
  59724. /**
  59725. * Update the uniform values of the procedural texture in the shader.
  59726. */
  59727. updateShaderUniforms(): void;
  59728. /**
  59729. * Define if the texture animates or not.
  59730. */
  59731. get animate(): boolean;
  59732. set animate(value: boolean);
  59733. }
  59734. }
  59735. declare module "babylonjs/Shaders/noise.fragment" {
  59736. /** @hidden */
  59737. export var noisePixelShader: {
  59738. name: string;
  59739. shader: string;
  59740. };
  59741. }
  59742. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59743. import { Nullable } from "babylonjs/types";
  59744. import { Scene } from "babylonjs/scene";
  59745. import { Texture } from "babylonjs/Materials/Textures/texture";
  59746. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59747. import "babylonjs/Shaders/noise.fragment";
  59748. /**
  59749. * Class used to generate noise procedural textures
  59750. */
  59751. export class NoiseProceduralTexture extends ProceduralTexture {
  59752. private _time;
  59753. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59754. brightness: number;
  59755. /** Defines the number of octaves to process */
  59756. octaves: number;
  59757. /** Defines the level of persistence (0.8 by default) */
  59758. persistence: number;
  59759. /** Gets or sets animation speed factor (default is 1) */
  59760. animationSpeedFactor: number;
  59761. /**
  59762. * Creates a new NoiseProceduralTexture
  59763. * @param name defines the name fo the texture
  59764. * @param size defines the size of the texture (default is 256)
  59765. * @param scene defines the hosting scene
  59766. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59767. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59768. */
  59769. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59770. private _updateShaderUniforms;
  59771. protected _getDefines(): string;
  59772. /** Generate the current state of the procedural texture */
  59773. render(useCameraPostProcess?: boolean): void;
  59774. /**
  59775. * Serializes this noise procedural texture
  59776. * @returns a serialized noise procedural texture object
  59777. */
  59778. serialize(): any;
  59779. /**
  59780. * Clone the texture.
  59781. * @returns the cloned texture
  59782. */
  59783. clone(): NoiseProceduralTexture;
  59784. /**
  59785. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59786. * @param parsedTexture defines parsed texture data
  59787. * @param scene defines the current scene
  59788. * @param rootUrl defines the root URL containing noise procedural texture information
  59789. * @returns a parsed NoiseProceduralTexture
  59790. */
  59791. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59792. }
  59793. }
  59794. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59795. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59796. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59797. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59798. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59799. }
  59800. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59801. import { Nullable } from "babylonjs/types";
  59802. import { Scene } from "babylonjs/scene";
  59803. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59804. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59805. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59806. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59807. /**
  59808. * Raw cube texture where the raw buffers are passed in
  59809. */
  59810. export class RawCubeTexture extends CubeTexture {
  59811. /**
  59812. * Creates a cube texture where the raw buffers are passed in.
  59813. * @param scene defines the scene the texture is attached to
  59814. * @param data defines the array of data to use to create each face
  59815. * @param size defines the size of the textures
  59816. * @param format defines the format of the data
  59817. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59818. * @param generateMipMaps defines if the engine should generate the mip levels
  59819. * @param invertY defines if data must be stored with Y axis inverted
  59820. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59821. * @param compression defines the compression used (null by default)
  59822. */
  59823. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59824. /**
  59825. * Updates the raw cube texture.
  59826. * @param data defines the data to store
  59827. * @param format defines the data format
  59828. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59829. * @param invertY defines if data must be stored with Y axis inverted
  59830. * @param compression defines the compression used (null by default)
  59831. * @param level defines which level of the texture to update
  59832. */
  59833. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59834. /**
  59835. * Updates a raw cube texture with RGBD encoded data.
  59836. * @param data defines the array of data [mipmap][face] to use to create each face
  59837. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59838. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59839. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59840. * @returns a promsie that resolves when the operation is complete
  59841. */
  59842. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59843. /**
  59844. * Clones the raw cube texture.
  59845. * @return a new cube texture
  59846. */
  59847. clone(): CubeTexture;
  59848. /** @hidden */
  59849. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59850. }
  59851. }
  59852. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59853. import { Scene } from "babylonjs/scene";
  59854. import { Texture } from "babylonjs/Materials/Textures/texture";
  59855. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59856. /**
  59857. * Class used to store 3D textures containing user data
  59858. */
  59859. export class RawTexture3D extends Texture {
  59860. /** Gets or sets the texture format to use */
  59861. format: number;
  59862. /**
  59863. * Create a new RawTexture3D
  59864. * @param data defines the data of the texture
  59865. * @param width defines the width of the texture
  59866. * @param height defines the height of the texture
  59867. * @param depth defines the depth of the texture
  59868. * @param format defines the texture format to use
  59869. * @param scene defines the hosting scene
  59870. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59871. * @param invertY defines if texture must be stored with Y axis inverted
  59872. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59873. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59874. */
  59875. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59876. /** Gets or sets the texture format to use */
  59877. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59878. /**
  59879. * Update the texture with new data
  59880. * @param data defines the data to store in the texture
  59881. */
  59882. update(data: ArrayBufferView): void;
  59883. }
  59884. }
  59885. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59886. import { Scene } from "babylonjs/scene";
  59887. import { Texture } from "babylonjs/Materials/Textures/texture";
  59888. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59889. /**
  59890. * Class used to store 2D array textures containing user data
  59891. */
  59892. export class RawTexture2DArray extends Texture {
  59893. /** Gets or sets the texture format to use */
  59894. format: number;
  59895. /**
  59896. * Create a new RawTexture2DArray
  59897. * @param data defines the data of the texture
  59898. * @param width defines the width of the texture
  59899. * @param height defines the height of the texture
  59900. * @param depth defines the number of layers of the texture
  59901. * @param format defines the texture format to use
  59902. * @param scene defines the hosting scene
  59903. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59904. * @param invertY defines if texture must be stored with Y axis inverted
  59905. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59906. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59907. */
  59908. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59909. /** Gets or sets the texture format to use */
  59910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59911. /**
  59912. * Update the texture with new data
  59913. * @param data defines the data to store in the texture
  59914. */
  59915. update(data: ArrayBufferView): void;
  59916. }
  59917. }
  59918. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59919. import { Scene } from "babylonjs/scene";
  59920. import { Plane } from "babylonjs/Maths/math.plane";
  59921. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59922. /**
  59923. * Creates a refraction texture used by refraction channel of the standard material.
  59924. * It is like a mirror but to see through a material.
  59925. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59926. */
  59927. export class RefractionTexture extends RenderTargetTexture {
  59928. /**
  59929. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59930. * 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.
  59931. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59932. */
  59933. refractionPlane: Plane;
  59934. /**
  59935. * Define how deep under the surface we should see.
  59936. */
  59937. depth: number;
  59938. /**
  59939. * Creates a refraction texture used by refraction channel of the standard material.
  59940. * It is like a mirror but to see through a material.
  59941. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59942. * @param name Define the texture name
  59943. * @param size Define the size of the underlying texture
  59944. * @param scene Define the scene the refraction belongs to
  59945. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59946. */
  59947. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59948. /**
  59949. * Clone the refraction texture.
  59950. * @returns the cloned texture
  59951. */
  59952. clone(): RefractionTexture;
  59953. /**
  59954. * Serialize the texture to a JSON representation you could use in Parse later on
  59955. * @returns the serialized JSON representation
  59956. */
  59957. serialize(): any;
  59958. }
  59959. }
  59960. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59961. import { Nullable } from "babylonjs/types";
  59962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59963. import { Matrix } from "babylonjs/Maths/math.vector";
  59964. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59965. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59966. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59967. import { Scene } from "babylonjs/scene";
  59968. /**
  59969. * Defines the options related to the creation of an HtmlElementTexture
  59970. */
  59971. export interface IHtmlElementTextureOptions {
  59972. /**
  59973. * Defines wether mip maps should be created or not.
  59974. */
  59975. generateMipMaps?: boolean;
  59976. /**
  59977. * Defines the sampling mode of the texture.
  59978. */
  59979. samplingMode?: number;
  59980. /**
  59981. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59982. */
  59983. engine: Nullable<ThinEngine>;
  59984. /**
  59985. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59986. */
  59987. scene: Nullable<Scene>;
  59988. }
  59989. /**
  59990. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59991. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59992. * is automatically managed.
  59993. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59994. * in your application.
  59995. *
  59996. * As the update is not automatic, you need to call them manually.
  59997. */
  59998. export class HtmlElementTexture extends BaseTexture {
  59999. /**
  60000. * The texture URL.
  60001. */
  60002. element: HTMLVideoElement | HTMLCanvasElement;
  60003. private static readonly DefaultOptions;
  60004. private _textureMatrix;
  60005. private _isVideo;
  60006. private _generateMipMaps;
  60007. private _samplingMode;
  60008. /**
  60009. * Instantiates a HtmlElementTexture from the following parameters.
  60010. *
  60011. * @param name Defines the name of the texture
  60012. * @param element Defines the video or canvas the texture is filled with
  60013. * @param options Defines the other none mandatory texture creation options
  60014. */
  60015. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60016. private _createInternalTexture;
  60017. /**
  60018. * Returns the texture matrix used in most of the material.
  60019. */
  60020. getTextureMatrix(): Matrix;
  60021. /**
  60022. * Updates the content of the texture.
  60023. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60024. */
  60025. update(invertY?: Nullable<boolean>): void;
  60026. }
  60027. }
  60028. declare module "babylonjs/Materials/Textures/Packer/frame" {
  60029. import { Vector2 } from "babylonjs/Maths/math.vector";
  60030. /**
  60031. * Defines the basic options interface of a TexturePacker Frame
  60032. */
  60033. export interface ITexturePackerFrame {
  60034. /**
  60035. * The frame ID
  60036. */
  60037. id: number;
  60038. /**
  60039. * The frames Scale
  60040. */
  60041. scale: Vector2;
  60042. /**
  60043. * The Frames offset
  60044. */
  60045. offset: Vector2;
  60046. }
  60047. /**
  60048. * This is a support class for frame Data on texture packer sets.
  60049. */
  60050. export class TexturePackerFrame implements ITexturePackerFrame {
  60051. /**
  60052. * The frame ID
  60053. */
  60054. id: number;
  60055. /**
  60056. * The frames Scale
  60057. */
  60058. scale: Vector2;
  60059. /**
  60060. * The Frames offset
  60061. */
  60062. offset: Vector2;
  60063. /**
  60064. * Initializes a texture package frame.
  60065. * @param id The numerical frame identifier
  60066. * @param scale Scalar Vector2 for UV frame
  60067. * @param offset Vector2 for the frame position in UV units.
  60068. * @returns TexturePackerFrame
  60069. */
  60070. constructor(id: number, scale: Vector2, offset: Vector2);
  60071. }
  60072. }
  60073. declare module "babylonjs/Materials/Textures/Packer/packer" {
  60074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60075. import { Scene } from "babylonjs/scene";
  60076. import { Nullable } from "babylonjs/types";
  60077. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  60078. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  60079. /**
  60080. * Defines the basic options interface of a TexturePacker
  60081. */
  60082. export interface ITexturePackerOptions {
  60083. /**
  60084. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60085. */
  60086. map?: string[];
  60087. /**
  60088. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60089. */
  60090. uvsIn?: string;
  60091. /**
  60092. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60093. */
  60094. uvsOut?: string;
  60095. /**
  60096. * number representing the layout style. Defaults to LAYOUT_STRIP
  60097. */
  60098. layout?: number;
  60099. /**
  60100. * number of columns if using custom column count layout(2). This defaults to 4.
  60101. */
  60102. colnum?: number;
  60103. /**
  60104. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60105. */
  60106. updateInputMeshes?: boolean;
  60107. /**
  60108. * boolean flag to dispose all the source textures. Defaults to true.
  60109. */
  60110. disposeSources?: boolean;
  60111. /**
  60112. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60113. */
  60114. fillBlanks?: boolean;
  60115. /**
  60116. * string value representing the context fill style color. Defaults to 'black'.
  60117. */
  60118. customFillColor?: string;
  60119. /**
  60120. * Width and Height Value of each Frame in the TexturePacker Sets
  60121. */
  60122. frameSize?: number;
  60123. /**
  60124. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60125. */
  60126. paddingRatio?: number;
  60127. /**
  60128. * Number that declares the fill method for the padding gutter.
  60129. */
  60130. paddingMode?: number;
  60131. /**
  60132. * If in SUBUV_COLOR padding mode what color to use.
  60133. */
  60134. paddingColor?: Color3 | Color4;
  60135. }
  60136. /**
  60137. * Defines the basic interface of a TexturePacker JSON File
  60138. */
  60139. export interface ITexturePackerJSON {
  60140. /**
  60141. * The frame ID
  60142. */
  60143. name: string;
  60144. /**
  60145. * The base64 channel data
  60146. */
  60147. sets: any;
  60148. /**
  60149. * The options of the Packer
  60150. */
  60151. options: ITexturePackerOptions;
  60152. /**
  60153. * The frame data of the Packer
  60154. */
  60155. frames: Array<number>;
  60156. }
  60157. /**
  60158. * This is a support class that generates a series of packed texture sets.
  60159. * @see https://doc.babylonjs.com/babylon101/materials
  60160. */
  60161. export class TexturePacker {
  60162. /** Packer Layout Constant 0 */
  60163. static readonly LAYOUT_STRIP: number;
  60164. /** Packer Layout Constant 1 */
  60165. static readonly LAYOUT_POWER2: number;
  60166. /** Packer Layout Constant 2 */
  60167. static readonly LAYOUT_COLNUM: number;
  60168. /** Packer Layout Constant 0 */
  60169. static readonly SUBUV_WRAP: number;
  60170. /** Packer Layout Constant 1 */
  60171. static readonly SUBUV_EXTEND: number;
  60172. /** Packer Layout Constant 2 */
  60173. static readonly SUBUV_COLOR: number;
  60174. /** The Name of the Texture Package */
  60175. name: string;
  60176. /** The scene scope of the TexturePacker */
  60177. scene: Scene;
  60178. /** The Meshes to target */
  60179. meshes: AbstractMesh[];
  60180. /** Arguments passed with the Constructor */
  60181. options: ITexturePackerOptions;
  60182. /** The promise that is started upon initialization */
  60183. promise: Nullable<Promise<TexturePacker | string>>;
  60184. /** The Container object for the channel sets that are generated */
  60185. sets: object;
  60186. /** The Container array for the frames that are generated */
  60187. frames: TexturePackerFrame[];
  60188. /** The expected number of textures the system is parsing. */
  60189. private _expecting;
  60190. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60191. private _paddingValue;
  60192. /**
  60193. * Initializes a texture package series from an array of meshes or a single mesh.
  60194. * @param name The name of the package
  60195. * @param meshes The target meshes to compose the package from
  60196. * @param options The arguments that texture packer should follow while building.
  60197. * @param scene The scene which the textures are scoped to.
  60198. * @returns TexturePacker
  60199. */
  60200. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60201. /**
  60202. * Starts the package process
  60203. * @param resolve The promises resolution function
  60204. * @returns TexturePacker
  60205. */
  60206. private _createFrames;
  60207. /**
  60208. * Calculates the Size of the Channel Sets
  60209. * @returns Vector2
  60210. */
  60211. private _calculateSize;
  60212. /**
  60213. * Calculates the UV data for the frames.
  60214. * @param baseSize the base frameSize
  60215. * @param padding the base frame padding
  60216. * @param dtSize size of the Dynamic Texture for that channel
  60217. * @param dtUnits is 1/dtSize
  60218. * @param update flag to update the input meshes
  60219. */
  60220. private _calculateMeshUVFrames;
  60221. /**
  60222. * Calculates the frames Offset.
  60223. * @param index of the frame
  60224. * @returns Vector2
  60225. */
  60226. private _getFrameOffset;
  60227. /**
  60228. * Updates a Mesh to the frame data
  60229. * @param mesh that is the target
  60230. * @param frameID or the frame index
  60231. */
  60232. private _updateMeshUV;
  60233. /**
  60234. * Updates a Meshes materials to use the texture packer channels
  60235. * @param m is the mesh to target
  60236. * @param force all channels on the packer to be set.
  60237. */
  60238. private _updateTextureReferences;
  60239. /**
  60240. * Public method to set a Mesh to a frame
  60241. * @param m that is the target
  60242. * @param frameID or the frame index
  60243. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60244. */
  60245. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60246. /**
  60247. * Starts the async promise to compile the texture packer.
  60248. * @returns Promise<void>
  60249. */
  60250. processAsync(): Promise<void>;
  60251. /**
  60252. * Disposes all textures associated with this packer
  60253. */
  60254. dispose(): void;
  60255. /**
  60256. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60257. * @param imageType is the image type to use.
  60258. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60259. */
  60260. download(imageType?: string, quality?: number): void;
  60261. /**
  60262. * Public method to load a texturePacker JSON file.
  60263. * @param data of the JSON file in string format.
  60264. */
  60265. updateFromJSON(data: string): void;
  60266. }
  60267. }
  60268. declare module "babylonjs/Materials/Textures/Packer/index" {
  60269. export * from "babylonjs/Materials/Textures/Packer/packer";
  60270. export * from "babylonjs/Materials/Textures/Packer/frame";
  60271. }
  60272. declare module "babylonjs/Materials/Textures/index" {
  60273. export * from "babylonjs/Materials/Textures/baseTexture";
  60274. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60275. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60276. export * from "babylonjs/Materials/Textures/cubeTexture";
  60277. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60278. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60279. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60280. export * from "babylonjs/Materials/Textures/internalTexture";
  60281. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60282. export * from "babylonjs/Materials/Textures/Loaders/index";
  60283. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60284. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60285. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60286. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60287. export * from "babylonjs/Materials/Textures/rawTexture";
  60288. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60289. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60290. export * from "babylonjs/Materials/Textures/refractionTexture";
  60291. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60292. export * from "babylonjs/Materials/Textures/texture";
  60293. export * from "babylonjs/Materials/Textures/videoTexture";
  60294. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60295. export * from "babylonjs/Materials/Textures/Packer/index";
  60296. }
  60297. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60298. /**
  60299. * Enum used to define the target of a block
  60300. */
  60301. export enum NodeMaterialBlockTargets {
  60302. /** Vertex shader */
  60303. Vertex = 1,
  60304. /** Fragment shader */
  60305. Fragment = 2,
  60306. /** Neutral */
  60307. Neutral = 4,
  60308. /** Vertex and Fragment */
  60309. VertexAndFragment = 3
  60310. }
  60311. }
  60312. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60313. /**
  60314. * Defines the kind of connection point for node based material
  60315. */
  60316. export enum NodeMaterialBlockConnectionPointTypes {
  60317. /** Float */
  60318. Float = 1,
  60319. /** Int */
  60320. Int = 2,
  60321. /** Vector2 */
  60322. Vector2 = 4,
  60323. /** Vector3 */
  60324. Vector3 = 8,
  60325. /** Vector4 */
  60326. Vector4 = 16,
  60327. /** Color3 */
  60328. Color3 = 32,
  60329. /** Color4 */
  60330. Color4 = 64,
  60331. /** Matrix */
  60332. Matrix = 128,
  60333. /** Custom object */
  60334. Object = 256,
  60335. /** Detect type based on connection */
  60336. AutoDetect = 1024,
  60337. /** Output type that will be defined by input type */
  60338. BasedOnInput = 2048
  60339. }
  60340. }
  60341. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60342. /**
  60343. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60344. */
  60345. export enum NodeMaterialBlockConnectionPointMode {
  60346. /** Value is an uniform */
  60347. Uniform = 0,
  60348. /** Value is a mesh attribute */
  60349. Attribute = 1,
  60350. /** Value is a varying between vertex and fragment shaders */
  60351. Varying = 2,
  60352. /** Mode is undefined */
  60353. Undefined = 3
  60354. }
  60355. }
  60356. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60357. /**
  60358. * Enum used to define system values e.g. values automatically provided by the system
  60359. */
  60360. export enum NodeMaterialSystemValues {
  60361. /** World */
  60362. World = 1,
  60363. /** View */
  60364. View = 2,
  60365. /** Projection */
  60366. Projection = 3,
  60367. /** ViewProjection */
  60368. ViewProjection = 4,
  60369. /** WorldView */
  60370. WorldView = 5,
  60371. /** WorldViewProjection */
  60372. WorldViewProjection = 6,
  60373. /** CameraPosition */
  60374. CameraPosition = 7,
  60375. /** Fog Color */
  60376. FogColor = 8,
  60377. /** Delta time */
  60378. DeltaTime = 9
  60379. }
  60380. }
  60381. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  60382. /**
  60383. * Enum used to define the material modes
  60384. */
  60385. export enum NodeMaterialModes {
  60386. /** Regular material */
  60387. Material = 0,
  60388. /** For post process */
  60389. PostProcess = 1
  60390. }
  60391. }
  60392. declare module "babylonjs/Materials/Node/Enums/index" {
  60393. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60394. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60395. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60396. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60397. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  60398. }
  60399. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60401. /**
  60402. * Root class for all node material optimizers
  60403. */
  60404. export class NodeMaterialOptimizer {
  60405. /**
  60406. * Function used to optimize a NodeMaterial graph
  60407. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60408. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60409. */
  60410. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60411. }
  60412. }
  60413. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60417. import { Scene } from "babylonjs/scene";
  60418. /**
  60419. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60420. */
  60421. export class TransformBlock extends NodeMaterialBlock {
  60422. /**
  60423. * Defines the value to use to complement W value to transform it to a Vector4
  60424. */
  60425. complementW: number;
  60426. /**
  60427. * Defines the value to use to complement z value to transform it to a Vector4
  60428. */
  60429. complementZ: number;
  60430. /**
  60431. * Creates a new TransformBlock
  60432. * @param name defines the block name
  60433. */
  60434. constructor(name: string);
  60435. /**
  60436. * Gets the current class name
  60437. * @returns the class name
  60438. */
  60439. getClassName(): string;
  60440. /**
  60441. * Gets the vector input
  60442. */
  60443. get vector(): NodeMaterialConnectionPoint;
  60444. /**
  60445. * Gets the output component
  60446. */
  60447. get output(): NodeMaterialConnectionPoint;
  60448. /**
  60449. * Gets the xyz output component
  60450. */
  60451. get xyz(): NodeMaterialConnectionPoint;
  60452. /**
  60453. * Gets the matrix transform input
  60454. */
  60455. get transform(): NodeMaterialConnectionPoint;
  60456. protected _buildBlock(state: NodeMaterialBuildState): this;
  60457. serialize(): any;
  60458. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60459. protected _dumpPropertiesCode(): string;
  60460. }
  60461. }
  60462. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60466. /**
  60467. * Block used to output the vertex position
  60468. */
  60469. export class VertexOutputBlock extends NodeMaterialBlock {
  60470. /**
  60471. * Creates a new VertexOutputBlock
  60472. * @param name defines the block name
  60473. */
  60474. constructor(name: string);
  60475. /**
  60476. * Gets the current class name
  60477. * @returns the class name
  60478. */
  60479. getClassName(): string;
  60480. /**
  60481. * Gets the vector input component
  60482. */
  60483. get vector(): NodeMaterialConnectionPoint;
  60484. protected _buildBlock(state: NodeMaterialBuildState): this;
  60485. }
  60486. }
  60487. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60491. /**
  60492. * Block used to output the final color
  60493. */
  60494. export class FragmentOutputBlock extends NodeMaterialBlock {
  60495. /**
  60496. * Create a new FragmentOutputBlock
  60497. * @param name defines the block name
  60498. */
  60499. constructor(name: string);
  60500. /**
  60501. * Gets the current class name
  60502. * @returns the class name
  60503. */
  60504. getClassName(): string;
  60505. /**
  60506. * Gets the rgba input component
  60507. */
  60508. get rgba(): NodeMaterialConnectionPoint;
  60509. /**
  60510. * Gets the rgb input component
  60511. */
  60512. get rgb(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Gets the a input component
  60515. */
  60516. get a(): NodeMaterialConnectionPoint;
  60517. protected _buildBlock(state: NodeMaterialBuildState): this;
  60518. }
  60519. }
  60520. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  60521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60527. import { Effect } from "babylonjs/Materials/effect";
  60528. import { Mesh } from "babylonjs/Meshes/mesh";
  60529. import { Nullable } from "babylonjs/types";
  60530. import { Scene } from "babylonjs/scene";
  60531. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60532. /**
  60533. * Base block used to read a reflection texture from a sampler
  60534. */
  60535. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  60536. /** @hidden */
  60537. _define3DName: string;
  60538. /** @hidden */
  60539. _defineCubicName: string;
  60540. /** @hidden */
  60541. _defineExplicitName: string;
  60542. /** @hidden */
  60543. _defineProjectionName: string;
  60544. /** @hidden */
  60545. _defineLocalCubicName: string;
  60546. /** @hidden */
  60547. _defineSphericalName: string;
  60548. /** @hidden */
  60549. _definePlanarName: string;
  60550. /** @hidden */
  60551. _defineEquirectangularName: string;
  60552. /** @hidden */
  60553. _defineMirroredEquirectangularFixedName: string;
  60554. /** @hidden */
  60555. _defineEquirectangularFixedName: string;
  60556. /** @hidden */
  60557. _defineSkyboxName: string;
  60558. /** @hidden */
  60559. _defineOppositeZ: string;
  60560. /** @hidden */
  60561. _cubeSamplerName: string;
  60562. /** @hidden */
  60563. _2DSamplerName: string;
  60564. protected _positionUVWName: string;
  60565. protected _directionWName: string;
  60566. protected _reflectionVectorName: string;
  60567. /** @hidden */
  60568. _reflectionCoordsName: string;
  60569. /** @hidden */
  60570. _reflectionMatrixName: string;
  60571. protected _reflectionColorName: string;
  60572. /**
  60573. * Gets or sets the texture associated with the node
  60574. */
  60575. texture: Nullable<BaseTexture>;
  60576. /**
  60577. * Create a new ReflectionTextureBaseBlock
  60578. * @param name defines the block name
  60579. */
  60580. constructor(name: string);
  60581. /**
  60582. * Gets the current class name
  60583. * @returns the class name
  60584. */
  60585. getClassName(): string;
  60586. /**
  60587. * Gets the world position input component
  60588. */
  60589. abstract get position(): NodeMaterialConnectionPoint;
  60590. /**
  60591. * Gets the world position input component
  60592. */
  60593. abstract get worldPosition(): NodeMaterialConnectionPoint;
  60594. /**
  60595. * Gets the world normal input component
  60596. */
  60597. abstract get worldNormal(): NodeMaterialConnectionPoint;
  60598. /**
  60599. * Gets the world input component
  60600. */
  60601. abstract get world(): NodeMaterialConnectionPoint;
  60602. /**
  60603. * Gets the camera (or eye) position component
  60604. */
  60605. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  60606. /**
  60607. * Gets the view input component
  60608. */
  60609. abstract get view(): NodeMaterialConnectionPoint;
  60610. protected _getTexture(): Nullable<BaseTexture>;
  60611. autoConfigure(material: NodeMaterial): void;
  60612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60613. isReady(): boolean;
  60614. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60615. /**
  60616. * Gets the code to inject in the vertex shader
  60617. * @param state current state of the node material building
  60618. * @returns the shader code
  60619. */
  60620. handleVertexSide(state: NodeMaterialBuildState): string;
  60621. /**
  60622. * Handles the inits for the fragment code path
  60623. * @param state node material build state
  60624. */
  60625. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  60626. /**
  60627. * Generates the reflection coords code for the fragment code path
  60628. * @param worldNormalVarName name of the world normal variable
  60629. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  60630. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  60631. * @returns the shader code
  60632. */
  60633. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  60634. /**
  60635. * Generates the reflection color code for the fragment code path
  60636. * @param lodVarName name of the lod variable
  60637. * @param swizzleLookupTexture swizzle to use for the final color variable
  60638. * @returns the shader code
  60639. */
  60640. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  60641. /**
  60642. * Generates the code corresponding to the connected output points
  60643. * @param state node material build state
  60644. * @param varName name of the variable to output
  60645. * @returns the shader code
  60646. */
  60647. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  60648. protected _buildBlock(state: NodeMaterialBuildState): this;
  60649. protected _dumpPropertiesCode(): string;
  60650. serialize(): any;
  60651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60652. }
  60653. }
  60654. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  60655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60656. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60657. import { Nullable } from "babylonjs/types";
  60658. /**
  60659. * Defines a connection point to be used for points with a custom object type
  60660. */
  60661. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  60662. private _blockType;
  60663. private _blockName;
  60664. private _nameForCheking?;
  60665. /**
  60666. * Creates a new connection point
  60667. * @param name defines the connection point name
  60668. * @param ownerBlock defines the block hosting this connection point
  60669. * @param direction defines the direction of the connection point
  60670. */
  60671. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  60672. /**
  60673. * Gets a number indicating if the current point can be connected to another point
  60674. * @param connectionPoint defines the other connection point
  60675. * @returns a number defining the compatibility state
  60676. */
  60677. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60678. /**
  60679. * Creates a block suitable to be used as an input for this input point.
  60680. * If null is returned, a block based on the point type will be created.
  60681. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  60682. */
  60683. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  60684. }
  60685. }
  60686. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  60687. /**
  60688. * Enum defining the type of properties that can be edited in the property pages in the NME
  60689. */
  60690. export enum PropertyTypeForEdition {
  60691. /** property is a boolean */
  60692. Boolean = 0,
  60693. /** property is a float */
  60694. Float = 1,
  60695. /** property is a Vector2 */
  60696. Vector2 = 2,
  60697. /** property is a list of values */
  60698. List = 3
  60699. }
  60700. /**
  60701. * Interface that defines an option in a variable of type list
  60702. */
  60703. export interface IEditablePropertyListOption {
  60704. /** label of the option */
  60705. "label": string;
  60706. /** value of the option */
  60707. "value": number;
  60708. }
  60709. /**
  60710. * Interface that defines the options available for an editable property
  60711. */
  60712. export interface IEditablePropertyOption {
  60713. /** min value */
  60714. "min"?: number;
  60715. /** max value */
  60716. "max"?: number;
  60717. /** notifiers: indicates which actions to take when the property is changed */
  60718. "notifiers"?: {
  60719. /** the material should be rebuilt */
  60720. "rebuild"?: boolean;
  60721. /** the preview should be updated */
  60722. "update"?: boolean;
  60723. };
  60724. /** list of the options for a variable of type list */
  60725. "options"?: IEditablePropertyListOption[];
  60726. }
  60727. /**
  60728. * Interface that describes an editable property
  60729. */
  60730. export interface IPropertyDescriptionForEdition {
  60731. /** name of the property */
  60732. "propertyName": string;
  60733. /** display name of the property */
  60734. "displayName": string;
  60735. /** type of the property */
  60736. "type": PropertyTypeForEdition;
  60737. /** group of the property - all properties with the same group value will be displayed in a specific section */
  60738. "groupName": string;
  60739. /** options for the property */
  60740. "options": IEditablePropertyOption;
  60741. }
  60742. /**
  60743. * Decorator that flags a property in a node material block as being editable
  60744. */
  60745. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  60746. }
  60747. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  60748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60750. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60752. import { Nullable } from "babylonjs/types";
  60753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60754. import { Mesh } from "babylonjs/Meshes/mesh";
  60755. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60756. import { Effect } from "babylonjs/Materials/effect";
  60757. import { Scene } from "babylonjs/scene";
  60758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60759. /**
  60760. * Block used to implement the refraction part of the sub surface module of the PBR material
  60761. */
  60762. export class RefractionBlock extends NodeMaterialBlock {
  60763. /** @hidden */
  60764. _define3DName: string;
  60765. /** @hidden */
  60766. _refractionMatrixName: string;
  60767. /** @hidden */
  60768. _defineLODRefractionAlpha: string;
  60769. /** @hidden */
  60770. _defineLinearSpecularRefraction: string;
  60771. /** @hidden */
  60772. _defineOppositeZ: string;
  60773. /** @hidden */
  60774. _cubeSamplerName: string;
  60775. /** @hidden */
  60776. _2DSamplerName: string;
  60777. /** @hidden */
  60778. _vRefractionMicrosurfaceInfosName: string;
  60779. /** @hidden */
  60780. _vRefractionInfosName: string;
  60781. private _scene;
  60782. /**
  60783. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60784. * Materials half opaque for instance using refraction could benefit from this control.
  60785. */
  60786. linkRefractionWithTransparency: boolean;
  60787. /**
  60788. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60789. */
  60790. invertRefractionY: boolean;
  60791. /**
  60792. * Gets or sets the texture associated with the node
  60793. */
  60794. texture: Nullable<BaseTexture>;
  60795. /**
  60796. * Create a new RefractionBlock
  60797. * @param name defines the block name
  60798. */
  60799. constructor(name: string);
  60800. /**
  60801. * Gets the current class name
  60802. * @returns the class name
  60803. */
  60804. getClassName(): string;
  60805. /**
  60806. * Gets the intensity input component
  60807. */
  60808. get intensity(): NodeMaterialConnectionPoint;
  60809. /**
  60810. * Gets the index of refraction input component
  60811. */
  60812. get indexOfRefraction(): NodeMaterialConnectionPoint;
  60813. /**
  60814. * Gets the tint at distance input component
  60815. */
  60816. get tintAtDistance(): NodeMaterialConnectionPoint;
  60817. /**
  60818. * Gets the view input component
  60819. */
  60820. get view(): NodeMaterialConnectionPoint;
  60821. /**
  60822. * Gets the refraction object output component
  60823. */
  60824. get refraction(): NodeMaterialConnectionPoint;
  60825. /**
  60826. * Returns true if the block has a texture
  60827. */
  60828. get hasTexture(): boolean;
  60829. protected _getTexture(): Nullable<BaseTexture>;
  60830. autoConfigure(material: NodeMaterial): void;
  60831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60832. isReady(): boolean;
  60833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  60834. /**
  60835. * Gets the main code of the block (fragment side)
  60836. * @param state current state of the node material building
  60837. * @returns the shader code
  60838. */
  60839. getCode(state: NodeMaterialBuildState): string;
  60840. protected _buildBlock(state: NodeMaterialBuildState): this;
  60841. protected _dumpPropertiesCode(): string;
  60842. serialize(): any;
  60843. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60844. }
  60845. }
  60846. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  60847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60849. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60852. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60854. import { Nullable } from "babylonjs/types";
  60855. import { Scene } from "babylonjs/scene";
  60856. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60857. /**
  60858. * Base block used as input for post process
  60859. */
  60860. export class CurrentScreenBlock extends NodeMaterialBlock {
  60861. private _samplerName;
  60862. private _linearDefineName;
  60863. private _gammaDefineName;
  60864. private _mainUVName;
  60865. private _tempTextureRead;
  60866. /**
  60867. * Gets or sets the texture associated with the node
  60868. */
  60869. texture: Nullable<BaseTexture>;
  60870. /**
  60871. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60872. */
  60873. convertToGammaSpace: boolean;
  60874. /**
  60875. * Gets or sets a boolean indicating if content needs to be converted to linear space
  60876. */
  60877. convertToLinearSpace: boolean;
  60878. /**
  60879. * Create a new CurrentScreenBlock
  60880. * @param name defines the block name
  60881. */
  60882. constructor(name: string);
  60883. /**
  60884. * Gets the current class name
  60885. * @returns the class name
  60886. */
  60887. getClassName(): string;
  60888. /**
  60889. * Gets the uv input component
  60890. */
  60891. get uv(): NodeMaterialConnectionPoint;
  60892. /**
  60893. * Gets the rgba output component
  60894. */
  60895. get rgba(): NodeMaterialConnectionPoint;
  60896. /**
  60897. * Gets the rgb output component
  60898. */
  60899. get rgb(): NodeMaterialConnectionPoint;
  60900. /**
  60901. * Gets the r output component
  60902. */
  60903. get r(): NodeMaterialConnectionPoint;
  60904. /**
  60905. * Gets the g output component
  60906. */
  60907. get g(): NodeMaterialConnectionPoint;
  60908. /**
  60909. * Gets the b output component
  60910. */
  60911. get b(): NodeMaterialConnectionPoint;
  60912. /**
  60913. * Gets the a output component
  60914. */
  60915. get a(): NodeMaterialConnectionPoint;
  60916. /**
  60917. * Initialize the block and prepare the context for build
  60918. * @param state defines the state that will be used for the build
  60919. */
  60920. initialize(state: NodeMaterialBuildState): void;
  60921. get target(): NodeMaterialBlockTargets;
  60922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60923. isReady(): boolean;
  60924. private _injectVertexCode;
  60925. private _writeTextureRead;
  60926. private _writeOutput;
  60927. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60928. serialize(): any;
  60929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60930. }
  60931. }
  60932. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60936. /**
  60937. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60938. */
  60939. export class VectorMergerBlock extends NodeMaterialBlock {
  60940. /**
  60941. * Create a new VectorMergerBlock
  60942. * @param name defines the block name
  60943. */
  60944. constructor(name: string);
  60945. /**
  60946. * Gets the current class name
  60947. * @returns the class name
  60948. */
  60949. getClassName(): string;
  60950. /**
  60951. * Gets the xyz component (input)
  60952. */
  60953. get xyzIn(): NodeMaterialConnectionPoint;
  60954. /**
  60955. * Gets the xy component (input)
  60956. */
  60957. get xyIn(): NodeMaterialConnectionPoint;
  60958. /**
  60959. * Gets the x component (input)
  60960. */
  60961. get x(): NodeMaterialConnectionPoint;
  60962. /**
  60963. * Gets the y component (input)
  60964. */
  60965. get y(): NodeMaterialConnectionPoint;
  60966. /**
  60967. * Gets the z component (input)
  60968. */
  60969. get z(): NodeMaterialConnectionPoint;
  60970. /**
  60971. * Gets the w component (input)
  60972. */
  60973. get w(): NodeMaterialConnectionPoint;
  60974. /**
  60975. * Gets the xyzw component (output)
  60976. */
  60977. get xyzw(): NodeMaterialConnectionPoint;
  60978. /**
  60979. * Gets the xyz component (output)
  60980. */
  60981. get xyzOut(): NodeMaterialConnectionPoint;
  60982. /**
  60983. * Gets the xy component (output)
  60984. */
  60985. get xyOut(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the xy component (output)
  60988. * @deprecated Please use xyOut instead.
  60989. */
  60990. get xy(): NodeMaterialConnectionPoint;
  60991. /**
  60992. * Gets the xyz component (output)
  60993. * @deprecated Please use xyzOut instead.
  60994. */
  60995. get xyz(): NodeMaterialConnectionPoint;
  60996. protected _buildBlock(state: NodeMaterialBuildState): this;
  60997. }
  60998. }
  60999. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61003. import { Vector2 } from "babylonjs/Maths/math.vector";
  61004. import { Scene } from "babylonjs/scene";
  61005. /**
  61006. * Block used to remap a float from a range to a new one
  61007. */
  61008. export class RemapBlock extends NodeMaterialBlock {
  61009. /**
  61010. * Gets or sets the source range
  61011. */
  61012. sourceRange: Vector2;
  61013. /**
  61014. * Gets or sets the target range
  61015. */
  61016. targetRange: Vector2;
  61017. /**
  61018. * Creates a new RemapBlock
  61019. * @param name defines the block name
  61020. */
  61021. constructor(name: string);
  61022. /**
  61023. * Gets the current class name
  61024. * @returns the class name
  61025. */
  61026. getClassName(): string;
  61027. /**
  61028. * Gets the input component
  61029. */
  61030. get input(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the source min input component
  61033. */
  61034. get sourceMin(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the source max input component
  61037. */
  61038. get sourceMax(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the target min input component
  61041. */
  61042. get targetMin(): NodeMaterialConnectionPoint;
  61043. /**
  61044. * Gets the target max input component
  61045. */
  61046. get targetMax(): NodeMaterialConnectionPoint;
  61047. /**
  61048. * Gets the output component
  61049. */
  61050. get output(): NodeMaterialConnectionPoint;
  61051. protected _buildBlock(state: NodeMaterialBuildState): this;
  61052. protected _dumpPropertiesCode(): string;
  61053. serialize(): any;
  61054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61055. }
  61056. }
  61057. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61061. /**
  61062. * Block used to multiply 2 values
  61063. */
  61064. export class MultiplyBlock extends NodeMaterialBlock {
  61065. /**
  61066. * Creates a new MultiplyBlock
  61067. * @param name defines the block name
  61068. */
  61069. constructor(name: string);
  61070. /**
  61071. * Gets the current class name
  61072. * @returns the class name
  61073. */
  61074. getClassName(): string;
  61075. /**
  61076. * Gets the left operand input component
  61077. */
  61078. get left(): NodeMaterialConnectionPoint;
  61079. /**
  61080. * Gets the right operand input component
  61081. */
  61082. get right(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Gets the output component
  61085. */
  61086. get output(): NodeMaterialConnectionPoint;
  61087. protected _buildBlock(state: NodeMaterialBuildState): this;
  61088. }
  61089. }
  61090. declare module "babylonjs/Materials/Node/nodeMaterial" {
  61091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61092. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  61093. import { Scene } from "babylonjs/scene";
  61094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61095. import { Matrix } from "babylonjs/Maths/math.vector";
  61096. import { Mesh } from "babylonjs/Meshes/mesh";
  61097. import { Engine } from "babylonjs/Engines/engine";
  61098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61099. import { Observable } from "babylonjs/Misc/observable";
  61100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61101. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  61102. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61103. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  61104. import { Nullable } from "babylonjs/types";
  61105. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61106. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61107. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61108. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61109. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61110. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61111. import { Camera } from "babylonjs/Cameras/camera";
  61112. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  61113. /**
  61114. * Interface used to configure the node material editor
  61115. */
  61116. export interface INodeMaterialEditorOptions {
  61117. /** Define the URl to load node editor script */
  61118. editorURL?: string;
  61119. }
  61120. /** @hidden */
  61121. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  61122. NORMAL: boolean;
  61123. TANGENT: boolean;
  61124. UV1: boolean;
  61125. /** BONES */
  61126. NUM_BONE_INFLUENCERS: number;
  61127. BonesPerMesh: number;
  61128. BONETEXTURE: boolean;
  61129. /** MORPH TARGETS */
  61130. MORPHTARGETS: boolean;
  61131. MORPHTARGETS_NORMAL: boolean;
  61132. MORPHTARGETS_TANGENT: boolean;
  61133. MORPHTARGETS_UV: boolean;
  61134. NUM_MORPH_INFLUENCERS: number;
  61135. /** IMAGE PROCESSING */
  61136. IMAGEPROCESSING: boolean;
  61137. VIGNETTE: boolean;
  61138. VIGNETTEBLENDMODEMULTIPLY: boolean;
  61139. VIGNETTEBLENDMODEOPAQUE: boolean;
  61140. TONEMAPPING: boolean;
  61141. TONEMAPPING_ACES: boolean;
  61142. CONTRAST: boolean;
  61143. EXPOSURE: boolean;
  61144. COLORCURVES: boolean;
  61145. COLORGRADING: boolean;
  61146. COLORGRADING3D: boolean;
  61147. SAMPLER3DGREENDEPTH: boolean;
  61148. SAMPLER3DBGRMAP: boolean;
  61149. IMAGEPROCESSINGPOSTPROCESS: boolean;
  61150. /** MISC. */
  61151. BUMPDIRECTUV: number;
  61152. constructor();
  61153. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  61154. }
  61155. /**
  61156. * Class used to configure NodeMaterial
  61157. */
  61158. export interface INodeMaterialOptions {
  61159. /**
  61160. * Defines if blocks should emit comments
  61161. */
  61162. emitComments: boolean;
  61163. }
  61164. /**
  61165. * Class used to create a node based material built by assembling shader blocks
  61166. */
  61167. export class NodeMaterial extends PushMaterial {
  61168. private static _BuildIdGenerator;
  61169. private _options;
  61170. private _vertexCompilationState;
  61171. private _fragmentCompilationState;
  61172. private _sharedData;
  61173. private _buildId;
  61174. private _buildWasSuccessful;
  61175. private _cachedWorldViewMatrix;
  61176. private _cachedWorldViewProjectionMatrix;
  61177. private _optimizers;
  61178. private _animationFrame;
  61179. /** Define the Url to load node editor script */
  61180. static EditorURL: string;
  61181. /** Define the Url to load snippets */
  61182. static SnippetUrl: string;
  61183. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  61184. static IgnoreTexturesAtLoadTime: boolean;
  61185. private BJSNODEMATERIALEDITOR;
  61186. /** Get the inspector from bundle or global */
  61187. private _getGlobalNodeMaterialEditor;
  61188. /**
  61189. * Snippet ID if the material was created from the snippet server
  61190. */
  61191. snippetId: string;
  61192. /**
  61193. * Gets or sets data used by visual editor
  61194. * @see https://nme.babylonjs.com
  61195. */
  61196. editorData: any;
  61197. /**
  61198. * 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)
  61199. */
  61200. ignoreAlpha: boolean;
  61201. /**
  61202. * Defines the maximum number of lights that can be used in the material
  61203. */
  61204. maxSimultaneousLights: number;
  61205. /**
  61206. * Observable raised when the material is built
  61207. */
  61208. onBuildObservable: Observable<NodeMaterial>;
  61209. /**
  61210. * Gets or sets the root nodes of the material vertex shader
  61211. */
  61212. _vertexOutputNodes: NodeMaterialBlock[];
  61213. /**
  61214. * Gets or sets the root nodes of the material fragment (pixel) shader
  61215. */
  61216. _fragmentOutputNodes: NodeMaterialBlock[];
  61217. /** Gets or sets options to control the node material overall behavior */
  61218. get options(): INodeMaterialOptions;
  61219. set options(options: INodeMaterialOptions);
  61220. /**
  61221. * Default configuration related to image processing available in the standard Material.
  61222. */
  61223. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61224. /**
  61225. * Gets the image processing configuration used either in this material.
  61226. */
  61227. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  61228. /**
  61229. * Sets the Default image processing configuration used either in the this material.
  61230. *
  61231. * If sets to null, the scene one is in use.
  61232. */
  61233. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  61234. /**
  61235. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  61236. */
  61237. attachedBlocks: NodeMaterialBlock[];
  61238. /**
  61239. * Specifies the mode of the node material
  61240. * @hidden
  61241. */
  61242. _mode: NodeMaterialModes;
  61243. /**
  61244. * Gets the mode property
  61245. */
  61246. get mode(): NodeMaterialModes;
  61247. /**
  61248. * Create a new node based material
  61249. * @param name defines the material name
  61250. * @param scene defines the hosting scene
  61251. * @param options defines creation option
  61252. */
  61253. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  61254. /**
  61255. * Gets the current class name of the material e.g. "NodeMaterial"
  61256. * @returns the class name
  61257. */
  61258. getClassName(): string;
  61259. /**
  61260. * Keep track of the image processing observer to allow dispose and replace.
  61261. */
  61262. private _imageProcessingObserver;
  61263. /**
  61264. * Attaches a new image processing configuration to the Standard Material.
  61265. * @param configuration
  61266. */
  61267. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61268. /**
  61269. * Get a block by its name
  61270. * @param name defines the name of the block to retrieve
  61271. * @returns the required block or null if not found
  61272. */
  61273. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  61274. /**
  61275. * Get a block by its name
  61276. * @param predicate defines the predicate used to find the good candidate
  61277. * @returns the required block or null if not found
  61278. */
  61279. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  61280. /**
  61281. * Get an input block by its name
  61282. * @param predicate defines the predicate used to find the good candidate
  61283. * @returns the required input block or null if not found
  61284. */
  61285. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  61286. /**
  61287. * Gets the list of input blocks attached to this material
  61288. * @returns an array of InputBlocks
  61289. */
  61290. getInputBlocks(): InputBlock[];
  61291. /**
  61292. * Adds a new optimizer to the list of optimizers
  61293. * @param optimizer defines the optimizers to add
  61294. * @returns the current material
  61295. */
  61296. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61297. /**
  61298. * Remove an optimizer from the list of optimizers
  61299. * @param optimizer defines the optimizers to remove
  61300. * @returns the current material
  61301. */
  61302. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61303. /**
  61304. * Add a new block to the list of output nodes
  61305. * @param node defines the node to add
  61306. * @returns the current material
  61307. */
  61308. addOutputNode(node: NodeMaterialBlock): this;
  61309. /**
  61310. * Remove a block from the list of root nodes
  61311. * @param node defines the node to remove
  61312. * @returns the current material
  61313. */
  61314. removeOutputNode(node: NodeMaterialBlock): this;
  61315. private _addVertexOutputNode;
  61316. private _removeVertexOutputNode;
  61317. private _addFragmentOutputNode;
  61318. private _removeFragmentOutputNode;
  61319. /**
  61320. * Specifies if the material will require alpha blending
  61321. * @returns a boolean specifying if alpha blending is needed
  61322. */
  61323. needAlphaBlending(): boolean;
  61324. /**
  61325. * Specifies if this material should be rendered in alpha test mode
  61326. * @returns a boolean specifying if an alpha test is needed.
  61327. */
  61328. needAlphaTesting(): boolean;
  61329. private _initializeBlock;
  61330. private _resetDualBlocks;
  61331. /**
  61332. * Remove a block from the current node material
  61333. * @param block defines the block to remove
  61334. */
  61335. removeBlock(block: NodeMaterialBlock): void;
  61336. /**
  61337. * Build the material and generates the inner effect
  61338. * @param verbose defines if the build should log activity
  61339. */
  61340. build(verbose?: boolean): void;
  61341. /**
  61342. * Runs an otpimization phase to try to improve the shader code
  61343. */
  61344. optimize(): void;
  61345. private _prepareDefinesForAttributes;
  61346. /**
  61347. * Create a post process from the material
  61348. * @param camera The camera to apply the render pass to.
  61349. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  61350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61351. * @param engine The engine which the post process will be applied. (default: current engine)
  61352. * @param reusable If the post process can be reused on the same frame. (default: false)
  61353. * @param textureType Type of textures used when performing the post process. (default: 0)
  61354. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  61355. * @returns the post process created
  61356. */
  61357. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  61358. private _processDefines;
  61359. /**
  61360. * Get if the submesh is ready to be used and all its information available.
  61361. * Child classes can use it to update shaders
  61362. * @param mesh defines the mesh to check
  61363. * @param subMesh defines which submesh to check
  61364. * @param useInstances specifies that instances should be used
  61365. * @returns a boolean indicating that the submesh is ready or not
  61366. */
  61367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61368. /**
  61369. * Get a string representing the shaders built by the current node graph
  61370. */
  61371. get compiledShaders(): string;
  61372. /**
  61373. * Binds the world matrix to the material
  61374. * @param world defines the world transformation matrix
  61375. */
  61376. bindOnlyWorldMatrix(world: Matrix): void;
  61377. /**
  61378. * Binds the submesh to this material by preparing the effect and shader to draw
  61379. * @param world defines the world transformation matrix
  61380. * @param mesh defines the mesh containing the submesh
  61381. * @param subMesh defines the submesh to bind the material to
  61382. */
  61383. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61384. /**
  61385. * Gets the active textures from the material
  61386. * @returns an array of textures
  61387. */
  61388. getActiveTextures(): BaseTexture[];
  61389. /**
  61390. * Gets the list of texture blocks
  61391. * @returns an array of texture blocks
  61392. */
  61393. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  61394. /**
  61395. * Specifies if the material uses a texture
  61396. * @param texture defines the texture to check against the material
  61397. * @returns a boolean specifying if the material uses the texture
  61398. */
  61399. hasTexture(texture: BaseTexture): boolean;
  61400. /**
  61401. * Disposes the material
  61402. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61403. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  61404. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  61405. */
  61406. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  61407. /** Creates the node editor window. */
  61408. private _createNodeEditor;
  61409. /**
  61410. * Launch the node material editor
  61411. * @param config Define the configuration of the editor
  61412. * @return a promise fulfilled when the node editor is visible
  61413. */
  61414. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  61415. /**
  61416. * Clear the current material
  61417. */
  61418. clear(): void;
  61419. /**
  61420. * Clear the current material and set it to a default state
  61421. */
  61422. setToDefault(): void;
  61423. /**
  61424. * Clear the current material and set it to a default state for post process
  61425. */
  61426. setToDefaultPostProcess(): void;
  61427. /**
  61428. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  61429. * @param url defines the url to load from
  61430. * @returns a promise that will fullfil when the material is fully loaded
  61431. */
  61432. loadAsync(url: string): Promise<void>;
  61433. private _gatherBlocks;
  61434. /**
  61435. * Generate a string containing the code declaration required to create an equivalent of this material
  61436. * @returns a string
  61437. */
  61438. generateCode(): string;
  61439. /**
  61440. * Serializes this material in a JSON representation
  61441. * @returns the serialized material object
  61442. */
  61443. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  61444. private _restoreConnections;
  61445. /**
  61446. * Clear the current graph and load a new one from a serialization object
  61447. * @param source defines the JSON representation of the material
  61448. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61449. */
  61450. loadFromSerialization(source: any, rootUrl?: string): void;
  61451. /**
  61452. * Makes a duplicate of the current material.
  61453. * @param name - name to use for the new material.
  61454. */
  61455. clone(name: string): NodeMaterial;
  61456. /**
  61457. * Creates a node material from parsed material data
  61458. * @param source defines the JSON representation of the material
  61459. * @param scene defines the hosting scene
  61460. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61461. * @returns a new node material
  61462. */
  61463. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  61464. /**
  61465. * Creates a node material from a snippet saved in a remote file
  61466. * @param name defines the name of the material to create
  61467. * @param url defines the url to load from
  61468. * @param scene defines the hosting scene
  61469. * @returns a promise that will resolve to the new node material
  61470. */
  61471. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  61472. /**
  61473. * Creates a node material from a snippet saved by the node material editor
  61474. * @param snippetId defines the snippet to load
  61475. * @param scene defines the hosting scene
  61476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61477. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  61478. * @returns a promise that will resolve to the new node material
  61479. */
  61480. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  61481. /**
  61482. * Creates a new node material set to default basic configuration
  61483. * @param name defines the name of the material
  61484. * @param scene defines the hosting scene
  61485. * @returns a new NodeMaterial
  61486. */
  61487. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  61488. }
  61489. }
  61490. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  61491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61493. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61496. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61497. import { Effect } from "babylonjs/Materials/effect";
  61498. import { Mesh } from "babylonjs/Meshes/mesh";
  61499. import { Nullable } from "babylonjs/types";
  61500. import { Texture } from "babylonjs/Materials/Textures/texture";
  61501. import { Scene } from "babylonjs/scene";
  61502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61503. /**
  61504. * Block used to read a texture from a sampler
  61505. */
  61506. export class TextureBlock extends NodeMaterialBlock {
  61507. private _defineName;
  61508. private _linearDefineName;
  61509. private _gammaDefineName;
  61510. private _tempTextureRead;
  61511. private _samplerName;
  61512. private _transformedUVName;
  61513. private _textureTransformName;
  61514. private _textureInfoName;
  61515. private _mainUVName;
  61516. private _mainUVDefineName;
  61517. /**
  61518. * Gets or sets the texture associated with the node
  61519. */
  61520. texture: Nullable<Texture>;
  61521. /**
  61522. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  61523. */
  61524. convertToGammaSpace: boolean;
  61525. /**
  61526. * Gets or sets a boolean indicating if content needs to be converted to linear space
  61527. */
  61528. convertToLinearSpace: boolean;
  61529. /**
  61530. * Create a new TextureBlock
  61531. * @param name defines the block name
  61532. */
  61533. constructor(name: string);
  61534. /**
  61535. * Gets the current class name
  61536. * @returns the class name
  61537. */
  61538. getClassName(): string;
  61539. /**
  61540. * Gets the uv input component
  61541. */
  61542. get uv(): NodeMaterialConnectionPoint;
  61543. /**
  61544. * Gets the rgba output component
  61545. */
  61546. get rgba(): NodeMaterialConnectionPoint;
  61547. /**
  61548. * Gets the rgb output component
  61549. */
  61550. get rgb(): NodeMaterialConnectionPoint;
  61551. /**
  61552. * Gets the r output component
  61553. */
  61554. get r(): NodeMaterialConnectionPoint;
  61555. /**
  61556. * Gets the g output component
  61557. */
  61558. get g(): NodeMaterialConnectionPoint;
  61559. /**
  61560. * Gets the b output component
  61561. */
  61562. get b(): NodeMaterialConnectionPoint;
  61563. /**
  61564. * Gets the a output component
  61565. */
  61566. get a(): NodeMaterialConnectionPoint;
  61567. get target(): NodeMaterialBlockTargets;
  61568. autoConfigure(material: NodeMaterial): void;
  61569. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61571. isReady(): boolean;
  61572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61573. private get _isMixed();
  61574. private _injectVertexCode;
  61575. private _writeTextureRead;
  61576. private _writeOutput;
  61577. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61578. protected _dumpPropertiesCode(): string;
  61579. serialize(): any;
  61580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61581. }
  61582. }
  61583. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  61584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61586. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61587. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61588. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61589. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61590. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61591. import { Scene } from "babylonjs/scene";
  61592. /**
  61593. * Class used to store shared data between 2 NodeMaterialBuildState
  61594. */
  61595. export class NodeMaterialBuildStateSharedData {
  61596. /**
  61597. * Gets the list of emitted varyings
  61598. */
  61599. temps: string[];
  61600. /**
  61601. * Gets the list of emitted varyings
  61602. */
  61603. varyings: string[];
  61604. /**
  61605. * Gets the varying declaration string
  61606. */
  61607. varyingDeclaration: string;
  61608. /**
  61609. * Input blocks
  61610. */
  61611. inputBlocks: InputBlock[];
  61612. /**
  61613. * Input blocks
  61614. */
  61615. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  61616. /**
  61617. * Bindable blocks (Blocks that need to set data to the effect)
  61618. */
  61619. bindableBlocks: NodeMaterialBlock[];
  61620. /**
  61621. * List of blocks that can provide a compilation fallback
  61622. */
  61623. blocksWithFallbacks: NodeMaterialBlock[];
  61624. /**
  61625. * List of blocks that can provide a define update
  61626. */
  61627. blocksWithDefines: NodeMaterialBlock[];
  61628. /**
  61629. * List of blocks that can provide a repeatable content
  61630. */
  61631. repeatableContentBlocks: NodeMaterialBlock[];
  61632. /**
  61633. * List of blocks that can provide a dynamic list of uniforms
  61634. */
  61635. dynamicUniformBlocks: NodeMaterialBlock[];
  61636. /**
  61637. * List of blocks that can block the isReady function for the material
  61638. */
  61639. blockingBlocks: NodeMaterialBlock[];
  61640. /**
  61641. * Gets the list of animated inputs
  61642. */
  61643. animatedInputs: InputBlock[];
  61644. /**
  61645. * Build Id used to avoid multiple recompilations
  61646. */
  61647. buildId: number;
  61648. /** List of emitted variables */
  61649. variableNames: {
  61650. [key: string]: number;
  61651. };
  61652. /** List of emitted defines */
  61653. defineNames: {
  61654. [key: string]: number;
  61655. };
  61656. /** Should emit comments? */
  61657. emitComments: boolean;
  61658. /** Emit build activity */
  61659. verbose: boolean;
  61660. /** Gets or sets the hosting scene */
  61661. scene: Scene;
  61662. /**
  61663. * Gets the compilation hints emitted at compilation time
  61664. */
  61665. hints: {
  61666. needWorldViewMatrix: boolean;
  61667. needWorldViewProjectionMatrix: boolean;
  61668. needAlphaBlending: boolean;
  61669. needAlphaTesting: boolean;
  61670. };
  61671. /**
  61672. * List of compilation checks
  61673. */
  61674. checks: {
  61675. emitVertex: boolean;
  61676. emitFragment: boolean;
  61677. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  61678. };
  61679. /** Creates a new shared data */
  61680. constructor();
  61681. /**
  61682. * Emits console errors and exceptions if there is a failing check
  61683. */
  61684. emitErrors(): void;
  61685. }
  61686. }
  61687. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  61688. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61689. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61690. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  61691. /**
  61692. * Class used to store node based material build state
  61693. */
  61694. export class NodeMaterialBuildState {
  61695. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  61696. supportUniformBuffers: boolean;
  61697. /**
  61698. * Gets the list of emitted attributes
  61699. */
  61700. attributes: string[];
  61701. /**
  61702. * Gets the list of emitted uniforms
  61703. */
  61704. uniforms: string[];
  61705. /**
  61706. * Gets the list of emitted constants
  61707. */
  61708. constants: string[];
  61709. /**
  61710. * Gets the list of emitted samplers
  61711. */
  61712. samplers: string[];
  61713. /**
  61714. * Gets the list of emitted functions
  61715. */
  61716. functions: {
  61717. [key: string]: string;
  61718. };
  61719. /**
  61720. * Gets the list of emitted extensions
  61721. */
  61722. extensions: {
  61723. [key: string]: string;
  61724. };
  61725. /**
  61726. * Gets the target of the compilation state
  61727. */
  61728. target: NodeMaterialBlockTargets;
  61729. /**
  61730. * Gets the list of emitted counters
  61731. */
  61732. counters: {
  61733. [key: string]: number;
  61734. };
  61735. /**
  61736. * Shared data between multiple NodeMaterialBuildState instances
  61737. */
  61738. sharedData: NodeMaterialBuildStateSharedData;
  61739. /** @hidden */
  61740. _vertexState: NodeMaterialBuildState;
  61741. /** @hidden */
  61742. _attributeDeclaration: string;
  61743. /** @hidden */
  61744. _uniformDeclaration: string;
  61745. /** @hidden */
  61746. _constantDeclaration: string;
  61747. /** @hidden */
  61748. _samplerDeclaration: string;
  61749. /** @hidden */
  61750. _varyingTransfer: string;
  61751. /** @hidden */
  61752. _injectAtEnd: string;
  61753. private _repeatableContentAnchorIndex;
  61754. /** @hidden */
  61755. _builtCompilationString: string;
  61756. /**
  61757. * Gets the emitted compilation strings
  61758. */
  61759. compilationString: string;
  61760. /**
  61761. * Finalize the compilation strings
  61762. * @param state defines the current compilation state
  61763. */
  61764. finalize(state: NodeMaterialBuildState): void;
  61765. /** @hidden */
  61766. get _repeatableContentAnchor(): string;
  61767. /** @hidden */
  61768. _getFreeVariableName(prefix: string): string;
  61769. /** @hidden */
  61770. _getFreeDefineName(prefix: string): string;
  61771. /** @hidden */
  61772. _excludeVariableName(name: string): void;
  61773. /** @hidden */
  61774. _emit2DSampler(name: string): void;
  61775. /** @hidden */
  61776. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61777. /** @hidden */
  61778. _emitExtension(name: string, extension: string, define?: string): void;
  61779. /** @hidden */
  61780. _emitFunction(name: string, code: string, comments: string): void;
  61781. /** @hidden */
  61782. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61783. replaceStrings?: {
  61784. search: RegExp;
  61785. replace: string;
  61786. }[];
  61787. repeatKey?: string;
  61788. }): string;
  61789. /** @hidden */
  61790. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61791. repeatKey?: string;
  61792. removeAttributes?: boolean;
  61793. removeUniforms?: boolean;
  61794. removeVaryings?: boolean;
  61795. removeIfDef?: boolean;
  61796. replaceStrings?: {
  61797. search: RegExp;
  61798. replace: string;
  61799. }[];
  61800. }, storeKey?: string): void;
  61801. /** @hidden */
  61802. _registerTempVariable(name: string): boolean;
  61803. /** @hidden */
  61804. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61805. /** @hidden */
  61806. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61807. /** @hidden */
  61808. _emitFloat(value: number): string;
  61809. }
  61810. }
  61811. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61812. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61814. import { Nullable } from "babylonjs/types";
  61815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61816. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61817. import { Effect } from "babylonjs/Materials/effect";
  61818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61819. import { Mesh } from "babylonjs/Meshes/mesh";
  61820. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61821. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61822. import { Scene } from "babylonjs/scene";
  61823. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61824. /**
  61825. * Defines a block that can be used inside a node based material
  61826. */
  61827. export class NodeMaterialBlock {
  61828. private _buildId;
  61829. private _buildTarget;
  61830. private _target;
  61831. private _isFinalMerger;
  61832. private _isInput;
  61833. protected _isUnique: boolean;
  61834. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61835. inputsAreExclusive: boolean;
  61836. /** @hidden */
  61837. _codeVariableName: string;
  61838. /** @hidden */
  61839. _inputs: NodeMaterialConnectionPoint[];
  61840. /** @hidden */
  61841. _outputs: NodeMaterialConnectionPoint[];
  61842. /** @hidden */
  61843. _preparationId: number;
  61844. /**
  61845. * Gets or sets the name of the block
  61846. */
  61847. name: string;
  61848. /**
  61849. * Gets or sets the unique id of the node
  61850. */
  61851. uniqueId: number;
  61852. /**
  61853. * Gets or sets the comments associated with this block
  61854. */
  61855. comments: string;
  61856. /**
  61857. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61858. */
  61859. get isUnique(): boolean;
  61860. /**
  61861. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61862. */
  61863. get isFinalMerger(): boolean;
  61864. /**
  61865. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61866. */
  61867. get isInput(): boolean;
  61868. /**
  61869. * Gets or sets the build Id
  61870. */
  61871. get buildId(): number;
  61872. set buildId(value: number);
  61873. /**
  61874. * Gets or sets the target of the block
  61875. */
  61876. get target(): NodeMaterialBlockTargets;
  61877. set target(value: NodeMaterialBlockTargets);
  61878. /**
  61879. * Gets the list of input points
  61880. */
  61881. get inputs(): NodeMaterialConnectionPoint[];
  61882. /** Gets the list of output points */
  61883. get outputs(): NodeMaterialConnectionPoint[];
  61884. /**
  61885. * Find an input by its name
  61886. * @param name defines the name of the input to look for
  61887. * @returns the input or null if not found
  61888. */
  61889. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61890. /**
  61891. * Find an output by its name
  61892. * @param name defines the name of the outputto look for
  61893. * @returns the output or null if not found
  61894. */
  61895. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61896. /**
  61897. * Creates a new NodeMaterialBlock
  61898. * @param name defines the block name
  61899. * @param target defines the target of that block (Vertex by default)
  61900. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61901. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61902. */
  61903. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61904. /**
  61905. * Initialize the block and prepare the context for build
  61906. * @param state defines the state that will be used for the build
  61907. */
  61908. initialize(state: NodeMaterialBuildState): void;
  61909. /**
  61910. * Bind data to effect. Will only be called for blocks with isBindable === true
  61911. * @param effect defines the effect to bind data to
  61912. * @param nodeMaterial defines the hosting NodeMaterial
  61913. * @param mesh defines the mesh that will be rendered
  61914. * @param subMesh defines the submesh that will be rendered
  61915. */
  61916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61917. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61918. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61919. protected _writeFloat(value: number): string;
  61920. /**
  61921. * Gets the current class name e.g. "NodeMaterialBlock"
  61922. * @returns the class name
  61923. */
  61924. getClassName(): string;
  61925. /**
  61926. * Register a new input. Must be called inside a block constructor
  61927. * @param name defines the connection point name
  61928. * @param type defines the connection point type
  61929. * @param isOptional defines a boolean indicating that this input can be omitted
  61930. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61931. * @param point an already created connection point. If not provided, create a new one
  61932. * @returns the current block
  61933. */
  61934. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61935. /**
  61936. * Register a new output. Must be called inside a block constructor
  61937. * @param name defines the connection point name
  61938. * @param type defines the connection point type
  61939. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61940. * @param point an already created connection point. If not provided, create a new one
  61941. * @returns the current block
  61942. */
  61943. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61944. /**
  61945. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61946. * @param forOutput defines an optional connection point to check compatibility with
  61947. * @returns the first available input or null
  61948. */
  61949. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61950. /**
  61951. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61952. * @param forBlock defines an optional block to check compatibility with
  61953. * @returns the first available input or null
  61954. */
  61955. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61956. /**
  61957. * Gets the sibling of the given output
  61958. * @param current defines the current output
  61959. * @returns the next output in the list or null
  61960. */
  61961. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61962. /**
  61963. * Connect current block with another block
  61964. * @param other defines the block to connect with
  61965. * @param options define the various options to help pick the right connections
  61966. * @returns the current block
  61967. */
  61968. connectTo(other: NodeMaterialBlock, options?: {
  61969. input?: string;
  61970. output?: string;
  61971. outputSwizzle?: string;
  61972. }): this | undefined;
  61973. protected _buildBlock(state: NodeMaterialBuildState): void;
  61974. /**
  61975. * Add uniforms, samplers and uniform buffers at compilation time
  61976. * @param state defines the state to update
  61977. * @param nodeMaterial defines the node material requesting the update
  61978. * @param defines defines the material defines to update
  61979. * @param uniformBuffers defines the list of uniform buffer names
  61980. */
  61981. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61982. /**
  61983. * Add potential fallbacks if shader compilation fails
  61984. * @param mesh defines the mesh to be rendered
  61985. * @param fallbacks defines the current prioritized list of fallbacks
  61986. */
  61987. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61988. /**
  61989. * Initialize defines for shader compilation
  61990. * @param mesh defines the mesh to be rendered
  61991. * @param nodeMaterial defines the node material requesting the update
  61992. * @param defines defines the material defines to update
  61993. * @param useInstances specifies that instances should be used
  61994. */
  61995. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61996. /**
  61997. * Update defines for shader compilation
  61998. * @param mesh defines the mesh to be rendered
  61999. * @param nodeMaterial defines the node material requesting the update
  62000. * @param defines defines the material defines to update
  62001. * @param useInstances specifies that instances should be used
  62002. */
  62003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  62004. /**
  62005. * Lets the block try to connect some inputs automatically
  62006. * @param material defines the hosting NodeMaterial
  62007. */
  62008. autoConfigure(material: NodeMaterial): void;
  62009. /**
  62010. * Function called when a block is declared as repeatable content generator
  62011. * @param vertexShaderState defines the current compilation state for the vertex shader
  62012. * @param fragmentShaderState defines the current compilation state for the fragment shader
  62013. * @param mesh defines the mesh to be rendered
  62014. * @param defines defines the material defines to update
  62015. */
  62016. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62017. /**
  62018. * Checks if the block is ready
  62019. * @param mesh defines the mesh to be rendered
  62020. * @param nodeMaterial defines the node material requesting the update
  62021. * @param defines defines the material defines to update
  62022. * @param useInstances specifies that instances should be used
  62023. * @returns true if the block is ready
  62024. */
  62025. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  62026. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  62027. private _processBuild;
  62028. /**
  62029. * Compile the current node and generate the shader code
  62030. * @param state defines the current compilation state (uniforms, samplers, current string)
  62031. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  62032. * @returns true if already built
  62033. */
  62034. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  62035. protected _inputRename(name: string): string;
  62036. protected _outputRename(name: string): string;
  62037. protected _dumpPropertiesCode(): string;
  62038. /** @hidden */
  62039. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  62040. /** @hidden */
  62041. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  62042. /**
  62043. * Clone the current block to a new identical block
  62044. * @param scene defines the hosting scene
  62045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  62046. * @returns a copy of the current block
  62047. */
  62048. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  62049. /**
  62050. * Serializes this block in a JSON representation
  62051. * @returns the serialized block object
  62052. */
  62053. serialize(): any;
  62054. /** @hidden */
  62055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62056. private _deserializePortDisplayNames;
  62057. /**
  62058. * Release resources
  62059. */
  62060. dispose(): void;
  62061. }
  62062. }
  62063. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  62064. /**
  62065. * Enum defining the type of animations supported by InputBlock
  62066. */
  62067. export enum AnimatedInputBlockTypes {
  62068. /** No animation */
  62069. None = 0,
  62070. /** Time based animation. Will only work for floats */
  62071. Time = 1
  62072. }
  62073. }
  62074. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  62075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62076. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62077. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  62078. import { Nullable } from "babylonjs/types";
  62079. import { Effect } from "babylonjs/Materials/effect";
  62080. import { Matrix } from "babylonjs/Maths/math.vector";
  62081. import { Scene } from "babylonjs/scene";
  62082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62084. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62085. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62086. import { Observable } from "babylonjs/Misc/observable";
  62087. /**
  62088. * Block used to expose an input value
  62089. */
  62090. export class InputBlock extends NodeMaterialBlock {
  62091. private _mode;
  62092. private _associatedVariableName;
  62093. private _storedValue;
  62094. private _valueCallback;
  62095. private _type;
  62096. private _animationType;
  62097. /** Gets or set a value used to limit the range of float values */
  62098. min: number;
  62099. /** Gets or set a value used to limit the range of float values */
  62100. max: number;
  62101. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  62102. isBoolean: boolean;
  62103. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  62104. matrixMode: number;
  62105. /** @hidden */
  62106. _systemValue: Nullable<NodeMaterialSystemValues>;
  62107. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  62108. visibleInInspector: boolean;
  62109. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  62110. isConstant: boolean;
  62111. /** Gets or sets the group to use to display this block in the Inspector */
  62112. groupInInspector: string;
  62113. /** Gets an observable raised when the value is changed */
  62114. onValueChangedObservable: Observable<InputBlock>;
  62115. /**
  62116. * Gets or sets the connection point type (default is float)
  62117. */
  62118. get type(): NodeMaterialBlockConnectionPointTypes;
  62119. /**
  62120. * Creates a new InputBlock
  62121. * @param name defines the block name
  62122. * @param target defines the target of that block (Vertex by default)
  62123. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  62124. */
  62125. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  62126. /**
  62127. * Gets the output component
  62128. */
  62129. get output(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Set the source of this connection point to a vertex attribute
  62132. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  62133. * @returns the current connection point
  62134. */
  62135. setAsAttribute(attributeName?: string): InputBlock;
  62136. /**
  62137. * Set the source of this connection point to a system value
  62138. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  62139. * @returns the current connection point
  62140. */
  62141. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  62142. /**
  62143. * Gets or sets the value of that point.
  62144. * Please note that this value will be ignored if valueCallback is defined
  62145. */
  62146. get value(): any;
  62147. set value(value: any);
  62148. /**
  62149. * Gets or sets a callback used to get the value of that point.
  62150. * Please note that setting this value will force the connection point to ignore the value property
  62151. */
  62152. get valueCallback(): () => any;
  62153. set valueCallback(value: () => any);
  62154. /**
  62155. * Gets or sets the associated variable name in the shader
  62156. */
  62157. get associatedVariableName(): string;
  62158. set associatedVariableName(value: string);
  62159. /** Gets or sets the type of animation applied to the input */
  62160. get animationType(): AnimatedInputBlockTypes;
  62161. set animationType(value: AnimatedInputBlockTypes);
  62162. /**
  62163. * Gets a boolean indicating that this connection point not defined yet
  62164. */
  62165. get isUndefined(): boolean;
  62166. /**
  62167. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  62168. * In this case the connection point name must be the name of the uniform to use.
  62169. * Can only be set on inputs
  62170. */
  62171. get isUniform(): boolean;
  62172. set isUniform(value: boolean);
  62173. /**
  62174. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  62175. * In this case the connection point name must be the name of the attribute to use
  62176. * Can only be set on inputs
  62177. */
  62178. get isAttribute(): boolean;
  62179. set isAttribute(value: boolean);
  62180. /**
  62181. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  62182. * Can only be set on exit points
  62183. */
  62184. get isVarying(): boolean;
  62185. set isVarying(value: boolean);
  62186. /**
  62187. * Gets a boolean indicating that the current connection point is a system value
  62188. */
  62189. get isSystemValue(): boolean;
  62190. /**
  62191. * Gets or sets the current well known value or null if not defined as a system value
  62192. */
  62193. get systemValue(): Nullable<NodeMaterialSystemValues>;
  62194. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  62195. /**
  62196. * Gets the current class name
  62197. * @returns the class name
  62198. */
  62199. getClassName(): string;
  62200. /**
  62201. * Animate the input if animationType !== None
  62202. * @param scene defines the rendering scene
  62203. */
  62204. animate(scene: Scene): void;
  62205. private _emitDefine;
  62206. initialize(state: NodeMaterialBuildState): void;
  62207. /**
  62208. * Set the input block to its default value (based on its type)
  62209. */
  62210. setDefaultValue(): void;
  62211. private _emitConstant;
  62212. private _emit;
  62213. /** @hidden */
  62214. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  62215. /** @hidden */
  62216. _transmit(effect: Effect, scene: Scene): void;
  62217. protected _buildBlock(state: NodeMaterialBuildState): void;
  62218. protected _dumpPropertiesCode(): string;
  62219. dispose(): void;
  62220. serialize(): any;
  62221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62222. }
  62223. }
  62224. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  62225. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62226. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62227. import { Nullable } from "babylonjs/types";
  62228. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62229. import { Observable } from "babylonjs/Misc/observable";
  62230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62231. /**
  62232. * Enum used to define the compatibility state between two connection points
  62233. */
  62234. export enum NodeMaterialConnectionPointCompatibilityStates {
  62235. /** Points are compatibles */
  62236. Compatible = 0,
  62237. /** Points are incompatible because of their types */
  62238. TypeIncompatible = 1,
  62239. /** Points are incompatible because of their targets (vertex vs fragment) */
  62240. TargetIncompatible = 2
  62241. }
  62242. /**
  62243. * Defines the direction of a connection point
  62244. */
  62245. export enum NodeMaterialConnectionPointDirection {
  62246. /** Input */
  62247. Input = 0,
  62248. /** Output */
  62249. Output = 1
  62250. }
  62251. /**
  62252. * Defines a connection point for a block
  62253. */
  62254. export class NodeMaterialConnectionPoint {
  62255. /** @hidden */
  62256. _ownerBlock: NodeMaterialBlock;
  62257. /** @hidden */
  62258. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  62259. private _endpoints;
  62260. private _associatedVariableName;
  62261. private _direction;
  62262. /** @hidden */
  62263. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62264. /** @hidden */
  62265. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62266. private _type;
  62267. /** @hidden */
  62268. _enforceAssociatedVariableName: boolean;
  62269. /** Gets the direction of the point */
  62270. get direction(): NodeMaterialConnectionPointDirection;
  62271. /** Indicates that this connection point needs dual validation before being connected to another point */
  62272. needDualDirectionValidation: boolean;
  62273. /**
  62274. * Gets or sets the additional types supported by this connection point
  62275. */
  62276. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62277. /**
  62278. * Gets or sets the additional types excluded by this connection point
  62279. */
  62280. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62281. /**
  62282. * Observable triggered when this point is connected
  62283. */
  62284. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  62285. /**
  62286. * Gets or sets the associated variable name in the shader
  62287. */
  62288. get associatedVariableName(): string;
  62289. set associatedVariableName(value: string);
  62290. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  62291. get innerType(): NodeMaterialBlockConnectionPointTypes;
  62292. /**
  62293. * Gets or sets the connection point type (default is float)
  62294. */
  62295. get type(): NodeMaterialBlockConnectionPointTypes;
  62296. set type(value: NodeMaterialBlockConnectionPointTypes);
  62297. /**
  62298. * Gets or sets the connection point name
  62299. */
  62300. name: string;
  62301. /**
  62302. * Gets or sets the connection point name
  62303. */
  62304. displayName: string;
  62305. /**
  62306. * Gets or sets a boolean indicating that this connection point can be omitted
  62307. */
  62308. isOptional: boolean;
  62309. /**
  62310. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  62311. */
  62312. define: string;
  62313. /** @hidden */
  62314. _prioritizeVertex: boolean;
  62315. private _target;
  62316. /** Gets or sets the target of that connection point */
  62317. get target(): NodeMaterialBlockTargets;
  62318. set target(value: NodeMaterialBlockTargets);
  62319. /**
  62320. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  62321. */
  62322. get isConnected(): boolean;
  62323. /**
  62324. * Gets a boolean indicating that the current point is connected to an input block
  62325. */
  62326. get isConnectedToInputBlock(): boolean;
  62327. /**
  62328. * Gets a the connected input block (if any)
  62329. */
  62330. get connectInputBlock(): Nullable<InputBlock>;
  62331. /** Get the other side of the connection (if any) */
  62332. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  62333. /** Get the block that owns this connection point */
  62334. get ownerBlock(): NodeMaterialBlock;
  62335. /** Get the block connected on the other side of this connection (if any) */
  62336. get sourceBlock(): Nullable<NodeMaterialBlock>;
  62337. /** Get the block connected on the endpoints of this connection (if any) */
  62338. get connectedBlocks(): Array<NodeMaterialBlock>;
  62339. /** Gets the list of connected endpoints */
  62340. get endpoints(): NodeMaterialConnectionPoint[];
  62341. /** Gets a boolean indicating if that output point is connected to at least one input */
  62342. get hasEndpoints(): boolean;
  62343. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  62344. get isConnectedInVertexShader(): boolean;
  62345. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  62346. get isConnectedInFragmentShader(): boolean;
  62347. /**
  62348. * Creates a block suitable to be used as an input for this input point.
  62349. * If null is returned, a block based on the point type will be created.
  62350. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  62351. */
  62352. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  62353. /**
  62354. * Creates a new connection point
  62355. * @param name defines the connection point name
  62356. * @param ownerBlock defines the block hosting this connection point
  62357. * @param direction defines the direction of the connection point
  62358. */
  62359. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  62360. /**
  62361. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  62362. * @returns the class name
  62363. */
  62364. getClassName(): string;
  62365. /**
  62366. * Gets a boolean indicating if the current point can be connected to another point
  62367. * @param connectionPoint defines the other connection point
  62368. * @returns a boolean
  62369. */
  62370. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  62371. /**
  62372. * Gets a number indicating if the current point can be connected to another point
  62373. * @param connectionPoint defines the other connection point
  62374. * @returns a number defining the compatibility state
  62375. */
  62376. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  62377. /**
  62378. * Connect this point to another connection point
  62379. * @param connectionPoint defines the other connection point
  62380. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  62381. * @returns the current connection point
  62382. */
  62383. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  62384. /**
  62385. * Disconnect this point from one of his endpoint
  62386. * @param endpoint defines the other connection point
  62387. * @returns the current connection point
  62388. */
  62389. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  62390. /**
  62391. * Serializes this point in a JSON representation
  62392. * @param isInput defines if the connection point is an input (default is true)
  62393. * @returns the serialized point object
  62394. */
  62395. serialize(isInput?: boolean): any;
  62396. /**
  62397. * Release resources
  62398. */
  62399. dispose(): void;
  62400. }
  62401. }
  62402. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  62403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62406. import { Mesh } from "babylonjs/Meshes/mesh";
  62407. import { Effect } from "babylonjs/Materials/effect";
  62408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62409. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62410. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62411. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62412. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62413. /**
  62414. * Block used to add support for vertex skinning (bones)
  62415. */
  62416. export class BonesBlock extends NodeMaterialBlock {
  62417. /**
  62418. * Creates a new BonesBlock
  62419. * @param name defines the block name
  62420. */
  62421. constructor(name: string);
  62422. /**
  62423. * Initialize the block and prepare the context for build
  62424. * @param state defines the state that will be used for the build
  62425. */
  62426. initialize(state: NodeMaterialBuildState): void;
  62427. /**
  62428. * Gets the current class name
  62429. * @returns the class name
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Gets the matrix indices input component
  62434. */
  62435. get matricesIndices(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the matrix weights input component
  62438. */
  62439. get matricesWeights(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the extra matrix indices input component
  62442. */
  62443. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the extra matrix weights input component
  62446. */
  62447. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the world input component
  62450. */
  62451. get world(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the output component
  62454. */
  62455. get output(): NodeMaterialConnectionPoint;
  62456. autoConfigure(material: NodeMaterial): void;
  62457. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62458. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62460. protected _buildBlock(state: NodeMaterialBuildState): this;
  62461. }
  62462. }
  62463. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  62464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62468. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62469. /**
  62470. * Block used to add support for instances
  62471. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62472. */
  62473. export class InstancesBlock extends NodeMaterialBlock {
  62474. /**
  62475. * Creates a new InstancesBlock
  62476. * @param name defines the block name
  62477. */
  62478. constructor(name: string);
  62479. /**
  62480. * Gets the current class name
  62481. * @returns the class name
  62482. */
  62483. getClassName(): string;
  62484. /**
  62485. * Gets the first world row input component
  62486. */
  62487. get world0(): NodeMaterialConnectionPoint;
  62488. /**
  62489. * Gets the second world row input component
  62490. */
  62491. get world1(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the third world row input component
  62494. */
  62495. get world2(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the forth world row input component
  62498. */
  62499. get world3(): NodeMaterialConnectionPoint;
  62500. /**
  62501. * Gets the world input component
  62502. */
  62503. get world(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the output component
  62506. */
  62507. get output(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the isntanceID component
  62510. */
  62511. get instanceID(): NodeMaterialConnectionPoint;
  62512. autoConfigure(material: NodeMaterial): void;
  62513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  62514. protected _buildBlock(state: NodeMaterialBuildState): this;
  62515. }
  62516. }
  62517. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  62518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62522. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62523. import { Effect } from "babylonjs/Materials/effect";
  62524. import { Mesh } from "babylonjs/Meshes/mesh";
  62525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62527. /**
  62528. * Block used to add morph targets support to vertex shader
  62529. */
  62530. export class MorphTargetsBlock extends NodeMaterialBlock {
  62531. private _repeatableContentAnchor;
  62532. /**
  62533. * Create a new MorphTargetsBlock
  62534. * @param name defines the block name
  62535. */
  62536. constructor(name: string);
  62537. /**
  62538. * Gets the current class name
  62539. * @returns the class name
  62540. */
  62541. getClassName(): string;
  62542. /**
  62543. * Gets the position input component
  62544. */
  62545. get position(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the normal input component
  62548. */
  62549. get normal(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the tangent input component
  62552. */
  62553. get tangent(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the tangent input component
  62556. */
  62557. get uv(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the position output component
  62560. */
  62561. get positionOutput(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the normal output component
  62564. */
  62565. get normalOutput(): NodeMaterialConnectionPoint;
  62566. /**
  62567. * Gets the tangent output component
  62568. */
  62569. get tangentOutput(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the tangent output component
  62572. */
  62573. get uvOutput(): NodeMaterialConnectionPoint;
  62574. initialize(state: NodeMaterialBuildState): void;
  62575. autoConfigure(material: NodeMaterial): void;
  62576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62578. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62579. protected _buildBlock(state: NodeMaterialBuildState): this;
  62580. }
  62581. }
  62582. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  62583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62586. import { Nullable } from "babylonjs/types";
  62587. import { Scene } from "babylonjs/scene";
  62588. import { Effect } from "babylonjs/Materials/effect";
  62589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62590. import { Mesh } from "babylonjs/Meshes/mesh";
  62591. import { Light } from "babylonjs/Lights/light";
  62592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62593. /**
  62594. * Block used to get data information from a light
  62595. */
  62596. export class LightInformationBlock extends NodeMaterialBlock {
  62597. private _lightDataUniformName;
  62598. private _lightColorUniformName;
  62599. private _lightTypeDefineName;
  62600. /**
  62601. * Gets or sets the light associated with this block
  62602. */
  62603. light: Nullable<Light>;
  62604. /**
  62605. * Creates a new LightInformationBlock
  62606. * @param name defines the block name
  62607. */
  62608. constructor(name: string);
  62609. /**
  62610. * Gets the current class name
  62611. * @returns the class name
  62612. */
  62613. getClassName(): string;
  62614. /**
  62615. * Gets the world position input component
  62616. */
  62617. get worldPosition(): NodeMaterialConnectionPoint;
  62618. /**
  62619. * Gets the direction output component
  62620. */
  62621. get direction(): NodeMaterialConnectionPoint;
  62622. /**
  62623. * Gets the direction output component
  62624. */
  62625. get color(): NodeMaterialConnectionPoint;
  62626. /**
  62627. * Gets the direction output component
  62628. */
  62629. get intensity(): NodeMaterialConnectionPoint;
  62630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62631. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62632. protected _buildBlock(state: NodeMaterialBuildState): this;
  62633. serialize(): any;
  62634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62635. }
  62636. }
  62637. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  62638. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  62639. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  62640. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  62641. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  62642. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  62643. }
  62644. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  62645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62649. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62650. import { Effect } from "babylonjs/Materials/effect";
  62651. import { Mesh } from "babylonjs/Meshes/mesh";
  62652. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62653. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62654. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62655. /**
  62656. * Block used to add image processing support to fragment shader
  62657. */
  62658. export class ImageProcessingBlock extends NodeMaterialBlock {
  62659. /**
  62660. * Create a new ImageProcessingBlock
  62661. * @param name defines the block name
  62662. */
  62663. constructor(name: string);
  62664. /**
  62665. * Gets the current class name
  62666. * @returns the class name
  62667. */
  62668. getClassName(): string;
  62669. /**
  62670. * Gets the color input component
  62671. */
  62672. get color(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the output component
  62675. */
  62676. get output(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Initialize the block and prepare the context for build
  62679. * @param state defines the state that will be used for the build
  62680. */
  62681. initialize(state: NodeMaterialBuildState): void;
  62682. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62685. protected _buildBlock(state: NodeMaterialBuildState): this;
  62686. }
  62687. }
  62688. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  62689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62692. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62694. import { Effect } from "babylonjs/Materials/effect";
  62695. import { Mesh } from "babylonjs/Meshes/mesh";
  62696. import { Scene } from "babylonjs/scene";
  62697. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  62698. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  62699. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  62700. /**
  62701. * Block used to pertub normals based on a normal map
  62702. */
  62703. export class PerturbNormalBlock extends NodeMaterialBlock {
  62704. private _tangentSpaceParameterName;
  62705. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62706. invertX: boolean;
  62707. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62708. invertY: boolean;
  62709. /**
  62710. * Create a new PerturbNormalBlock
  62711. * @param name defines the block name
  62712. */
  62713. constructor(name: string);
  62714. /**
  62715. * Gets the current class name
  62716. * @returns the class name
  62717. */
  62718. getClassName(): string;
  62719. /**
  62720. * Gets the world position input component
  62721. */
  62722. get worldPosition(): NodeMaterialConnectionPoint;
  62723. /**
  62724. * Gets the world normal input component
  62725. */
  62726. get worldNormal(): NodeMaterialConnectionPoint;
  62727. /**
  62728. * Gets the world tangent input component
  62729. */
  62730. get worldTangent(): NodeMaterialConnectionPoint;
  62731. /**
  62732. * Gets the uv input component
  62733. */
  62734. get uv(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the normal map color input component
  62737. */
  62738. get normalMapColor(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the strength input component
  62741. */
  62742. get strength(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the output component
  62745. */
  62746. get output(): NodeMaterialConnectionPoint;
  62747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62748. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62749. autoConfigure(material: NodeMaterial): void;
  62750. protected _buildBlock(state: NodeMaterialBuildState): this;
  62751. protected _dumpPropertiesCode(): string;
  62752. serialize(): any;
  62753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62754. }
  62755. }
  62756. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  62757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62760. /**
  62761. * Block used to discard a pixel if a value is smaller than a cutoff
  62762. */
  62763. export class DiscardBlock extends NodeMaterialBlock {
  62764. /**
  62765. * Create a new DiscardBlock
  62766. * @param name defines the block name
  62767. */
  62768. constructor(name: string);
  62769. /**
  62770. * Gets the current class name
  62771. * @returns the class name
  62772. */
  62773. getClassName(): string;
  62774. /**
  62775. * Gets the color input component
  62776. */
  62777. get value(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the cutoff input component
  62780. */
  62781. get cutoff(): NodeMaterialConnectionPoint;
  62782. protected _buildBlock(state: NodeMaterialBuildState): this;
  62783. }
  62784. }
  62785. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62789. /**
  62790. * Block used to test if the fragment shader is front facing
  62791. */
  62792. export class FrontFacingBlock extends NodeMaterialBlock {
  62793. /**
  62794. * Creates a new FrontFacingBlock
  62795. * @param name defines the block name
  62796. */
  62797. constructor(name: string);
  62798. /**
  62799. * Gets the current class name
  62800. * @returns the class name
  62801. */
  62802. getClassName(): string;
  62803. /**
  62804. * Gets the output component
  62805. */
  62806. get output(): NodeMaterialConnectionPoint;
  62807. protected _buildBlock(state: NodeMaterialBuildState): this;
  62808. }
  62809. }
  62810. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62814. /**
  62815. * Block used to get the derivative value on x and y of a given input
  62816. */
  62817. export class DerivativeBlock extends NodeMaterialBlock {
  62818. /**
  62819. * Create a new DerivativeBlock
  62820. * @param name defines the block name
  62821. */
  62822. constructor(name: string);
  62823. /**
  62824. * Gets the current class name
  62825. * @returns the class name
  62826. */
  62827. getClassName(): string;
  62828. /**
  62829. * Gets the input component
  62830. */
  62831. get input(): NodeMaterialConnectionPoint;
  62832. /**
  62833. * Gets the derivative output on x
  62834. */
  62835. get dx(): NodeMaterialConnectionPoint;
  62836. /**
  62837. * Gets the derivative output on y
  62838. */
  62839. get dy(): NodeMaterialConnectionPoint;
  62840. protected _buildBlock(state: NodeMaterialBuildState): this;
  62841. }
  62842. }
  62843. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62844. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62845. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62846. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62847. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62848. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62849. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62850. }
  62851. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62854. import { Mesh } from "babylonjs/Meshes/mesh";
  62855. import { Effect } from "babylonjs/Materials/effect";
  62856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62858. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62859. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62860. /**
  62861. * Block used to add support for scene fog
  62862. */
  62863. export class FogBlock extends NodeMaterialBlock {
  62864. private _fogDistanceName;
  62865. private _fogParameters;
  62866. /**
  62867. * Create a new FogBlock
  62868. * @param name defines the block name
  62869. */
  62870. constructor(name: string);
  62871. /**
  62872. * Gets the current class name
  62873. * @returns the class name
  62874. */
  62875. getClassName(): string;
  62876. /**
  62877. * Gets the world position input component
  62878. */
  62879. get worldPosition(): NodeMaterialConnectionPoint;
  62880. /**
  62881. * Gets the view input component
  62882. */
  62883. get view(): NodeMaterialConnectionPoint;
  62884. /**
  62885. * Gets the color input component
  62886. */
  62887. get input(): NodeMaterialConnectionPoint;
  62888. /**
  62889. * Gets the fog color input component
  62890. */
  62891. get fogColor(): NodeMaterialConnectionPoint;
  62892. /**
  62893. * Gets the output component
  62894. */
  62895. get output(): NodeMaterialConnectionPoint;
  62896. autoConfigure(material: NodeMaterial): void;
  62897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62899. protected _buildBlock(state: NodeMaterialBuildState): this;
  62900. }
  62901. }
  62902. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62907. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62908. import { Effect } from "babylonjs/Materials/effect";
  62909. import { Mesh } from "babylonjs/Meshes/mesh";
  62910. import { Light } from "babylonjs/Lights/light";
  62911. import { Nullable } from "babylonjs/types";
  62912. import { Scene } from "babylonjs/scene";
  62913. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62914. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62915. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62916. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62917. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62918. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62919. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62920. /**
  62921. * Block used to add light in the fragment shader
  62922. */
  62923. export class LightBlock extends NodeMaterialBlock {
  62924. private _lightId;
  62925. /**
  62926. * Gets or sets the light associated with this block
  62927. */
  62928. light: Nullable<Light>;
  62929. /**
  62930. * Create a new LightBlock
  62931. * @param name defines the block name
  62932. */
  62933. constructor(name: string);
  62934. /**
  62935. * Gets the current class name
  62936. * @returns the class name
  62937. */
  62938. getClassName(): string;
  62939. /**
  62940. * Gets the world position input component
  62941. */
  62942. get worldPosition(): NodeMaterialConnectionPoint;
  62943. /**
  62944. * Gets the world normal input component
  62945. */
  62946. get worldNormal(): NodeMaterialConnectionPoint;
  62947. /**
  62948. * Gets the camera (or eye) position component
  62949. */
  62950. get cameraPosition(): NodeMaterialConnectionPoint;
  62951. /**
  62952. * Gets the glossiness component
  62953. */
  62954. get glossiness(): NodeMaterialConnectionPoint;
  62955. /**
  62956. * Gets the glossinness power component
  62957. */
  62958. get glossPower(): NodeMaterialConnectionPoint;
  62959. /**
  62960. * Gets the diffuse color component
  62961. */
  62962. get diffuseColor(): NodeMaterialConnectionPoint;
  62963. /**
  62964. * Gets the specular color component
  62965. */
  62966. get specularColor(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the diffuse output component
  62969. */
  62970. get diffuseOutput(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the specular output component
  62973. */
  62974. get specularOutput(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the shadow output component
  62977. */
  62978. get shadow(): NodeMaterialConnectionPoint;
  62979. autoConfigure(material: NodeMaterial): void;
  62980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62981. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62983. private _injectVertexCode;
  62984. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62985. serialize(): any;
  62986. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62987. }
  62988. }
  62989. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  62990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62992. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62993. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  62994. /**
  62995. * Block used to read a reflection texture from a sampler
  62996. */
  62997. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62998. /**
  62999. * Create a new ReflectionTextureBlock
  63000. * @param name defines the block name
  63001. */
  63002. constructor(name: string);
  63003. /**
  63004. * Gets the current class name
  63005. * @returns the class name
  63006. */
  63007. getClassName(): string;
  63008. /**
  63009. * Gets the world position input component
  63010. */
  63011. get position(): NodeMaterialConnectionPoint;
  63012. /**
  63013. * Gets the world position input component
  63014. */
  63015. get worldPosition(): NodeMaterialConnectionPoint;
  63016. /**
  63017. * Gets the world normal input component
  63018. */
  63019. get worldNormal(): NodeMaterialConnectionPoint;
  63020. /**
  63021. * Gets the world input component
  63022. */
  63023. get world(): NodeMaterialConnectionPoint;
  63024. /**
  63025. * Gets the camera (or eye) position component
  63026. */
  63027. get cameraPosition(): NodeMaterialConnectionPoint;
  63028. /**
  63029. * Gets the view input component
  63030. */
  63031. get view(): NodeMaterialConnectionPoint;
  63032. /**
  63033. * Gets the rgb output component
  63034. */
  63035. get rgb(): NodeMaterialConnectionPoint;
  63036. /**
  63037. * Gets the r output component
  63038. */
  63039. get r(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the g output component
  63042. */
  63043. get g(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the b output component
  63046. */
  63047. get b(): NodeMaterialConnectionPoint;
  63048. autoConfigure(material: NodeMaterial): void;
  63049. protected _buildBlock(state: NodeMaterialBuildState): this;
  63050. }
  63051. }
  63052. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  63053. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  63054. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  63055. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  63058. }
  63059. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  63060. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  63062. }
  63063. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  63064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63067. /**
  63068. * Block used to add 2 vectors
  63069. */
  63070. export class AddBlock extends NodeMaterialBlock {
  63071. /**
  63072. * Creates a new AddBlock
  63073. * @param name defines the block name
  63074. */
  63075. constructor(name: string);
  63076. /**
  63077. * Gets the current class name
  63078. * @returns the class name
  63079. */
  63080. getClassName(): string;
  63081. /**
  63082. * Gets the left operand input component
  63083. */
  63084. get left(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the right operand input component
  63087. */
  63088. get right(): NodeMaterialConnectionPoint;
  63089. /**
  63090. * Gets the output component
  63091. */
  63092. get output(): NodeMaterialConnectionPoint;
  63093. protected _buildBlock(state: NodeMaterialBuildState): this;
  63094. }
  63095. }
  63096. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  63097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63100. /**
  63101. * Block used to scale a vector by a float
  63102. */
  63103. export class ScaleBlock extends NodeMaterialBlock {
  63104. /**
  63105. * Creates a new ScaleBlock
  63106. * @param name defines the block name
  63107. */
  63108. constructor(name: string);
  63109. /**
  63110. * Gets the current class name
  63111. * @returns the class name
  63112. */
  63113. getClassName(): string;
  63114. /**
  63115. * Gets the input component
  63116. */
  63117. get input(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the factor input component
  63120. */
  63121. get factor(): NodeMaterialConnectionPoint;
  63122. /**
  63123. * Gets the output component
  63124. */
  63125. get output(): NodeMaterialConnectionPoint;
  63126. protected _buildBlock(state: NodeMaterialBuildState): this;
  63127. }
  63128. }
  63129. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  63130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63133. import { Scene } from "babylonjs/scene";
  63134. /**
  63135. * Block used to clamp a float
  63136. */
  63137. export class ClampBlock extends NodeMaterialBlock {
  63138. /** Gets or sets the minimum range */
  63139. minimum: number;
  63140. /** Gets or sets the maximum range */
  63141. maximum: number;
  63142. /**
  63143. * Creates a new ClampBlock
  63144. * @param name defines the block name
  63145. */
  63146. constructor(name: string);
  63147. /**
  63148. * Gets the current class name
  63149. * @returns the class name
  63150. */
  63151. getClassName(): string;
  63152. /**
  63153. * Gets the value input component
  63154. */
  63155. get value(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the output component
  63158. */
  63159. get output(): NodeMaterialConnectionPoint;
  63160. protected _buildBlock(state: NodeMaterialBuildState): this;
  63161. protected _dumpPropertiesCode(): string;
  63162. serialize(): any;
  63163. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63164. }
  63165. }
  63166. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  63167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63170. /**
  63171. * Block used to apply a cross product between 2 vectors
  63172. */
  63173. export class CrossBlock extends NodeMaterialBlock {
  63174. /**
  63175. * Creates a new CrossBlock
  63176. * @param name defines the block name
  63177. */
  63178. constructor(name: string);
  63179. /**
  63180. * Gets the current class name
  63181. * @returns the class name
  63182. */
  63183. getClassName(): string;
  63184. /**
  63185. * Gets the left operand input component
  63186. */
  63187. get left(): NodeMaterialConnectionPoint;
  63188. /**
  63189. * Gets the right operand input component
  63190. */
  63191. get right(): NodeMaterialConnectionPoint;
  63192. /**
  63193. * Gets the output component
  63194. */
  63195. get output(): NodeMaterialConnectionPoint;
  63196. protected _buildBlock(state: NodeMaterialBuildState): this;
  63197. }
  63198. }
  63199. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  63200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63203. /**
  63204. * Block used to apply a dot product between 2 vectors
  63205. */
  63206. export class DotBlock extends NodeMaterialBlock {
  63207. /**
  63208. * Creates a new DotBlock
  63209. * @param name defines the block name
  63210. */
  63211. constructor(name: string);
  63212. /**
  63213. * Gets the current class name
  63214. * @returns the class name
  63215. */
  63216. getClassName(): string;
  63217. /**
  63218. * Gets the left operand input component
  63219. */
  63220. get left(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the right operand input component
  63223. */
  63224. get right(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the output component
  63227. */
  63228. get output(): NodeMaterialConnectionPoint;
  63229. protected _buildBlock(state: NodeMaterialBuildState): this;
  63230. }
  63231. }
  63232. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  63233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63236. /**
  63237. * Block used to normalize a vector
  63238. */
  63239. export class NormalizeBlock extends NodeMaterialBlock {
  63240. /**
  63241. * Creates a new NormalizeBlock
  63242. * @param name defines the block name
  63243. */
  63244. constructor(name: string);
  63245. /**
  63246. * Gets the current class name
  63247. * @returns the class name
  63248. */
  63249. getClassName(): string;
  63250. /**
  63251. * Gets the input component
  63252. */
  63253. get input(): NodeMaterialConnectionPoint;
  63254. /**
  63255. * Gets the output component
  63256. */
  63257. get output(): NodeMaterialConnectionPoint;
  63258. protected _buildBlock(state: NodeMaterialBuildState): this;
  63259. }
  63260. }
  63261. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  63262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63265. import { Scene } from "babylonjs/scene";
  63266. /**
  63267. * Operations supported by the Trigonometry block
  63268. */
  63269. export enum TrigonometryBlockOperations {
  63270. /** Cos */
  63271. Cos = 0,
  63272. /** Sin */
  63273. Sin = 1,
  63274. /** Abs */
  63275. Abs = 2,
  63276. /** Exp */
  63277. Exp = 3,
  63278. /** Exp2 */
  63279. Exp2 = 4,
  63280. /** Round */
  63281. Round = 5,
  63282. /** Floor */
  63283. Floor = 6,
  63284. /** Ceiling */
  63285. Ceiling = 7,
  63286. /** Square root */
  63287. Sqrt = 8,
  63288. /** Log */
  63289. Log = 9,
  63290. /** Tangent */
  63291. Tan = 10,
  63292. /** Arc tangent */
  63293. ArcTan = 11,
  63294. /** Arc cosinus */
  63295. ArcCos = 12,
  63296. /** Arc sinus */
  63297. ArcSin = 13,
  63298. /** Fraction */
  63299. Fract = 14,
  63300. /** Sign */
  63301. Sign = 15,
  63302. /** To radians (from degrees) */
  63303. Radians = 16,
  63304. /** To degrees (from radians) */
  63305. Degrees = 17
  63306. }
  63307. /**
  63308. * Block used to apply trigonometry operation to floats
  63309. */
  63310. export class TrigonometryBlock extends NodeMaterialBlock {
  63311. /**
  63312. * Gets or sets the operation applied by the block
  63313. */
  63314. operation: TrigonometryBlockOperations;
  63315. /**
  63316. * Creates a new TrigonometryBlock
  63317. * @param name defines the block name
  63318. */
  63319. constructor(name: string);
  63320. /**
  63321. * Gets the current class name
  63322. * @returns the class name
  63323. */
  63324. getClassName(): string;
  63325. /**
  63326. * Gets the input component
  63327. */
  63328. get input(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the output component
  63331. */
  63332. get output(): NodeMaterialConnectionPoint;
  63333. protected _buildBlock(state: NodeMaterialBuildState): this;
  63334. serialize(): any;
  63335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63336. protected _dumpPropertiesCode(): string;
  63337. }
  63338. }
  63339. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  63340. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63341. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63342. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63343. /**
  63344. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63345. */
  63346. export class ColorMergerBlock extends NodeMaterialBlock {
  63347. /**
  63348. * Create a new ColorMergerBlock
  63349. * @param name defines the block name
  63350. */
  63351. constructor(name: string);
  63352. /**
  63353. * Gets the current class name
  63354. * @returns the class name
  63355. */
  63356. getClassName(): string;
  63357. /**
  63358. * Gets the rgb component (input)
  63359. */
  63360. get rgbIn(): NodeMaterialConnectionPoint;
  63361. /**
  63362. * Gets the r component (input)
  63363. */
  63364. get r(): NodeMaterialConnectionPoint;
  63365. /**
  63366. * Gets the g component (input)
  63367. */
  63368. get g(): NodeMaterialConnectionPoint;
  63369. /**
  63370. * Gets the b component (input)
  63371. */
  63372. get b(): NodeMaterialConnectionPoint;
  63373. /**
  63374. * Gets the a component (input)
  63375. */
  63376. get a(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the rgba component (output)
  63379. */
  63380. get rgba(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the rgb component (output)
  63383. */
  63384. get rgbOut(): NodeMaterialConnectionPoint;
  63385. /**
  63386. * Gets the rgb component (output)
  63387. * @deprecated Please use rgbOut instead.
  63388. */
  63389. get rgb(): NodeMaterialConnectionPoint;
  63390. protected _buildBlock(state: NodeMaterialBuildState): this;
  63391. }
  63392. }
  63393. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  63394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63397. /**
  63398. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  63399. */
  63400. export class ColorSplitterBlock extends NodeMaterialBlock {
  63401. /**
  63402. * Create a new ColorSplitterBlock
  63403. * @param name defines the block name
  63404. */
  63405. constructor(name: string);
  63406. /**
  63407. * Gets the current class name
  63408. * @returns the class name
  63409. */
  63410. getClassName(): string;
  63411. /**
  63412. * Gets the rgba component (input)
  63413. */
  63414. get rgba(): NodeMaterialConnectionPoint;
  63415. /**
  63416. * Gets the rgb component (input)
  63417. */
  63418. get rgbIn(): NodeMaterialConnectionPoint;
  63419. /**
  63420. * Gets the rgb component (output)
  63421. */
  63422. get rgbOut(): NodeMaterialConnectionPoint;
  63423. /**
  63424. * Gets the r component (output)
  63425. */
  63426. get r(): NodeMaterialConnectionPoint;
  63427. /**
  63428. * Gets the g component (output)
  63429. */
  63430. get g(): NodeMaterialConnectionPoint;
  63431. /**
  63432. * Gets the b component (output)
  63433. */
  63434. get b(): NodeMaterialConnectionPoint;
  63435. /**
  63436. * Gets the a component (output)
  63437. */
  63438. get a(): NodeMaterialConnectionPoint;
  63439. protected _inputRename(name: string): string;
  63440. protected _outputRename(name: string): string;
  63441. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63442. }
  63443. }
  63444. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  63445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63448. /**
  63449. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63450. */
  63451. export class VectorSplitterBlock extends NodeMaterialBlock {
  63452. /**
  63453. * Create a new VectorSplitterBlock
  63454. * @param name defines the block name
  63455. */
  63456. constructor(name: string);
  63457. /**
  63458. * Gets the current class name
  63459. * @returns the class name
  63460. */
  63461. getClassName(): string;
  63462. /**
  63463. * Gets the xyzw component (input)
  63464. */
  63465. get xyzw(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the xyz component (input)
  63468. */
  63469. get xyzIn(): NodeMaterialConnectionPoint;
  63470. /**
  63471. * Gets the xy component (input)
  63472. */
  63473. get xyIn(): NodeMaterialConnectionPoint;
  63474. /**
  63475. * Gets the xyz component (output)
  63476. */
  63477. get xyzOut(): NodeMaterialConnectionPoint;
  63478. /**
  63479. * Gets the xy component (output)
  63480. */
  63481. get xyOut(): NodeMaterialConnectionPoint;
  63482. /**
  63483. * Gets the x component (output)
  63484. */
  63485. get x(): NodeMaterialConnectionPoint;
  63486. /**
  63487. * Gets the y component (output)
  63488. */
  63489. get y(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the z component (output)
  63492. */
  63493. get z(): NodeMaterialConnectionPoint;
  63494. /**
  63495. * Gets the w component (output)
  63496. */
  63497. get w(): NodeMaterialConnectionPoint;
  63498. protected _inputRename(name: string): string;
  63499. protected _outputRename(name: string): string;
  63500. protected _buildBlock(state: NodeMaterialBuildState): this;
  63501. }
  63502. }
  63503. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  63504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63507. /**
  63508. * Block used to lerp between 2 values
  63509. */
  63510. export class LerpBlock extends NodeMaterialBlock {
  63511. /**
  63512. * Creates a new LerpBlock
  63513. * @param name defines the block name
  63514. */
  63515. constructor(name: string);
  63516. /**
  63517. * Gets the current class name
  63518. * @returns the class name
  63519. */
  63520. getClassName(): string;
  63521. /**
  63522. * Gets the left operand input component
  63523. */
  63524. get left(): NodeMaterialConnectionPoint;
  63525. /**
  63526. * Gets the right operand input component
  63527. */
  63528. get right(): NodeMaterialConnectionPoint;
  63529. /**
  63530. * Gets the gradient operand input component
  63531. */
  63532. get gradient(): NodeMaterialConnectionPoint;
  63533. /**
  63534. * Gets the output component
  63535. */
  63536. get output(): NodeMaterialConnectionPoint;
  63537. protected _buildBlock(state: NodeMaterialBuildState): this;
  63538. }
  63539. }
  63540. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  63541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63544. /**
  63545. * Block used to divide 2 vectors
  63546. */
  63547. export class DivideBlock extends NodeMaterialBlock {
  63548. /**
  63549. * Creates a new DivideBlock
  63550. * @param name defines the block name
  63551. */
  63552. constructor(name: string);
  63553. /**
  63554. * Gets the current class name
  63555. * @returns the class name
  63556. */
  63557. getClassName(): string;
  63558. /**
  63559. * Gets the left operand input component
  63560. */
  63561. get left(): NodeMaterialConnectionPoint;
  63562. /**
  63563. * Gets the right operand input component
  63564. */
  63565. get right(): NodeMaterialConnectionPoint;
  63566. /**
  63567. * Gets the output component
  63568. */
  63569. get output(): NodeMaterialConnectionPoint;
  63570. protected _buildBlock(state: NodeMaterialBuildState): this;
  63571. }
  63572. }
  63573. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  63574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63577. /**
  63578. * Block used to subtract 2 vectors
  63579. */
  63580. export class SubtractBlock extends NodeMaterialBlock {
  63581. /**
  63582. * Creates a new SubtractBlock
  63583. * @param name defines the block name
  63584. */
  63585. constructor(name: string);
  63586. /**
  63587. * Gets the current class name
  63588. * @returns the class name
  63589. */
  63590. getClassName(): string;
  63591. /**
  63592. * Gets the left operand input component
  63593. */
  63594. get left(): NodeMaterialConnectionPoint;
  63595. /**
  63596. * Gets the right operand input component
  63597. */
  63598. get right(): NodeMaterialConnectionPoint;
  63599. /**
  63600. * Gets the output component
  63601. */
  63602. get output(): NodeMaterialConnectionPoint;
  63603. protected _buildBlock(state: NodeMaterialBuildState): this;
  63604. }
  63605. }
  63606. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  63607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63610. /**
  63611. * Block used to step a value
  63612. */
  63613. export class StepBlock extends NodeMaterialBlock {
  63614. /**
  63615. * Creates a new StepBlock
  63616. * @param name defines the block name
  63617. */
  63618. constructor(name: string);
  63619. /**
  63620. * Gets the current class name
  63621. * @returns the class name
  63622. */
  63623. getClassName(): string;
  63624. /**
  63625. * Gets the value operand input component
  63626. */
  63627. get value(): NodeMaterialConnectionPoint;
  63628. /**
  63629. * Gets the edge operand input component
  63630. */
  63631. get edge(): NodeMaterialConnectionPoint;
  63632. /**
  63633. * Gets the output component
  63634. */
  63635. get output(): NodeMaterialConnectionPoint;
  63636. protected _buildBlock(state: NodeMaterialBuildState): this;
  63637. }
  63638. }
  63639. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  63640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63643. /**
  63644. * Block used to get the opposite (1 - x) of a value
  63645. */
  63646. export class OneMinusBlock extends NodeMaterialBlock {
  63647. /**
  63648. * Creates a new OneMinusBlock
  63649. * @param name defines the block name
  63650. */
  63651. constructor(name: string);
  63652. /**
  63653. * Gets the current class name
  63654. * @returns the class name
  63655. */
  63656. getClassName(): string;
  63657. /**
  63658. * Gets the input component
  63659. */
  63660. get input(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the output component
  63663. */
  63664. get output(): NodeMaterialConnectionPoint;
  63665. protected _buildBlock(state: NodeMaterialBuildState): this;
  63666. }
  63667. }
  63668. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63672. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63673. /**
  63674. * Block used to get the view direction
  63675. */
  63676. export class ViewDirectionBlock extends NodeMaterialBlock {
  63677. /**
  63678. * Creates a new ViewDirectionBlock
  63679. * @param name defines the block name
  63680. */
  63681. constructor(name: string);
  63682. /**
  63683. * Gets the current class name
  63684. * @returns the class name
  63685. */
  63686. getClassName(): string;
  63687. /**
  63688. * Gets the world position component
  63689. */
  63690. get worldPosition(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the camera position component
  63693. */
  63694. get cameraPosition(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the output component
  63697. */
  63698. get output(): NodeMaterialConnectionPoint;
  63699. autoConfigure(material: NodeMaterial): void;
  63700. protected _buildBlock(state: NodeMaterialBuildState): this;
  63701. }
  63702. }
  63703. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63707. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63708. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63709. /**
  63710. * Block used to compute fresnel value
  63711. */
  63712. export class FresnelBlock extends NodeMaterialBlock {
  63713. /**
  63714. * Create a new FresnelBlock
  63715. * @param name defines the block name
  63716. */
  63717. constructor(name: string);
  63718. /**
  63719. * Gets the current class name
  63720. * @returns the class name
  63721. */
  63722. getClassName(): string;
  63723. /**
  63724. * Gets the world normal input component
  63725. */
  63726. get worldNormal(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the view direction input component
  63729. */
  63730. get viewDirection(): NodeMaterialConnectionPoint;
  63731. /**
  63732. * Gets the bias input component
  63733. */
  63734. get bias(): NodeMaterialConnectionPoint;
  63735. /**
  63736. * Gets the camera (or eye) position component
  63737. */
  63738. get power(): NodeMaterialConnectionPoint;
  63739. /**
  63740. * Gets the fresnel output component
  63741. */
  63742. get fresnel(): NodeMaterialConnectionPoint;
  63743. autoConfigure(material: NodeMaterial): void;
  63744. protected _buildBlock(state: NodeMaterialBuildState): this;
  63745. }
  63746. }
  63747. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63751. /**
  63752. * Block used to get the max of 2 values
  63753. */
  63754. export class MaxBlock extends NodeMaterialBlock {
  63755. /**
  63756. * Creates a new MaxBlock
  63757. * @param name defines the block name
  63758. */
  63759. constructor(name: string);
  63760. /**
  63761. * Gets the current class name
  63762. * @returns the class name
  63763. */
  63764. getClassName(): string;
  63765. /**
  63766. * Gets the left operand input component
  63767. */
  63768. get left(): NodeMaterialConnectionPoint;
  63769. /**
  63770. * Gets the right operand input component
  63771. */
  63772. get right(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the output component
  63775. */
  63776. get output(): NodeMaterialConnectionPoint;
  63777. protected _buildBlock(state: NodeMaterialBuildState): this;
  63778. }
  63779. }
  63780. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63784. /**
  63785. * Block used to get the min of 2 values
  63786. */
  63787. export class MinBlock extends NodeMaterialBlock {
  63788. /**
  63789. * Creates a new MinBlock
  63790. * @param name defines the block name
  63791. */
  63792. constructor(name: string);
  63793. /**
  63794. * Gets the current class name
  63795. * @returns the class name
  63796. */
  63797. getClassName(): string;
  63798. /**
  63799. * Gets the left operand input component
  63800. */
  63801. get left(): NodeMaterialConnectionPoint;
  63802. /**
  63803. * Gets the right operand input component
  63804. */
  63805. get right(): NodeMaterialConnectionPoint;
  63806. /**
  63807. * Gets the output component
  63808. */
  63809. get output(): NodeMaterialConnectionPoint;
  63810. protected _buildBlock(state: NodeMaterialBuildState): this;
  63811. }
  63812. }
  63813. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63817. /**
  63818. * Block used to get the distance between 2 values
  63819. */
  63820. export class DistanceBlock extends NodeMaterialBlock {
  63821. /**
  63822. * Creates a new DistanceBlock
  63823. * @param name defines the block name
  63824. */
  63825. constructor(name: string);
  63826. /**
  63827. * Gets the current class name
  63828. * @returns the class name
  63829. */
  63830. getClassName(): string;
  63831. /**
  63832. * Gets the left operand input component
  63833. */
  63834. get left(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the right operand input component
  63837. */
  63838. get right(): NodeMaterialConnectionPoint;
  63839. /**
  63840. * Gets the output component
  63841. */
  63842. get output(): NodeMaterialConnectionPoint;
  63843. protected _buildBlock(state: NodeMaterialBuildState): this;
  63844. }
  63845. }
  63846. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63850. /**
  63851. * Block used to get the length of a vector
  63852. */
  63853. export class LengthBlock extends NodeMaterialBlock {
  63854. /**
  63855. * Creates a new LengthBlock
  63856. * @param name defines the block name
  63857. */
  63858. constructor(name: string);
  63859. /**
  63860. * Gets the current class name
  63861. * @returns the class name
  63862. */
  63863. getClassName(): string;
  63864. /**
  63865. * Gets the value input component
  63866. */
  63867. get value(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the output component
  63870. */
  63871. get output(): NodeMaterialConnectionPoint;
  63872. protected _buildBlock(state: NodeMaterialBuildState): this;
  63873. }
  63874. }
  63875. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63879. /**
  63880. * Block used to get negative version of a value (i.e. x * -1)
  63881. */
  63882. export class NegateBlock extends NodeMaterialBlock {
  63883. /**
  63884. * Creates a new NegateBlock
  63885. * @param name defines the block name
  63886. */
  63887. constructor(name: string);
  63888. /**
  63889. * Gets the current class name
  63890. * @returns the class name
  63891. */
  63892. getClassName(): string;
  63893. /**
  63894. * Gets the value input component
  63895. */
  63896. get value(): NodeMaterialConnectionPoint;
  63897. /**
  63898. * Gets the output component
  63899. */
  63900. get output(): NodeMaterialConnectionPoint;
  63901. protected _buildBlock(state: NodeMaterialBuildState): this;
  63902. }
  63903. }
  63904. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63905. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63906. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63908. /**
  63909. * Block used to get the value of the first parameter raised to the power of the second
  63910. */
  63911. export class PowBlock extends NodeMaterialBlock {
  63912. /**
  63913. * Creates a new PowBlock
  63914. * @param name defines the block name
  63915. */
  63916. constructor(name: string);
  63917. /**
  63918. * Gets the current class name
  63919. * @returns the class name
  63920. */
  63921. getClassName(): string;
  63922. /**
  63923. * Gets the value operand input component
  63924. */
  63925. get value(): NodeMaterialConnectionPoint;
  63926. /**
  63927. * Gets the power operand input component
  63928. */
  63929. get power(): NodeMaterialConnectionPoint;
  63930. /**
  63931. * Gets the output component
  63932. */
  63933. get output(): NodeMaterialConnectionPoint;
  63934. protected _buildBlock(state: NodeMaterialBuildState): this;
  63935. }
  63936. }
  63937. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63942. /**
  63943. * Block used to get a random number
  63944. */
  63945. export class RandomNumberBlock extends NodeMaterialBlock {
  63946. /**
  63947. * Creates a new RandomNumberBlock
  63948. * @param name defines the block name
  63949. */
  63950. constructor(name: string);
  63951. /**
  63952. * Gets the current class name
  63953. * @returns the class name
  63954. */
  63955. getClassName(): string;
  63956. /**
  63957. * Gets the seed input component
  63958. */
  63959. get seed(): NodeMaterialConnectionPoint;
  63960. /**
  63961. * Gets the output component
  63962. */
  63963. get output(): NodeMaterialConnectionPoint;
  63964. protected _buildBlock(state: NodeMaterialBuildState): this;
  63965. }
  63966. }
  63967. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63971. /**
  63972. * Block used to compute arc tangent of 2 values
  63973. */
  63974. export class ArcTan2Block extends NodeMaterialBlock {
  63975. /**
  63976. * Creates a new ArcTan2Block
  63977. * @param name defines the block name
  63978. */
  63979. constructor(name: string);
  63980. /**
  63981. * Gets the current class name
  63982. * @returns the class name
  63983. */
  63984. getClassName(): string;
  63985. /**
  63986. * Gets the x operand input component
  63987. */
  63988. get x(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the y operand input component
  63991. */
  63992. get y(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the output component
  63995. */
  63996. get output(): NodeMaterialConnectionPoint;
  63997. protected _buildBlock(state: NodeMaterialBuildState): this;
  63998. }
  63999. }
  64000. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  64001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64004. /**
  64005. * Block used to smooth step a value
  64006. */
  64007. export class SmoothStepBlock extends NodeMaterialBlock {
  64008. /**
  64009. * Creates a new SmoothStepBlock
  64010. * @param name defines the block name
  64011. */
  64012. constructor(name: string);
  64013. /**
  64014. * Gets the current class name
  64015. * @returns the class name
  64016. */
  64017. getClassName(): string;
  64018. /**
  64019. * Gets the value operand input component
  64020. */
  64021. get value(): NodeMaterialConnectionPoint;
  64022. /**
  64023. * Gets the first edge operand input component
  64024. */
  64025. get edge0(): NodeMaterialConnectionPoint;
  64026. /**
  64027. * Gets the second edge operand input component
  64028. */
  64029. get edge1(): NodeMaterialConnectionPoint;
  64030. /**
  64031. * Gets the output component
  64032. */
  64033. get output(): NodeMaterialConnectionPoint;
  64034. protected _buildBlock(state: NodeMaterialBuildState): this;
  64035. }
  64036. }
  64037. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  64038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64041. /**
  64042. * Block used to get the reciprocal (1 / x) of a value
  64043. */
  64044. export class ReciprocalBlock extends NodeMaterialBlock {
  64045. /**
  64046. * Creates a new ReciprocalBlock
  64047. * @param name defines the block name
  64048. */
  64049. constructor(name: string);
  64050. /**
  64051. * Gets the current class name
  64052. * @returns the class name
  64053. */
  64054. getClassName(): string;
  64055. /**
  64056. * Gets the input component
  64057. */
  64058. get input(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the output component
  64061. */
  64062. get output(): NodeMaterialConnectionPoint;
  64063. protected _buildBlock(state: NodeMaterialBuildState): this;
  64064. }
  64065. }
  64066. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  64067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64070. /**
  64071. * Block used to replace a color by another one
  64072. */
  64073. export class ReplaceColorBlock extends NodeMaterialBlock {
  64074. /**
  64075. * Creates a new ReplaceColorBlock
  64076. * @param name defines the block name
  64077. */
  64078. constructor(name: string);
  64079. /**
  64080. * Gets the current class name
  64081. * @returns the class name
  64082. */
  64083. getClassName(): string;
  64084. /**
  64085. * Gets the value input component
  64086. */
  64087. get value(): NodeMaterialConnectionPoint;
  64088. /**
  64089. * Gets the reference input component
  64090. */
  64091. get reference(): NodeMaterialConnectionPoint;
  64092. /**
  64093. * Gets the distance input component
  64094. */
  64095. get distance(): NodeMaterialConnectionPoint;
  64096. /**
  64097. * Gets the replacement input component
  64098. */
  64099. get replacement(): NodeMaterialConnectionPoint;
  64100. /**
  64101. * Gets the output component
  64102. */
  64103. get output(): NodeMaterialConnectionPoint;
  64104. protected _buildBlock(state: NodeMaterialBuildState): this;
  64105. }
  64106. }
  64107. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  64108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64111. /**
  64112. * Block used to posterize a value
  64113. * @see https://en.wikipedia.org/wiki/Posterization
  64114. */
  64115. export class PosterizeBlock extends NodeMaterialBlock {
  64116. /**
  64117. * Creates a new PosterizeBlock
  64118. * @param name defines the block name
  64119. */
  64120. constructor(name: string);
  64121. /**
  64122. * Gets the current class name
  64123. * @returns the class name
  64124. */
  64125. getClassName(): string;
  64126. /**
  64127. * Gets the value input component
  64128. */
  64129. get value(): NodeMaterialConnectionPoint;
  64130. /**
  64131. * Gets the steps input component
  64132. */
  64133. get steps(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the output component
  64136. */
  64137. get output(): NodeMaterialConnectionPoint;
  64138. protected _buildBlock(state: NodeMaterialBuildState): this;
  64139. }
  64140. }
  64141. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  64142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64145. import { Scene } from "babylonjs/scene";
  64146. /**
  64147. * Operations supported by the Wave block
  64148. */
  64149. export enum WaveBlockKind {
  64150. /** SawTooth */
  64151. SawTooth = 0,
  64152. /** Square */
  64153. Square = 1,
  64154. /** Triangle */
  64155. Triangle = 2
  64156. }
  64157. /**
  64158. * Block used to apply wave operation to floats
  64159. */
  64160. export class WaveBlock extends NodeMaterialBlock {
  64161. /**
  64162. * Gets or sets the kibnd of wave to be applied by the block
  64163. */
  64164. kind: WaveBlockKind;
  64165. /**
  64166. * Creates a new WaveBlock
  64167. * @param name defines the block name
  64168. */
  64169. constructor(name: string);
  64170. /**
  64171. * Gets the current class name
  64172. * @returns the class name
  64173. */
  64174. getClassName(): string;
  64175. /**
  64176. * Gets the input component
  64177. */
  64178. get input(): NodeMaterialConnectionPoint;
  64179. /**
  64180. * Gets the output component
  64181. */
  64182. get output(): NodeMaterialConnectionPoint;
  64183. protected _buildBlock(state: NodeMaterialBuildState): this;
  64184. serialize(): any;
  64185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64186. }
  64187. }
  64188. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  64189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64192. import { Color3 } from "babylonjs/Maths/math.color";
  64193. import { Scene } from "babylonjs/scene";
  64194. /**
  64195. * Class used to store a color step for the GradientBlock
  64196. */
  64197. export class GradientBlockColorStep {
  64198. /**
  64199. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64200. */
  64201. step: number;
  64202. /**
  64203. * Gets or sets the color associated with this step
  64204. */
  64205. color: Color3;
  64206. /**
  64207. * Creates a new GradientBlockColorStep
  64208. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64209. * @param color defines the color associated with this step
  64210. */
  64211. constructor(
  64212. /**
  64213. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64214. */
  64215. step: number,
  64216. /**
  64217. * Gets or sets the color associated with this step
  64218. */
  64219. color: Color3);
  64220. }
  64221. /**
  64222. * Block used to return a color from a gradient based on an input value between 0 and 1
  64223. */
  64224. export class GradientBlock extends NodeMaterialBlock {
  64225. /**
  64226. * Gets or sets the list of color steps
  64227. */
  64228. colorSteps: GradientBlockColorStep[];
  64229. /**
  64230. * Creates a new GradientBlock
  64231. * @param name defines the block name
  64232. */
  64233. constructor(name: string);
  64234. /**
  64235. * Gets the current class name
  64236. * @returns the class name
  64237. */
  64238. getClassName(): string;
  64239. /**
  64240. * Gets the gradient input component
  64241. */
  64242. get gradient(): NodeMaterialConnectionPoint;
  64243. /**
  64244. * Gets the output component
  64245. */
  64246. get output(): NodeMaterialConnectionPoint;
  64247. private _writeColorConstant;
  64248. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64249. serialize(): any;
  64250. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64251. protected _dumpPropertiesCode(): string;
  64252. }
  64253. }
  64254. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  64255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64258. /**
  64259. * Block used to normalize lerp between 2 values
  64260. */
  64261. export class NLerpBlock extends NodeMaterialBlock {
  64262. /**
  64263. * Creates a new NLerpBlock
  64264. * @param name defines the block name
  64265. */
  64266. constructor(name: string);
  64267. /**
  64268. * Gets the current class name
  64269. * @returns the class name
  64270. */
  64271. getClassName(): string;
  64272. /**
  64273. * Gets the left operand input component
  64274. */
  64275. get left(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the right operand input component
  64278. */
  64279. get right(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the gradient operand input component
  64282. */
  64283. get gradient(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the output component
  64286. */
  64287. get output(): NodeMaterialConnectionPoint;
  64288. protected _buildBlock(state: NodeMaterialBuildState): this;
  64289. }
  64290. }
  64291. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  64292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64295. import { Scene } from "babylonjs/scene";
  64296. /**
  64297. * block used to Generate a Worley Noise 3D Noise Pattern
  64298. */
  64299. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64300. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64301. manhattanDistance: boolean;
  64302. /**
  64303. * Creates a new WorleyNoise3DBlock
  64304. * @param name defines the block name
  64305. */
  64306. constructor(name: string);
  64307. /**
  64308. * Gets the current class name
  64309. * @returns the class name
  64310. */
  64311. getClassName(): string;
  64312. /**
  64313. * Gets the seed input component
  64314. */
  64315. get seed(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the jitter input component
  64318. */
  64319. get jitter(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the output component
  64322. */
  64323. get output(): NodeMaterialConnectionPoint;
  64324. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64325. /**
  64326. * Exposes the properties to the UI?
  64327. */
  64328. protected _dumpPropertiesCode(): string;
  64329. /**
  64330. * Exposes the properties to the Seralize?
  64331. */
  64332. serialize(): any;
  64333. /**
  64334. * Exposes the properties to the deseralize?
  64335. */
  64336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64337. }
  64338. }
  64339. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  64340. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64341. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64342. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64343. /**
  64344. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64345. */
  64346. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64347. /**
  64348. * Creates a new SimplexPerlin3DBlock
  64349. * @param name defines the block name
  64350. */
  64351. constructor(name: string);
  64352. /**
  64353. * Gets the current class name
  64354. * @returns the class name
  64355. */
  64356. getClassName(): string;
  64357. /**
  64358. * Gets the seed operand input component
  64359. */
  64360. get seed(): NodeMaterialConnectionPoint;
  64361. /**
  64362. * Gets the output component
  64363. */
  64364. get output(): NodeMaterialConnectionPoint;
  64365. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64366. }
  64367. }
  64368. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  64369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64372. /**
  64373. * Block used to blend normals
  64374. */
  64375. export class NormalBlendBlock extends NodeMaterialBlock {
  64376. /**
  64377. * Creates a new NormalBlendBlock
  64378. * @param name defines the block name
  64379. */
  64380. constructor(name: string);
  64381. /**
  64382. * Gets the current class name
  64383. * @returns the class name
  64384. */
  64385. getClassName(): string;
  64386. /**
  64387. * Gets the first input component
  64388. */
  64389. get normalMap0(): NodeMaterialConnectionPoint;
  64390. /**
  64391. * Gets the second input component
  64392. */
  64393. get normalMap1(): NodeMaterialConnectionPoint;
  64394. /**
  64395. * Gets the output component
  64396. */
  64397. get output(): NodeMaterialConnectionPoint;
  64398. protected _buildBlock(state: NodeMaterialBuildState): this;
  64399. }
  64400. }
  64401. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  64402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64405. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64406. /**
  64407. * Block used to rotate a 2d vector by a given angle
  64408. */
  64409. export class Rotate2dBlock extends NodeMaterialBlock {
  64410. /**
  64411. * Creates a new Rotate2dBlock
  64412. * @param name defines the block name
  64413. */
  64414. constructor(name: string);
  64415. /**
  64416. * Gets the current class name
  64417. * @returns the class name
  64418. */
  64419. getClassName(): string;
  64420. /**
  64421. * Gets the input vector
  64422. */
  64423. get input(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the input angle
  64426. */
  64427. get angle(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the output component
  64430. */
  64431. get output(): NodeMaterialConnectionPoint;
  64432. autoConfigure(material: NodeMaterial): void;
  64433. protected _buildBlock(state: NodeMaterialBuildState): this;
  64434. }
  64435. }
  64436. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  64437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64440. /**
  64441. * Block used to get the reflected vector from a direction and a normal
  64442. */
  64443. export class ReflectBlock extends NodeMaterialBlock {
  64444. /**
  64445. * Creates a new ReflectBlock
  64446. * @param name defines the block name
  64447. */
  64448. constructor(name: string);
  64449. /**
  64450. * Gets the current class name
  64451. * @returns the class name
  64452. */
  64453. getClassName(): string;
  64454. /**
  64455. * Gets the incident component
  64456. */
  64457. get incident(): NodeMaterialConnectionPoint;
  64458. /**
  64459. * Gets the normal component
  64460. */
  64461. get normal(): NodeMaterialConnectionPoint;
  64462. /**
  64463. * Gets the output component
  64464. */
  64465. get output(): NodeMaterialConnectionPoint;
  64466. protected _buildBlock(state: NodeMaterialBuildState): this;
  64467. }
  64468. }
  64469. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  64470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64473. /**
  64474. * Block used to get the refracted vector from a direction and a normal
  64475. */
  64476. export class RefractBlock extends NodeMaterialBlock {
  64477. /**
  64478. * Creates a new RefractBlock
  64479. * @param name defines the block name
  64480. */
  64481. constructor(name: string);
  64482. /**
  64483. * Gets the current class name
  64484. * @returns the class name
  64485. */
  64486. getClassName(): string;
  64487. /**
  64488. * Gets the incident component
  64489. */
  64490. get incident(): NodeMaterialConnectionPoint;
  64491. /**
  64492. * Gets the normal component
  64493. */
  64494. get normal(): NodeMaterialConnectionPoint;
  64495. /**
  64496. * Gets the index of refraction component
  64497. */
  64498. get ior(): NodeMaterialConnectionPoint;
  64499. /**
  64500. * Gets the output component
  64501. */
  64502. get output(): NodeMaterialConnectionPoint;
  64503. protected _buildBlock(state: NodeMaterialBuildState): this;
  64504. }
  64505. }
  64506. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  64507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64510. /**
  64511. * Block used to desaturate a color
  64512. */
  64513. export class DesaturateBlock extends NodeMaterialBlock {
  64514. /**
  64515. * Creates a new DesaturateBlock
  64516. * @param name defines the block name
  64517. */
  64518. constructor(name: string);
  64519. /**
  64520. * Gets the current class name
  64521. * @returns the class name
  64522. */
  64523. getClassName(): string;
  64524. /**
  64525. * Gets the color operand input component
  64526. */
  64527. get color(): NodeMaterialConnectionPoint;
  64528. /**
  64529. * Gets the level operand input component
  64530. */
  64531. get level(): NodeMaterialConnectionPoint;
  64532. /**
  64533. * Gets the output component
  64534. */
  64535. get output(): NodeMaterialConnectionPoint;
  64536. protected _buildBlock(state: NodeMaterialBuildState): this;
  64537. }
  64538. }
  64539. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  64540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64543. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64544. import { Nullable } from "babylonjs/types";
  64545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64546. import { Scene } from "babylonjs/scene";
  64547. /**
  64548. * Block used to implement the ambient occlusion module of the PBR material
  64549. */
  64550. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64551. /**
  64552. * Create a new AmbientOcclusionBlock
  64553. * @param name defines the block name
  64554. */
  64555. constructor(name: string);
  64556. /**
  64557. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64558. */
  64559. useAmbientInGrayScale: boolean;
  64560. /**
  64561. * Initialize the block and prepare the context for build
  64562. * @param state defines the state that will be used for the build
  64563. */
  64564. initialize(state: NodeMaterialBuildState): void;
  64565. /**
  64566. * Gets the current class name
  64567. * @returns the class name
  64568. */
  64569. getClassName(): string;
  64570. /**
  64571. * Gets the texture input component
  64572. */
  64573. get texture(): NodeMaterialConnectionPoint;
  64574. /**
  64575. * Gets the texture intensity component
  64576. */
  64577. get intensity(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the direct light intensity input component
  64580. */
  64581. get directLightIntensity(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Gets the ambient occlusion object output component
  64584. */
  64585. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64586. /**
  64587. * Gets the main code of the block (fragment side)
  64588. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64589. * @returns the shader code
  64590. */
  64591. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64593. protected _buildBlock(state: NodeMaterialBuildState): this;
  64594. protected _dumpPropertiesCode(): string;
  64595. serialize(): any;
  64596. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64597. }
  64598. }
  64599. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  64600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64602. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64603. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64605. import { Nullable } from "babylonjs/types";
  64606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64607. import { Mesh } from "babylonjs/Meshes/mesh";
  64608. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64609. import { Effect } from "babylonjs/Materials/effect";
  64610. import { Scene } from "babylonjs/scene";
  64611. /**
  64612. * Block used to implement the reflection module of the PBR material
  64613. */
  64614. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64615. /** @hidden */
  64616. _defineLODReflectionAlpha: string;
  64617. /** @hidden */
  64618. _defineLinearSpecularReflection: string;
  64619. private _vEnvironmentIrradianceName;
  64620. /** @hidden */
  64621. _vReflectionMicrosurfaceInfosName: string;
  64622. /** @hidden */
  64623. _vReflectionInfosName: string;
  64624. private _scene;
  64625. /**
  64626. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64627. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64628. * It's less burden on the user side in the editor part.
  64629. */
  64630. /** @hidden */
  64631. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64632. /** @hidden */
  64633. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64634. /** @hidden */
  64635. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64636. /**
  64637. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64638. * diffuse part of the IBL.
  64639. */
  64640. useSphericalHarmonics: boolean;
  64641. /**
  64642. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64643. */
  64644. forceIrradianceInFragment: boolean;
  64645. /**
  64646. * Create a new ReflectionBlock
  64647. * @param name defines the block name
  64648. */
  64649. constructor(name: string);
  64650. /**
  64651. * Gets the current class name
  64652. * @returns the class name
  64653. */
  64654. getClassName(): string;
  64655. /**
  64656. * Gets the position input component
  64657. */
  64658. get position(): NodeMaterialConnectionPoint;
  64659. /**
  64660. * Gets the world position input component
  64661. */
  64662. get worldPosition(): NodeMaterialConnectionPoint;
  64663. /**
  64664. * Gets the world normal input component
  64665. */
  64666. get worldNormal(): NodeMaterialConnectionPoint;
  64667. /**
  64668. * Gets the world input component
  64669. */
  64670. get world(): NodeMaterialConnectionPoint;
  64671. /**
  64672. * Gets the camera (or eye) position component
  64673. */
  64674. get cameraPosition(): NodeMaterialConnectionPoint;
  64675. /**
  64676. * Gets the view input component
  64677. */
  64678. get view(): NodeMaterialConnectionPoint;
  64679. /**
  64680. * Gets the color input component
  64681. */
  64682. get color(): NodeMaterialConnectionPoint;
  64683. /**
  64684. * Gets the reflection object output component
  64685. */
  64686. get reflection(): NodeMaterialConnectionPoint;
  64687. /**
  64688. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64689. */
  64690. get hasTexture(): boolean;
  64691. /**
  64692. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64693. */
  64694. get reflectionColor(): string;
  64695. protected _getTexture(): Nullable<BaseTexture>;
  64696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64698. /**
  64699. * Gets the code to inject in the vertex shader
  64700. * @param state current state of the node material building
  64701. * @returns the shader code
  64702. */
  64703. handleVertexSide(state: NodeMaterialBuildState): string;
  64704. /**
  64705. * Gets the main code of the block (fragment side)
  64706. * @param state current state of the node material building
  64707. * @param normalVarName name of the existing variable corresponding to the normal
  64708. * @returns the shader code
  64709. */
  64710. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64711. protected _buildBlock(state: NodeMaterialBuildState): this;
  64712. protected _dumpPropertiesCode(): string;
  64713. serialize(): any;
  64714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64715. }
  64716. }
  64717. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  64718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64721. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64723. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64724. import { Scene } from "babylonjs/scene";
  64725. import { Nullable } from "babylonjs/types";
  64726. /**
  64727. * Block used to implement the sheen module of the PBR material
  64728. */
  64729. export class SheenBlock extends NodeMaterialBlock {
  64730. /**
  64731. * Create a new SheenBlock
  64732. * @param name defines the block name
  64733. */
  64734. constructor(name: string);
  64735. /**
  64736. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64737. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64738. * making it easier to setup and tweak the effect
  64739. */
  64740. albedoScaling: boolean;
  64741. /**
  64742. * Defines if the sheen is linked to the sheen color.
  64743. */
  64744. linkSheenWithAlbedo: boolean;
  64745. /**
  64746. * Initialize the block and prepare the context for build
  64747. * @param state defines the state that will be used for the build
  64748. */
  64749. initialize(state: NodeMaterialBuildState): void;
  64750. /**
  64751. * Gets the current class name
  64752. * @returns the class name
  64753. */
  64754. getClassName(): string;
  64755. /**
  64756. * Gets the intensity input component
  64757. */
  64758. get intensity(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the color input component
  64761. */
  64762. get color(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the roughness input component
  64765. */
  64766. get roughness(): NodeMaterialConnectionPoint;
  64767. /**
  64768. * Gets the texture input component
  64769. */
  64770. get texture(): NodeMaterialConnectionPoint;
  64771. /**
  64772. * Gets the sheen object output component
  64773. */
  64774. get sheen(): NodeMaterialConnectionPoint;
  64775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64776. /**
  64777. * Gets the main code of the block (fragment side)
  64778. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64779. * @returns the shader code
  64780. */
  64781. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64782. protected _buildBlock(state: NodeMaterialBuildState): this;
  64783. protected _dumpPropertiesCode(): string;
  64784. serialize(): any;
  64785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64786. }
  64787. }
  64788. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  64789. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64794. import { Scene } from "babylonjs/scene";
  64795. /**
  64796. * Block used to implement the reflectivity module of the PBR material
  64797. */
  64798. export class ReflectivityBlock extends NodeMaterialBlock {
  64799. /**
  64800. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64801. */
  64802. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64803. /**
  64804. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64805. */
  64806. useMetallnessFromMetallicTextureBlue: boolean;
  64807. /**
  64808. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64809. */
  64810. useRoughnessFromMetallicTextureAlpha: boolean;
  64811. /**
  64812. * Specifies if the metallic texture contains the roughness information in its green channel.
  64813. */
  64814. useRoughnessFromMetallicTextureGreen: boolean;
  64815. /**
  64816. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  64817. */
  64818. useMetallicF0FactorFromMetallicTexture: boolean;
  64819. /**
  64820. * Create a new ReflectivityBlock
  64821. * @param name defines the block name
  64822. */
  64823. constructor(name: string);
  64824. /**
  64825. * Initialize the block and prepare the context for build
  64826. * @param state defines the state that will be used for the build
  64827. */
  64828. initialize(state: NodeMaterialBuildState): void;
  64829. /**
  64830. * Gets the current class name
  64831. * @returns the class name
  64832. */
  64833. getClassName(): string;
  64834. /**
  64835. * Gets the metallic input component
  64836. */
  64837. get metallic(): NodeMaterialConnectionPoint;
  64838. /**
  64839. * Gets the roughness input component
  64840. */
  64841. get roughness(): NodeMaterialConnectionPoint;
  64842. /**
  64843. * Gets the texture input component
  64844. */
  64845. get texture(): NodeMaterialConnectionPoint;
  64846. /**
  64847. * Gets the reflectivity object output component
  64848. */
  64849. get reflectivity(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the main code of the block (fragment side)
  64852. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64853. * @returns the shader code
  64854. */
  64855. getCode(aoIntensityVarName: string): string;
  64856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64857. protected _buildBlock(state: NodeMaterialBuildState): this;
  64858. protected _dumpPropertiesCode(): string;
  64859. serialize(): any;
  64860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64861. }
  64862. }
  64863. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  64864. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64869. /**
  64870. * Block used to implement the anisotropy module of the PBR material
  64871. */
  64872. export class AnisotropyBlock extends NodeMaterialBlock {
  64873. /**
  64874. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64875. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64876. * It's less burden on the user side in the editor part.
  64877. */
  64878. /** @hidden */
  64879. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64880. /** @hidden */
  64881. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64882. /**
  64883. * Create a new AnisotropyBlock
  64884. * @param name defines the block name
  64885. */
  64886. constructor(name: string);
  64887. /**
  64888. * Initialize the block and prepare the context for build
  64889. * @param state defines the state that will be used for the build
  64890. */
  64891. initialize(state: NodeMaterialBuildState): void;
  64892. /**
  64893. * Gets the current class name
  64894. * @returns the class name
  64895. */
  64896. getClassName(): string;
  64897. /**
  64898. * Gets the intensity input component
  64899. */
  64900. get intensity(): NodeMaterialConnectionPoint;
  64901. /**
  64902. * Gets the direction input component
  64903. */
  64904. get direction(): NodeMaterialConnectionPoint;
  64905. /**
  64906. * Gets the texture input component
  64907. */
  64908. get texture(): NodeMaterialConnectionPoint;
  64909. /**
  64910. * Gets the uv input component
  64911. */
  64912. get uv(): NodeMaterialConnectionPoint;
  64913. /**
  64914. * Gets the worldTangent input component
  64915. */
  64916. get worldTangent(): NodeMaterialConnectionPoint;
  64917. /**
  64918. * Gets the anisotropy object output component
  64919. */
  64920. get anisotropy(): NodeMaterialConnectionPoint;
  64921. private _generateTBNSpace;
  64922. /**
  64923. * Gets the main code of the block (fragment side)
  64924. * @param state current state of the node material building
  64925. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64926. * @returns the shader code
  64927. */
  64928. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64930. protected _buildBlock(state: NodeMaterialBuildState): this;
  64931. }
  64932. }
  64933. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  64934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64939. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64940. import { Nullable } from "babylonjs/types";
  64941. import { Mesh } from "babylonjs/Meshes/mesh";
  64942. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64943. import { Effect } from "babylonjs/Materials/effect";
  64944. /**
  64945. * Block used to implement the clear coat module of the PBR material
  64946. */
  64947. export class ClearCoatBlock extends NodeMaterialBlock {
  64948. private _scene;
  64949. /**
  64950. * Create a new ClearCoatBlock
  64951. * @param name defines the block name
  64952. */
  64953. constructor(name: string);
  64954. /**
  64955. * Initialize the block and prepare the context for build
  64956. * @param state defines the state that will be used for the build
  64957. */
  64958. initialize(state: NodeMaterialBuildState): void;
  64959. /**
  64960. * Gets the current class name
  64961. * @returns the class name
  64962. */
  64963. getClassName(): string;
  64964. /**
  64965. * Gets the intensity input component
  64966. */
  64967. get intensity(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the roughness input component
  64970. */
  64971. get roughness(): NodeMaterialConnectionPoint;
  64972. /**
  64973. * Gets the ior input component
  64974. */
  64975. get ior(): NodeMaterialConnectionPoint;
  64976. /**
  64977. * Gets the texture input component
  64978. */
  64979. get texture(): NodeMaterialConnectionPoint;
  64980. /**
  64981. * Gets the bump texture input component
  64982. */
  64983. get bumpTexture(): NodeMaterialConnectionPoint;
  64984. /**
  64985. * Gets the uv input component
  64986. */
  64987. get uv(): NodeMaterialConnectionPoint;
  64988. /**
  64989. * Gets the tint color input component
  64990. */
  64991. get tintColor(): NodeMaterialConnectionPoint;
  64992. /**
  64993. * Gets the tint "at distance" input component
  64994. */
  64995. get tintAtDistance(): NodeMaterialConnectionPoint;
  64996. /**
  64997. * Gets the tint thickness input component
  64998. */
  64999. get tintThickness(): NodeMaterialConnectionPoint;
  65000. /**
  65001. * Gets the tint texture input component
  65002. */
  65003. get tintTexture(): NodeMaterialConnectionPoint;
  65004. /**
  65005. * Gets the world tangent input component
  65006. */
  65007. get worldTangent(): NodeMaterialConnectionPoint;
  65008. /**
  65009. * Gets the clear coat object output component
  65010. */
  65011. get clearcoat(): NodeMaterialConnectionPoint;
  65012. autoConfigure(material: NodeMaterial): void;
  65013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65015. private _generateTBNSpace;
  65016. /**
  65017. * Gets the main code of the block (fragment side)
  65018. * @param state current state of the node material building
  65019. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65020. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65021. * @param worldPosVarName name of the variable holding the world position
  65022. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65023. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65024. * @param worldNormalVarName name of the variable holding the world normal
  65025. * @returns the shader code
  65026. */
  65027. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65028. protected _buildBlock(state: NodeMaterialBuildState): this;
  65029. }
  65030. }
  65031. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  65032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65035. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65037. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65038. import { Nullable } from "babylonjs/types";
  65039. /**
  65040. * Block used to implement the sub surface module of the PBR material
  65041. */
  65042. export class SubSurfaceBlock extends NodeMaterialBlock {
  65043. /**
  65044. * Create a new SubSurfaceBlock
  65045. * @param name defines the block name
  65046. */
  65047. constructor(name: string);
  65048. /**
  65049. * Stores the intensity of the different subsurface effects in the thickness texture.
  65050. * * the green channel is the translucency intensity.
  65051. * * the blue channel is the scattering intensity.
  65052. * * the alpha channel is the refraction intensity.
  65053. */
  65054. useMaskFromThicknessTexture: boolean;
  65055. /**
  65056. * Initialize the block and prepare the context for build
  65057. * @param state defines the state that will be used for the build
  65058. */
  65059. initialize(state: NodeMaterialBuildState): void;
  65060. /**
  65061. * Gets the current class name
  65062. * @returns the class name
  65063. */
  65064. getClassName(): string;
  65065. /**
  65066. * Gets the min thickness input component
  65067. */
  65068. get minThickness(): NodeMaterialConnectionPoint;
  65069. /**
  65070. * Gets the max thickness input component
  65071. */
  65072. get maxThickness(): NodeMaterialConnectionPoint;
  65073. /**
  65074. * Gets the thickness texture component
  65075. */
  65076. get thicknessTexture(): NodeMaterialConnectionPoint;
  65077. /**
  65078. * Gets the tint color input component
  65079. */
  65080. get tintColor(): NodeMaterialConnectionPoint;
  65081. /**
  65082. * Gets the translucency intensity input component
  65083. */
  65084. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the translucency diffusion distance input component
  65087. */
  65088. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the refraction object parameters
  65091. */
  65092. get refraction(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the sub surface object output component
  65095. */
  65096. get subsurface(): NodeMaterialConnectionPoint;
  65097. autoConfigure(material: NodeMaterial): void;
  65098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65099. /**
  65100. * Gets the main code of the block (fragment side)
  65101. * @param state current state of the node material building
  65102. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65103. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65104. * @param worldPosVarName name of the variable holding the world position
  65105. * @returns the shader code
  65106. */
  65107. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65108. protected _buildBlock(state: NodeMaterialBuildState): this;
  65109. }
  65110. }
  65111. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  65112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65115. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65116. import { Light } from "babylonjs/Lights/light";
  65117. import { Nullable } from "babylonjs/types";
  65118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65119. import { Effect } from "babylonjs/Materials/effect";
  65120. import { Mesh } from "babylonjs/Meshes/mesh";
  65121. import { Scene } from "babylonjs/scene";
  65122. /**
  65123. * Block used to implement the PBR metallic/roughness model
  65124. */
  65125. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65126. /**
  65127. * Gets or sets the light associated with this block
  65128. */
  65129. light: Nullable<Light>;
  65130. private _lightId;
  65131. private _scene;
  65132. private _environmentBRDFTexture;
  65133. private _environmentBrdfSamplerName;
  65134. private _vNormalWName;
  65135. private _invertNormalName;
  65136. /**
  65137. * Create a new ReflectionBlock
  65138. * @param name defines the block name
  65139. */
  65140. constructor(name: string);
  65141. /**
  65142. * Intensity of the direct lights e.g. the four lights available in your scene.
  65143. * This impacts both the direct diffuse and specular highlights.
  65144. */
  65145. directIntensity: number;
  65146. /**
  65147. * Intensity of the environment e.g. how much the environment will light the object
  65148. * either through harmonics for rough material or through the refelction for shiny ones.
  65149. */
  65150. environmentIntensity: number;
  65151. /**
  65152. * This is a special control allowing the reduction of the specular highlights coming from the
  65153. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65154. */
  65155. specularIntensity: number;
  65156. /**
  65157. * Defines the falloff type used in this material.
  65158. * It by default is Physical.
  65159. */
  65160. lightFalloff: number;
  65161. /**
  65162. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65163. */
  65164. useAlphaFromAlbedoTexture: boolean;
  65165. /**
  65166. * Specifies that alpha test should be used
  65167. */
  65168. useAlphaTest: boolean;
  65169. /**
  65170. * Defines the alpha limits in alpha test mode.
  65171. */
  65172. alphaTestCutoff: number;
  65173. /**
  65174. * Specifies that alpha blending should be used
  65175. */
  65176. useAlphaBlending: boolean;
  65177. /**
  65178. * Defines if the alpha value should be determined via the rgb values.
  65179. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65180. */
  65181. opacityRGB: boolean;
  65182. /**
  65183. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65184. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65185. */
  65186. useRadianceOverAlpha: boolean;
  65187. /**
  65188. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65189. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65190. */
  65191. useSpecularOverAlpha: boolean;
  65192. /**
  65193. * Enables specular anti aliasing in the PBR shader.
  65194. * It will both interacts on the Geometry for analytical and IBL lighting.
  65195. * It also prefilter the roughness map based on the bump values.
  65196. */
  65197. enableSpecularAntiAliasing: boolean;
  65198. /**
  65199. * Defines if the material uses energy conservation.
  65200. */
  65201. useEnergyConservation: boolean;
  65202. /**
  65203. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65204. * too much the area relying on ambient texture to define their ambient occlusion.
  65205. */
  65206. useRadianceOcclusion: boolean;
  65207. /**
  65208. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65209. * makes the reflect vector face the model (under horizon).
  65210. */
  65211. useHorizonOcclusion: boolean;
  65212. /**
  65213. * If set to true, no lighting calculations will be applied.
  65214. */
  65215. unlit: boolean;
  65216. /**
  65217. * Force normal to face away from face.
  65218. */
  65219. forceNormalForward: boolean;
  65220. /**
  65221. * Defines the material debug mode.
  65222. * It helps seeing only some components of the material while troubleshooting.
  65223. */
  65224. debugMode: number;
  65225. /**
  65226. * Specify from where on screen the debug mode should start.
  65227. * The value goes from -1 (full screen) to 1 (not visible)
  65228. * It helps with side by side comparison against the final render
  65229. * This defaults to 0
  65230. */
  65231. debugLimit: number;
  65232. /**
  65233. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65234. * You can use the factor to better multiply the final value.
  65235. */
  65236. debugFactor: number;
  65237. /**
  65238. * Initialize the block and prepare the context for build
  65239. * @param state defines the state that will be used for the build
  65240. */
  65241. initialize(state: NodeMaterialBuildState): void;
  65242. /**
  65243. * Gets the current class name
  65244. * @returns the class name
  65245. */
  65246. getClassName(): string;
  65247. /**
  65248. * Gets the world position input component
  65249. */
  65250. get worldPosition(): NodeMaterialConnectionPoint;
  65251. /**
  65252. * Gets the world normal input component
  65253. */
  65254. get worldNormal(): NodeMaterialConnectionPoint;
  65255. /**
  65256. * Gets the perturbed normal input component
  65257. */
  65258. get perturbedNormal(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the camera position input component
  65261. */
  65262. get cameraPosition(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the base color input component
  65265. */
  65266. get baseColor(): NodeMaterialConnectionPoint;
  65267. /**
  65268. * Gets the base texture input component
  65269. */
  65270. get baseTexture(): NodeMaterialConnectionPoint;
  65271. /**
  65272. * Gets the opacity texture input component
  65273. */
  65274. get opacityTexture(): NodeMaterialConnectionPoint;
  65275. /**
  65276. * Gets the ambient color input component
  65277. */
  65278. get ambientColor(): NodeMaterialConnectionPoint;
  65279. /**
  65280. * Gets the reflectivity object parameters
  65281. */
  65282. get reflectivity(): NodeMaterialConnectionPoint;
  65283. /**
  65284. * Gets the ambient occlusion object parameters
  65285. */
  65286. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65287. /**
  65288. * Gets the reflection object parameters
  65289. */
  65290. get reflection(): NodeMaterialConnectionPoint;
  65291. /**
  65292. * Gets the sheen object parameters
  65293. */
  65294. get sheen(): NodeMaterialConnectionPoint;
  65295. /**
  65296. * Gets the clear coat object parameters
  65297. */
  65298. get clearcoat(): NodeMaterialConnectionPoint;
  65299. /**
  65300. * Gets the sub surface object parameters
  65301. */
  65302. get subsurface(): NodeMaterialConnectionPoint;
  65303. /**
  65304. * Gets the anisotropy object parameters
  65305. */
  65306. get anisotropy(): NodeMaterialConnectionPoint;
  65307. /**
  65308. * Gets the ambient output component
  65309. */
  65310. get ambient(): NodeMaterialConnectionPoint;
  65311. /**
  65312. * Gets the diffuse output component
  65313. */
  65314. get diffuse(): NodeMaterialConnectionPoint;
  65315. /**
  65316. * Gets the specular output component
  65317. */
  65318. get specular(): NodeMaterialConnectionPoint;
  65319. /**
  65320. * Gets the sheen output component
  65321. */
  65322. get sheenDir(): NodeMaterialConnectionPoint;
  65323. /**
  65324. * Gets the clear coat output component
  65325. */
  65326. get clearcoatDir(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the indirect diffuse output component
  65329. */
  65330. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65331. /**
  65332. * Gets the indirect specular output component
  65333. */
  65334. get specularIndirect(): NodeMaterialConnectionPoint;
  65335. /**
  65336. * Gets the indirect sheen output component
  65337. */
  65338. get sheenIndirect(): NodeMaterialConnectionPoint;
  65339. /**
  65340. * Gets the indirect clear coat output component
  65341. */
  65342. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65343. /**
  65344. * Gets the refraction output component
  65345. */
  65346. get refraction(): NodeMaterialConnectionPoint;
  65347. /**
  65348. * Gets the global lighting output component
  65349. */
  65350. get lighting(): NodeMaterialConnectionPoint;
  65351. /**
  65352. * Gets the shadow output component
  65353. */
  65354. get shadow(): NodeMaterialConnectionPoint;
  65355. /**
  65356. * Gets the alpha output component
  65357. */
  65358. get alpha(): NodeMaterialConnectionPoint;
  65359. autoConfigure(material: NodeMaterial): void;
  65360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65361. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65363. private _injectVertexCode;
  65364. /**
  65365. * Gets the code corresponding to the albedo/opacity module
  65366. * @returns the shader code
  65367. */
  65368. getAlbedoOpacityCode(): string;
  65369. protected _buildBlock(state: NodeMaterialBuildState): this;
  65370. protected _dumpPropertiesCode(): string;
  65371. serialize(): any;
  65372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65373. }
  65374. }
  65375. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  65376. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  65377. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  65378. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  65379. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  65380. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  65381. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65382. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  65383. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  65384. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  65385. }
  65386. declare module "babylonjs/Materials/Node/Blocks/index" {
  65387. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  65388. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  65389. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  65390. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  65391. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  65392. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  65393. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  65394. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  65395. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  65396. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  65397. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  65398. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  65399. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  65400. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  65401. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  65402. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  65403. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  65404. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  65405. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  65406. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  65407. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  65408. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  65409. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  65410. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  65411. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  65412. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  65413. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  65414. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  65415. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  65416. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  65417. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  65418. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  65419. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  65420. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  65421. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  65422. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  65423. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  65424. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  65425. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  65426. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  65427. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  65428. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  65429. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  65430. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  65431. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  65432. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  65433. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  65434. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  65435. }
  65436. declare module "babylonjs/Materials/Node/Optimizers/index" {
  65437. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  65438. }
  65439. declare module "babylonjs/Materials/Node/index" {
  65440. export * from "babylonjs/Materials/Node/Enums/index";
  65441. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65442. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  65443. export * from "babylonjs/Materials/Node/nodeMaterial";
  65444. export * from "babylonjs/Materials/Node/Blocks/index";
  65445. export * from "babylonjs/Materials/Node/Optimizers/index";
  65446. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  65447. }
  65448. declare module "babylonjs/Materials/effectRenderer" {
  65449. import { Nullable } from "babylonjs/types";
  65450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65451. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65452. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65453. import { Viewport } from "babylonjs/Maths/math.viewport";
  65454. import { Observable } from "babylonjs/Misc/observable";
  65455. import { Effect } from "babylonjs/Materials/effect";
  65456. import "babylonjs/Shaders/postprocess.vertex";
  65457. /**
  65458. * Effect Render Options
  65459. */
  65460. export interface IEffectRendererOptions {
  65461. /**
  65462. * Defines the vertices positions.
  65463. */
  65464. positions?: number[];
  65465. /**
  65466. * Defines the indices.
  65467. */
  65468. indices?: number[];
  65469. }
  65470. /**
  65471. * Helper class to render one or more effects.
  65472. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65473. */
  65474. export class EffectRenderer {
  65475. private engine;
  65476. private static _DefaultOptions;
  65477. private _vertexBuffers;
  65478. private _indexBuffer;
  65479. private _fullscreenViewport;
  65480. /**
  65481. * Creates an effect renderer
  65482. * @param engine the engine to use for rendering
  65483. * @param options defines the options of the effect renderer
  65484. */
  65485. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65486. /**
  65487. * Sets the current viewport in normalized coordinates 0-1
  65488. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65489. */
  65490. setViewport(viewport?: Viewport): void;
  65491. /**
  65492. * Binds the embedded attributes buffer to the effect.
  65493. * @param effect Defines the effect to bind the attributes for
  65494. */
  65495. bindBuffers(effect: Effect): void;
  65496. /**
  65497. * Sets the current effect wrapper to use during draw.
  65498. * The effect needs to be ready before calling this api.
  65499. * This also sets the default full screen position attribute.
  65500. * @param effectWrapper Defines the effect to draw with
  65501. */
  65502. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65503. /**
  65504. * Draws a full screen quad.
  65505. */
  65506. draw(): void;
  65507. private isRenderTargetTexture;
  65508. /**
  65509. * renders one or more effects to a specified texture
  65510. * @param effectWrapper the effect to renderer
  65511. * @param outputTexture texture to draw to, if null it will render to the screen.
  65512. */
  65513. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65514. /**
  65515. * Disposes of the effect renderer
  65516. */
  65517. dispose(): void;
  65518. }
  65519. /**
  65520. * Options to create an EffectWrapper
  65521. */
  65522. interface EffectWrapperCreationOptions {
  65523. /**
  65524. * Engine to use to create the effect
  65525. */
  65526. engine: ThinEngine;
  65527. /**
  65528. * Fragment shader for the effect
  65529. */
  65530. fragmentShader: string;
  65531. /**
  65532. * Vertex shader for the effect
  65533. */
  65534. vertexShader?: string;
  65535. /**
  65536. * Attributes to use in the shader
  65537. */
  65538. attributeNames?: Array<string>;
  65539. /**
  65540. * Uniforms to use in the shader
  65541. */
  65542. uniformNames?: Array<string>;
  65543. /**
  65544. * Texture sampler names to use in the shader
  65545. */
  65546. samplerNames?: Array<string>;
  65547. /**
  65548. * The friendly name of the effect displayed in Spector.
  65549. */
  65550. name?: string;
  65551. }
  65552. /**
  65553. * Wraps an effect to be used for rendering
  65554. */
  65555. export class EffectWrapper {
  65556. /**
  65557. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65558. */
  65559. onApplyObservable: Observable<{}>;
  65560. /**
  65561. * The underlying effect
  65562. */
  65563. effect: Effect;
  65564. /**
  65565. * Creates an effect to be renderer
  65566. * @param creationOptions options to create the effect
  65567. */
  65568. constructor(creationOptions: EffectWrapperCreationOptions);
  65569. /**
  65570. * Disposes of the effect wrapper
  65571. */
  65572. dispose(): void;
  65573. }
  65574. }
  65575. declare module "babylonjs/Materials/index" {
  65576. export * from "babylonjs/Materials/Background/index";
  65577. export * from "babylonjs/Materials/colorCurves";
  65578. export * from "babylonjs/Materials/iEffectFallbacks";
  65579. export * from "babylonjs/Materials/effectFallbacks";
  65580. export * from "babylonjs/Materials/effect";
  65581. export * from "babylonjs/Materials/fresnelParameters";
  65582. export * from "babylonjs/Materials/imageProcessingConfiguration";
  65583. export * from "babylonjs/Materials/material";
  65584. export * from "babylonjs/Materials/materialDefines";
  65585. export * from "babylonjs/Materials/materialHelper";
  65586. export * from "babylonjs/Materials/multiMaterial";
  65587. export * from "babylonjs/Materials/PBR/index";
  65588. export * from "babylonjs/Materials/pushMaterial";
  65589. export * from "babylonjs/Materials/shaderMaterial";
  65590. export * from "babylonjs/Materials/standardMaterial";
  65591. export * from "babylonjs/Materials/Textures/index";
  65592. export * from "babylonjs/Materials/uniformBuffer";
  65593. export * from "babylonjs/Materials/materialFlags";
  65594. export * from "babylonjs/Materials/Node/index";
  65595. export * from "babylonjs/Materials/effectRenderer";
  65596. export * from "babylonjs/Materials/shadowDepthWrapper";
  65597. }
  65598. declare module "babylonjs/Maths/index" {
  65599. export * from "babylonjs/Maths/math.scalar";
  65600. export * from "babylonjs/Maths/math";
  65601. export * from "babylonjs/Maths/sphericalPolynomial";
  65602. }
  65603. declare module "babylonjs/Misc/workerPool" {
  65604. import { IDisposable } from "babylonjs/scene";
  65605. /**
  65606. * Helper class to push actions to a pool of workers.
  65607. */
  65608. export class WorkerPool implements IDisposable {
  65609. private _workerInfos;
  65610. private _pendingActions;
  65611. /**
  65612. * Constructor
  65613. * @param workers Array of workers to use for actions
  65614. */
  65615. constructor(workers: Array<Worker>);
  65616. /**
  65617. * Terminates all workers and clears any pending actions.
  65618. */
  65619. dispose(): void;
  65620. /**
  65621. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65622. * pended until a worker has completed its action.
  65623. * @param action The action to perform. Call onComplete when the action is complete.
  65624. */
  65625. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65626. private _execute;
  65627. }
  65628. }
  65629. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  65630. import { IDisposable } from "babylonjs/scene";
  65631. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65632. /**
  65633. * Configuration for Draco compression
  65634. */
  65635. export interface IDracoCompressionConfiguration {
  65636. /**
  65637. * Configuration for the decoder.
  65638. */
  65639. decoder: {
  65640. /**
  65641. * The url to the WebAssembly module.
  65642. */
  65643. wasmUrl?: string;
  65644. /**
  65645. * The url to the WebAssembly binary.
  65646. */
  65647. wasmBinaryUrl?: string;
  65648. /**
  65649. * The url to the fallback JavaScript module.
  65650. */
  65651. fallbackUrl?: string;
  65652. };
  65653. }
  65654. /**
  65655. * Draco compression (https://google.github.io/draco/)
  65656. *
  65657. * This class wraps the Draco module.
  65658. *
  65659. * **Encoder**
  65660. *
  65661. * The encoder is not currently implemented.
  65662. *
  65663. * **Decoder**
  65664. *
  65665. * 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.
  65666. *
  65667. * To update the configuration, use the following code:
  65668. * ```javascript
  65669. * DracoCompression.Configuration = {
  65670. * decoder: {
  65671. * wasmUrl: "<url to the WebAssembly library>",
  65672. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65673. * fallbackUrl: "<url to the fallback JavaScript library>",
  65674. * }
  65675. * };
  65676. * ```
  65677. *
  65678. * 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.
  65679. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65680. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65681. *
  65682. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65683. * ```javascript
  65684. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65685. * ```
  65686. *
  65687. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65688. */
  65689. export class DracoCompression implements IDisposable {
  65690. private _workerPoolPromise?;
  65691. private _decoderModulePromise?;
  65692. /**
  65693. * The configuration. Defaults to the following urls:
  65694. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65695. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65696. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65697. */
  65698. static Configuration: IDracoCompressionConfiguration;
  65699. /**
  65700. * Returns true if the decoder configuration is available.
  65701. */
  65702. static get DecoderAvailable(): boolean;
  65703. /**
  65704. * Default number of workers to create when creating the draco compression object.
  65705. */
  65706. static DefaultNumWorkers: number;
  65707. private static GetDefaultNumWorkers;
  65708. private static _Default;
  65709. /**
  65710. * Default instance for the draco compression object.
  65711. */
  65712. static get Default(): DracoCompression;
  65713. /**
  65714. * Constructor
  65715. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65716. */
  65717. constructor(numWorkers?: number);
  65718. /**
  65719. * Stop all async operations and release resources.
  65720. */
  65721. dispose(): void;
  65722. /**
  65723. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65724. * @returns a promise that resolves when ready
  65725. */
  65726. whenReadyAsync(): Promise<void>;
  65727. /**
  65728. * Decode Draco compressed mesh data to vertex data.
  65729. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65730. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65731. * @returns A promise that resolves with the decoded vertex data
  65732. */
  65733. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65734. [kind: string]: number;
  65735. }): Promise<VertexData>;
  65736. }
  65737. }
  65738. declare module "babylonjs/Meshes/Compression/index" {
  65739. export * from "babylonjs/Meshes/Compression/dracoCompression";
  65740. }
  65741. declare module "babylonjs/Meshes/csg" {
  65742. import { Nullable } from "babylonjs/types";
  65743. import { Scene } from "babylonjs/scene";
  65744. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  65745. import { Mesh } from "babylonjs/Meshes/mesh";
  65746. import { Material } from "babylonjs/Materials/material";
  65747. /**
  65748. * Class for building Constructive Solid Geometry
  65749. */
  65750. export class CSG {
  65751. private polygons;
  65752. /**
  65753. * The world matrix
  65754. */
  65755. matrix: Matrix;
  65756. /**
  65757. * Stores the position
  65758. */
  65759. position: Vector3;
  65760. /**
  65761. * Stores the rotation
  65762. */
  65763. rotation: Vector3;
  65764. /**
  65765. * Stores the rotation quaternion
  65766. */
  65767. rotationQuaternion: Nullable<Quaternion>;
  65768. /**
  65769. * Stores the scaling vector
  65770. */
  65771. scaling: Vector3;
  65772. /**
  65773. * Convert the Mesh to CSG
  65774. * @param mesh The Mesh to convert to CSG
  65775. * @returns A new CSG from the Mesh
  65776. */
  65777. static FromMesh(mesh: Mesh): CSG;
  65778. /**
  65779. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65780. * @param polygons Polygons used to construct a CSG solid
  65781. */
  65782. private static FromPolygons;
  65783. /**
  65784. * Clones, or makes a deep copy, of the CSG
  65785. * @returns A new CSG
  65786. */
  65787. clone(): CSG;
  65788. /**
  65789. * Unions this CSG with another CSG
  65790. * @param csg The CSG to union against this CSG
  65791. * @returns The unioned CSG
  65792. */
  65793. union(csg: CSG): CSG;
  65794. /**
  65795. * Unions this CSG with another CSG in place
  65796. * @param csg The CSG to union against this CSG
  65797. */
  65798. unionInPlace(csg: CSG): void;
  65799. /**
  65800. * Subtracts this CSG with another CSG
  65801. * @param csg The CSG to subtract against this CSG
  65802. * @returns A new CSG
  65803. */
  65804. subtract(csg: CSG): CSG;
  65805. /**
  65806. * Subtracts this CSG with another CSG in place
  65807. * @param csg The CSG to subtact against this CSG
  65808. */
  65809. subtractInPlace(csg: CSG): void;
  65810. /**
  65811. * Intersect this CSG with another CSG
  65812. * @param csg The CSG to intersect against this CSG
  65813. * @returns A new CSG
  65814. */
  65815. intersect(csg: CSG): CSG;
  65816. /**
  65817. * Intersects this CSG with another CSG in place
  65818. * @param csg The CSG to intersect against this CSG
  65819. */
  65820. intersectInPlace(csg: CSG): void;
  65821. /**
  65822. * Return a new CSG solid with solid and empty space switched. This solid is
  65823. * not modified.
  65824. * @returns A new CSG solid with solid and empty space switched
  65825. */
  65826. inverse(): CSG;
  65827. /**
  65828. * Inverses the CSG in place
  65829. */
  65830. inverseInPlace(): void;
  65831. /**
  65832. * This is used to keep meshes transformations so they can be restored
  65833. * when we build back a Babylon Mesh
  65834. * NB : All CSG operations are performed in world coordinates
  65835. * @param csg The CSG to copy the transform attributes from
  65836. * @returns This CSG
  65837. */
  65838. copyTransformAttributes(csg: CSG): CSG;
  65839. /**
  65840. * Build Raw mesh from CSG
  65841. * Coordinates here are in world space
  65842. * @param name The name of the mesh geometry
  65843. * @param scene The Scene
  65844. * @param keepSubMeshes Specifies if the submeshes should be kept
  65845. * @returns A new Mesh
  65846. */
  65847. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65848. /**
  65849. * Build Mesh from CSG taking material and transforms into account
  65850. * @param name The name of the Mesh
  65851. * @param material The material of the Mesh
  65852. * @param scene The Scene
  65853. * @param keepSubMeshes Specifies if submeshes should be kept
  65854. * @returns The new Mesh
  65855. */
  65856. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65857. }
  65858. }
  65859. declare module "babylonjs/Meshes/trailMesh" {
  65860. import { Mesh } from "babylonjs/Meshes/mesh";
  65861. import { Scene } from "babylonjs/scene";
  65862. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65863. /**
  65864. * Class used to create a trail following a mesh
  65865. */
  65866. export class TrailMesh extends Mesh {
  65867. private _generator;
  65868. private _autoStart;
  65869. private _running;
  65870. private _diameter;
  65871. private _length;
  65872. private _sectionPolygonPointsCount;
  65873. private _sectionVectors;
  65874. private _sectionNormalVectors;
  65875. private _beforeRenderObserver;
  65876. /**
  65877. * @constructor
  65878. * @param name The value used by scene.getMeshByName() to do a lookup.
  65879. * @param generator The mesh or transform node to generate a trail.
  65880. * @param scene The scene to add this mesh to.
  65881. * @param diameter Diameter of trailing mesh. Default is 1.
  65882. * @param length Length of trailing mesh. Default is 60.
  65883. * @param autoStart Automatically start trailing mesh. Default true.
  65884. */
  65885. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65886. /**
  65887. * "TrailMesh"
  65888. * @returns "TrailMesh"
  65889. */
  65890. getClassName(): string;
  65891. private _createMesh;
  65892. /**
  65893. * Start trailing mesh.
  65894. */
  65895. start(): void;
  65896. /**
  65897. * Stop trailing mesh.
  65898. */
  65899. stop(): void;
  65900. /**
  65901. * Update trailing mesh geometry.
  65902. */
  65903. update(): void;
  65904. /**
  65905. * Returns a new TrailMesh object.
  65906. * @param name is a string, the name given to the new mesh
  65907. * @param newGenerator use new generator object for cloned trail mesh
  65908. * @returns a new mesh
  65909. */
  65910. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65911. /**
  65912. * Serializes this trail mesh
  65913. * @param serializationObject object to write serialization to
  65914. */
  65915. serialize(serializationObject: any): void;
  65916. /**
  65917. * Parses a serialized trail mesh
  65918. * @param parsedMesh the serialized mesh
  65919. * @param scene the scene to create the trail mesh in
  65920. * @returns the created trail mesh
  65921. */
  65922. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65923. }
  65924. }
  65925. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  65926. import { Nullable } from "babylonjs/types";
  65927. import { Scene } from "babylonjs/scene";
  65928. import { Vector4 } from "babylonjs/Maths/math.vector";
  65929. import { Color4 } from "babylonjs/Maths/math.color";
  65930. import { Mesh } from "babylonjs/Meshes/mesh";
  65931. /**
  65932. * Class containing static functions to help procedurally build meshes
  65933. */
  65934. export class TiledBoxBuilder {
  65935. /**
  65936. * Creates a box mesh
  65937. * 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)
  65938. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65940. * * 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
  65941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65942. * @param name defines the name of the mesh
  65943. * @param options defines the options used to create the mesh
  65944. * @param scene defines the hosting scene
  65945. * @returns the box mesh
  65946. */
  65947. static CreateTiledBox(name: string, options: {
  65948. pattern?: number;
  65949. width?: number;
  65950. height?: number;
  65951. depth?: number;
  65952. tileSize?: number;
  65953. tileWidth?: number;
  65954. tileHeight?: number;
  65955. alignHorizontal?: number;
  65956. alignVertical?: number;
  65957. faceUV?: Vector4[];
  65958. faceColors?: Color4[];
  65959. sideOrientation?: number;
  65960. updatable?: boolean;
  65961. }, scene?: Nullable<Scene>): Mesh;
  65962. }
  65963. }
  65964. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  65965. import { Vector4 } from "babylonjs/Maths/math.vector";
  65966. import { Mesh } from "babylonjs/Meshes/mesh";
  65967. /**
  65968. * Class containing static functions to help procedurally build meshes
  65969. */
  65970. export class TorusKnotBuilder {
  65971. /**
  65972. * Creates a torus knot mesh
  65973. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65974. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65975. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65976. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65978. * * 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
  65979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65980. * @param name defines the name of the mesh
  65981. * @param options defines the options used to create the mesh
  65982. * @param scene defines the hosting scene
  65983. * @returns the torus knot mesh
  65984. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65985. */
  65986. static CreateTorusKnot(name: string, options: {
  65987. radius?: number;
  65988. tube?: number;
  65989. radialSegments?: number;
  65990. tubularSegments?: number;
  65991. p?: number;
  65992. q?: number;
  65993. updatable?: boolean;
  65994. sideOrientation?: number;
  65995. frontUVs?: Vector4;
  65996. backUVs?: Vector4;
  65997. }, scene: any): Mesh;
  65998. }
  65999. }
  66000. declare module "babylonjs/Meshes/polygonMesh" {
  66001. import { Scene } from "babylonjs/scene";
  66002. import { Vector2 } from "babylonjs/Maths/math.vector";
  66003. import { Mesh } from "babylonjs/Meshes/mesh";
  66004. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66005. import { Path2 } from "babylonjs/Maths/math.path";
  66006. /**
  66007. * Polygon
  66008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66009. */
  66010. export class Polygon {
  66011. /**
  66012. * Creates a rectangle
  66013. * @param xmin bottom X coord
  66014. * @param ymin bottom Y coord
  66015. * @param xmax top X coord
  66016. * @param ymax top Y coord
  66017. * @returns points that make the resulting rectation
  66018. */
  66019. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66020. /**
  66021. * Creates a circle
  66022. * @param radius radius of circle
  66023. * @param cx scale in x
  66024. * @param cy scale in y
  66025. * @param numberOfSides number of sides that make up the circle
  66026. * @returns points that make the resulting circle
  66027. */
  66028. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66029. /**
  66030. * Creates a polygon from input string
  66031. * @param input Input polygon data
  66032. * @returns the parsed points
  66033. */
  66034. static Parse(input: string): Vector2[];
  66035. /**
  66036. * Starts building a polygon from x and y coordinates
  66037. * @param x x coordinate
  66038. * @param y y coordinate
  66039. * @returns the started path2
  66040. */
  66041. static StartingAt(x: number, y: number): Path2;
  66042. }
  66043. /**
  66044. * Builds a polygon
  66045. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66046. */
  66047. export class PolygonMeshBuilder {
  66048. private _points;
  66049. private _outlinepoints;
  66050. private _holes;
  66051. private _name;
  66052. private _scene;
  66053. private _epoints;
  66054. private _eholes;
  66055. private _addToepoint;
  66056. /**
  66057. * Babylon reference to the earcut plugin.
  66058. */
  66059. bjsEarcut: any;
  66060. /**
  66061. * Creates a PolygonMeshBuilder
  66062. * @param name name of the builder
  66063. * @param contours Path of the polygon
  66064. * @param scene scene to add to when creating the mesh
  66065. * @param earcutInjection can be used to inject your own earcut reference
  66066. */
  66067. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66068. /**
  66069. * Adds a whole within the polygon
  66070. * @param hole Array of points defining the hole
  66071. * @returns this
  66072. */
  66073. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66074. /**
  66075. * Creates the polygon
  66076. * @param updatable If the mesh should be updatable
  66077. * @param depth The depth of the mesh created
  66078. * @returns the created mesh
  66079. */
  66080. build(updatable?: boolean, depth?: number): Mesh;
  66081. /**
  66082. * Creates the polygon
  66083. * @param depth The depth of the mesh created
  66084. * @returns the created VertexData
  66085. */
  66086. buildVertexData(depth?: number): VertexData;
  66087. /**
  66088. * Adds a side to the polygon
  66089. * @param positions points that make the polygon
  66090. * @param normals normals of the polygon
  66091. * @param uvs uvs of the polygon
  66092. * @param indices indices of the polygon
  66093. * @param bounds bounds of the polygon
  66094. * @param points points of the polygon
  66095. * @param depth depth of the polygon
  66096. * @param flip flip of the polygon
  66097. */
  66098. private addSide;
  66099. }
  66100. }
  66101. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  66102. import { Scene } from "babylonjs/scene";
  66103. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66104. import { Color4 } from "babylonjs/Maths/math.color";
  66105. import { Mesh } from "babylonjs/Meshes/mesh";
  66106. import { Nullable } from "babylonjs/types";
  66107. /**
  66108. * Class containing static functions to help procedurally build meshes
  66109. */
  66110. export class PolygonBuilder {
  66111. /**
  66112. * Creates a polygon mesh
  66113. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66114. * * 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
  66115. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66117. * * 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)
  66118. * * Remember you can only change the shape positions, not their number when updating a polygon
  66119. * @param name defines the name of the mesh
  66120. * @param options defines the options used to create the mesh
  66121. * @param scene defines the hosting scene
  66122. * @param earcutInjection can be used to inject your own earcut reference
  66123. * @returns the polygon mesh
  66124. */
  66125. static CreatePolygon(name: string, options: {
  66126. shape: Vector3[];
  66127. holes?: Vector3[][];
  66128. depth?: number;
  66129. faceUV?: Vector4[];
  66130. faceColors?: Color4[];
  66131. updatable?: boolean;
  66132. sideOrientation?: number;
  66133. frontUVs?: Vector4;
  66134. backUVs?: Vector4;
  66135. wrap?: boolean;
  66136. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66137. /**
  66138. * Creates an extruded polygon mesh, with depth in the Y direction.
  66139. * * 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)
  66140. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66141. * @param name defines the name of the mesh
  66142. * @param options defines the options used to create the mesh
  66143. * @param scene defines the hosting scene
  66144. * @param earcutInjection can be used to inject your own earcut reference
  66145. * @returns the polygon mesh
  66146. */
  66147. static ExtrudePolygon(name: string, options: {
  66148. shape: Vector3[];
  66149. holes?: Vector3[][];
  66150. depth?: number;
  66151. faceUV?: Vector4[];
  66152. faceColors?: Color4[];
  66153. updatable?: boolean;
  66154. sideOrientation?: number;
  66155. frontUVs?: Vector4;
  66156. backUVs?: Vector4;
  66157. wrap?: boolean;
  66158. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66159. }
  66160. }
  66161. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  66162. import { Scene } from "babylonjs/scene";
  66163. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66164. import { Mesh } from "babylonjs/Meshes/mesh";
  66165. import { Nullable } from "babylonjs/types";
  66166. /**
  66167. * Class containing static functions to help procedurally build meshes
  66168. */
  66169. export class LatheBuilder {
  66170. /**
  66171. * Creates lathe mesh.
  66172. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66173. * * 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
  66174. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66175. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66176. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66177. * * 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
  66178. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66179. * * 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
  66180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66181. * * 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
  66182. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66184. * @param name defines the name of the mesh
  66185. * @param options defines the options used to create the mesh
  66186. * @param scene defines the hosting scene
  66187. * @returns the lathe mesh
  66188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66189. */
  66190. static CreateLathe(name: string, options: {
  66191. shape: Vector3[];
  66192. radius?: number;
  66193. tessellation?: number;
  66194. clip?: number;
  66195. arc?: number;
  66196. closed?: boolean;
  66197. updatable?: boolean;
  66198. sideOrientation?: number;
  66199. frontUVs?: Vector4;
  66200. backUVs?: Vector4;
  66201. cap?: number;
  66202. invertUV?: boolean;
  66203. }, scene?: Nullable<Scene>): Mesh;
  66204. }
  66205. }
  66206. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  66207. import { Nullable } from "babylonjs/types";
  66208. import { Scene } from "babylonjs/scene";
  66209. import { Vector4 } from "babylonjs/Maths/math.vector";
  66210. import { Mesh } from "babylonjs/Meshes/mesh";
  66211. /**
  66212. * Class containing static functions to help procedurally build meshes
  66213. */
  66214. export class TiledPlaneBuilder {
  66215. /**
  66216. * Creates a tiled plane mesh
  66217. * * The parameter `pattern` will, depending on value, do nothing or
  66218. * * * flip (reflect about central vertical) alternate tiles across and up
  66219. * * * flip every tile on alternate rows
  66220. * * * rotate (180 degs) alternate tiles across and up
  66221. * * * rotate every tile on alternate rows
  66222. * * * flip and rotate alternate tiles across and up
  66223. * * * flip and rotate every tile on alternate rows
  66224. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66225. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66226. * * 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
  66227. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66228. * * 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)
  66229. * * 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)
  66230. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66231. * @param name defines the name of the mesh
  66232. * @param options defines the options used to create the mesh
  66233. * @param scene defines the hosting scene
  66234. * @returns the box mesh
  66235. */
  66236. static CreateTiledPlane(name: string, options: {
  66237. pattern?: number;
  66238. tileSize?: number;
  66239. tileWidth?: number;
  66240. tileHeight?: number;
  66241. size?: number;
  66242. width?: number;
  66243. height?: number;
  66244. alignHorizontal?: number;
  66245. alignVertical?: number;
  66246. sideOrientation?: number;
  66247. frontUVs?: Vector4;
  66248. backUVs?: Vector4;
  66249. updatable?: boolean;
  66250. }, scene?: Nullable<Scene>): Mesh;
  66251. }
  66252. }
  66253. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  66254. import { Nullable } from "babylonjs/types";
  66255. import { Scene } from "babylonjs/scene";
  66256. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66257. import { Mesh } from "babylonjs/Meshes/mesh";
  66258. /**
  66259. * Class containing static functions to help procedurally build meshes
  66260. */
  66261. export class TubeBuilder {
  66262. /**
  66263. * Creates a tube mesh.
  66264. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66265. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66266. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66267. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66268. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66269. * * 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)
  66270. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66271. * * 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
  66272. * * 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
  66273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66274. * * 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
  66275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66277. * @param name defines the name of the mesh
  66278. * @param options defines the options used to create the mesh
  66279. * @param scene defines the hosting scene
  66280. * @returns the tube mesh
  66281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66282. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66283. */
  66284. static CreateTube(name: string, options: {
  66285. path: Vector3[];
  66286. radius?: number;
  66287. tessellation?: number;
  66288. radiusFunction?: {
  66289. (i: number, distance: number): number;
  66290. };
  66291. cap?: number;
  66292. arc?: number;
  66293. updatable?: boolean;
  66294. sideOrientation?: number;
  66295. frontUVs?: Vector4;
  66296. backUVs?: Vector4;
  66297. instance?: Mesh;
  66298. invertUV?: boolean;
  66299. }, scene?: Nullable<Scene>): Mesh;
  66300. }
  66301. }
  66302. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  66303. import { Scene } from "babylonjs/scene";
  66304. import { Vector4 } from "babylonjs/Maths/math.vector";
  66305. import { Mesh } from "babylonjs/Meshes/mesh";
  66306. import { Nullable } from "babylonjs/types";
  66307. /**
  66308. * Class containing static functions to help procedurally build meshes
  66309. */
  66310. export class IcoSphereBuilder {
  66311. /**
  66312. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66313. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66314. * * 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`)
  66315. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66316. * * 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
  66317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66318. * * 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
  66319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66320. * @param name defines the name of the mesh
  66321. * @param options defines the options used to create the mesh
  66322. * @param scene defines the hosting scene
  66323. * @returns the icosahedron mesh
  66324. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66325. */
  66326. static CreateIcoSphere(name: string, options: {
  66327. radius?: number;
  66328. radiusX?: number;
  66329. radiusY?: number;
  66330. radiusZ?: number;
  66331. flat?: boolean;
  66332. subdivisions?: number;
  66333. sideOrientation?: number;
  66334. frontUVs?: Vector4;
  66335. backUVs?: Vector4;
  66336. updatable?: boolean;
  66337. }, scene?: Nullable<Scene>): Mesh;
  66338. }
  66339. }
  66340. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  66341. import { Vector3 } from "babylonjs/Maths/math.vector";
  66342. import { Mesh } from "babylonjs/Meshes/mesh";
  66343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66344. /**
  66345. * Class containing static functions to help procedurally build meshes
  66346. */
  66347. export class DecalBuilder {
  66348. /**
  66349. * Creates a decal mesh.
  66350. * 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
  66351. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66352. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66353. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66354. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66355. * @param name defines the name of the mesh
  66356. * @param sourceMesh defines the mesh where the decal must be applied
  66357. * @param options defines the options used to create the mesh
  66358. * @param scene defines the hosting scene
  66359. * @returns the decal mesh
  66360. * @see https://doc.babylonjs.com/how_to/decals
  66361. */
  66362. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66363. position?: Vector3;
  66364. normal?: Vector3;
  66365. size?: Vector3;
  66366. angle?: number;
  66367. }): Mesh;
  66368. }
  66369. }
  66370. declare module "babylonjs/Meshes/meshBuilder" {
  66371. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  66372. import { Nullable } from "babylonjs/types";
  66373. import { Scene } from "babylonjs/scene";
  66374. import { Mesh } from "babylonjs/Meshes/mesh";
  66375. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  66376. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  66377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66378. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66379. import { Plane } from "babylonjs/Maths/math.plane";
  66380. /**
  66381. * Class containing static functions to help procedurally build meshes
  66382. */
  66383. export class MeshBuilder {
  66384. /**
  66385. * Creates a box mesh
  66386. * * The parameter `size` sets the size (float) of each box side (default 1)
  66387. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66388. * * 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)
  66389. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66391. * * 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
  66392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66393. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66394. * @param name defines the name of the mesh
  66395. * @param options defines the options used to create the mesh
  66396. * @param scene defines the hosting scene
  66397. * @returns the box mesh
  66398. */
  66399. static CreateBox(name: string, options: {
  66400. size?: number;
  66401. width?: number;
  66402. height?: number;
  66403. depth?: number;
  66404. faceUV?: Vector4[];
  66405. faceColors?: Color4[];
  66406. sideOrientation?: number;
  66407. frontUVs?: Vector4;
  66408. backUVs?: Vector4;
  66409. wrap?: boolean;
  66410. topBaseAt?: number;
  66411. bottomBaseAt?: number;
  66412. updatable?: boolean;
  66413. }, scene?: Nullable<Scene>): Mesh;
  66414. /**
  66415. * Creates a tiled box mesh
  66416. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66418. * @param name defines the name of the mesh
  66419. * @param options defines the options used to create the mesh
  66420. * @param scene defines the hosting scene
  66421. * @returns the tiled box mesh
  66422. */
  66423. static CreateTiledBox(name: string, options: {
  66424. pattern?: number;
  66425. size?: number;
  66426. width?: number;
  66427. height?: number;
  66428. depth: number;
  66429. tileSize?: number;
  66430. tileWidth?: number;
  66431. tileHeight?: number;
  66432. faceUV?: Vector4[];
  66433. faceColors?: Color4[];
  66434. alignHorizontal?: number;
  66435. alignVertical?: number;
  66436. sideOrientation?: number;
  66437. updatable?: boolean;
  66438. }, scene?: Nullable<Scene>): Mesh;
  66439. /**
  66440. * Creates a sphere mesh
  66441. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66442. * * 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`)
  66443. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66444. * * 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
  66445. * * 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)
  66446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66447. * * 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
  66448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66449. * @param name defines the name of the mesh
  66450. * @param options defines the options used to create the mesh
  66451. * @param scene defines the hosting scene
  66452. * @returns the sphere mesh
  66453. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66454. */
  66455. static CreateSphere(name: string, options: {
  66456. segments?: number;
  66457. diameter?: number;
  66458. diameterX?: number;
  66459. diameterY?: number;
  66460. diameterZ?: number;
  66461. arc?: number;
  66462. slice?: number;
  66463. sideOrientation?: number;
  66464. frontUVs?: Vector4;
  66465. backUVs?: Vector4;
  66466. updatable?: boolean;
  66467. }, scene?: Nullable<Scene>): Mesh;
  66468. /**
  66469. * Creates a plane polygonal mesh. By default, this is a disc
  66470. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66471. * * 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
  66472. * * 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
  66473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66474. * * 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
  66475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66476. * @param name defines the name of the mesh
  66477. * @param options defines the options used to create the mesh
  66478. * @param scene defines the hosting scene
  66479. * @returns the plane polygonal mesh
  66480. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66481. */
  66482. static CreateDisc(name: string, options: {
  66483. radius?: number;
  66484. tessellation?: number;
  66485. arc?: number;
  66486. updatable?: boolean;
  66487. sideOrientation?: number;
  66488. frontUVs?: Vector4;
  66489. backUVs?: Vector4;
  66490. }, scene?: Nullable<Scene>): Mesh;
  66491. /**
  66492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66494. * * 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`)
  66495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66496. * * 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
  66497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66498. * * 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
  66499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66500. * @param name defines the name of the mesh
  66501. * @param options defines the options used to create the mesh
  66502. * @param scene defines the hosting scene
  66503. * @returns the icosahedron mesh
  66504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66505. */
  66506. static CreateIcoSphere(name: string, options: {
  66507. radius?: number;
  66508. radiusX?: number;
  66509. radiusY?: number;
  66510. radiusZ?: number;
  66511. flat?: boolean;
  66512. subdivisions?: number;
  66513. sideOrientation?: number;
  66514. frontUVs?: Vector4;
  66515. backUVs?: Vector4;
  66516. updatable?: boolean;
  66517. }, scene?: Nullable<Scene>): Mesh;
  66518. /**
  66519. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66520. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66521. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66522. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66523. * * 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
  66524. * * 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
  66525. * * 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
  66526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66527. * * 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
  66528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66529. * * 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
  66530. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66531. * * 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
  66532. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66534. * @param name defines the name of the mesh
  66535. * @param options defines the options used to create the mesh
  66536. * @param scene defines the hosting scene
  66537. * @returns the ribbon mesh
  66538. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66540. */
  66541. static CreateRibbon(name: string, options: {
  66542. pathArray: Vector3[][];
  66543. closeArray?: boolean;
  66544. closePath?: boolean;
  66545. offset?: number;
  66546. updatable?: boolean;
  66547. sideOrientation?: number;
  66548. frontUVs?: Vector4;
  66549. backUVs?: Vector4;
  66550. instance?: Mesh;
  66551. invertUV?: boolean;
  66552. uvs?: Vector2[];
  66553. colors?: Color4[];
  66554. }, scene?: Nullable<Scene>): Mesh;
  66555. /**
  66556. * Creates a cylinder or a cone mesh
  66557. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66558. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66559. * * 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.
  66560. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66561. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66562. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66563. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66564. * * 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).
  66565. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66566. * * 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).
  66567. * * 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
  66568. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66569. * * 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
  66570. * * 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.
  66571. * * If `enclose` is false, a ring surface is one element.
  66572. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66573. * * 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
  66574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66575. * * 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
  66576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66577. * @param name defines the name of the mesh
  66578. * @param options defines the options used to create the mesh
  66579. * @param scene defines the hosting scene
  66580. * @returns the cylinder mesh
  66581. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66582. */
  66583. static CreateCylinder(name: string, options: {
  66584. height?: number;
  66585. diameterTop?: number;
  66586. diameterBottom?: number;
  66587. diameter?: number;
  66588. tessellation?: number;
  66589. subdivisions?: number;
  66590. arc?: number;
  66591. faceColors?: Color4[];
  66592. faceUV?: Vector4[];
  66593. updatable?: boolean;
  66594. hasRings?: boolean;
  66595. enclose?: boolean;
  66596. cap?: number;
  66597. sideOrientation?: number;
  66598. frontUVs?: Vector4;
  66599. backUVs?: Vector4;
  66600. }, scene?: Nullable<Scene>): Mesh;
  66601. /**
  66602. * Creates a torus mesh
  66603. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66604. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66605. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66607. * * 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
  66608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66609. * @param name defines the name of the mesh
  66610. * @param options defines the options used to create the mesh
  66611. * @param scene defines the hosting scene
  66612. * @returns the torus mesh
  66613. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66614. */
  66615. static CreateTorus(name: string, options: {
  66616. diameter?: number;
  66617. thickness?: number;
  66618. tessellation?: number;
  66619. updatable?: boolean;
  66620. sideOrientation?: number;
  66621. frontUVs?: Vector4;
  66622. backUVs?: Vector4;
  66623. }, scene?: Nullable<Scene>): Mesh;
  66624. /**
  66625. * Creates a torus knot mesh
  66626. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66627. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66628. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66629. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66631. * * 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
  66632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66633. * @param name defines the name of the mesh
  66634. * @param options defines the options used to create the mesh
  66635. * @param scene defines the hosting scene
  66636. * @returns the torus knot mesh
  66637. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66638. */
  66639. static CreateTorusKnot(name: string, options: {
  66640. radius?: number;
  66641. tube?: number;
  66642. radialSegments?: number;
  66643. tubularSegments?: number;
  66644. p?: number;
  66645. q?: number;
  66646. updatable?: boolean;
  66647. sideOrientation?: number;
  66648. frontUVs?: Vector4;
  66649. backUVs?: Vector4;
  66650. }, scene?: Nullable<Scene>): Mesh;
  66651. /**
  66652. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66653. * * 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
  66654. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66655. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66656. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66657. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66658. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66659. * * 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
  66660. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66663. * @param name defines the name of the new line system
  66664. * @param options defines the options used to create the line system
  66665. * @param scene defines the hosting scene
  66666. * @returns a new line system mesh
  66667. */
  66668. static CreateLineSystem(name: string, options: {
  66669. lines: Vector3[][];
  66670. updatable?: boolean;
  66671. instance?: Nullable<LinesMesh>;
  66672. colors?: Nullable<Color4[][]>;
  66673. useVertexAlpha?: boolean;
  66674. }, scene: Nullable<Scene>): LinesMesh;
  66675. /**
  66676. * Creates a line mesh
  66677. * 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
  66678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66679. * * The parameter `points` is an array successive Vector3
  66680. * * 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
  66681. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66682. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66683. * * When updating an instance, remember that only point positions can change, not the number of points
  66684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66686. * @param name defines the name of the new line system
  66687. * @param options defines the options used to create the line system
  66688. * @param scene defines the hosting scene
  66689. * @returns a new line mesh
  66690. */
  66691. static CreateLines(name: string, options: {
  66692. points: Vector3[];
  66693. updatable?: boolean;
  66694. instance?: Nullable<LinesMesh>;
  66695. colors?: Color4[];
  66696. useVertexAlpha?: boolean;
  66697. }, scene?: Nullable<Scene>): LinesMesh;
  66698. /**
  66699. * Creates a dashed line mesh
  66700. * * 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
  66701. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66702. * * The parameter `points` is an array successive Vector3
  66703. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66704. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66705. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66706. * * 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
  66707. * * When updating an instance, remember that only point positions can change, not the number of points
  66708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66709. * @param name defines the name of the mesh
  66710. * @param options defines the options used to create the mesh
  66711. * @param scene defines the hosting scene
  66712. * @returns the dashed line mesh
  66713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66714. */
  66715. static CreateDashedLines(name: string, options: {
  66716. points: Vector3[];
  66717. dashSize?: number;
  66718. gapSize?: number;
  66719. dashNb?: number;
  66720. updatable?: boolean;
  66721. instance?: LinesMesh;
  66722. }, scene?: Nullable<Scene>): LinesMesh;
  66723. /**
  66724. * 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.
  66725. * * 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.
  66726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66727. * * 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.
  66728. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66729. * * 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
  66730. * * 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
  66731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66733. * * 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
  66734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66736. * @param name defines the name of the mesh
  66737. * @param options defines the options used to create the mesh
  66738. * @param scene defines the hosting scene
  66739. * @returns the extruded shape mesh
  66740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66742. */
  66743. static ExtrudeShape(name: string, options: {
  66744. shape: Vector3[];
  66745. path: Vector3[];
  66746. scale?: number;
  66747. rotation?: number;
  66748. cap?: number;
  66749. updatable?: boolean;
  66750. sideOrientation?: number;
  66751. frontUVs?: Vector4;
  66752. backUVs?: Vector4;
  66753. instance?: Mesh;
  66754. invertUV?: boolean;
  66755. }, scene?: Nullable<Scene>): Mesh;
  66756. /**
  66757. * Creates an custom extruded shape mesh.
  66758. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66759. * * 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.
  66760. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66761. * * 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
  66762. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66763. * * 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
  66764. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66765. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66766. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66767. * * 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
  66768. * * 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
  66769. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66771. * * 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
  66772. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66774. * @param name defines the name of the mesh
  66775. * @param options defines the options used to create the mesh
  66776. * @param scene defines the hosting scene
  66777. * @returns the custom extruded shape mesh
  66778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66781. */
  66782. static ExtrudeShapeCustom(name: string, options: {
  66783. shape: Vector3[];
  66784. path: Vector3[];
  66785. scaleFunction?: any;
  66786. rotationFunction?: any;
  66787. ribbonCloseArray?: boolean;
  66788. ribbonClosePath?: boolean;
  66789. cap?: number;
  66790. updatable?: boolean;
  66791. sideOrientation?: number;
  66792. frontUVs?: Vector4;
  66793. backUVs?: Vector4;
  66794. instance?: Mesh;
  66795. invertUV?: boolean;
  66796. }, scene?: Nullable<Scene>): Mesh;
  66797. /**
  66798. * Creates lathe mesh.
  66799. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66800. * * 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
  66801. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66802. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66803. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66804. * * 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
  66805. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66806. * * 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
  66807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66808. * * 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
  66809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66811. * @param name defines the name of the mesh
  66812. * @param options defines the options used to create the mesh
  66813. * @param scene defines the hosting scene
  66814. * @returns the lathe mesh
  66815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66816. */
  66817. static CreateLathe(name: string, options: {
  66818. shape: Vector3[];
  66819. radius?: number;
  66820. tessellation?: number;
  66821. clip?: number;
  66822. arc?: number;
  66823. closed?: boolean;
  66824. updatable?: boolean;
  66825. sideOrientation?: number;
  66826. frontUVs?: Vector4;
  66827. backUVs?: Vector4;
  66828. cap?: number;
  66829. invertUV?: boolean;
  66830. }, scene?: Nullable<Scene>): Mesh;
  66831. /**
  66832. * Creates a tiled plane mesh
  66833. * * You can set a limited pattern arrangement with the tiles
  66834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66835. * * 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
  66836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66837. * @param name defines the name of the mesh
  66838. * @param options defines the options used to create the mesh
  66839. * @param scene defines the hosting scene
  66840. * @returns the plane mesh
  66841. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66842. */
  66843. static CreateTiledPlane(name: string, options: {
  66844. pattern?: number;
  66845. tileSize?: number;
  66846. tileWidth?: number;
  66847. tileHeight?: number;
  66848. size?: number;
  66849. width?: number;
  66850. height?: number;
  66851. alignHorizontal?: number;
  66852. alignVertical?: number;
  66853. sideOrientation?: number;
  66854. frontUVs?: Vector4;
  66855. backUVs?: Vector4;
  66856. updatable?: boolean;
  66857. }, scene?: Nullable<Scene>): Mesh;
  66858. /**
  66859. * Creates a plane mesh
  66860. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66861. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66862. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66864. * * 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
  66865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66866. * @param name defines the name of the mesh
  66867. * @param options defines the options used to create the mesh
  66868. * @param scene defines the hosting scene
  66869. * @returns the plane mesh
  66870. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66871. */
  66872. static CreatePlane(name: string, options: {
  66873. size?: number;
  66874. width?: number;
  66875. height?: number;
  66876. sideOrientation?: number;
  66877. frontUVs?: Vector4;
  66878. backUVs?: Vector4;
  66879. updatable?: boolean;
  66880. sourcePlane?: Plane;
  66881. }, scene?: Nullable<Scene>): Mesh;
  66882. /**
  66883. * Creates a ground mesh
  66884. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66885. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66887. * @param name defines the name of the mesh
  66888. * @param options defines the options used to create the mesh
  66889. * @param scene defines the hosting scene
  66890. * @returns the ground mesh
  66891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66892. */
  66893. static CreateGround(name: string, options: {
  66894. width?: number;
  66895. height?: number;
  66896. subdivisions?: number;
  66897. subdivisionsX?: number;
  66898. subdivisionsY?: number;
  66899. updatable?: boolean;
  66900. }, scene?: Nullable<Scene>): Mesh;
  66901. /**
  66902. * Creates a tiled ground mesh
  66903. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66904. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66905. * * 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
  66906. * * 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
  66907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66908. * @param name defines the name of the mesh
  66909. * @param options defines the options used to create the mesh
  66910. * @param scene defines the hosting scene
  66911. * @returns the tiled ground mesh
  66912. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66913. */
  66914. static CreateTiledGround(name: string, options: {
  66915. xmin: number;
  66916. zmin: number;
  66917. xmax: number;
  66918. zmax: number;
  66919. subdivisions?: {
  66920. w: number;
  66921. h: number;
  66922. };
  66923. precision?: {
  66924. w: number;
  66925. h: number;
  66926. };
  66927. updatable?: boolean;
  66928. }, scene?: Nullable<Scene>): Mesh;
  66929. /**
  66930. * Creates a ground mesh from a height map
  66931. * * The parameter `url` sets the URL of the height map image resource.
  66932. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66933. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66934. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66935. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66936. * * 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.
  66937. * * 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).
  66938. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66940. * @param name defines the name of the mesh
  66941. * @param url defines the url to the height map
  66942. * @param options defines the options used to create the mesh
  66943. * @param scene defines the hosting scene
  66944. * @returns the ground mesh
  66945. * @see https://doc.babylonjs.com/babylon101/height_map
  66946. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66947. */
  66948. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66949. width?: number;
  66950. height?: number;
  66951. subdivisions?: number;
  66952. minHeight?: number;
  66953. maxHeight?: number;
  66954. colorFilter?: Color3;
  66955. alphaFilter?: number;
  66956. updatable?: boolean;
  66957. onReady?: (mesh: GroundMesh) => void;
  66958. }, scene?: Nullable<Scene>): GroundMesh;
  66959. /**
  66960. * Creates a polygon mesh
  66961. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66962. * * 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
  66963. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66965. * * 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)
  66966. * * Remember you can only change the shape positions, not their number when updating a polygon
  66967. * @param name defines the name of the mesh
  66968. * @param options defines the options used to create the mesh
  66969. * @param scene defines the hosting scene
  66970. * @param earcutInjection can be used to inject your own earcut reference
  66971. * @returns the polygon mesh
  66972. */
  66973. static CreatePolygon(name: string, options: {
  66974. shape: Vector3[];
  66975. holes?: Vector3[][];
  66976. depth?: number;
  66977. faceUV?: Vector4[];
  66978. faceColors?: Color4[];
  66979. updatable?: boolean;
  66980. sideOrientation?: number;
  66981. frontUVs?: Vector4;
  66982. backUVs?: Vector4;
  66983. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66984. /**
  66985. * Creates an extruded polygon mesh, with depth in the Y direction.
  66986. * * 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)
  66987. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66988. * @param name defines the name of the mesh
  66989. * @param options defines the options used to create the mesh
  66990. * @param scene defines the hosting scene
  66991. * @param earcutInjection can be used to inject your own earcut reference
  66992. * @returns the polygon mesh
  66993. */
  66994. static ExtrudePolygon(name: string, options: {
  66995. shape: Vector3[];
  66996. holes?: Vector3[][];
  66997. depth?: number;
  66998. faceUV?: Vector4[];
  66999. faceColors?: Color4[];
  67000. updatable?: boolean;
  67001. sideOrientation?: number;
  67002. frontUVs?: Vector4;
  67003. backUVs?: Vector4;
  67004. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67005. /**
  67006. * Creates a tube mesh.
  67007. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67008. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67009. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67010. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67011. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67012. * * 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)
  67013. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67014. * * 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
  67015. * * 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
  67016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67017. * * 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
  67018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67020. * @param name defines the name of the mesh
  67021. * @param options defines the options used to create the mesh
  67022. * @param scene defines the hosting scene
  67023. * @returns the tube mesh
  67024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67025. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67026. */
  67027. static CreateTube(name: string, options: {
  67028. path: Vector3[];
  67029. radius?: number;
  67030. tessellation?: number;
  67031. radiusFunction?: {
  67032. (i: number, distance: number): number;
  67033. };
  67034. cap?: number;
  67035. arc?: number;
  67036. updatable?: boolean;
  67037. sideOrientation?: number;
  67038. frontUVs?: Vector4;
  67039. backUVs?: Vector4;
  67040. instance?: Mesh;
  67041. invertUV?: boolean;
  67042. }, scene?: Nullable<Scene>): Mesh;
  67043. /**
  67044. * Creates a polyhedron mesh
  67045. * * 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
  67046. * * The parameter `size` (positive float, default 1) sets the polygon size
  67047. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67048. * * 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`
  67049. * * 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
  67050. * * 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)`)
  67051. * * 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
  67052. * * 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
  67053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67054. * * 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
  67055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67056. * @param name defines the name of the mesh
  67057. * @param options defines the options used to create the mesh
  67058. * @param scene defines the hosting scene
  67059. * @returns the polyhedron mesh
  67060. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67061. */
  67062. static CreatePolyhedron(name: string, options: {
  67063. type?: number;
  67064. size?: number;
  67065. sizeX?: number;
  67066. sizeY?: number;
  67067. sizeZ?: number;
  67068. custom?: any;
  67069. faceUV?: Vector4[];
  67070. faceColors?: Color4[];
  67071. flat?: boolean;
  67072. updatable?: boolean;
  67073. sideOrientation?: number;
  67074. frontUVs?: Vector4;
  67075. backUVs?: Vector4;
  67076. }, scene?: Nullable<Scene>): Mesh;
  67077. /**
  67078. * Creates a decal mesh.
  67079. * 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
  67080. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67081. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67082. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67083. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67084. * @param name defines the name of the mesh
  67085. * @param sourceMesh defines the mesh where the decal must be applied
  67086. * @param options defines the options used to create the mesh
  67087. * @param scene defines the hosting scene
  67088. * @returns the decal mesh
  67089. * @see https://doc.babylonjs.com/how_to/decals
  67090. */
  67091. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67092. position?: Vector3;
  67093. normal?: Vector3;
  67094. size?: Vector3;
  67095. angle?: number;
  67096. }): Mesh;
  67097. }
  67098. }
  67099. declare module "babylonjs/Meshes/meshSimplification" {
  67100. import { Mesh } from "babylonjs/Meshes/mesh";
  67101. /**
  67102. * A simplifier interface for future simplification implementations
  67103. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67104. */
  67105. export interface ISimplifier {
  67106. /**
  67107. * Simplification of a given mesh according to the given settings.
  67108. * Since this requires computation, it is assumed that the function runs async.
  67109. * @param settings The settings of the simplification, including quality and distance
  67110. * @param successCallback A callback that will be called after the mesh was simplified.
  67111. * @param errorCallback in case of an error, this callback will be called. optional.
  67112. */
  67113. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67114. }
  67115. /**
  67116. * Expected simplification settings.
  67117. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67118. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67119. */
  67120. export interface ISimplificationSettings {
  67121. /**
  67122. * Gets or sets the expected quality
  67123. */
  67124. quality: number;
  67125. /**
  67126. * Gets or sets the distance when this optimized version should be used
  67127. */
  67128. distance: number;
  67129. /**
  67130. * Gets an already optimized mesh
  67131. */
  67132. optimizeMesh?: boolean;
  67133. }
  67134. /**
  67135. * Class used to specify simplification options
  67136. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67137. */
  67138. export class SimplificationSettings implements ISimplificationSettings {
  67139. /** expected quality */
  67140. quality: number;
  67141. /** distance when this optimized version should be used */
  67142. distance: number;
  67143. /** already optimized mesh */
  67144. optimizeMesh?: boolean | undefined;
  67145. /**
  67146. * Creates a SimplificationSettings
  67147. * @param quality expected quality
  67148. * @param distance distance when this optimized version should be used
  67149. * @param optimizeMesh already optimized mesh
  67150. */
  67151. constructor(
  67152. /** expected quality */
  67153. quality: number,
  67154. /** distance when this optimized version should be used */
  67155. distance: number,
  67156. /** already optimized mesh */
  67157. optimizeMesh?: boolean | undefined);
  67158. }
  67159. /**
  67160. * Interface used to define a simplification task
  67161. */
  67162. export interface ISimplificationTask {
  67163. /**
  67164. * Array of settings
  67165. */
  67166. settings: Array<ISimplificationSettings>;
  67167. /**
  67168. * Simplification type
  67169. */
  67170. simplificationType: SimplificationType;
  67171. /**
  67172. * Mesh to simplify
  67173. */
  67174. mesh: Mesh;
  67175. /**
  67176. * Callback called on success
  67177. */
  67178. successCallback?: () => void;
  67179. /**
  67180. * Defines if parallel processing can be used
  67181. */
  67182. parallelProcessing: boolean;
  67183. }
  67184. /**
  67185. * Queue used to order the simplification tasks
  67186. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67187. */
  67188. export class SimplificationQueue {
  67189. private _simplificationArray;
  67190. /**
  67191. * Gets a boolean indicating that the process is still running
  67192. */
  67193. running: boolean;
  67194. /**
  67195. * Creates a new queue
  67196. */
  67197. constructor();
  67198. /**
  67199. * Adds a new simplification task
  67200. * @param task defines a task to add
  67201. */
  67202. addTask(task: ISimplificationTask): void;
  67203. /**
  67204. * Execute next task
  67205. */
  67206. executeNext(): void;
  67207. /**
  67208. * Execute a simplification task
  67209. * @param task defines the task to run
  67210. */
  67211. runSimplification(task: ISimplificationTask): void;
  67212. private getSimplifier;
  67213. }
  67214. /**
  67215. * The implemented types of simplification
  67216. * At the moment only Quadratic Error Decimation is implemented
  67217. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67218. */
  67219. export enum SimplificationType {
  67220. /** Quadratic error decimation */
  67221. QUADRATIC = 0
  67222. }
  67223. /**
  67224. * An implementation of the Quadratic Error simplification algorithm.
  67225. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67226. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67227. * @author RaananW
  67228. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67229. */
  67230. export class QuadraticErrorSimplification implements ISimplifier {
  67231. private _mesh;
  67232. private triangles;
  67233. private vertices;
  67234. private references;
  67235. private _reconstructedMesh;
  67236. /** Gets or sets the number pf sync interations */
  67237. syncIterations: number;
  67238. /** Gets or sets the aggressiveness of the simplifier */
  67239. aggressiveness: number;
  67240. /** Gets or sets the number of allowed iterations for decimation */
  67241. decimationIterations: number;
  67242. /** Gets or sets the espilon to use for bounding box computation */
  67243. boundingBoxEpsilon: number;
  67244. /**
  67245. * Creates a new QuadraticErrorSimplification
  67246. * @param _mesh defines the target mesh
  67247. */
  67248. constructor(_mesh: Mesh);
  67249. /**
  67250. * Simplification of a given mesh according to the given settings.
  67251. * Since this requires computation, it is assumed that the function runs async.
  67252. * @param settings The settings of the simplification, including quality and distance
  67253. * @param successCallback A callback that will be called after the mesh was simplified.
  67254. */
  67255. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67256. private runDecimation;
  67257. private initWithMesh;
  67258. private init;
  67259. private reconstructMesh;
  67260. private initDecimatedMesh;
  67261. private isFlipped;
  67262. private updateTriangles;
  67263. private identifyBorder;
  67264. private updateMesh;
  67265. private vertexError;
  67266. private calculateError;
  67267. }
  67268. }
  67269. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  67270. import { Scene } from "babylonjs/scene";
  67271. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  67272. import { ISceneComponent } from "babylonjs/sceneComponent";
  67273. module "babylonjs/scene" {
  67274. interface Scene {
  67275. /** @hidden (Backing field) */
  67276. _simplificationQueue: SimplificationQueue;
  67277. /**
  67278. * Gets or sets the simplification queue attached to the scene
  67279. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67280. */
  67281. simplificationQueue: SimplificationQueue;
  67282. }
  67283. }
  67284. module "babylonjs/Meshes/mesh" {
  67285. interface Mesh {
  67286. /**
  67287. * Simplify the mesh according to the given array of settings.
  67288. * Function will return immediately and will simplify async
  67289. * @param settings a collection of simplification settings
  67290. * @param parallelProcessing should all levels calculate parallel or one after the other
  67291. * @param simplificationType the type of simplification to run
  67292. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67293. * @returns the current mesh
  67294. */
  67295. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67296. }
  67297. }
  67298. /**
  67299. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67300. * created in a scene
  67301. */
  67302. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67303. /**
  67304. * The component name helpfull to identify the component in the list of scene components.
  67305. */
  67306. readonly name: string;
  67307. /**
  67308. * The scene the component belongs to.
  67309. */
  67310. scene: Scene;
  67311. /**
  67312. * Creates a new instance of the component for the given scene
  67313. * @param scene Defines the scene to register the component in
  67314. */
  67315. constructor(scene: Scene);
  67316. /**
  67317. * Registers the component in a given scene
  67318. */
  67319. register(): void;
  67320. /**
  67321. * Rebuilds the elements related to this component in case of
  67322. * context lost for instance.
  67323. */
  67324. rebuild(): void;
  67325. /**
  67326. * Disposes the component and the associated ressources
  67327. */
  67328. dispose(): void;
  67329. private _beforeCameraUpdate;
  67330. }
  67331. }
  67332. declare module "babylonjs/Meshes/Builders/index" {
  67333. export * from "babylonjs/Meshes/Builders/boxBuilder";
  67334. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  67335. export * from "babylonjs/Meshes/Builders/discBuilder";
  67336. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  67337. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  67338. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  67339. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  67340. export * from "babylonjs/Meshes/Builders/torusBuilder";
  67341. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  67342. export * from "babylonjs/Meshes/Builders/linesBuilder";
  67343. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  67344. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  67345. export * from "babylonjs/Meshes/Builders/latheBuilder";
  67346. export * from "babylonjs/Meshes/Builders/planeBuilder";
  67347. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  67348. export * from "babylonjs/Meshes/Builders/groundBuilder";
  67349. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  67350. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  67351. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  67352. export * from "babylonjs/Meshes/Builders/decalBuilder";
  67353. }
  67354. declare module "babylonjs/Meshes/index" {
  67355. export * from "babylonjs/Meshes/abstractMesh";
  67356. export * from "babylonjs/Meshes/buffer";
  67357. export * from "babylonjs/Meshes/Compression/index";
  67358. export * from "babylonjs/Meshes/csg";
  67359. export * from "babylonjs/Meshes/geometry";
  67360. export * from "babylonjs/Meshes/groundMesh";
  67361. export * from "babylonjs/Meshes/trailMesh";
  67362. export * from "babylonjs/Meshes/instancedMesh";
  67363. export * from "babylonjs/Meshes/linesMesh";
  67364. export * from "babylonjs/Meshes/mesh";
  67365. export * from "babylonjs/Meshes/mesh.vertexData";
  67366. export * from "babylonjs/Meshes/meshBuilder";
  67367. export * from "babylonjs/Meshes/meshSimplification";
  67368. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  67369. export * from "babylonjs/Meshes/polygonMesh";
  67370. export * from "babylonjs/Meshes/subMesh";
  67371. export * from "babylonjs/Meshes/meshLODLevel";
  67372. export * from "babylonjs/Meshes/transformNode";
  67373. export * from "babylonjs/Meshes/Builders/index";
  67374. export * from "babylonjs/Meshes/dataBuffer";
  67375. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  67376. }
  67377. declare module "babylonjs/Morph/index" {
  67378. export * from "babylonjs/Morph/morphTarget";
  67379. export * from "babylonjs/Morph/morphTargetManager";
  67380. }
  67381. declare module "babylonjs/Navigation/INavigationEngine" {
  67382. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67383. import { Vector3 } from "babylonjs/Maths/math";
  67384. import { Mesh } from "babylonjs/Meshes/mesh";
  67385. import { Scene } from "babylonjs/scene";
  67386. /**
  67387. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67388. */
  67389. export interface INavigationEnginePlugin {
  67390. /**
  67391. * plugin name
  67392. */
  67393. name: string;
  67394. /**
  67395. * Creates a navigation mesh
  67396. * @param meshes array of all the geometry used to compute the navigatio mesh
  67397. * @param parameters bunch of parameters used to filter geometry
  67398. */
  67399. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67400. /**
  67401. * Create a navigation mesh debug mesh
  67402. * @param scene is where the mesh will be added
  67403. * @returns debug display mesh
  67404. */
  67405. createDebugNavMesh(scene: Scene): Mesh;
  67406. /**
  67407. * Get a navigation mesh constrained position, closest to the parameter position
  67408. * @param position world position
  67409. * @returns the closest point to position constrained by the navigation mesh
  67410. */
  67411. getClosestPoint(position: Vector3): Vector3;
  67412. /**
  67413. * Get a navigation mesh constrained position, closest to the parameter position
  67414. * @param position world position
  67415. * @param result output the closest point to position constrained by the navigation mesh
  67416. */
  67417. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67418. /**
  67419. * Get a navigation mesh constrained position, within a particular radius
  67420. * @param position world position
  67421. * @param maxRadius the maximum distance to the constrained world position
  67422. * @returns the closest point to position constrained by the navigation mesh
  67423. */
  67424. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67425. /**
  67426. * Get a navigation mesh constrained position, within a particular radius
  67427. * @param position world position
  67428. * @param maxRadius the maximum distance to the constrained world position
  67429. * @param result output the closest point to position constrained by the navigation mesh
  67430. */
  67431. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67432. /**
  67433. * Compute the final position from a segment made of destination-position
  67434. * @param position world position
  67435. * @param destination world position
  67436. * @returns the resulting point along the navmesh
  67437. */
  67438. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67439. /**
  67440. * Compute the final position from a segment made of destination-position
  67441. * @param position world position
  67442. * @param destination world position
  67443. * @param result output the resulting point along the navmesh
  67444. */
  67445. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67446. /**
  67447. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67448. * @param start world position
  67449. * @param end world position
  67450. * @returns array containing world position composing the path
  67451. */
  67452. computePath(start: Vector3, end: Vector3): Vector3[];
  67453. /**
  67454. * If this plugin is supported
  67455. * @returns true if plugin is supported
  67456. */
  67457. isSupported(): boolean;
  67458. /**
  67459. * Create a new Crowd so you can add agents
  67460. * @param maxAgents the maximum agent count in the crowd
  67461. * @param maxAgentRadius the maximum radius an agent can have
  67462. * @param scene to attach the crowd to
  67463. * @returns the crowd you can add agents to
  67464. */
  67465. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67466. /**
  67467. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67468. * The queries will try to find a solution within those bounds
  67469. * default is (1,1,1)
  67470. * @param extent x,y,z value that define the extent around the queries point of reference
  67471. */
  67472. setDefaultQueryExtent(extent: Vector3): void;
  67473. /**
  67474. * Get the Bounding box extent specified by setDefaultQueryExtent
  67475. * @returns the box extent values
  67476. */
  67477. getDefaultQueryExtent(): Vector3;
  67478. /**
  67479. * build the navmesh from a previously saved state using getNavmeshData
  67480. * @param data the Uint8Array returned by getNavmeshData
  67481. */
  67482. buildFromNavmeshData(data: Uint8Array): void;
  67483. /**
  67484. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67485. * @returns data the Uint8Array that can be saved and reused
  67486. */
  67487. getNavmeshData(): Uint8Array;
  67488. /**
  67489. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67490. * @param result output the box extent values
  67491. */
  67492. getDefaultQueryExtentToRef(result: Vector3): void;
  67493. /**
  67494. * Release all resources
  67495. */
  67496. dispose(): void;
  67497. }
  67498. /**
  67499. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67500. */
  67501. export interface ICrowd {
  67502. /**
  67503. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67504. * You can attach anything to that node. The node position is updated in the scene update tick.
  67505. * @param pos world position that will be constrained by the navigation mesh
  67506. * @param parameters agent parameters
  67507. * @param transform hooked to the agent that will be update by the scene
  67508. * @returns agent index
  67509. */
  67510. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67511. /**
  67512. * Returns the agent position in world space
  67513. * @param index agent index returned by addAgent
  67514. * @returns world space position
  67515. */
  67516. getAgentPosition(index: number): Vector3;
  67517. /**
  67518. * Gets the agent position result in world space
  67519. * @param index agent index returned by addAgent
  67520. * @param result output world space position
  67521. */
  67522. getAgentPositionToRef(index: number, result: Vector3): void;
  67523. /**
  67524. * Gets the agent velocity in world space
  67525. * @param index agent index returned by addAgent
  67526. * @returns world space velocity
  67527. */
  67528. getAgentVelocity(index: number): Vector3;
  67529. /**
  67530. * Gets the agent velocity result in world space
  67531. * @param index agent index returned by addAgent
  67532. * @param result output world space velocity
  67533. */
  67534. getAgentVelocityToRef(index: number, result: Vector3): void;
  67535. /**
  67536. * remove a particular agent previously created
  67537. * @param index agent index returned by addAgent
  67538. */
  67539. removeAgent(index: number): void;
  67540. /**
  67541. * get the list of all agents attached to this crowd
  67542. * @returns list of agent indices
  67543. */
  67544. getAgents(): number[];
  67545. /**
  67546. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67547. * @param deltaTime in seconds
  67548. */
  67549. update(deltaTime: number): void;
  67550. /**
  67551. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67552. * @param index agent index returned by addAgent
  67553. * @param destination targeted world position
  67554. */
  67555. agentGoto(index: number, destination: Vector3): void;
  67556. /**
  67557. * Teleport the agent to a new position
  67558. * @param index agent index returned by addAgent
  67559. * @param destination targeted world position
  67560. */
  67561. agentTeleport(index: number, destination: Vector3): void;
  67562. /**
  67563. * Update agent parameters
  67564. * @param index agent index returned by addAgent
  67565. * @param parameters agent parameters
  67566. */
  67567. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67568. /**
  67569. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67570. * The queries will try to find a solution within those bounds
  67571. * default is (1,1,1)
  67572. * @param extent x,y,z value that define the extent around the queries point of reference
  67573. */
  67574. setDefaultQueryExtent(extent: Vector3): void;
  67575. /**
  67576. * Get the Bounding box extent specified by setDefaultQueryExtent
  67577. * @returns the box extent values
  67578. */
  67579. getDefaultQueryExtent(): Vector3;
  67580. /**
  67581. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67582. * @param result output the box extent values
  67583. */
  67584. getDefaultQueryExtentToRef(result: Vector3): void;
  67585. /**
  67586. * Release all resources
  67587. */
  67588. dispose(): void;
  67589. }
  67590. /**
  67591. * Configures an agent
  67592. */
  67593. export interface IAgentParameters {
  67594. /**
  67595. * Agent radius. [Limit: >= 0]
  67596. */
  67597. radius: number;
  67598. /**
  67599. * Agent height. [Limit: > 0]
  67600. */
  67601. height: number;
  67602. /**
  67603. * Maximum allowed acceleration. [Limit: >= 0]
  67604. */
  67605. maxAcceleration: number;
  67606. /**
  67607. * Maximum allowed speed. [Limit: >= 0]
  67608. */
  67609. maxSpeed: number;
  67610. /**
  67611. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67612. */
  67613. collisionQueryRange: number;
  67614. /**
  67615. * The path visibility optimization range. [Limit: > 0]
  67616. */
  67617. pathOptimizationRange: number;
  67618. /**
  67619. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67620. */
  67621. separationWeight: number;
  67622. }
  67623. /**
  67624. * Configures the navigation mesh creation
  67625. */
  67626. export interface INavMeshParameters {
  67627. /**
  67628. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67629. */
  67630. cs: number;
  67631. /**
  67632. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67633. */
  67634. ch: number;
  67635. /**
  67636. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67637. */
  67638. walkableSlopeAngle: number;
  67639. /**
  67640. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67641. * be considered walkable. [Limit: >= 3] [Units: vx]
  67642. */
  67643. walkableHeight: number;
  67644. /**
  67645. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67646. */
  67647. walkableClimb: number;
  67648. /**
  67649. * The distance to erode/shrink the walkable area of the heightfield away from
  67650. * obstructions. [Limit: >=0] [Units: vx]
  67651. */
  67652. walkableRadius: number;
  67653. /**
  67654. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67655. */
  67656. maxEdgeLen: number;
  67657. /**
  67658. * The maximum distance a simplfied contour's border edges should deviate
  67659. * the original raw contour. [Limit: >=0] [Units: vx]
  67660. */
  67661. maxSimplificationError: number;
  67662. /**
  67663. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67664. */
  67665. minRegionArea: number;
  67666. /**
  67667. * Any regions with a span count smaller than this value will, if possible,
  67668. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67669. */
  67670. mergeRegionArea: number;
  67671. /**
  67672. * The maximum number of vertices allowed for polygons generated during the
  67673. * contour to polygon conversion process. [Limit: >= 3]
  67674. */
  67675. maxVertsPerPoly: number;
  67676. /**
  67677. * Sets the sampling distance to use when generating the detail mesh.
  67678. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67679. */
  67680. detailSampleDist: number;
  67681. /**
  67682. * The maximum distance the detail mesh surface should deviate from heightfield
  67683. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67684. */
  67685. detailSampleMaxError: number;
  67686. }
  67687. }
  67688. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  67689. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  67690. import { Mesh } from "babylonjs/Meshes/mesh";
  67691. import { Scene } from "babylonjs/scene";
  67692. import { Vector3 } from "babylonjs/Maths/math";
  67693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67694. /**
  67695. * RecastJS navigation plugin
  67696. */
  67697. export class RecastJSPlugin implements INavigationEnginePlugin {
  67698. /**
  67699. * Reference to the Recast library
  67700. */
  67701. bjsRECAST: any;
  67702. /**
  67703. * plugin name
  67704. */
  67705. name: string;
  67706. /**
  67707. * the first navmesh created. We might extend this to support multiple navmeshes
  67708. */
  67709. navMesh: any;
  67710. /**
  67711. * Initializes the recastJS plugin
  67712. * @param recastInjection can be used to inject your own recast reference
  67713. */
  67714. constructor(recastInjection?: any);
  67715. /**
  67716. * Creates a navigation mesh
  67717. * @param meshes array of all the geometry used to compute the navigatio mesh
  67718. * @param parameters bunch of parameters used to filter geometry
  67719. */
  67720. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67721. /**
  67722. * Create a navigation mesh debug mesh
  67723. * @param scene is where the mesh will be added
  67724. * @returns debug display mesh
  67725. */
  67726. createDebugNavMesh(scene: Scene): Mesh;
  67727. /**
  67728. * Get a navigation mesh constrained position, closest to the parameter position
  67729. * @param position world position
  67730. * @returns the closest point to position constrained by the navigation mesh
  67731. */
  67732. getClosestPoint(position: Vector3): Vector3;
  67733. /**
  67734. * Get a navigation mesh constrained position, closest to the parameter position
  67735. * @param position world position
  67736. * @param result output the closest point to position constrained by the navigation mesh
  67737. */
  67738. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67739. /**
  67740. * Get a navigation mesh constrained position, within a particular radius
  67741. * @param position world position
  67742. * @param maxRadius the maximum distance to the constrained world position
  67743. * @returns the closest point to position constrained by the navigation mesh
  67744. */
  67745. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67746. /**
  67747. * Get a navigation mesh constrained position, within a particular radius
  67748. * @param position world position
  67749. * @param maxRadius the maximum distance to the constrained world position
  67750. * @param result output the closest point to position constrained by the navigation mesh
  67751. */
  67752. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67753. /**
  67754. * Compute the final position from a segment made of destination-position
  67755. * @param position world position
  67756. * @param destination world position
  67757. * @returns the resulting point along the navmesh
  67758. */
  67759. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67760. /**
  67761. * Compute the final position from a segment made of destination-position
  67762. * @param position world position
  67763. * @param destination world position
  67764. * @param result output the resulting point along the navmesh
  67765. */
  67766. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67767. /**
  67768. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67769. * @param start world position
  67770. * @param end world position
  67771. * @returns array containing world position composing the path
  67772. */
  67773. computePath(start: Vector3, end: Vector3): Vector3[];
  67774. /**
  67775. * Create a new Crowd so you can add agents
  67776. * @param maxAgents the maximum agent count in the crowd
  67777. * @param maxAgentRadius the maximum radius an agent can have
  67778. * @param scene to attach the crowd to
  67779. * @returns the crowd you can add agents to
  67780. */
  67781. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67782. /**
  67783. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67784. * The queries will try to find a solution within those bounds
  67785. * default is (1,1,1)
  67786. * @param extent x,y,z value that define the extent around the queries point of reference
  67787. */
  67788. setDefaultQueryExtent(extent: Vector3): void;
  67789. /**
  67790. * Get the Bounding box extent specified by setDefaultQueryExtent
  67791. * @returns the box extent values
  67792. */
  67793. getDefaultQueryExtent(): Vector3;
  67794. /**
  67795. * build the navmesh from a previously saved state using getNavmeshData
  67796. * @param data the Uint8Array returned by getNavmeshData
  67797. */
  67798. buildFromNavmeshData(data: Uint8Array): void;
  67799. /**
  67800. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67801. * @returns data the Uint8Array that can be saved and reused
  67802. */
  67803. getNavmeshData(): Uint8Array;
  67804. /**
  67805. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67806. * @param result output the box extent values
  67807. */
  67808. getDefaultQueryExtentToRef(result: Vector3): void;
  67809. /**
  67810. * Disposes
  67811. */
  67812. dispose(): void;
  67813. /**
  67814. * If this plugin is supported
  67815. * @returns true if plugin is supported
  67816. */
  67817. isSupported(): boolean;
  67818. }
  67819. /**
  67820. * Recast detour crowd implementation
  67821. */
  67822. export class RecastJSCrowd implements ICrowd {
  67823. /**
  67824. * Recast/detour plugin
  67825. */
  67826. bjsRECASTPlugin: RecastJSPlugin;
  67827. /**
  67828. * Link to the detour crowd
  67829. */
  67830. recastCrowd: any;
  67831. /**
  67832. * One transform per agent
  67833. */
  67834. transforms: TransformNode[];
  67835. /**
  67836. * All agents created
  67837. */
  67838. agents: number[];
  67839. /**
  67840. * Link to the scene is kept to unregister the crowd from the scene
  67841. */
  67842. private _scene;
  67843. /**
  67844. * Observer for crowd updates
  67845. */
  67846. private _onBeforeAnimationsObserver;
  67847. /**
  67848. * Constructor
  67849. * @param plugin recastJS plugin
  67850. * @param maxAgents the maximum agent count in the crowd
  67851. * @param maxAgentRadius the maximum radius an agent can have
  67852. * @param scene to attach the crowd to
  67853. * @returns the crowd you can add agents to
  67854. */
  67855. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67856. /**
  67857. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67858. * You can attach anything to that node. The node position is updated in the scene update tick.
  67859. * @param pos world position that will be constrained by the navigation mesh
  67860. * @param parameters agent parameters
  67861. * @param transform hooked to the agent that will be update by the scene
  67862. * @returns agent index
  67863. */
  67864. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67865. /**
  67866. * Returns the agent position in world space
  67867. * @param index agent index returned by addAgent
  67868. * @returns world space position
  67869. */
  67870. getAgentPosition(index: number): Vector3;
  67871. /**
  67872. * Returns the agent position result in world space
  67873. * @param index agent index returned by addAgent
  67874. * @param result output world space position
  67875. */
  67876. getAgentPositionToRef(index: number, result: Vector3): void;
  67877. /**
  67878. * Returns the agent velocity in world space
  67879. * @param index agent index returned by addAgent
  67880. * @returns world space velocity
  67881. */
  67882. getAgentVelocity(index: number): Vector3;
  67883. /**
  67884. * Returns the agent velocity result in world space
  67885. * @param index agent index returned by addAgent
  67886. * @param result output world space velocity
  67887. */
  67888. getAgentVelocityToRef(index: number, result: Vector3): void;
  67889. /**
  67890. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67891. * @param index agent index returned by addAgent
  67892. * @param destination targeted world position
  67893. */
  67894. agentGoto(index: number, destination: Vector3): void;
  67895. /**
  67896. * Teleport the agent to a new position
  67897. * @param index agent index returned by addAgent
  67898. * @param destination targeted world position
  67899. */
  67900. agentTeleport(index: number, destination: Vector3): void;
  67901. /**
  67902. * Update agent parameters
  67903. * @param index agent index returned by addAgent
  67904. * @param parameters agent parameters
  67905. */
  67906. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67907. /**
  67908. * remove a particular agent previously created
  67909. * @param index agent index returned by addAgent
  67910. */
  67911. removeAgent(index: number): void;
  67912. /**
  67913. * get the list of all agents attached to this crowd
  67914. * @returns list of agent indices
  67915. */
  67916. getAgents(): number[];
  67917. /**
  67918. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67919. * @param deltaTime in seconds
  67920. */
  67921. update(deltaTime: number): void;
  67922. /**
  67923. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67924. * The queries will try to find a solution within those bounds
  67925. * default is (1,1,1)
  67926. * @param extent x,y,z value that define the extent around the queries point of reference
  67927. */
  67928. setDefaultQueryExtent(extent: Vector3): void;
  67929. /**
  67930. * Get the Bounding box extent specified by setDefaultQueryExtent
  67931. * @returns the box extent values
  67932. */
  67933. getDefaultQueryExtent(): Vector3;
  67934. /**
  67935. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67936. * @param result output the box extent values
  67937. */
  67938. getDefaultQueryExtentToRef(result: Vector3): void;
  67939. /**
  67940. * Release all resources
  67941. */
  67942. dispose(): void;
  67943. }
  67944. }
  67945. declare module "babylonjs/Navigation/Plugins/index" {
  67946. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  67947. }
  67948. declare module "babylonjs/Navigation/index" {
  67949. export * from "babylonjs/Navigation/INavigationEngine";
  67950. export * from "babylonjs/Navigation/Plugins/index";
  67951. }
  67952. declare module "babylonjs/Offline/database" {
  67953. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  67954. /**
  67955. * Class used to enable access to IndexedDB
  67956. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67957. */
  67958. export class Database implements IOfflineProvider {
  67959. private _callbackManifestChecked;
  67960. private _currentSceneUrl;
  67961. private _db;
  67962. private _enableSceneOffline;
  67963. private _enableTexturesOffline;
  67964. private _manifestVersionFound;
  67965. private _mustUpdateRessources;
  67966. private _hasReachedQuota;
  67967. private _isSupported;
  67968. private _idbFactory;
  67969. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67970. private static IsUASupportingBlobStorage;
  67971. /**
  67972. * Gets a boolean indicating if Database storate is enabled (off by default)
  67973. */
  67974. static IDBStorageEnabled: boolean;
  67975. /**
  67976. * Gets a boolean indicating if scene must be saved in the database
  67977. */
  67978. get enableSceneOffline(): boolean;
  67979. /**
  67980. * Gets a boolean indicating if textures must be saved in the database
  67981. */
  67982. get enableTexturesOffline(): boolean;
  67983. /**
  67984. * Creates a new Database
  67985. * @param urlToScene defines the url to load the scene
  67986. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67987. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67988. */
  67989. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67990. private static _ParseURL;
  67991. private static _ReturnFullUrlLocation;
  67992. private _checkManifestFile;
  67993. /**
  67994. * Open the database and make it available
  67995. * @param successCallback defines the callback to call on success
  67996. * @param errorCallback defines the callback to call on error
  67997. */
  67998. open(successCallback: () => void, errorCallback: () => void): void;
  67999. /**
  68000. * Loads an image from the database
  68001. * @param url defines the url to load from
  68002. * @param image defines the target DOM image
  68003. */
  68004. loadImage(url: string, image: HTMLImageElement): void;
  68005. private _loadImageFromDBAsync;
  68006. private _saveImageIntoDBAsync;
  68007. private _checkVersionFromDB;
  68008. private _loadVersionFromDBAsync;
  68009. private _saveVersionIntoDBAsync;
  68010. /**
  68011. * Loads a file from database
  68012. * @param url defines the URL to load from
  68013. * @param sceneLoaded defines a callback to call on success
  68014. * @param progressCallBack defines a callback to call when progress changed
  68015. * @param errorCallback defines a callback to call on error
  68016. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68017. */
  68018. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68019. private _loadFileAsync;
  68020. private _saveFileAsync;
  68021. /**
  68022. * Validates if xhr data is correct
  68023. * @param xhr defines the request to validate
  68024. * @param dataType defines the expected data type
  68025. * @returns true if data is correct
  68026. */
  68027. private static _ValidateXHRData;
  68028. }
  68029. }
  68030. declare module "babylonjs/Offline/index" {
  68031. export * from "babylonjs/Offline/database";
  68032. export * from "babylonjs/Offline/IOfflineProvider";
  68033. }
  68034. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  68035. /** @hidden */
  68036. export var gpuUpdateParticlesPixelShader: {
  68037. name: string;
  68038. shader: string;
  68039. };
  68040. }
  68041. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  68042. /** @hidden */
  68043. export var gpuUpdateParticlesVertexShader: {
  68044. name: string;
  68045. shader: string;
  68046. };
  68047. }
  68048. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  68049. /** @hidden */
  68050. export var clipPlaneFragmentDeclaration2: {
  68051. name: string;
  68052. shader: string;
  68053. };
  68054. }
  68055. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  68056. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  68057. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  68058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68059. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  68060. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  68061. /** @hidden */
  68062. export var gpuRenderParticlesPixelShader: {
  68063. name: string;
  68064. shader: string;
  68065. };
  68066. }
  68067. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  68068. /** @hidden */
  68069. export var clipPlaneVertexDeclaration2: {
  68070. name: string;
  68071. shader: string;
  68072. };
  68073. }
  68074. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  68075. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  68076. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  68077. /** @hidden */
  68078. export var gpuRenderParticlesVertexShader: {
  68079. name: string;
  68080. shader: string;
  68081. };
  68082. }
  68083. declare module "babylonjs/Particles/gpuParticleSystem" {
  68084. import { Nullable } from "babylonjs/types";
  68085. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  68086. import { Observable } from "babylonjs/Misc/observable";
  68087. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68088. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68089. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  68090. import { Scene, IDisposable } from "babylonjs/scene";
  68091. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68092. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68093. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  68094. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  68095. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  68096. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  68097. /**
  68098. * This represents a GPU particle system in Babylon
  68099. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68100. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68101. */
  68102. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68103. /**
  68104. * The layer mask we are rendering the particles through.
  68105. */
  68106. layerMask: number;
  68107. private _capacity;
  68108. private _activeCount;
  68109. private _currentActiveCount;
  68110. private _accumulatedCount;
  68111. private _renderEffect;
  68112. private _updateEffect;
  68113. private _buffer0;
  68114. private _buffer1;
  68115. private _spriteBuffer;
  68116. private _updateVAO;
  68117. private _renderVAO;
  68118. private _targetIndex;
  68119. private _sourceBuffer;
  68120. private _targetBuffer;
  68121. private _engine;
  68122. private _currentRenderId;
  68123. private _started;
  68124. private _stopped;
  68125. private _timeDelta;
  68126. private _randomTexture;
  68127. private _randomTexture2;
  68128. private _attributesStrideSize;
  68129. private _updateEffectOptions;
  68130. private _randomTextureSize;
  68131. private _actualFrame;
  68132. private readonly _rawTextureWidth;
  68133. /**
  68134. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68135. */
  68136. static get IsSupported(): boolean;
  68137. /**
  68138. * An event triggered when the system is disposed.
  68139. */
  68140. onDisposeObservable: Observable<GPUParticleSystem>;
  68141. /**
  68142. * Gets the maximum number of particles active at the same time.
  68143. * @returns The max number of active particles.
  68144. */
  68145. getCapacity(): number;
  68146. /**
  68147. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68148. * to override the particles.
  68149. */
  68150. forceDepthWrite: boolean;
  68151. /**
  68152. * Gets or set the number of active particles
  68153. */
  68154. get activeParticleCount(): number;
  68155. set activeParticleCount(value: number);
  68156. private _preWarmDone;
  68157. /**
  68158. * Specifies if the particles are updated in emitter local space or world space.
  68159. */
  68160. isLocal: boolean;
  68161. /**
  68162. * Is this system ready to be used/rendered
  68163. * @return true if the system is ready
  68164. */
  68165. isReady(): boolean;
  68166. /**
  68167. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68168. * @returns True if it has been started, otherwise false.
  68169. */
  68170. isStarted(): boolean;
  68171. /**
  68172. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68173. * @returns True if it has been stopped, otherwise false.
  68174. */
  68175. isStopped(): boolean;
  68176. /**
  68177. * Gets a boolean indicating that the system is stopping
  68178. * @returns true if the system is currently stopping
  68179. */
  68180. isStopping(): boolean;
  68181. /**
  68182. * Gets the number of particles active at the same time.
  68183. * @returns The number of active particles.
  68184. */
  68185. getActiveCount(): number;
  68186. /**
  68187. * Starts the particle system and begins to emit
  68188. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68189. */
  68190. start(delay?: number): void;
  68191. /**
  68192. * Stops the particle system.
  68193. */
  68194. stop(): void;
  68195. /**
  68196. * Remove all active particles
  68197. */
  68198. reset(): void;
  68199. /**
  68200. * Returns the string "GPUParticleSystem"
  68201. * @returns a string containing the class name
  68202. */
  68203. getClassName(): string;
  68204. private _colorGradientsTexture;
  68205. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68206. /**
  68207. * Adds a new color gradient
  68208. * @param gradient defines the gradient to use (between 0 and 1)
  68209. * @param color1 defines the color to affect to the specified gradient
  68210. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68211. * @returns the current particle system
  68212. */
  68213. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68214. private _refreshColorGradient;
  68215. /** Force the system to rebuild all gradients that need to be resync */
  68216. forceRefreshGradients(): void;
  68217. /**
  68218. * Remove a specific color gradient
  68219. * @param gradient defines the gradient to remove
  68220. * @returns the current particle system
  68221. */
  68222. removeColorGradient(gradient: number): GPUParticleSystem;
  68223. private _angularSpeedGradientsTexture;
  68224. private _sizeGradientsTexture;
  68225. private _velocityGradientsTexture;
  68226. private _limitVelocityGradientsTexture;
  68227. private _dragGradientsTexture;
  68228. private _addFactorGradient;
  68229. /**
  68230. * Adds a new size gradient
  68231. * @param gradient defines the gradient to use (between 0 and 1)
  68232. * @param factor defines the size factor to affect to the specified gradient
  68233. * @returns the current particle system
  68234. */
  68235. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68236. /**
  68237. * Remove a specific size gradient
  68238. * @param gradient defines the gradient to remove
  68239. * @returns the current particle system
  68240. */
  68241. removeSizeGradient(gradient: number): GPUParticleSystem;
  68242. private _refreshFactorGradient;
  68243. /**
  68244. * Adds a new angular speed gradient
  68245. * @param gradient defines the gradient to use (between 0 and 1)
  68246. * @param factor defines the angular speed to affect to the specified gradient
  68247. * @returns the current particle system
  68248. */
  68249. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68250. /**
  68251. * Remove a specific angular speed gradient
  68252. * @param gradient defines the gradient to remove
  68253. * @returns the current particle system
  68254. */
  68255. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68256. /**
  68257. * Adds a new velocity gradient
  68258. * @param gradient defines the gradient to use (between 0 and 1)
  68259. * @param factor defines the velocity to affect to the specified gradient
  68260. * @returns the current particle system
  68261. */
  68262. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68263. /**
  68264. * Remove a specific velocity gradient
  68265. * @param gradient defines the gradient to remove
  68266. * @returns the current particle system
  68267. */
  68268. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68269. /**
  68270. * Adds a new limit velocity gradient
  68271. * @param gradient defines the gradient to use (between 0 and 1)
  68272. * @param factor defines the limit velocity value to affect to the specified gradient
  68273. * @returns the current particle system
  68274. */
  68275. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68276. /**
  68277. * Remove a specific limit velocity gradient
  68278. * @param gradient defines the gradient to remove
  68279. * @returns the current particle system
  68280. */
  68281. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68282. /**
  68283. * Adds a new drag gradient
  68284. * @param gradient defines the gradient to use (between 0 and 1)
  68285. * @param factor defines the drag value to affect to the specified gradient
  68286. * @returns the current particle system
  68287. */
  68288. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68289. /**
  68290. * Remove a specific drag gradient
  68291. * @param gradient defines the gradient to remove
  68292. * @returns the current particle system
  68293. */
  68294. removeDragGradient(gradient: number): GPUParticleSystem;
  68295. /**
  68296. * Not supported by GPUParticleSystem
  68297. * @param gradient defines the gradient to use (between 0 and 1)
  68298. * @param factor defines the emit rate value to affect to the specified gradient
  68299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68300. * @returns the current particle system
  68301. */
  68302. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68303. /**
  68304. * Not supported by GPUParticleSystem
  68305. * @param gradient defines the gradient to remove
  68306. * @returns the current particle system
  68307. */
  68308. removeEmitRateGradient(gradient: number): IParticleSystem;
  68309. /**
  68310. * Not supported by GPUParticleSystem
  68311. * @param gradient defines the gradient to use (between 0 and 1)
  68312. * @param factor defines the start size value to affect to the specified gradient
  68313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68314. * @returns the current particle system
  68315. */
  68316. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68317. /**
  68318. * Not supported by GPUParticleSystem
  68319. * @param gradient defines the gradient to remove
  68320. * @returns the current particle system
  68321. */
  68322. removeStartSizeGradient(gradient: number): IParticleSystem;
  68323. /**
  68324. * Not supported by GPUParticleSystem
  68325. * @param gradient defines the gradient to use (between 0 and 1)
  68326. * @param min defines the color remap minimal range
  68327. * @param max defines the color remap maximal range
  68328. * @returns the current particle system
  68329. */
  68330. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68331. /**
  68332. * Not supported by GPUParticleSystem
  68333. * @param gradient defines the gradient to remove
  68334. * @returns the current particle system
  68335. */
  68336. removeColorRemapGradient(): IParticleSystem;
  68337. /**
  68338. * Not supported by GPUParticleSystem
  68339. * @param gradient defines the gradient to use (between 0 and 1)
  68340. * @param min defines the alpha remap minimal range
  68341. * @param max defines the alpha remap maximal range
  68342. * @returns the current particle system
  68343. */
  68344. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68345. /**
  68346. * Not supported by GPUParticleSystem
  68347. * @param gradient defines the gradient to remove
  68348. * @returns the current particle system
  68349. */
  68350. removeAlphaRemapGradient(): IParticleSystem;
  68351. /**
  68352. * Not supported by GPUParticleSystem
  68353. * @param gradient defines the gradient to use (between 0 and 1)
  68354. * @param color defines the color to affect to the specified gradient
  68355. * @returns the current particle system
  68356. */
  68357. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68358. /**
  68359. * Not supported by GPUParticleSystem
  68360. * @param gradient defines the gradient to remove
  68361. * @returns the current particle system
  68362. */
  68363. removeRampGradient(): IParticleSystem;
  68364. /**
  68365. * Not supported by GPUParticleSystem
  68366. * @returns the list of ramp gradients
  68367. */
  68368. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68369. /**
  68370. * Not supported by GPUParticleSystem
  68371. * Gets or sets a boolean indicating that ramp gradients must be used
  68372. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68373. */
  68374. get useRampGradients(): boolean;
  68375. set useRampGradients(value: boolean);
  68376. /**
  68377. * Not supported by GPUParticleSystem
  68378. * @param gradient defines the gradient to use (between 0 and 1)
  68379. * @param factor defines the life time factor to affect to the specified gradient
  68380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68381. * @returns the current particle system
  68382. */
  68383. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68384. /**
  68385. * Not supported by GPUParticleSystem
  68386. * @param gradient defines the gradient to remove
  68387. * @returns the current particle system
  68388. */
  68389. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68390. /**
  68391. * Instantiates a GPU particle system.
  68392. * 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.
  68393. * @param name The name of the particle system
  68394. * @param options The options used to create the system
  68395. * @param scene The scene the particle system belongs to
  68396. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68397. */
  68398. constructor(name: string, options: Partial<{
  68399. capacity: number;
  68400. randomTextureSize: number;
  68401. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  68402. protected _reset(): void;
  68403. private _createUpdateVAO;
  68404. private _createRenderVAO;
  68405. private _initialize;
  68406. /** @hidden */
  68407. _recreateUpdateEffect(): void;
  68408. /** @hidden */
  68409. _recreateRenderEffect(): void;
  68410. /**
  68411. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68412. * @param preWarm defines if we are in the pre-warmimg phase
  68413. */
  68414. animate(preWarm?: boolean): void;
  68415. private _createFactorGradientTexture;
  68416. private _createSizeGradientTexture;
  68417. private _createAngularSpeedGradientTexture;
  68418. private _createVelocityGradientTexture;
  68419. private _createLimitVelocityGradientTexture;
  68420. private _createDragGradientTexture;
  68421. private _createColorGradientTexture;
  68422. /**
  68423. * Renders the particle system in its current state
  68424. * @param preWarm defines if the system should only update the particles but not render them
  68425. * @returns the current number of particles
  68426. */
  68427. render(preWarm?: boolean): number;
  68428. /**
  68429. * Rebuilds the particle system
  68430. */
  68431. rebuild(): void;
  68432. private _releaseBuffers;
  68433. private _releaseVAOs;
  68434. /**
  68435. * Disposes the particle system and free the associated resources
  68436. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68437. */
  68438. dispose(disposeTexture?: boolean): void;
  68439. /**
  68440. * Clones the particle system.
  68441. * @param name The name of the cloned object
  68442. * @param newEmitter The new emitter to use
  68443. * @returns the cloned particle system
  68444. */
  68445. clone(name: string, newEmitter: any): GPUParticleSystem;
  68446. /**
  68447. * Serializes the particle system to a JSON object
  68448. * @param serializeTexture defines if the texture must be serialized as well
  68449. * @returns the JSON object
  68450. */
  68451. serialize(serializeTexture?: boolean): any;
  68452. /**
  68453. * Parses a JSON object to create a GPU particle system.
  68454. * @param parsedParticleSystem The JSON object to parse
  68455. * @param scene The scene to create the particle system in
  68456. * @param rootUrl The root url to use to load external dependencies like texture
  68457. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68458. * @returns the parsed GPU particle system
  68459. */
  68460. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68461. }
  68462. }
  68463. declare module "babylonjs/Particles/particleSystemSet" {
  68464. import { Nullable } from "babylonjs/types";
  68465. import { Color3 } from "babylonjs/Maths/math.color";
  68466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68468. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68469. import { Scene, IDisposable } from "babylonjs/scene";
  68470. /**
  68471. * Represents a set of particle systems working together to create a specific effect
  68472. */
  68473. export class ParticleSystemSet implements IDisposable {
  68474. /**
  68475. * Gets or sets base Assets URL
  68476. */
  68477. static BaseAssetsUrl: string;
  68478. private _emitterCreationOptions;
  68479. private _emitterNode;
  68480. /**
  68481. * Gets the particle system list
  68482. */
  68483. systems: IParticleSystem[];
  68484. /**
  68485. * Gets the emitter node used with this set
  68486. */
  68487. get emitterNode(): Nullable<TransformNode>;
  68488. /**
  68489. * Creates a new emitter mesh as a sphere
  68490. * @param options defines the options used to create the sphere
  68491. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68492. * @param scene defines the hosting scene
  68493. */
  68494. setEmitterAsSphere(options: {
  68495. diameter: number;
  68496. segments: number;
  68497. color: Color3;
  68498. }, renderingGroupId: number, scene: Scene): void;
  68499. /**
  68500. * Starts all particle systems of the set
  68501. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68502. */
  68503. start(emitter?: AbstractMesh): void;
  68504. /**
  68505. * Release all associated resources
  68506. */
  68507. dispose(): void;
  68508. /**
  68509. * Serialize the set into a JSON compatible object
  68510. * @param serializeTexture defines if the texture must be serialized as well
  68511. * @returns a JSON compatible representation of the set
  68512. */
  68513. serialize(serializeTexture?: boolean): any;
  68514. /**
  68515. * Parse a new ParticleSystemSet from a serialized source
  68516. * @param data defines a JSON compatible representation of the set
  68517. * @param scene defines the hosting scene
  68518. * @param gpu defines if we want GPU particles or CPU particles
  68519. * @returns a new ParticleSystemSet
  68520. */
  68521. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68522. }
  68523. }
  68524. declare module "babylonjs/Particles/particleHelper" {
  68525. import { Nullable } from "babylonjs/types";
  68526. import { Scene } from "babylonjs/scene";
  68527. import { Vector3 } from "babylonjs/Maths/math.vector";
  68528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68529. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68530. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  68531. /**
  68532. * This class is made for on one-liner static method to help creating particle system set.
  68533. */
  68534. export class ParticleHelper {
  68535. /**
  68536. * Gets or sets base Assets URL
  68537. */
  68538. static BaseAssetsUrl: string;
  68539. /** Define the Url to load snippets */
  68540. static SnippetUrl: string;
  68541. /**
  68542. * Create a default particle system that you can tweak
  68543. * @param emitter defines the emitter to use
  68544. * @param capacity defines the system capacity (default is 500 particles)
  68545. * @param scene defines the hosting scene
  68546. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68547. * @returns the new Particle system
  68548. */
  68549. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68550. /**
  68551. * This is the main static method (one-liner) of this helper to create different particle systems
  68552. * @param type This string represents the type to the particle system to create
  68553. * @param scene The scene where the particle system should live
  68554. * @param gpu If the system will use gpu
  68555. * @returns the ParticleSystemSet created
  68556. */
  68557. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68558. /**
  68559. * Static function used to export a particle system to a ParticleSystemSet variable.
  68560. * Please note that the emitter shape is not exported
  68561. * @param systems defines the particle systems to export
  68562. * @returns the created particle system set
  68563. */
  68564. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68565. /**
  68566. * Creates a particle system from a snippet saved in a remote file
  68567. * @param name defines the name of the particle system to create
  68568. * @param url defines the url to load from
  68569. * @param scene defines the hosting scene
  68570. * @param gpu If the system will use gpu
  68571. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68572. * @returns a promise that will resolve to the new particle system
  68573. */
  68574. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68575. /**
  68576. * Creates a particle system from a snippet saved by the particle system editor
  68577. * @param snippetId defines the snippet to load
  68578. * @param scene defines the hosting scene
  68579. * @param gpu If the system will use gpu
  68580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68581. * @returns a promise that will resolve to the new particle system
  68582. */
  68583. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68584. }
  68585. }
  68586. declare module "babylonjs/Particles/particleSystemComponent" {
  68587. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68588. import { Effect } from "babylonjs/Materials/effect";
  68589. import "babylonjs/Shaders/particles.vertex";
  68590. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  68591. module "babylonjs/Engines/engine" {
  68592. interface Engine {
  68593. /**
  68594. * Create an effect to use with particle systems.
  68595. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  68596. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68597. * @param uniformsNames defines a list of attribute names
  68598. * @param samplers defines an array of string used to represent textures
  68599. * @param defines defines the string containing the defines to use to compile the shaders
  68600. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68601. * @param onCompiled defines a function to call when the effect creation is successful
  68602. * @param onError defines a function to call when the effect creation has failed
  68603. * @returns the new Effect
  68604. */
  68605. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  68606. }
  68607. }
  68608. module "babylonjs/Meshes/mesh" {
  68609. interface Mesh {
  68610. /**
  68611. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68612. * @returns an array of IParticleSystem
  68613. */
  68614. getEmittedParticleSystems(): IParticleSystem[];
  68615. /**
  68616. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68617. * @returns an array of IParticleSystem
  68618. */
  68619. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68620. }
  68621. }
  68622. /**
  68623. * @hidden
  68624. */
  68625. export var _IDoNeedToBeInTheBuild: number;
  68626. }
  68627. declare module "babylonjs/Particles/pointsCloudSystem" {
  68628. import { Color4 } from "babylonjs/Maths/math";
  68629. import { Mesh } from "babylonjs/Meshes/mesh";
  68630. import { Scene, IDisposable } from "babylonjs/scene";
  68631. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  68632. /** Defines the 4 color options */
  68633. export enum PointColor {
  68634. /** color value */
  68635. Color = 2,
  68636. /** uv value */
  68637. UV = 1,
  68638. /** random value */
  68639. Random = 0,
  68640. /** stated value */
  68641. Stated = 3
  68642. }
  68643. /**
  68644. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68645. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  68646. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68647. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68648. *
  68649. * Full documentation here : TO BE ENTERED
  68650. */
  68651. export class PointsCloudSystem implements IDisposable {
  68652. /**
  68653. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68654. * Example : var p = SPS.particles[i];
  68655. */
  68656. particles: CloudPoint[];
  68657. /**
  68658. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68659. */
  68660. nbParticles: number;
  68661. /**
  68662. * This a counter for your own usage. It's not set by any SPS functions.
  68663. */
  68664. counter: number;
  68665. /**
  68666. * The PCS name. This name is also given to the underlying mesh.
  68667. */
  68668. name: string;
  68669. /**
  68670. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68671. */
  68672. mesh: Mesh;
  68673. /**
  68674. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68675. * Please read :
  68676. */
  68677. vars: any;
  68678. /**
  68679. * @hidden
  68680. */
  68681. _size: number;
  68682. private _scene;
  68683. private _promises;
  68684. private _positions;
  68685. private _indices;
  68686. private _normals;
  68687. private _colors;
  68688. private _uvs;
  68689. private _indices32;
  68690. private _positions32;
  68691. private _colors32;
  68692. private _uvs32;
  68693. private _updatable;
  68694. private _isVisibilityBoxLocked;
  68695. private _alwaysVisible;
  68696. private _groups;
  68697. private _groupCounter;
  68698. private _computeParticleColor;
  68699. private _computeParticleTexture;
  68700. private _computeParticleRotation;
  68701. private _computeBoundingBox;
  68702. private _isReady;
  68703. /**
  68704. * Creates a PCS (Points Cloud System) object
  68705. * @param name (String) is the PCS name, this will be the underlying mesh name
  68706. * @param pointSize (number) is the size for each point
  68707. * @param scene (Scene) is the scene in which the PCS is added
  68708. * @param options defines the options of the PCS e.g.
  68709. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68710. */
  68711. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68712. updatable?: boolean;
  68713. });
  68714. /**
  68715. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68716. * If no points were added to the PCS, the returned mesh is just a single point.
  68717. * @returns a promise for the created mesh
  68718. */
  68719. buildMeshAsync(): Promise<Mesh>;
  68720. /**
  68721. * @hidden
  68722. */
  68723. private _buildMesh;
  68724. private _addParticle;
  68725. private _randomUnitVector;
  68726. private _getColorIndicesForCoord;
  68727. private _setPointsColorOrUV;
  68728. private _colorFromTexture;
  68729. private _calculateDensity;
  68730. /**
  68731. * Adds points to the PCS in random positions within a unit sphere
  68732. * @param nb (positive integer) the number of particles to be created from this model
  68733. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68734. * @returns the number of groups in the system
  68735. */
  68736. addPoints(nb: number, pointFunction?: any): number;
  68737. /**
  68738. * Adds points to the PCS from the surface of the model shape
  68739. * @param mesh is any Mesh object that will be used as a surface model for the points
  68740. * @param nb (positive integer) the number of particles to be created from this model
  68741. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68742. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68743. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68744. * @returns the number of groups in the system
  68745. */
  68746. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68747. /**
  68748. * Adds points to the PCS inside the model shape
  68749. * @param mesh is any Mesh object that will be used as a surface model for the points
  68750. * @param nb (positive integer) the number of particles to be created from this model
  68751. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68752. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68753. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68754. * @returns the number of groups in the system
  68755. */
  68756. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68757. /**
  68758. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68759. * This method calls `updateParticle()` for each particle of the SPS.
  68760. * For an animated SPS, it is usually called within the render loop.
  68761. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68762. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68763. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68764. * @returns the PCS.
  68765. */
  68766. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68767. /**
  68768. * Disposes the PCS.
  68769. */
  68770. dispose(): void;
  68771. /**
  68772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68773. * doc :
  68774. * @returns the PCS.
  68775. */
  68776. refreshVisibleSize(): PointsCloudSystem;
  68777. /**
  68778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68779. * @param size the size (float) of the visibility box
  68780. * note : this doesn't lock the PCS mesh bounding box.
  68781. * doc :
  68782. */
  68783. setVisibilityBox(size: number): void;
  68784. /**
  68785. * Gets whether the PCS is always visible or not
  68786. * doc :
  68787. */
  68788. get isAlwaysVisible(): boolean;
  68789. /**
  68790. * Sets the PCS as always visible or not
  68791. * doc :
  68792. */
  68793. set isAlwaysVisible(val: boolean);
  68794. /**
  68795. * Tells to `setParticles()` to compute the particle rotations or not
  68796. * Default value : false. The PCS is faster when it's set to false
  68797. * Note : particle rotations are only applied to parent particles
  68798. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68799. */
  68800. set computeParticleRotation(val: boolean);
  68801. /**
  68802. * Tells to `setParticles()` to compute the particle colors or not.
  68803. * Default value : true. The PCS is faster when it's set to false.
  68804. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68805. */
  68806. set computeParticleColor(val: boolean);
  68807. set computeParticleTexture(val: boolean);
  68808. /**
  68809. * Gets if `setParticles()` computes the particle colors or not.
  68810. * Default value : false. The PCS is faster when it's set to false.
  68811. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68812. */
  68813. get computeParticleColor(): boolean;
  68814. /**
  68815. * Gets if `setParticles()` computes the particle textures or not.
  68816. * Default value : false. The PCS is faster when it's set to false.
  68817. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68818. */
  68819. get computeParticleTexture(): boolean;
  68820. /**
  68821. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68822. */
  68823. set computeBoundingBox(val: boolean);
  68824. /**
  68825. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68826. */
  68827. get computeBoundingBox(): boolean;
  68828. /**
  68829. * This function does nothing. It may be overwritten to set all the particle first values.
  68830. * The PCS doesn't call this function, you may have to call it by your own.
  68831. * doc :
  68832. */
  68833. initParticles(): void;
  68834. /**
  68835. * This function does nothing. It may be overwritten to recycle a particle
  68836. * The PCS doesn't call this function, you can to call it
  68837. * doc :
  68838. * @param particle The particle to recycle
  68839. * @returns the recycled particle
  68840. */
  68841. recycleParticle(particle: CloudPoint): CloudPoint;
  68842. /**
  68843. * Updates a particle : this function should be overwritten by the user.
  68844. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68845. * doc :
  68846. * @example : just set a particle position or velocity and recycle conditions
  68847. * @param particle The particle to update
  68848. * @returns the updated particle
  68849. */
  68850. updateParticle(particle: CloudPoint): CloudPoint;
  68851. /**
  68852. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68853. * This does nothing and may be overwritten by the user.
  68854. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68855. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68856. * @param update the boolean update value actually passed to setParticles()
  68857. */
  68858. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68859. /**
  68860. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68861. * This will be passed three parameters.
  68862. * This does nothing and may be overwritten by the user.
  68863. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68864. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68865. * @param update the boolean update value actually passed to setParticles()
  68866. */
  68867. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68868. }
  68869. }
  68870. declare module "babylonjs/Particles/cloudPoint" {
  68871. import { Nullable } from "babylonjs/types";
  68872. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  68873. import { Mesh } from "babylonjs/Meshes/mesh";
  68874. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  68875. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  68876. /**
  68877. * Represents one particle of a points cloud system.
  68878. */
  68879. export class CloudPoint {
  68880. /**
  68881. * particle global index
  68882. */
  68883. idx: number;
  68884. /**
  68885. * The color of the particle
  68886. */
  68887. color: Nullable<Color4>;
  68888. /**
  68889. * The world space position of the particle.
  68890. */
  68891. position: Vector3;
  68892. /**
  68893. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68894. */
  68895. rotation: Vector3;
  68896. /**
  68897. * The world space rotation quaternion of the particle.
  68898. */
  68899. rotationQuaternion: Nullable<Quaternion>;
  68900. /**
  68901. * The uv of the particle.
  68902. */
  68903. uv: Nullable<Vector2>;
  68904. /**
  68905. * The current speed of the particle.
  68906. */
  68907. velocity: Vector3;
  68908. /**
  68909. * The pivot point in the particle local space.
  68910. */
  68911. pivot: Vector3;
  68912. /**
  68913. * Must the particle be translated from its pivot point in its local space ?
  68914. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68915. * Default : false
  68916. */
  68917. translateFromPivot: boolean;
  68918. /**
  68919. * Index of this particle in the global "positions" array (Internal use)
  68920. * @hidden
  68921. */
  68922. _pos: number;
  68923. /**
  68924. * @hidden Index of this particle in the global "indices" array (Internal use)
  68925. */
  68926. _ind: number;
  68927. /**
  68928. * Group this particle belongs to
  68929. */
  68930. _group: PointsGroup;
  68931. /**
  68932. * Group id of this particle
  68933. */
  68934. groupId: number;
  68935. /**
  68936. * Index of the particle in its group id (Internal use)
  68937. */
  68938. idxInGroup: number;
  68939. /**
  68940. * @hidden Particle BoundingInfo object (Internal use)
  68941. */
  68942. _boundingInfo: BoundingInfo;
  68943. /**
  68944. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68945. */
  68946. _pcs: PointsCloudSystem;
  68947. /**
  68948. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68949. */
  68950. _stillInvisible: boolean;
  68951. /**
  68952. * @hidden Last computed particle rotation matrix
  68953. */
  68954. _rotationMatrix: number[];
  68955. /**
  68956. * Parent particle Id, if any.
  68957. * Default null.
  68958. */
  68959. parentId: Nullable<number>;
  68960. /**
  68961. * @hidden Internal global position in the PCS.
  68962. */
  68963. _globalPosition: Vector3;
  68964. /**
  68965. * Creates a Point Cloud object.
  68966. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68967. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68968. * @param group (PointsGroup) is the group the particle belongs to
  68969. * @param groupId (integer) is the group identifier in the PCS.
  68970. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68971. * @param pcs defines the PCS it is associated to
  68972. */
  68973. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68974. /**
  68975. * get point size
  68976. */
  68977. get size(): Vector3;
  68978. /**
  68979. * Set point size
  68980. */
  68981. set size(scale: Vector3);
  68982. /**
  68983. * Legacy support, changed quaternion to rotationQuaternion
  68984. */
  68985. get quaternion(): Nullable<Quaternion>;
  68986. /**
  68987. * Legacy support, changed quaternion to rotationQuaternion
  68988. */
  68989. set quaternion(q: Nullable<Quaternion>);
  68990. /**
  68991. * Returns a boolean. True if the particle intersects a mesh, else false
  68992. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68993. * @param target is the object (point or mesh) what the intersection is computed against
  68994. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68995. * @returns true if it intersects
  68996. */
  68997. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68998. /**
  68999. * get the rotation matrix of the particle
  69000. * @hidden
  69001. */
  69002. getRotationMatrix(m: Matrix): void;
  69003. }
  69004. /**
  69005. * Represents a group of points in a points cloud system
  69006. * * PCS internal tool, don't use it manually.
  69007. */
  69008. export class PointsGroup {
  69009. /**
  69010. * The group id
  69011. * @hidden
  69012. */
  69013. groupID: number;
  69014. /**
  69015. * image data for group (internal use)
  69016. * @hidden
  69017. */
  69018. _groupImageData: Nullable<ArrayBufferView>;
  69019. /**
  69020. * Image Width (internal use)
  69021. * @hidden
  69022. */
  69023. _groupImgWidth: number;
  69024. /**
  69025. * Image Height (internal use)
  69026. * @hidden
  69027. */
  69028. _groupImgHeight: number;
  69029. /**
  69030. * Custom position function (internal use)
  69031. * @hidden
  69032. */
  69033. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69034. /**
  69035. * density per facet for surface points
  69036. * @hidden
  69037. */
  69038. _groupDensity: number[];
  69039. /**
  69040. * Only when points are colored by texture carries pointer to texture list array
  69041. * @hidden
  69042. */
  69043. _textureNb: number;
  69044. /**
  69045. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69046. * PCS internal tool, don't use it manually.
  69047. * @hidden
  69048. */
  69049. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69050. }
  69051. }
  69052. declare module "babylonjs/Particles/index" {
  69053. export * from "babylonjs/Particles/baseParticleSystem";
  69054. export * from "babylonjs/Particles/EmitterTypes/index";
  69055. export * from "babylonjs/Particles/gpuParticleSystem";
  69056. export * from "babylonjs/Particles/IParticleSystem";
  69057. export * from "babylonjs/Particles/particle";
  69058. export * from "babylonjs/Particles/particleHelper";
  69059. export * from "babylonjs/Particles/particleSystem";
  69060. export * from "babylonjs/Particles/particleSystemComponent";
  69061. export * from "babylonjs/Particles/particleSystemSet";
  69062. export * from "babylonjs/Particles/solidParticle";
  69063. export * from "babylonjs/Particles/solidParticleSystem";
  69064. export * from "babylonjs/Particles/cloudPoint";
  69065. export * from "babylonjs/Particles/pointsCloudSystem";
  69066. export * from "babylonjs/Particles/subEmitter";
  69067. }
  69068. declare module "babylonjs/Physics/physicsEngineComponent" {
  69069. import { Nullable } from "babylonjs/types";
  69070. import { Observable, Observer } from "babylonjs/Misc/observable";
  69071. import { Vector3 } from "babylonjs/Maths/math.vector";
  69072. import { Mesh } from "babylonjs/Meshes/mesh";
  69073. import { ISceneComponent } from "babylonjs/sceneComponent";
  69074. import { Scene } from "babylonjs/scene";
  69075. import { Node } from "babylonjs/node";
  69076. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  69077. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69078. module "babylonjs/scene" {
  69079. interface Scene {
  69080. /** @hidden (Backing field) */
  69081. _physicsEngine: Nullable<IPhysicsEngine>;
  69082. /** @hidden */
  69083. _physicsTimeAccumulator: number;
  69084. /**
  69085. * Gets the current physics engine
  69086. * @returns a IPhysicsEngine or null if none attached
  69087. */
  69088. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69089. /**
  69090. * Enables physics to the current scene
  69091. * @param gravity defines the scene's gravity for the physics engine
  69092. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69093. * @return a boolean indicating if the physics engine was initialized
  69094. */
  69095. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69096. /**
  69097. * Disables and disposes the physics engine associated with the scene
  69098. */
  69099. disablePhysicsEngine(): void;
  69100. /**
  69101. * Gets a boolean indicating if there is an active physics engine
  69102. * @returns a boolean indicating if there is an active physics engine
  69103. */
  69104. isPhysicsEnabled(): boolean;
  69105. /**
  69106. * Deletes a physics compound impostor
  69107. * @param compound defines the compound to delete
  69108. */
  69109. deleteCompoundImpostor(compound: any): void;
  69110. /**
  69111. * An event triggered when physic simulation is about to be run
  69112. */
  69113. onBeforePhysicsObservable: Observable<Scene>;
  69114. /**
  69115. * An event triggered when physic simulation has been done
  69116. */
  69117. onAfterPhysicsObservable: Observable<Scene>;
  69118. }
  69119. }
  69120. module "babylonjs/Meshes/abstractMesh" {
  69121. interface AbstractMesh {
  69122. /** @hidden */
  69123. _physicsImpostor: Nullable<PhysicsImpostor>;
  69124. /**
  69125. * Gets or sets impostor used for physic simulation
  69126. * @see http://doc.babylonjs.com/features/physics_engine
  69127. */
  69128. physicsImpostor: Nullable<PhysicsImpostor>;
  69129. /**
  69130. * Gets the current physics impostor
  69131. * @see http://doc.babylonjs.com/features/physics_engine
  69132. * @returns a physics impostor or null
  69133. */
  69134. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69135. /** Apply a physic impulse to the mesh
  69136. * @param force defines the force to apply
  69137. * @param contactPoint defines where to apply the force
  69138. * @returns the current mesh
  69139. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  69140. */
  69141. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69142. /**
  69143. * Creates a physic joint between two meshes
  69144. * @param otherMesh defines the other mesh to use
  69145. * @param pivot1 defines the pivot to use on this mesh
  69146. * @param pivot2 defines the pivot to use on the other mesh
  69147. * @param options defines additional options (can be plugin dependent)
  69148. * @returns the current mesh
  69149. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69150. */
  69151. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69152. /** @hidden */
  69153. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69154. }
  69155. }
  69156. /**
  69157. * Defines the physics engine scene component responsible to manage a physics engine
  69158. */
  69159. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69160. /**
  69161. * The component name helpful to identify the component in the list of scene components.
  69162. */
  69163. readonly name: string;
  69164. /**
  69165. * The scene the component belongs to.
  69166. */
  69167. scene: Scene;
  69168. /**
  69169. * Creates a new instance of the component for the given scene
  69170. * @param scene Defines the scene to register the component in
  69171. */
  69172. constructor(scene: Scene);
  69173. /**
  69174. * Registers the component in a given scene
  69175. */
  69176. register(): void;
  69177. /**
  69178. * Rebuilds the elements related to this component in case of
  69179. * context lost for instance.
  69180. */
  69181. rebuild(): void;
  69182. /**
  69183. * Disposes the component and the associated ressources
  69184. */
  69185. dispose(): void;
  69186. }
  69187. }
  69188. declare module "babylonjs/Physics/physicsHelper" {
  69189. import { Nullable } from "babylonjs/types";
  69190. import { Vector3 } from "babylonjs/Maths/math.vector";
  69191. import { Mesh } from "babylonjs/Meshes/mesh";
  69192. import { Scene } from "babylonjs/scene";
  69193. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69194. /**
  69195. * A helper for physics simulations
  69196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69197. */
  69198. export class PhysicsHelper {
  69199. private _scene;
  69200. private _physicsEngine;
  69201. /**
  69202. * Initializes the Physics helper
  69203. * @param scene Babylon.js scene
  69204. */
  69205. constructor(scene: Scene);
  69206. /**
  69207. * Applies a radial explosion impulse
  69208. * @param origin the origin of the explosion
  69209. * @param radiusOrEventOptions the radius or the options of radial explosion
  69210. * @param strength the explosion strength
  69211. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69212. * @returns A physics radial explosion event, or null
  69213. */
  69214. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69215. /**
  69216. * Applies a radial explosion force
  69217. * @param origin the origin of the explosion
  69218. * @param radiusOrEventOptions the radius or the options of radial explosion
  69219. * @param strength the explosion strength
  69220. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69221. * @returns A physics radial explosion event, or null
  69222. */
  69223. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69224. /**
  69225. * Creates a gravitational field
  69226. * @param origin the origin of the explosion
  69227. * @param radiusOrEventOptions the radius or the options of radial explosion
  69228. * @param strength the explosion strength
  69229. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69230. * @returns A physics gravitational field event, or null
  69231. */
  69232. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69233. /**
  69234. * Creates a physics updraft event
  69235. * @param origin the origin of the updraft
  69236. * @param radiusOrEventOptions the radius or the options of the updraft
  69237. * @param strength the strength of the updraft
  69238. * @param height the height of the updraft
  69239. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69240. * @returns A physics updraft event, or null
  69241. */
  69242. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69243. /**
  69244. * Creates a physics vortex event
  69245. * @param origin the of the vortex
  69246. * @param radiusOrEventOptions the radius or the options of the vortex
  69247. * @param strength the strength of the vortex
  69248. * @param height the height of the vortex
  69249. * @returns a Physics vortex event, or null
  69250. * A physics vortex event or null
  69251. */
  69252. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69253. }
  69254. /**
  69255. * Represents a physics radial explosion event
  69256. */
  69257. class PhysicsRadialExplosionEvent {
  69258. private _scene;
  69259. private _options;
  69260. private _sphere;
  69261. private _dataFetched;
  69262. /**
  69263. * Initializes a radial explosioin event
  69264. * @param _scene BabylonJS scene
  69265. * @param _options The options for the vortex event
  69266. */
  69267. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69268. /**
  69269. * Returns the data related to the radial explosion event (sphere).
  69270. * @returns The radial explosion event data
  69271. */
  69272. getData(): PhysicsRadialExplosionEventData;
  69273. /**
  69274. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69275. * @param impostor A physics imposter
  69276. * @param origin the origin of the explosion
  69277. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69278. */
  69279. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69280. /**
  69281. * Triggers affecterd impostors callbacks
  69282. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69283. */
  69284. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69285. /**
  69286. * Disposes the sphere.
  69287. * @param force Specifies if the sphere should be disposed by force
  69288. */
  69289. dispose(force?: boolean): void;
  69290. /*** Helpers ***/
  69291. private _prepareSphere;
  69292. private _intersectsWithSphere;
  69293. }
  69294. /**
  69295. * Represents a gravitational field event
  69296. */
  69297. class PhysicsGravitationalFieldEvent {
  69298. private _physicsHelper;
  69299. private _scene;
  69300. private _origin;
  69301. private _options;
  69302. private _tickCallback;
  69303. private _sphere;
  69304. private _dataFetched;
  69305. /**
  69306. * Initializes the physics gravitational field event
  69307. * @param _physicsHelper A physics helper
  69308. * @param _scene BabylonJS scene
  69309. * @param _origin The origin position of the gravitational field event
  69310. * @param _options The options for the vortex event
  69311. */
  69312. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69313. /**
  69314. * Returns the data related to the gravitational field event (sphere).
  69315. * @returns A gravitational field event
  69316. */
  69317. getData(): PhysicsGravitationalFieldEventData;
  69318. /**
  69319. * Enables the gravitational field.
  69320. */
  69321. enable(): void;
  69322. /**
  69323. * Disables the gravitational field.
  69324. */
  69325. disable(): void;
  69326. /**
  69327. * Disposes the sphere.
  69328. * @param force The force to dispose from the gravitational field event
  69329. */
  69330. dispose(force?: boolean): void;
  69331. private _tick;
  69332. }
  69333. /**
  69334. * Represents a physics updraft event
  69335. */
  69336. class PhysicsUpdraftEvent {
  69337. private _scene;
  69338. private _origin;
  69339. private _options;
  69340. private _physicsEngine;
  69341. private _originTop;
  69342. private _originDirection;
  69343. private _tickCallback;
  69344. private _cylinder;
  69345. private _cylinderPosition;
  69346. private _dataFetched;
  69347. /**
  69348. * Initializes the physics updraft event
  69349. * @param _scene BabylonJS scene
  69350. * @param _origin The origin position of the updraft
  69351. * @param _options The options for the updraft event
  69352. */
  69353. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69354. /**
  69355. * Returns the data related to the updraft event (cylinder).
  69356. * @returns A physics updraft event
  69357. */
  69358. getData(): PhysicsUpdraftEventData;
  69359. /**
  69360. * Enables the updraft.
  69361. */
  69362. enable(): void;
  69363. /**
  69364. * Disables the updraft.
  69365. */
  69366. disable(): void;
  69367. /**
  69368. * Disposes the cylinder.
  69369. * @param force Specifies if the updraft should be disposed by force
  69370. */
  69371. dispose(force?: boolean): void;
  69372. private getImpostorHitData;
  69373. private _tick;
  69374. /*** Helpers ***/
  69375. private _prepareCylinder;
  69376. private _intersectsWithCylinder;
  69377. }
  69378. /**
  69379. * Represents a physics vortex event
  69380. */
  69381. class PhysicsVortexEvent {
  69382. private _scene;
  69383. private _origin;
  69384. private _options;
  69385. private _physicsEngine;
  69386. private _originTop;
  69387. private _tickCallback;
  69388. private _cylinder;
  69389. private _cylinderPosition;
  69390. private _dataFetched;
  69391. /**
  69392. * Initializes the physics vortex event
  69393. * @param _scene The BabylonJS scene
  69394. * @param _origin The origin position of the vortex
  69395. * @param _options The options for the vortex event
  69396. */
  69397. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69398. /**
  69399. * Returns the data related to the vortex event (cylinder).
  69400. * @returns The physics vortex event data
  69401. */
  69402. getData(): PhysicsVortexEventData;
  69403. /**
  69404. * Enables the vortex.
  69405. */
  69406. enable(): void;
  69407. /**
  69408. * Disables the cortex.
  69409. */
  69410. disable(): void;
  69411. /**
  69412. * Disposes the sphere.
  69413. * @param force
  69414. */
  69415. dispose(force?: boolean): void;
  69416. private getImpostorHitData;
  69417. private _tick;
  69418. /*** Helpers ***/
  69419. private _prepareCylinder;
  69420. private _intersectsWithCylinder;
  69421. }
  69422. /**
  69423. * Options fot the radial explosion event
  69424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69425. */
  69426. export class PhysicsRadialExplosionEventOptions {
  69427. /**
  69428. * The radius of the sphere for the radial explosion.
  69429. */
  69430. radius: number;
  69431. /**
  69432. * The strenth of the explosion.
  69433. */
  69434. strength: number;
  69435. /**
  69436. * The strenght of the force in correspondence to the distance of the affected object
  69437. */
  69438. falloff: PhysicsRadialImpulseFalloff;
  69439. /**
  69440. * Sphere options for the radial explosion.
  69441. */
  69442. sphere: {
  69443. segments: number;
  69444. diameter: number;
  69445. };
  69446. /**
  69447. * Sphere options for the radial explosion.
  69448. */
  69449. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69450. }
  69451. /**
  69452. * Options fot the updraft event
  69453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69454. */
  69455. export class PhysicsUpdraftEventOptions {
  69456. /**
  69457. * The radius of the cylinder for the vortex
  69458. */
  69459. radius: number;
  69460. /**
  69461. * The strenth of the updraft.
  69462. */
  69463. strength: number;
  69464. /**
  69465. * The height of the cylinder for the updraft.
  69466. */
  69467. height: number;
  69468. /**
  69469. * The mode for the the updraft.
  69470. */
  69471. updraftMode: PhysicsUpdraftMode;
  69472. }
  69473. /**
  69474. * Options fot the vortex event
  69475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69476. */
  69477. export class PhysicsVortexEventOptions {
  69478. /**
  69479. * The radius of the cylinder for the vortex
  69480. */
  69481. radius: number;
  69482. /**
  69483. * The strenth of the vortex.
  69484. */
  69485. strength: number;
  69486. /**
  69487. * The height of the cylinder for the vortex.
  69488. */
  69489. height: number;
  69490. /**
  69491. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69492. */
  69493. centripetalForceThreshold: number;
  69494. /**
  69495. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69496. */
  69497. centripetalForceMultiplier: number;
  69498. /**
  69499. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69500. */
  69501. centrifugalForceMultiplier: number;
  69502. /**
  69503. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69504. */
  69505. updraftForceMultiplier: number;
  69506. }
  69507. /**
  69508. * The strenght of the force in correspondence to the distance of the affected object
  69509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69510. */
  69511. export enum PhysicsRadialImpulseFalloff {
  69512. /** Defines that impulse is constant in strength across it's whole radius */
  69513. Constant = 0,
  69514. /** Defines that impulse gets weaker if it's further from the origin */
  69515. Linear = 1
  69516. }
  69517. /**
  69518. * The strength of the force in correspondence to the distance of the affected object
  69519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69520. */
  69521. export enum PhysicsUpdraftMode {
  69522. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69523. Center = 0,
  69524. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69525. Perpendicular = 1
  69526. }
  69527. /**
  69528. * Interface for a physics hit data
  69529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69530. */
  69531. export interface PhysicsHitData {
  69532. /**
  69533. * The force applied at the contact point
  69534. */
  69535. force: Vector3;
  69536. /**
  69537. * The contact point
  69538. */
  69539. contactPoint: Vector3;
  69540. /**
  69541. * The distance from the origin to the contact point
  69542. */
  69543. distanceFromOrigin: number;
  69544. }
  69545. /**
  69546. * Interface for radial explosion event data
  69547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69548. */
  69549. export interface PhysicsRadialExplosionEventData {
  69550. /**
  69551. * A sphere used for the radial explosion event
  69552. */
  69553. sphere: Mesh;
  69554. }
  69555. /**
  69556. * Interface for gravitational field event data
  69557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69558. */
  69559. export interface PhysicsGravitationalFieldEventData {
  69560. /**
  69561. * A sphere mesh used for the gravitational field event
  69562. */
  69563. sphere: Mesh;
  69564. }
  69565. /**
  69566. * Interface for updraft event data
  69567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69568. */
  69569. export interface PhysicsUpdraftEventData {
  69570. /**
  69571. * A cylinder used for the updraft event
  69572. */
  69573. cylinder: Mesh;
  69574. }
  69575. /**
  69576. * Interface for vortex event data
  69577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69578. */
  69579. export interface PhysicsVortexEventData {
  69580. /**
  69581. * A cylinder used for the vortex event
  69582. */
  69583. cylinder: Mesh;
  69584. }
  69585. /**
  69586. * Interface for an affected physics impostor
  69587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69588. */
  69589. export interface PhysicsAffectedImpostorWithData {
  69590. /**
  69591. * The impostor affected by the effect
  69592. */
  69593. impostor: PhysicsImpostor;
  69594. /**
  69595. * The data about the hit/horce from the explosion
  69596. */
  69597. hitData: PhysicsHitData;
  69598. }
  69599. }
  69600. declare module "babylonjs/Physics/Plugins/index" {
  69601. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  69602. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  69603. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  69604. }
  69605. declare module "babylonjs/Physics/index" {
  69606. export * from "babylonjs/Physics/IPhysicsEngine";
  69607. export * from "babylonjs/Physics/physicsEngine";
  69608. export * from "babylonjs/Physics/physicsEngineComponent";
  69609. export * from "babylonjs/Physics/physicsHelper";
  69610. export * from "babylonjs/Physics/physicsImpostor";
  69611. export * from "babylonjs/Physics/physicsJoint";
  69612. export * from "babylonjs/Physics/Plugins/index";
  69613. }
  69614. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  69615. /** @hidden */
  69616. export var blackAndWhitePixelShader: {
  69617. name: string;
  69618. shader: string;
  69619. };
  69620. }
  69621. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  69622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69623. import { Camera } from "babylonjs/Cameras/camera";
  69624. import { Engine } from "babylonjs/Engines/engine";
  69625. import "babylonjs/Shaders/blackAndWhite.fragment";
  69626. /**
  69627. * Post process used to render in black and white
  69628. */
  69629. export class BlackAndWhitePostProcess extends PostProcess {
  69630. /**
  69631. * Linear about to convert he result to black and white (default: 1)
  69632. */
  69633. degree: number;
  69634. /**
  69635. * Creates a black and white post process
  69636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69637. * @param name The name of the effect.
  69638. * @param options The required width/height ratio to downsize to before computing the render pass.
  69639. * @param camera The camera to apply the render pass to.
  69640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69641. * @param engine The engine which the post process will be applied. (default: current engine)
  69642. * @param reusable If the post process can be reused on the same frame. (default: false)
  69643. */
  69644. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69645. }
  69646. }
  69647. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  69648. import { Nullable } from "babylonjs/types";
  69649. import { Camera } from "babylonjs/Cameras/camera";
  69650. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69651. import { Engine } from "babylonjs/Engines/engine";
  69652. /**
  69653. * This represents a set of one or more post processes in Babylon.
  69654. * A post process can be used to apply a shader to a texture after it is rendered.
  69655. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69656. */
  69657. export class PostProcessRenderEffect {
  69658. private _postProcesses;
  69659. private _getPostProcesses;
  69660. private _singleInstance;
  69661. private _cameras;
  69662. private _indicesForCamera;
  69663. /**
  69664. * Name of the effect
  69665. * @hidden
  69666. */
  69667. _name: string;
  69668. /**
  69669. * Instantiates a post process render effect.
  69670. * A post process can be used to apply a shader to a texture after it is rendered.
  69671. * @param engine The engine the effect is tied to
  69672. * @param name The name of the effect
  69673. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69674. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69675. */
  69676. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69677. /**
  69678. * Checks if all the post processes in the effect are supported.
  69679. */
  69680. get isSupported(): boolean;
  69681. /**
  69682. * Updates the current state of the effect
  69683. * @hidden
  69684. */
  69685. _update(): void;
  69686. /**
  69687. * Attaches the effect on cameras
  69688. * @param cameras The camera to attach to.
  69689. * @hidden
  69690. */
  69691. _attachCameras(cameras: Camera): void;
  69692. /**
  69693. * Attaches the effect on cameras
  69694. * @param cameras The camera to attach to.
  69695. * @hidden
  69696. */
  69697. _attachCameras(cameras: Camera[]): void;
  69698. /**
  69699. * Detaches the effect on cameras
  69700. * @param cameras The camera to detatch from.
  69701. * @hidden
  69702. */
  69703. _detachCameras(cameras: Camera): void;
  69704. /**
  69705. * Detatches the effect on cameras
  69706. * @param cameras The camera to detatch from.
  69707. * @hidden
  69708. */
  69709. _detachCameras(cameras: Camera[]): void;
  69710. /**
  69711. * Enables the effect on given cameras
  69712. * @param cameras The camera to enable.
  69713. * @hidden
  69714. */
  69715. _enable(cameras: Camera): void;
  69716. /**
  69717. * Enables the effect on given cameras
  69718. * @param cameras The camera to enable.
  69719. * @hidden
  69720. */
  69721. _enable(cameras: Nullable<Camera[]>): void;
  69722. /**
  69723. * Disables the effect on the given cameras
  69724. * @param cameras The camera to disable.
  69725. * @hidden
  69726. */
  69727. _disable(cameras: Camera): void;
  69728. /**
  69729. * Disables the effect on the given cameras
  69730. * @param cameras The camera to disable.
  69731. * @hidden
  69732. */
  69733. _disable(cameras: Nullable<Camera[]>): void;
  69734. /**
  69735. * Gets a list of the post processes contained in the effect.
  69736. * @param camera The camera to get the post processes on.
  69737. * @returns The list of the post processes in the effect.
  69738. */
  69739. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69740. }
  69741. }
  69742. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  69743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69744. /** @hidden */
  69745. export var extractHighlightsPixelShader: {
  69746. name: string;
  69747. shader: string;
  69748. };
  69749. }
  69750. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  69751. import { Nullable } from "babylonjs/types";
  69752. import { Camera } from "babylonjs/Cameras/camera";
  69753. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69754. import { Engine } from "babylonjs/Engines/engine";
  69755. import "babylonjs/Shaders/extractHighlights.fragment";
  69756. /**
  69757. * 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.
  69758. */
  69759. export class ExtractHighlightsPostProcess extends PostProcess {
  69760. /**
  69761. * The luminance threshold, pixels below this value will be set to black.
  69762. */
  69763. threshold: number;
  69764. /** @hidden */
  69765. _exposure: number;
  69766. /**
  69767. * Post process which has the input texture to be used when performing highlight extraction
  69768. * @hidden
  69769. */
  69770. _inputPostProcess: Nullable<PostProcess>;
  69771. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69772. }
  69773. }
  69774. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  69775. /** @hidden */
  69776. export var bloomMergePixelShader: {
  69777. name: string;
  69778. shader: string;
  69779. };
  69780. }
  69781. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  69782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69783. import { Nullable } from "babylonjs/types";
  69784. import { Engine } from "babylonjs/Engines/engine";
  69785. import { Camera } from "babylonjs/Cameras/camera";
  69786. import "babylonjs/Shaders/bloomMerge.fragment";
  69787. /**
  69788. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69789. */
  69790. export class BloomMergePostProcess extends PostProcess {
  69791. /** Weight of the bloom to be added to the original input. */
  69792. weight: number;
  69793. /**
  69794. * Creates a new instance of @see BloomMergePostProcess
  69795. * @param name The name of the effect.
  69796. * @param originalFromInput Post process which's input will be used for the merge.
  69797. * @param blurred Blurred highlights post process which's output will be used.
  69798. * @param weight Weight of the bloom to be added to the original input.
  69799. * @param options The required width/height ratio to downsize to before computing the render pass.
  69800. * @param camera The camera to apply the render pass to.
  69801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69802. * @param engine The engine which the post process will be applied. (default: current engine)
  69803. * @param reusable If the post process can be reused on the same frame. (default: false)
  69804. * @param textureType Type of textures used when performing the post process. (default: 0)
  69805. * @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)
  69806. */
  69807. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69808. /** Weight of the bloom to be added to the original input. */
  69809. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69810. }
  69811. }
  69812. declare module "babylonjs/PostProcesses/bloomEffect" {
  69813. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69815. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69816. import { Camera } from "babylonjs/Cameras/camera";
  69817. import { Scene } from "babylonjs/scene";
  69818. /**
  69819. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69820. */
  69821. export class BloomEffect extends PostProcessRenderEffect {
  69822. private bloomScale;
  69823. /**
  69824. * @hidden Internal
  69825. */
  69826. _effects: Array<PostProcess>;
  69827. /**
  69828. * @hidden Internal
  69829. */
  69830. _downscale: ExtractHighlightsPostProcess;
  69831. private _blurX;
  69832. private _blurY;
  69833. private _merge;
  69834. /**
  69835. * The luminance threshold to find bright areas of the image to bloom.
  69836. */
  69837. get threshold(): number;
  69838. set threshold(value: number);
  69839. /**
  69840. * The strength of the bloom.
  69841. */
  69842. get weight(): number;
  69843. set weight(value: number);
  69844. /**
  69845. * Specifies the size of the bloom blur kernel, relative to the final output size
  69846. */
  69847. get kernel(): number;
  69848. set kernel(value: number);
  69849. /**
  69850. * Creates a new instance of @see BloomEffect
  69851. * @param scene The scene the effect belongs to.
  69852. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69853. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69854. * @param bloomWeight The the strength of bloom.
  69855. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69856. * @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)
  69857. */
  69858. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69859. /**
  69860. * Disposes each of the internal effects for a given camera.
  69861. * @param camera The camera to dispose the effect on.
  69862. */
  69863. disposeEffects(camera: Camera): void;
  69864. /**
  69865. * @hidden Internal
  69866. */
  69867. _updateEffects(): void;
  69868. /**
  69869. * Internal
  69870. * @returns if all the contained post processes are ready.
  69871. * @hidden
  69872. */
  69873. _isReady(): boolean;
  69874. }
  69875. }
  69876. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  69877. /** @hidden */
  69878. export var chromaticAberrationPixelShader: {
  69879. name: string;
  69880. shader: string;
  69881. };
  69882. }
  69883. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  69884. import { Vector2 } from "babylonjs/Maths/math.vector";
  69885. import { Nullable } from "babylonjs/types";
  69886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69887. import { Camera } from "babylonjs/Cameras/camera";
  69888. import { Engine } from "babylonjs/Engines/engine";
  69889. import "babylonjs/Shaders/chromaticAberration.fragment";
  69890. /**
  69891. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69892. */
  69893. export class ChromaticAberrationPostProcess extends PostProcess {
  69894. /**
  69895. * The amount of seperation of rgb channels (default: 30)
  69896. */
  69897. aberrationAmount: number;
  69898. /**
  69899. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69900. */
  69901. radialIntensity: number;
  69902. /**
  69903. * 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))
  69904. */
  69905. direction: Vector2;
  69906. /**
  69907. * 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))
  69908. */
  69909. centerPosition: Vector2;
  69910. /**
  69911. * Creates a new instance ChromaticAberrationPostProcess
  69912. * @param name The name of the effect.
  69913. * @param screenWidth The width of the screen to apply the effect on.
  69914. * @param screenHeight The height of the screen to apply the effect on.
  69915. * @param options The required width/height ratio to downsize to before computing the render pass.
  69916. * @param camera The camera to apply the render pass to.
  69917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69918. * @param engine The engine which the post process will be applied. (default: current engine)
  69919. * @param reusable If the post process can be reused on the same frame. (default: false)
  69920. * @param textureType Type of textures used when performing the post process. (default: 0)
  69921. * @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)
  69922. */
  69923. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69924. }
  69925. }
  69926. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  69927. /** @hidden */
  69928. export var circleOfConfusionPixelShader: {
  69929. name: string;
  69930. shader: string;
  69931. };
  69932. }
  69933. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  69934. import { Nullable } from "babylonjs/types";
  69935. import { Engine } from "babylonjs/Engines/engine";
  69936. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69937. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69938. import { Camera } from "babylonjs/Cameras/camera";
  69939. import "babylonjs/Shaders/circleOfConfusion.fragment";
  69940. /**
  69941. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69942. */
  69943. export class CircleOfConfusionPostProcess extends PostProcess {
  69944. /**
  69945. * 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.
  69946. */
  69947. lensSize: number;
  69948. /**
  69949. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69950. */
  69951. fStop: number;
  69952. /**
  69953. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69954. */
  69955. focusDistance: number;
  69956. /**
  69957. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69958. */
  69959. focalLength: number;
  69960. private _depthTexture;
  69961. /**
  69962. * Creates a new instance CircleOfConfusionPostProcess
  69963. * @param name The name of the effect.
  69964. * @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.
  69965. * @param options The required width/height ratio to downsize to before computing the render pass.
  69966. * @param camera The camera to apply the render pass to.
  69967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69968. * @param engine The engine which the post process will be applied. (default: current engine)
  69969. * @param reusable If the post process can be reused on the same frame. (default: false)
  69970. * @param textureType Type of textures used when performing the post process. (default: 0)
  69971. * @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)
  69972. */
  69973. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69974. /**
  69975. * 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.
  69976. */
  69977. set depthTexture(value: RenderTargetTexture);
  69978. }
  69979. }
  69980. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  69981. /** @hidden */
  69982. export var colorCorrectionPixelShader: {
  69983. name: string;
  69984. shader: string;
  69985. };
  69986. }
  69987. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  69988. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69989. import { Engine } from "babylonjs/Engines/engine";
  69990. import { Camera } from "babylonjs/Cameras/camera";
  69991. import "babylonjs/Shaders/colorCorrection.fragment";
  69992. /**
  69993. *
  69994. * This post-process allows the modification of rendered colors by using
  69995. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69996. *
  69997. * The object needs to be provided an url to a texture containing the color
  69998. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69999. * Use an image editing software to tweak the LUT to match your needs.
  70000. *
  70001. * For an example of a color LUT, see here:
  70002. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70003. * For explanations on color grading, see here:
  70004. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70005. *
  70006. */
  70007. export class ColorCorrectionPostProcess extends PostProcess {
  70008. private _colorTableTexture;
  70009. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70010. }
  70011. }
  70012. declare module "babylonjs/Shaders/convolution.fragment" {
  70013. /** @hidden */
  70014. export var convolutionPixelShader: {
  70015. name: string;
  70016. shader: string;
  70017. };
  70018. }
  70019. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  70020. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70021. import { Nullable } from "babylonjs/types";
  70022. import { Camera } from "babylonjs/Cameras/camera";
  70023. import { Engine } from "babylonjs/Engines/engine";
  70024. import "babylonjs/Shaders/convolution.fragment";
  70025. /**
  70026. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70027. * input texture to perform effects such as edge detection or sharpening
  70028. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70029. */
  70030. export class ConvolutionPostProcess extends PostProcess {
  70031. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70032. kernel: number[];
  70033. /**
  70034. * Creates a new instance ConvolutionPostProcess
  70035. * @param name The name of the effect.
  70036. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70037. * @param options The required width/height ratio to downsize to before computing the render pass.
  70038. * @param camera The camera to apply the render pass to.
  70039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70040. * @param engine The engine which the post process will be applied. (default: current engine)
  70041. * @param reusable If the post process can be reused on the same frame. (default: false)
  70042. * @param textureType Type of textures used when performing the post process. (default: 0)
  70043. */
  70044. constructor(name: string,
  70045. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70046. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70047. /**
  70048. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70049. */
  70050. static EdgeDetect0Kernel: number[];
  70051. /**
  70052. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70053. */
  70054. static EdgeDetect1Kernel: number[];
  70055. /**
  70056. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70057. */
  70058. static EdgeDetect2Kernel: number[];
  70059. /**
  70060. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70061. */
  70062. static SharpenKernel: number[];
  70063. /**
  70064. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70065. */
  70066. static EmbossKernel: number[];
  70067. /**
  70068. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70069. */
  70070. static GaussianKernel: number[];
  70071. }
  70072. }
  70073. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  70074. import { Nullable } from "babylonjs/types";
  70075. import { Vector2 } from "babylonjs/Maths/math.vector";
  70076. import { Camera } from "babylonjs/Cameras/camera";
  70077. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70078. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70079. import { Engine } from "babylonjs/Engines/engine";
  70080. import { Scene } from "babylonjs/scene";
  70081. /**
  70082. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70083. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70084. * based on samples that have a large difference in distance than the center pixel.
  70085. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70086. */
  70087. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70088. direction: Vector2;
  70089. /**
  70090. * Creates a new instance CircleOfConfusionPostProcess
  70091. * @param name The name of the effect.
  70092. * @param scene The scene the effect belongs to.
  70093. * @param direction The direction the blur should be applied.
  70094. * @param kernel The size of the kernel used to blur.
  70095. * @param options The required width/height ratio to downsize to before computing the render pass.
  70096. * @param camera The camera to apply the render pass to.
  70097. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70098. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70100. * @param engine The engine which the post process will be applied. (default: current engine)
  70101. * @param reusable If the post process can be reused on the same frame. (default: false)
  70102. * @param textureType Type of textures used when performing the post process. (default: 0)
  70103. * @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)
  70104. */
  70105. 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);
  70106. }
  70107. }
  70108. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  70109. /** @hidden */
  70110. export var depthOfFieldMergePixelShader: {
  70111. name: string;
  70112. shader: string;
  70113. };
  70114. }
  70115. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  70116. import { Nullable } from "babylonjs/types";
  70117. import { Camera } from "babylonjs/Cameras/camera";
  70118. import { Effect } from "babylonjs/Materials/effect";
  70119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70120. import { Engine } from "babylonjs/Engines/engine";
  70121. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  70122. /**
  70123. * Options to be set when merging outputs from the default pipeline.
  70124. */
  70125. export class DepthOfFieldMergePostProcessOptions {
  70126. /**
  70127. * The original image to merge on top of
  70128. */
  70129. originalFromInput: PostProcess;
  70130. /**
  70131. * Parameters to perform the merge of the depth of field effect
  70132. */
  70133. depthOfField?: {
  70134. circleOfConfusion: PostProcess;
  70135. blurSteps: Array<PostProcess>;
  70136. };
  70137. /**
  70138. * Parameters to perform the merge of bloom effect
  70139. */
  70140. bloom?: {
  70141. blurred: PostProcess;
  70142. weight: number;
  70143. };
  70144. }
  70145. /**
  70146. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70147. */
  70148. export class DepthOfFieldMergePostProcess extends PostProcess {
  70149. private blurSteps;
  70150. /**
  70151. * Creates a new instance of DepthOfFieldMergePostProcess
  70152. * @param name The name of the effect.
  70153. * @param originalFromInput Post process which's input will be used for the merge.
  70154. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70155. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70156. * @param options The required width/height ratio to downsize to before computing the render pass.
  70157. * @param camera The camera to apply the render pass to.
  70158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70159. * @param engine The engine which the post process will be applied. (default: current engine)
  70160. * @param reusable If the post process can be reused on the same frame. (default: false)
  70161. * @param textureType Type of textures used when performing the post process. (default: 0)
  70162. * @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)
  70163. */
  70164. 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);
  70165. /**
  70166. * Updates the effect with the current post process compile time values and recompiles the shader.
  70167. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70168. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70169. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70170. * @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
  70171. * @param onCompiled Called when the shader has been compiled.
  70172. * @param onError Called if there is an error when compiling a shader.
  70173. */
  70174. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70175. }
  70176. }
  70177. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  70178. import { Nullable } from "babylonjs/types";
  70179. import { Camera } from "babylonjs/Cameras/camera";
  70180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70182. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70183. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70184. import { Scene } from "babylonjs/scene";
  70185. /**
  70186. * Specifies the level of max blur that should be applied when using the depth of field effect
  70187. */
  70188. export enum DepthOfFieldEffectBlurLevel {
  70189. /**
  70190. * Subtle blur
  70191. */
  70192. Low = 0,
  70193. /**
  70194. * Medium blur
  70195. */
  70196. Medium = 1,
  70197. /**
  70198. * Large blur
  70199. */
  70200. High = 2
  70201. }
  70202. /**
  70203. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70204. */
  70205. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70206. private _circleOfConfusion;
  70207. /**
  70208. * @hidden Internal, blurs from high to low
  70209. */
  70210. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70211. private _depthOfFieldBlurY;
  70212. private _dofMerge;
  70213. /**
  70214. * @hidden Internal post processes in depth of field effect
  70215. */
  70216. _effects: Array<PostProcess>;
  70217. /**
  70218. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70219. */
  70220. set focalLength(value: number);
  70221. get focalLength(): number;
  70222. /**
  70223. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70224. */
  70225. set fStop(value: number);
  70226. get fStop(): number;
  70227. /**
  70228. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70229. */
  70230. set focusDistance(value: number);
  70231. get focusDistance(): number;
  70232. /**
  70233. * 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.
  70234. */
  70235. set lensSize(value: number);
  70236. get lensSize(): number;
  70237. /**
  70238. * Creates a new instance DepthOfFieldEffect
  70239. * @param scene The scene the effect belongs to.
  70240. * @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.
  70241. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70242. * @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)
  70243. */
  70244. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70245. /**
  70246. * Get the current class name of the current effet
  70247. * @returns "DepthOfFieldEffect"
  70248. */
  70249. getClassName(): string;
  70250. /**
  70251. * 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.
  70252. */
  70253. set depthTexture(value: RenderTargetTexture);
  70254. /**
  70255. * Disposes each of the internal effects for a given camera.
  70256. * @param camera The camera to dispose the effect on.
  70257. */
  70258. disposeEffects(camera: Camera): void;
  70259. /**
  70260. * @hidden Internal
  70261. */
  70262. _updateEffects(): void;
  70263. /**
  70264. * Internal
  70265. * @returns if all the contained post processes are ready.
  70266. * @hidden
  70267. */
  70268. _isReady(): boolean;
  70269. }
  70270. }
  70271. declare module "babylonjs/Shaders/displayPass.fragment" {
  70272. /** @hidden */
  70273. export var displayPassPixelShader: {
  70274. name: string;
  70275. shader: string;
  70276. };
  70277. }
  70278. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  70279. import { Nullable } from "babylonjs/types";
  70280. import { Camera } from "babylonjs/Cameras/camera";
  70281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70282. import { Engine } from "babylonjs/Engines/engine";
  70283. import "babylonjs/Shaders/displayPass.fragment";
  70284. /**
  70285. * DisplayPassPostProcess which produces an output the same as it's input
  70286. */
  70287. export class DisplayPassPostProcess extends PostProcess {
  70288. /**
  70289. * Creates the DisplayPassPostProcess
  70290. * @param name The name of the effect.
  70291. * @param options The required width/height ratio to downsize to before computing the render pass.
  70292. * @param camera The camera to apply the render pass to.
  70293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70294. * @param engine The engine which the post process will be applied. (default: current engine)
  70295. * @param reusable If the post process can be reused on the same frame. (default: false)
  70296. */
  70297. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70298. }
  70299. }
  70300. declare module "babylonjs/Shaders/filter.fragment" {
  70301. /** @hidden */
  70302. export var filterPixelShader: {
  70303. name: string;
  70304. shader: string;
  70305. };
  70306. }
  70307. declare module "babylonjs/PostProcesses/filterPostProcess" {
  70308. import { Nullable } from "babylonjs/types";
  70309. import { Matrix } from "babylonjs/Maths/math.vector";
  70310. import { Camera } from "babylonjs/Cameras/camera";
  70311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70312. import { Engine } from "babylonjs/Engines/engine";
  70313. import "babylonjs/Shaders/filter.fragment";
  70314. /**
  70315. * Applies a kernel filter to the image
  70316. */
  70317. export class FilterPostProcess extends PostProcess {
  70318. /** The matrix to be applied to the image */
  70319. kernelMatrix: Matrix;
  70320. /**
  70321. *
  70322. * @param name The name of the effect.
  70323. * @param kernelMatrix The matrix to be applied to the image
  70324. * @param options The required width/height ratio to downsize to before computing the render pass.
  70325. * @param camera The camera to apply the render pass to.
  70326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70327. * @param engine The engine which the post process will be applied. (default: current engine)
  70328. * @param reusable If the post process can be reused on the same frame. (default: false)
  70329. */
  70330. constructor(name: string,
  70331. /** The matrix to be applied to the image */
  70332. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70333. }
  70334. }
  70335. declare module "babylonjs/Shaders/fxaa.fragment" {
  70336. /** @hidden */
  70337. export var fxaaPixelShader: {
  70338. name: string;
  70339. shader: string;
  70340. };
  70341. }
  70342. declare module "babylonjs/Shaders/fxaa.vertex" {
  70343. /** @hidden */
  70344. export var fxaaVertexShader: {
  70345. name: string;
  70346. shader: string;
  70347. };
  70348. }
  70349. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  70350. import { Nullable } from "babylonjs/types";
  70351. import { Camera } from "babylonjs/Cameras/camera";
  70352. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70353. import { Engine } from "babylonjs/Engines/engine";
  70354. import "babylonjs/Shaders/fxaa.fragment";
  70355. import "babylonjs/Shaders/fxaa.vertex";
  70356. /**
  70357. * Fxaa post process
  70358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70359. */
  70360. export class FxaaPostProcess extends PostProcess {
  70361. /** @hidden */
  70362. texelWidth: number;
  70363. /** @hidden */
  70364. texelHeight: number;
  70365. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70366. private _getDefines;
  70367. }
  70368. }
  70369. declare module "babylonjs/Shaders/grain.fragment" {
  70370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70371. /** @hidden */
  70372. export var grainPixelShader: {
  70373. name: string;
  70374. shader: string;
  70375. };
  70376. }
  70377. declare module "babylonjs/PostProcesses/grainPostProcess" {
  70378. import { Nullable } from "babylonjs/types";
  70379. import { Camera } from "babylonjs/Cameras/camera";
  70380. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70381. import { Engine } from "babylonjs/Engines/engine";
  70382. import "babylonjs/Shaders/grain.fragment";
  70383. /**
  70384. * The GrainPostProcess adds noise to the image at mid luminance levels
  70385. */
  70386. export class GrainPostProcess extends PostProcess {
  70387. /**
  70388. * The intensity of the grain added (default: 30)
  70389. */
  70390. intensity: number;
  70391. /**
  70392. * If the grain should be randomized on every frame
  70393. */
  70394. animated: boolean;
  70395. /**
  70396. * Creates a new instance of @see GrainPostProcess
  70397. * @param name The name of the effect.
  70398. * @param options The required width/height ratio to downsize to before computing the render pass.
  70399. * @param camera The camera to apply the render pass to.
  70400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70401. * @param engine The engine which the post process will be applied. (default: current engine)
  70402. * @param reusable If the post process can be reused on the same frame. (default: false)
  70403. * @param textureType Type of textures used when performing the post process. (default: 0)
  70404. * @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)
  70405. */
  70406. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70407. }
  70408. }
  70409. declare module "babylonjs/Shaders/highlights.fragment" {
  70410. /** @hidden */
  70411. export var highlightsPixelShader: {
  70412. name: string;
  70413. shader: string;
  70414. };
  70415. }
  70416. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  70417. import { Nullable } from "babylonjs/types";
  70418. import { Camera } from "babylonjs/Cameras/camera";
  70419. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70420. import { Engine } from "babylonjs/Engines/engine";
  70421. import "babylonjs/Shaders/highlights.fragment";
  70422. /**
  70423. * Extracts highlights from the image
  70424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70425. */
  70426. export class HighlightsPostProcess extends PostProcess {
  70427. /**
  70428. * Extracts highlights from the image
  70429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70430. * @param name The name of the effect.
  70431. * @param options The required width/height ratio to downsize to before computing the render pass.
  70432. * @param camera The camera to apply the render pass to.
  70433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70434. * @param engine The engine which the post process will be applied. (default: current engine)
  70435. * @param reusable If the post process can be reused on the same frame. (default: false)
  70436. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70437. */
  70438. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70439. }
  70440. }
  70441. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  70442. /** @hidden */
  70443. export var mrtFragmentDeclaration: {
  70444. name: string;
  70445. shader: string;
  70446. };
  70447. }
  70448. declare module "babylonjs/Shaders/geometry.fragment" {
  70449. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  70450. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70451. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70452. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70453. /** @hidden */
  70454. export var geometryPixelShader: {
  70455. name: string;
  70456. shader: string;
  70457. };
  70458. }
  70459. declare module "babylonjs/Shaders/geometry.vertex" {
  70460. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70461. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70463. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70466. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70467. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  70468. /** @hidden */
  70469. export var geometryVertexShader: {
  70470. name: string;
  70471. shader: string;
  70472. };
  70473. }
  70474. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  70475. import { Matrix } from "babylonjs/Maths/math.vector";
  70476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70477. import { Mesh } from "babylonjs/Meshes/mesh";
  70478. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  70479. import { Effect } from "babylonjs/Materials/effect";
  70480. import { Scene } from "babylonjs/scene";
  70481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70482. import "babylonjs/Shaders/geometry.fragment";
  70483. import "babylonjs/Shaders/geometry.vertex";
  70484. /** @hidden */
  70485. interface ISavedTransformationMatrix {
  70486. world: Matrix;
  70487. viewProjection: Matrix;
  70488. }
  70489. /**
  70490. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70491. */
  70492. export class GeometryBufferRenderer {
  70493. /**
  70494. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70495. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70496. */
  70497. static readonly POSITION_TEXTURE_TYPE: number;
  70498. /**
  70499. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70500. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70501. */
  70502. static readonly VELOCITY_TEXTURE_TYPE: number;
  70503. /**
  70504. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70505. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70506. */
  70507. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70508. /**
  70509. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70510. * in order to compute objects velocities when enableVelocity is set to "true"
  70511. * @hidden
  70512. */
  70513. _previousTransformationMatrices: {
  70514. [index: number]: ISavedTransformationMatrix;
  70515. };
  70516. /**
  70517. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70518. * in order to compute objects velocities when enableVelocity is set to "true"
  70519. * @hidden
  70520. */
  70521. _previousBonesTransformationMatrices: {
  70522. [index: number]: Float32Array;
  70523. };
  70524. /**
  70525. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70526. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70527. */
  70528. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70529. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70530. renderTransparentMeshes: boolean;
  70531. private _scene;
  70532. private _multiRenderTarget;
  70533. private _ratio;
  70534. private _enablePosition;
  70535. private _enableVelocity;
  70536. private _enableReflectivity;
  70537. private _positionIndex;
  70538. private _velocityIndex;
  70539. private _reflectivityIndex;
  70540. protected _effect: Effect;
  70541. protected _cachedDefines: string;
  70542. /**
  70543. * Set the render list (meshes to be rendered) used in the G buffer.
  70544. */
  70545. set renderList(meshes: Mesh[]);
  70546. /**
  70547. * Gets wether or not G buffer are supported by the running hardware.
  70548. * This requires draw buffer supports
  70549. */
  70550. get isSupported(): boolean;
  70551. /**
  70552. * Returns the index of the given texture type in the G-Buffer textures array
  70553. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70554. * @returns the index of the given texture type in the G-Buffer textures array
  70555. */
  70556. getTextureIndex(textureType: number): number;
  70557. /**
  70558. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70559. */
  70560. get enablePosition(): boolean;
  70561. /**
  70562. * Sets whether or not objects positions are enabled for the G buffer.
  70563. */
  70564. set enablePosition(enable: boolean);
  70565. /**
  70566. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70567. */
  70568. get enableVelocity(): boolean;
  70569. /**
  70570. * Sets wether or not objects velocities are enabled for the G buffer.
  70571. */
  70572. set enableVelocity(enable: boolean);
  70573. /**
  70574. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70575. */
  70576. get enableReflectivity(): boolean;
  70577. /**
  70578. * Sets wether or not objects roughness are enabled for the G buffer.
  70579. */
  70580. set enableReflectivity(enable: boolean);
  70581. /**
  70582. * Gets the scene associated with the buffer.
  70583. */
  70584. get scene(): Scene;
  70585. /**
  70586. * Gets the ratio used by the buffer during its creation.
  70587. * How big is the buffer related to the main canvas.
  70588. */
  70589. get ratio(): number;
  70590. /** @hidden */
  70591. static _SceneComponentInitialization: (scene: Scene) => void;
  70592. /**
  70593. * Creates a new G Buffer for the scene
  70594. * @param scene The scene the buffer belongs to
  70595. * @param ratio How big is the buffer related to the main canvas.
  70596. */
  70597. constructor(scene: Scene, ratio?: number);
  70598. /**
  70599. * Checks wether everything is ready to render a submesh to the G buffer.
  70600. * @param subMesh the submesh to check readiness for
  70601. * @param useInstances is the mesh drawn using instance or not
  70602. * @returns true if ready otherwise false
  70603. */
  70604. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70605. /**
  70606. * Gets the current underlying G Buffer.
  70607. * @returns the buffer
  70608. */
  70609. getGBuffer(): MultiRenderTarget;
  70610. /**
  70611. * Gets the number of samples used to render the buffer (anti aliasing).
  70612. */
  70613. get samples(): number;
  70614. /**
  70615. * Sets the number of samples used to render the buffer (anti aliasing).
  70616. */
  70617. set samples(value: number);
  70618. /**
  70619. * Disposes the renderer and frees up associated resources.
  70620. */
  70621. dispose(): void;
  70622. protected _createRenderTargets(): void;
  70623. private _copyBonesTransformationMatrices;
  70624. }
  70625. }
  70626. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  70627. import { Nullable } from "babylonjs/types";
  70628. import { Scene } from "babylonjs/scene";
  70629. import { ISceneComponent } from "babylonjs/sceneComponent";
  70630. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  70631. module "babylonjs/scene" {
  70632. interface Scene {
  70633. /** @hidden (Backing field) */
  70634. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70635. /**
  70636. * Gets or Sets the current geometry buffer associated to the scene.
  70637. */
  70638. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70639. /**
  70640. * Enables a GeometryBufferRender and associates it with the scene
  70641. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70642. * @returns the GeometryBufferRenderer
  70643. */
  70644. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70645. /**
  70646. * Disables the GeometryBufferRender associated with the scene
  70647. */
  70648. disableGeometryBufferRenderer(): void;
  70649. }
  70650. }
  70651. /**
  70652. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70653. * in several rendering techniques.
  70654. */
  70655. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70656. /**
  70657. * The component name helpful to identify the component in the list of scene components.
  70658. */
  70659. readonly name: string;
  70660. /**
  70661. * The scene the component belongs to.
  70662. */
  70663. scene: Scene;
  70664. /**
  70665. * Creates a new instance of the component for the given scene
  70666. * @param scene Defines the scene to register the component in
  70667. */
  70668. constructor(scene: Scene);
  70669. /**
  70670. * Registers the component in a given scene
  70671. */
  70672. register(): void;
  70673. /**
  70674. * Rebuilds the elements related to this component in case of
  70675. * context lost for instance.
  70676. */
  70677. rebuild(): void;
  70678. /**
  70679. * Disposes the component and the associated ressources
  70680. */
  70681. dispose(): void;
  70682. private _gatherRenderTargets;
  70683. }
  70684. }
  70685. declare module "babylonjs/Shaders/motionBlur.fragment" {
  70686. /** @hidden */
  70687. export var motionBlurPixelShader: {
  70688. name: string;
  70689. shader: string;
  70690. };
  70691. }
  70692. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  70693. import { Nullable } from "babylonjs/types";
  70694. import { Camera } from "babylonjs/Cameras/camera";
  70695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70696. import { Scene } from "babylonjs/scene";
  70697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70698. import "babylonjs/Animations/animatable";
  70699. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70700. import "babylonjs/Shaders/motionBlur.fragment";
  70701. import { Engine } from "babylonjs/Engines/engine";
  70702. /**
  70703. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70704. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70705. * As an example, all you have to do is to create the post-process:
  70706. * var mb = new BABYLON.MotionBlurPostProcess(
  70707. * 'mb', // The name of the effect.
  70708. * scene, // The scene containing the objects to blur according to their velocity.
  70709. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70710. * camera // The camera to apply the render pass to.
  70711. * );
  70712. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70713. */
  70714. export class MotionBlurPostProcess extends PostProcess {
  70715. /**
  70716. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70717. */
  70718. motionStrength: number;
  70719. /**
  70720. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70721. */
  70722. get motionBlurSamples(): number;
  70723. /**
  70724. * Sets the number of iterations to be used for motion blur quality
  70725. */
  70726. set motionBlurSamples(samples: number);
  70727. private _motionBlurSamples;
  70728. private _geometryBufferRenderer;
  70729. /**
  70730. * Creates a new instance MotionBlurPostProcess
  70731. * @param name The name of the effect.
  70732. * @param scene The scene containing the objects to blur according to their velocity.
  70733. * @param options The required width/height ratio to downsize to before computing the render pass.
  70734. * @param camera The camera to apply the render pass to.
  70735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70736. * @param engine The engine which the post process will be applied. (default: current engine)
  70737. * @param reusable If the post process can be reused on the same frame. (default: false)
  70738. * @param textureType Type of textures used when performing the post process. (default: 0)
  70739. * @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)
  70740. */
  70741. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70742. /**
  70743. * Excludes the given skinned mesh from computing bones velocities.
  70744. * 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.
  70745. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70746. */
  70747. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70748. /**
  70749. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70750. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70751. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70752. */
  70753. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70754. /**
  70755. * Disposes the post process.
  70756. * @param camera The camera to dispose the post process on.
  70757. */
  70758. dispose(camera?: Camera): void;
  70759. }
  70760. }
  70761. declare module "babylonjs/Shaders/refraction.fragment" {
  70762. /** @hidden */
  70763. export var refractionPixelShader: {
  70764. name: string;
  70765. shader: string;
  70766. };
  70767. }
  70768. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  70769. import { Color3 } from "babylonjs/Maths/math.color";
  70770. import { Camera } from "babylonjs/Cameras/camera";
  70771. import { Texture } from "babylonjs/Materials/Textures/texture";
  70772. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70773. import { Engine } from "babylonjs/Engines/engine";
  70774. import "babylonjs/Shaders/refraction.fragment";
  70775. /**
  70776. * Post process which applies a refractin texture
  70777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70778. */
  70779. export class RefractionPostProcess extends PostProcess {
  70780. /** the base color of the refraction (used to taint the rendering) */
  70781. color: Color3;
  70782. /** simulated refraction depth */
  70783. depth: number;
  70784. /** the coefficient of the base color (0 to remove base color tainting) */
  70785. colorLevel: number;
  70786. private _refTexture;
  70787. private _ownRefractionTexture;
  70788. /**
  70789. * Gets or sets the refraction texture
  70790. * Please note that you are responsible for disposing the texture if you set it manually
  70791. */
  70792. get refractionTexture(): Texture;
  70793. set refractionTexture(value: Texture);
  70794. /**
  70795. * Initializes the RefractionPostProcess
  70796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70797. * @param name The name of the effect.
  70798. * @param refractionTextureUrl Url of the refraction texture to use
  70799. * @param color the base color of the refraction (used to taint the rendering)
  70800. * @param depth simulated refraction depth
  70801. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70802. * @param camera The camera to apply the render pass to.
  70803. * @param options The required width/height ratio to downsize to before computing the render pass.
  70804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70805. * @param engine The engine which the post process will be applied. (default: current engine)
  70806. * @param reusable If the post process can be reused on the same frame. (default: false)
  70807. */
  70808. constructor(name: string, refractionTextureUrl: string,
  70809. /** the base color of the refraction (used to taint the rendering) */
  70810. color: Color3,
  70811. /** simulated refraction depth */
  70812. depth: number,
  70813. /** the coefficient of the base color (0 to remove base color tainting) */
  70814. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70815. /**
  70816. * Disposes of the post process
  70817. * @param camera Camera to dispose post process on
  70818. */
  70819. dispose(camera: Camera): void;
  70820. }
  70821. }
  70822. declare module "babylonjs/Shaders/sharpen.fragment" {
  70823. /** @hidden */
  70824. export var sharpenPixelShader: {
  70825. name: string;
  70826. shader: string;
  70827. };
  70828. }
  70829. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  70830. import { Nullable } from "babylonjs/types";
  70831. import { Camera } from "babylonjs/Cameras/camera";
  70832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70833. import "babylonjs/Shaders/sharpen.fragment";
  70834. import { Engine } from "babylonjs/Engines/engine";
  70835. /**
  70836. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70837. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70838. */
  70839. export class SharpenPostProcess extends PostProcess {
  70840. /**
  70841. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70842. */
  70843. colorAmount: number;
  70844. /**
  70845. * How much sharpness should be applied (default: 0.3)
  70846. */
  70847. edgeAmount: number;
  70848. /**
  70849. * Creates a new instance ConvolutionPostProcess
  70850. * @param name The name of the effect.
  70851. * @param options The required width/height ratio to downsize to before computing the render pass.
  70852. * @param camera The camera to apply the render pass to.
  70853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70854. * @param engine The engine which the post process will be applied. (default: current engine)
  70855. * @param reusable If the post process can be reused on the same frame. (default: false)
  70856. * @param textureType Type of textures used when performing the post process. (default: 0)
  70857. * @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)
  70858. */
  70859. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70860. }
  70861. }
  70862. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  70863. import { Nullable } from "babylonjs/types";
  70864. import { Camera } from "babylonjs/Cameras/camera";
  70865. import { Engine } from "babylonjs/Engines/engine";
  70866. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70867. import { IInspectable } from "babylonjs/Misc/iInspectable";
  70868. /**
  70869. * PostProcessRenderPipeline
  70870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70871. */
  70872. export class PostProcessRenderPipeline {
  70873. private engine;
  70874. private _renderEffects;
  70875. private _renderEffectsForIsolatedPass;
  70876. /**
  70877. * List of inspectable custom properties (used by the Inspector)
  70878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70879. */
  70880. inspectableCustomProperties: IInspectable[];
  70881. /**
  70882. * @hidden
  70883. */
  70884. protected _cameras: Camera[];
  70885. /** @hidden */
  70886. _name: string;
  70887. /**
  70888. * Gets pipeline name
  70889. */
  70890. get name(): string;
  70891. /** Gets the list of attached cameras */
  70892. get cameras(): Camera[];
  70893. /**
  70894. * Initializes a PostProcessRenderPipeline
  70895. * @param engine engine to add the pipeline to
  70896. * @param name name of the pipeline
  70897. */
  70898. constructor(engine: Engine, name: string);
  70899. /**
  70900. * Gets the class name
  70901. * @returns "PostProcessRenderPipeline"
  70902. */
  70903. getClassName(): string;
  70904. /**
  70905. * If all the render effects in the pipeline are supported
  70906. */
  70907. get isSupported(): boolean;
  70908. /**
  70909. * Adds an effect to the pipeline
  70910. * @param renderEffect the effect to add
  70911. */
  70912. addEffect(renderEffect: PostProcessRenderEffect): void;
  70913. /** @hidden */
  70914. _rebuild(): void;
  70915. /** @hidden */
  70916. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70917. /** @hidden */
  70918. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70919. /** @hidden */
  70920. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70921. /** @hidden */
  70922. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70923. /** @hidden */
  70924. _attachCameras(cameras: Camera, unique: boolean): void;
  70925. /** @hidden */
  70926. _attachCameras(cameras: Camera[], unique: boolean): void;
  70927. /** @hidden */
  70928. _detachCameras(cameras: Camera): void;
  70929. /** @hidden */
  70930. _detachCameras(cameras: Nullable<Camera[]>): void;
  70931. /** @hidden */
  70932. _update(): void;
  70933. /** @hidden */
  70934. _reset(): void;
  70935. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70936. /**
  70937. * Disposes of the pipeline
  70938. */
  70939. dispose(): void;
  70940. }
  70941. }
  70942. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  70943. import { Camera } from "babylonjs/Cameras/camera";
  70944. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70945. /**
  70946. * PostProcessRenderPipelineManager class
  70947. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70948. */
  70949. export class PostProcessRenderPipelineManager {
  70950. private _renderPipelines;
  70951. /**
  70952. * Initializes a PostProcessRenderPipelineManager
  70953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70954. */
  70955. constructor();
  70956. /**
  70957. * Gets the list of supported render pipelines
  70958. */
  70959. get supportedPipelines(): PostProcessRenderPipeline[];
  70960. /**
  70961. * Adds a pipeline to the manager
  70962. * @param renderPipeline The pipeline to add
  70963. */
  70964. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70965. /**
  70966. * Attaches a camera to the pipeline
  70967. * @param renderPipelineName The name of the pipeline to attach to
  70968. * @param cameras the camera to attach
  70969. * @param unique if the camera can be attached multiple times to the pipeline
  70970. */
  70971. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70972. /**
  70973. * Detaches a camera from the pipeline
  70974. * @param renderPipelineName The name of the pipeline to detach from
  70975. * @param cameras the camera to detach
  70976. */
  70977. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70978. /**
  70979. * Enables an effect by name on a pipeline
  70980. * @param renderPipelineName the name of the pipeline to enable the effect in
  70981. * @param renderEffectName the name of the effect to enable
  70982. * @param cameras the cameras that the effect should be enabled on
  70983. */
  70984. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70985. /**
  70986. * Disables an effect by name on a pipeline
  70987. * @param renderPipelineName the name of the pipeline to disable the effect in
  70988. * @param renderEffectName the name of the effect to disable
  70989. * @param cameras the cameras that the effect should be disabled on
  70990. */
  70991. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70992. /**
  70993. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70994. */
  70995. update(): void;
  70996. /** @hidden */
  70997. _rebuild(): void;
  70998. /**
  70999. * Disposes of the manager and pipelines
  71000. */
  71001. dispose(): void;
  71002. }
  71003. }
  71004. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  71005. import { ISceneComponent } from "babylonjs/sceneComponent";
  71006. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  71007. import { Scene } from "babylonjs/scene";
  71008. module "babylonjs/scene" {
  71009. interface Scene {
  71010. /** @hidden (Backing field) */
  71011. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71012. /**
  71013. * Gets the postprocess render pipeline manager
  71014. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71015. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71016. */
  71017. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71018. }
  71019. }
  71020. /**
  71021. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71022. */
  71023. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71024. /**
  71025. * The component name helpfull to identify the component in the list of scene components.
  71026. */
  71027. readonly name: string;
  71028. /**
  71029. * The scene the component belongs to.
  71030. */
  71031. scene: Scene;
  71032. /**
  71033. * Creates a new instance of the component for the given scene
  71034. * @param scene Defines the scene to register the component in
  71035. */
  71036. constructor(scene: Scene);
  71037. /**
  71038. * Registers the component in a given scene
  71039. */
  71040. register(): void;
  71041. /**
  71042. * Rebuilds the elements related to this component in case of
  71043. * context lost for instance.
  71044. */
  71045. rebuild(): void;
  71046. /**
  71047. * Disposes the component and the associated ressources
  71048. */
  71049. dispose(): void;
  71050. private _gatherRenderTargets;
  71051. }
  71052. }
  71053. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  71054. import { Nullable } from "babylonjs/types";
  71055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71056. import { Camera } from "babylonjs/Cameras/camera";
  71057. import { IDisposable } from "babylonjs/scene";
  71058. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  71059. import { Scene } from "babylonjs/scene";
  71060. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  71061. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  71062. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  71063. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  71064. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71065. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71066. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  71067. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71068. import { Animation } from "babylonjs/Animations/animation";
  71069. /**
  71070. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71071. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71072. */
  71073. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71074. private _scene;
  71075. private _camerasToBeAttached;
  71076. /**
  71077. * ID of the sharpen post process,
  71078. */
  71079. private readonly SharpenPostProcessId;
  71080. /**
  71081. * @ignore
  71082. * ID of the image processing post process;
  71083. */
  71084. readonly ImageProcessingPostProcessId: string;
  71085. /**
  71086. * @ignore
  71087. * ID of the Fast Approximate Anti-Aliasing post process;
  71088. */
  71089. readonly FxaaPostProcessId: string;
  71090. /**
  71091. * ID of the chromatic aberration post process,
  71092. */
  71093. private readonly ChromaticAberrationPostProcessId;
  71094. /**
  71095. * ID of the grain post process
  71096. */
  71097. private readonly GrainPostProcessId;
  71098. /**
  71099. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71100. */
  71101. sharpen: SharpenPostProcess;
  71102. private _sharpenEffect;
  71103. private bloom;
  71104. /**
  71105. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71106. */
  71107. depthOfField: DepthOfFieldEffect;
  71108. /**
  71109. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71110. */
  71111. fxaa: FxaaPostProcess;
  71112. /**
  71113. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71114. */
  71115. imageProcessing: ImageProcessingPostProcess;
  71116. /**
  71117. * Chromatic aberration post process which will shift rgb colors in the image
  71118. */
  71119. chromaticAberration: ChromaticAberrationPostProcess;
  71120. private _chromaticAberrationEffect;
  71121. /**
  71122. * Grain post process which add noise to the image
  71123. */
  71124. grain: GrainPostProcess;
  71125. private _grainEffect;
  71126. /**
  71127. * Glow post process which adds a glow to emissive areas of the image
  71128. */
  71129. private _glowLayer;
  71130. /**
  71131. * Animations which can be used to tweak settings over a period of time
  71132. */
  71133. animations: Animation[];
  71134. private _imageProcessingConfigurationObserver;
  71135. private _sharpenEnabled;
  71136. private _bloomEnabled;
  71137. private _depthOfFieldEnabled;
  71138. private _depthOfFieldBlurLevel;
  71139. private _fxaaEnabled;
  71140. private _imageProcessingEnabled;
  71141. private _defaultPipelineTextureType;
  71142. private _bloomScale;
  71143. private _chromaticAberrationEnabled;
  71144. private _grainEnabled;
  71145. private _buildAllowed;
  71146. /**
  71147. * Gets active scene
  71148. */
  71149. get scene(): Scene;
  71150. /**
  71151. * Enable or disable the sharpen process from the pipeline
  71152. */
  71153. set sharpenEnabled(enabled: boolean);
  71154. get sharpenEnabled(): boolean;
  71155. private _resizeObserver;
  71156. private _hardwareScaleLevel;
  71157. private _bloomKernel;
  71158. /**
  71159. * Specifies the size of the bloom blur kernel, relative to the final output size
  71160. */
  71161. get bloomKernel(): number;
  71162. set bloomKernel(value: number);
  71163. /**
  71164. * Specifies the weight of the bloom in the final rendering
  71165. */
  71166. private _bloomWeight;
  71167. /**
  71168. * Specifies the luma threshold for the area that will be blurred by the bloom
  71169. */
  71170. private _bloomThreshold;
  71171. private _hdr;
  71172. /**
  71173. * The strength of the bloom.
  71174. */
  71175. set bloomWeight(value: number);
  71176. get bloomWeight(): number;
  71177. /**
  71178. * The strength of the bloom.
  71179. */
  71180. set bloomThreshold(value: number);
  71181. get bloomThreshold(): number;
  71182. /**
  71183. * The scale of the bloom, lower value will provide better performance.
  71184. */
  71185. set bloomScale(value: number);
  71186. get bloomScale(): number;
  71187. /**
  71188. * Enable or disable the bloom from the pipeline
  71189. */
  71190. set bloomEnabled(enabled: boolean);
  71191. get bloomEnabled(): boolean;
  71192. private _rebuildBloom;
  71193. /**
  71194. * If the depth of field is enabled.
  71195. */
  71196. get depthOfFieldEnabled(): boolean;
  71197. set depthOfFieldEnabled(enabled: boolean);
  71198. /**
  71199. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71200. */
  71201. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71202. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71203. /**
  71204. * If the anti aliasing is enabled.
  71205. */
  71206. set fxaaEnabled(enabled: boolean);
  71207. get fxaaEnabled(): boolean;
  71208. private _samples;
  71209. /**
  71210. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71211. */
  71212. set samples(sampleCount: number);
  71213. get samples(): number;
  71214. /**
  71215. * If image processing is enabled.
  71216. */
  71217. set imageProcessingEnabled(enabled: boolean);
  71218. get imageProcessingEnabled(): boolean;
  71219. /**
  71220. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71221. */
  71222. set glowLayerEnabled(enabled: boolean);
  71223. get glowLayerEnabled(): boolean;
  71224. /**
  71225. * Gets the glow layer (or null if not defined)
  71226. */
  71227. get glowLayer(): Nullable<GlowLayer>;
  71228. /**
  71229. * Enable or disable the chromaticAberration process from the pipeline
  71230. */
  71231. set chromaticAberrationEnabled(enabled: boolean);
  71232. get chromaticAberrationEnabled(): boolean;
  71233. /**
  71234. * Enable or disable the grain process from the pipeline
  71235. */
  71236. set grainEnabled(enabled: boolean);
  71237. get grainEnabled(): boolean;
  71238. /**
  71239. * @constructor
  71240. * @param name - The rendering pipeline name (default: "")
  71241. * @param hdr - If high dynamic range textures should be used (default: true)
  71242. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71243. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71244. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71245. */
  71246. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71247. /**
  71248. * Get the class name
  71249. * @returns "DefaultRenderingPipeline"
  71250. */
  71251. getClassName(): string;
  71252. /**
  71253. * Force the compilation of the entire pipeline.
  71254. */
  71255. prepare(): void;
  71256. private _hasCleared;
  71257. private _prevPostProcess;
  71258. private _prevPrevPostProcess;
  71259. private _setAutoClearAndTextureSharing;
  71260. private _depthOfFieldSceneObserver;
  71261. private _buildPipeline;
  71262. private _disposePostProcesses;
  71263. /**
  71264. * Adds a camera to the pipeline
  71265. * @param camera the camera to be added
  71266. */
  71267. addCamera(camera: Camera): void;
  71268. /**
  71269. * Removes a camera from the pipeline
  71270. * @param camera the camera to remove
  71271. */
  71272. removeCamera(camera: Camera): void;
  71273. /**
  71274. * Dispose of the pipeline and stop all post processes
  71275. */
  71276. dispose(): void;
  71277. /**
  71278. * Serialize the rendering pipeline (Used when exporting)
  71279. * @returns the serialized object
  71280. */
  71281. serialize(): any;
  71282. /**
  71283. * Parse the serialized pipeline
  71284. * @param source Source pipeline.
  71285. * @param scene The scene to load the pipeline to.
  71286. * @param rootUrl The URL of the serialized pipeline.
  71287. * @returns An instantiated pipeline from the serialized object.
  71288. */
  71289. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71290. }
  71291. }
  71292. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  71293. /** @hidden */
  71294. export var lensHighlightsPixelShader: {
  71295. name: string;
  71296. shader: string;
  71297. };
  71298. }
  71299. declare module "babylonjs/Shaders/depthOfField.fragment" {
  71300. /** @hidden */
  71301. export var depthOfFieldPixelShader: {
  71302. name: string;
  71303. shader: string;
  71304. };
  71305. }
  71306. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  71307. import { Camera } from "babylonjs/Cameras/camera";
  71308. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71309. import { Scene } from "babylonjs/scene";
  71310. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71311. import "babylonjs/Shaders/chromaticAberration.fragment";
  71312. import "babylonjs/Shaders/lensHighlights.fragment";
  71313. import "babylonjs/Shaders/depthOfField.fragment";
  71314. /**
  71315. * BABYLON.JS Chromatic Aberration GLSL Shader
  71316. * Author: Olivier Guyot
  71317. * Separates very slightly R, G and B colors on the edges of the screen
  71318. * Inspired by Francois Tarlier & Martins Upitis
  71319. */
  71320. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71321. /**
  71322. * @ignore
  71323. * The chromatic aberration PostProcess id in the pipeline
  71324. */
  71325. LensChromaticAberrationEffect: string;
  71326. /**
  71327. * @ignore
  71328. * The highlights enhancing PostProcess id in the pipeline
  71329. */
  71330. HighlightsEnhancingEffect: string;
  71331. /**
  71332. * @ignore
  71333. * The depth-of-field PostProcess id in the pipeline
  71334. */
  71335. LensDepthOfFieldEffect: string;
  71336. private _scene;
  71337. private _depthTexture;
  71338. private _grainTexture;
  71339. private _chromaticAberrationPostProcess;
  71340. private _highlightsPostProcess;
  71341. private _depthOfFieldPostProcess;
  71342. private _edgeBlur;
  71343. private _grainAmount;
  71344. private _chromaticAberration;
  71345. private _distortion;
  71346. private _highlightsGain;
  71347. private _highlightsThreshold;
  71348. private _dofDistance;
  71349. private _dofAperture;
  71350. private _dofDarken;
  71351. private _dofPentagon;
  71352. private _blurNoise;
  71353. /**
  71354. * @constructor
  71355. *
  71356. * Effect parameters are as follow:
  71357. * {
  71358. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71359. * edge_blur: number; // from 0 to x (1 for realism)
  71360. * distortion: number; // from 0 to x (1 for realism)
  71361. * grain_amount: number; // from 0 to 1
  71362. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71363. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71364. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71365. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71366. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71367. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71368. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71369. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71370. * }
  71371. * Note: if an effect parameter is unset, effect is disabled
  71372. *
  71373. * @param name The rendering pipeline name
  71374. * @param parameters - An object containing all parameters (see above)
  71375. * @param scene The scene linked to this pipeline
  71376. * @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)
  71377. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71378. */
  71379. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71380. /**
  71381. * Get the class name
  71382. * @returns "LensRenderingPipeline"
  71383. */
  71384. getClassName(): string;
  71385. /**
  71386. * Gets associated scene
  71387. */
  71388. get scene(): Scene;
  71389. /**
  71390. * Gets or sets the edge blur
  71391. */
  71392. get edgeBlur(): number;
  71393. set edgeBlur(value: number);
  71394. /**
  71395. * Gets or sets the grain amount
  71396. */
  71397. get grainAmount(): number;
  71398. set grainAmount(value: number);
  71399. /**
  71400. * Gets or sets the chromatic aberration amount
  71401. */
  71402. get chromaticAberration(): number;
  71403. set chromaticAberration(value: number);
  71404. /**
  71405. * Gets or sets the depth of field aperture
  71406. */
  71407. get dofAperture(): number;
  71408. set dofAperture(value: number);
  71409. /**
  71410. * Gets or sets the edge distortion
  71411. */
  71412. get edgeDistortion(): number;
  71413. set edgeDistortion(value: number);
  71414. /**
  71415. * Gets or sets the depth of field distortion
  71416. */
  71417. get dofDistortion(): number;
  71418. set dofDistortion(value: number);
  71419. /**
  71420. * Gets or sets the darken out of focus amount
  71421. */
  71422. get darkenOutOfFocus(): number;
  71423. set darkenOutOfFocus(value: number);
  71424. /**
  71425. * Gets or sets a boolean indicating if blur noise is enabled
  71426. */
  71427. get blurNoise(): boolean;
  71428. set blurNoise(value: boolean);
  71429. /**
  71430. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71431. */
  71432. get pentagonBokeh(): boolean;
  71433. set pentagonBokeh(value: boolean);
  71434. /**
  71435. * Gets or sets the highlight grain amount
  71436. */
  71437. get highlightsGain(): number;
  71438. set highlightsGain(value: number);
  71439. /**
  71440. * Gets or sets the highlight threshold
  71441. */
  71442. get highlightsThreshold(): number;
  71443. set highlightsThreshold(value: number);
  71444. /**
  71445. * Sets the amount of blur at the edges
  71446. * @param amount blur amount
  71447. */
  71448. setEdgeBlur(amount: number): void;
  71449. /**
  71450. * Sets edge blur to 0
  71451. */
  71452. disableEdgeBlur(): void;
  71453. /**
  71454. * Sets the amout of grain
  71455. * @param amount Amount of grain
  71456. */
  71457. setGrainAmount(amount: number): void;
  71458. /**
  71459. * Set grain amount to 0
  71460. */
  71461. disableGrain(): void;
  71462. /**
  71463. * Sets the chromatic aberration amount
  71464. * @param amount amount of chromatic aberration
  71465. */
  71466. setChromaticAberration(amount: number): void;
  71467. /**
  71468. * Sets chromatic aberration amount to 0
  71469. */
  71470. disableChromaticAberration(): void;
  71471. /**
  71472. * Sets the EdgeDistortion amount
  71473. * @param amount amount of EdgeDistortion
  71474. */
  71475. setEdgeDistortion(amount: number): void;
  71476. /**
  71477. * Sets edge distortion to 0
  71478. */
  71479. disableEdgeDistortion(): void;
  71480. /**
  71481. * Sets the FocusDistance amount
  71482. * @param amount amount of FocusDistance
  71483. */
  71484. setFocusDistance(amount: number): void;
  71485. /**
  71486. * Disables depth of field
  71487. */
  71488. disableDepthOfField(): void;
  71489. /**
  71490. * Sets the Aperture amount
  71491. * @param amount amount of Aperture
  71492. */
  71493. setAperture(amount: number): void;
  71494. /**
  71495. * Sets the DarkenOutOfFocus amount
  71496. * @param amount amount of DarkenOutOfFocus
  71497. */
  71498. setDarkenOutOfFocus(amount: number): void;
  71499. private _pentagonBokehIsEnabled;
  71500. /**
  71501. * Creates a pentagon bokeh effect
  71502. */
  71503. enablePentagonBokeh(): void;
  71504. /**
  71505. * Disables the pentagon bokeh effect
  71506. */
  71507. disablePentagonBokeh(): void;
  71508. /**
  71509. * Enables noise blur
  71510. */
  71511. enableNoiseBlur(): void;
  71512. /**
  71513. * Disables noise blur
  71514. */
  71515. disableNoiseBlur(): void;
  71516. /**
  71517. * Sets the HighlightsGain amount
  71518. * @param amount amount of HighlightsGain
  71519. */
  71520. setHighlightsGain(amount: number): void;
  71521. /**
  71522. * Sets the HighlightsThreshold amount
  71523. * @param amount amount of HighlightsThreshold
  71524. */
  71525. setHighlightsThreshold(amount: number): void;
  71526. /**
  71527. * Disables highlights
  71528. */
  71529. disableHighlights(): void;
  71530. /**
  71531. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71532. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71533. */
  71534. dispose(disableDepthRender?: boolean): void;
  71535. private _createChromaticAberrationPostProcess;
  71536. private _createHighlightsPostProcess;
  71537. private _createDepthOfFieldPostProcess;
  71538. private _createGrainTexture;
  71539. }
  71540. }
  71541. declare module "babylonjs/Shaders/ssao2.fragment" {
  71542. /** @hidden */
  71543. export var ssao2PixelShader: {
  71544. name: string;
  71545. shader: string;
  71546. };
  71547. }
  71548. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  71549. /** @hidden */
  71550. export var ssaoCombinePixelShader: {
  71551. name: string;
  71552. shader: string;
  71553. };
  71554. }
  71555. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  71556. import { Camera } from "babylonjs/Cameras/camera";
  71557. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71558. import { Scene } from "babylonjs/scene";
  71559. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71560. import "babylonjs/Shaders/ssao2.fragment";
  71561. import "babylonjs/Shaders/ssaoCombine.fragment";
  71562. /**
  71563. * Render pipeline to produce ssao effect
  71564. */
  71565. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71566. /**
  71567. * @ignore
  71568. * The PassPostProcess id in the pipeline that contains the original scene color
  71569. */
  71570. SSAOOriginalSceneColorEffect: string;
  71571. /**
  71572. * @ignore
  71573. * The SSAO PostProcess id in the pipeline
  71574. */
  71575. SSAORenderEffect: string;
  71576. /**
  71577. * @ignore
  71578. * The horizontal blur PostProcess id in the pipeline
  71579. */
  71580. SSAOBlurHRenderEffect: string;
  71581. /**
  71582. * @ignore
  71583. * The vertical blur PostProcess id in the pipeline
  71584. */
  71585. SSAOBlurVRenderEffect: string;
  71586. /**
  71587. * @ignore
  71588. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71589. */
  71590. SSAOCombineRenderEffect: string;
  71591. /**
  71592. * The output strength of the SSAO post-process. Default value is 1.0.
  71593. */
  71594. totalStrength: number;
  71595. /**
  71596. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71597. */
  71598. maxZ: number;
  71599. /**
  71600. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71601. */
  71602. minZAspect: number;
  71603. private _samples;
  71604. /**
  71605. * Number of samples used for the SSAO calculations. Default value is 8
  71606. */
  71607. set samples(n: number);
  71608. get samples(): number;
  71609. private _textureSamples;
  71610. /**
  71611. * Number of samples to use for antialiasing
  71612. */
  71613. set textureSamples(n: number);
  71614. get textureSamples(): number;
  71615. /**
  71616. * Ratio object used for SSAO ratio and blur ratio
  71617. */
  71618. private _ratio;
  71619. /**
  71620. * Dynamically generated sphere sampler.
  71621. */
  71622. private _sampleSphere;
  71623. /**
  71624. * Blur filter offsets
  71625. */
  71626. private _samplerOffsets;
  71627. private _expensiveBlur;
  71628. /**
  71629. * If bilateral blur should be used
  71630. */
  71631. set expensiveBlur(b: boolean);
  71632. get expensiveBlur(): boolean;
  71633. /**
  71634. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71635. */
  71636. radius: number;
  71637. /**
  71638. * The base color of the SSAO post-process
  71639. * The final result is "base + ssao" between [0, 1]
  71640. */
  71641. base: number;
  71642. /**
  71643. * Support test.
  71644. */
  71645. static get IsSupported(): boolean;
  71646. private _scene;
  71647. private _depthTexture;
  71648. private _normalTexture;
  71649. private _randomTexture;
  71650. private _originalColorPostProcess;
  71651. private _ssaoPostProcess;
  71652. private _blurHPostProcess;
  71653. private _blurVPostProcess;
  71654. private _ssaoCombinePostProcess;
  71655. /**
  71656. * Gets active scene
  71657. */
  71658. get scene(): Scene;
  71659. /**
  71660. * @constructor
  71661. * @param name The rendering pipeline name
  71662. * @param scene The scene linked to this pipeline
  71663. * @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 }
  71664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71665. */
  71666. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71667. /**
  71668. * Get the class name
  71669. * @returns "SSAO2RenderingPipeline"
  71670. */
  71671. getClassName(): string;
  71672. /**
  71673. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71674. */
  71675. dispose(disableGeometryBufferRenderer?: boolean): void;
  71676. private _createBlurPostProcess;
  71677. /** @hidden */
  71678. _rebuild(): void;
  71679. private _bits;
  71680. private _radicalInverse_VdC;
  71681. private _hammersley;
  71682. private _hemisphereSample_uniform;
  71683. private _generateHemisphere;
  71684. private _createSSAOPostProcess;
  71685. private _createSSAOCombinePostProcess;
  71686. private _createRandomTexture;
  71687. /**
  71688. * Serialize the rendering pipeline (Used when exporting)
  71689. * @returns the serialized object
  71690. */
  71691. serialize(): any;
  71692. /**
  71693. * Parse the serialized pipeline
  71694. * @param source Source pipeline.
  71695. * @param scene The scene to load the pipeline to.
  71696. * @param rootUrl The URL of the serialized pipeline.
  71697. * @returns An instantiated pipeline from the serialized object.
  71698. */
  71699. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71700. }
  71701. }
  71702. declare module "babylonjs/Shaders/ssao.fragment" {
  71703. /** @hidden */
  71704. export var ssaoPixelShader: {
  71705. name: string;
  71706. shader: string;
  71707. };
  71708. }
  71709. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  71710. import { Camera } from "babylonjs/Cameras/camera";
  71711. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71712. import { Scene } from "babylonjs/scene";
  71713. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71714. import "babylonjs/Shaders/ssao.fragment";
  71715. import "babylonjs/Shaders/ssaoCombine.fragment";
  71716. /**
  71717. * Render pipeline to produce ssao effect
  71718. */
  71719. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71720. /**
  71721. * @ignore
  71722. * The PassPostProcess id in the pipeline that contains the original scene color
  71723. */
  71724. SSAOOriginalSceneColorEffect: string;
  71725. /**
  71726. * @ignore
  71727. * The SSAO PostProcess id in the pipeline
  71728. */
  71729. SSAORenderEffect: string;
  71730. /**
  71731. * @ignore
  71732. * The horizontal blur PostProcess id in the pipeline
  71733. */
  71734. SSAOBlurHRenderEffect: string;
  71735. /**
  71736. * @ignore
  71737. * The vertical blur PostProcess id in the pipeline
  71738. */
  71739. SSAOBlurVRenderEffect: string;
  71740. /**
  71741. * @ignore
  71742. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71743. */
  71744. SSAOCombineRenderEffect: string;
  71745. /**
  71746. * The output strength of the SSAO post-process. Default value is 1.0.
  71747. */
  71748. totalStrength: number;
  71749. /**
  71750. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71751. */
  71752. radius: number;
  71753. /**
  71754. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71755. * Must not be equal to fallOff and superior to fallOff.
  71756. * Default value is 0.0075
  71757. */
  71758. area: number;
  71759. /**
  71760. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71761. * Must not be equal to area and inferior to area.
  71762. * Default value is 0.000001
  71763. */
  71764. fallOff: number;
  71765. /**
  71766. * The base color of the SSAO post-process
  71767. * The final result is "base + ssao" between [0, 1]
  71768. */
  71769. base: number;
  71770. private _scene;
  71771. private _depthTexture;
  71772. private _randomTexture;
  71773. private _originalColorPostProcess;
  71774. private _ssaoPostProcess;
  71775. private _blurHPostProcess;
  71776. private _blurVPostProcess;
  71777. private _ssaoCombinePostProcess;
  71778. private _firstUpdate;
  71779. /**
  71780. * Gets active scene
  71781. */
  71782. get scene(): Scene;
  71783. /**
  71784. * @constructor
  71785. * @param name - The rendering pipeline name
  71786. * @param scene - The scene linked to this pipeline
  71787. * @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 }
  71788. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71789. */
  71790. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71791. /**
  71792. * Get the class name
  71793. * @returns "SSAORenderingPipeline"
  71794. */
  71795. getClassName(): string;
  71796. /**
  71797. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71798. */
  71799. dispose(disableDepthRender?: boolean): void;
  71800. private _createBlurPostProcess;
  71801. /** @hidden */
  71802. _rebuild(): void;
  71803. private _createSSAOPostProcess;
  71804. private _createSSAOCombinePostProcess;
  71805. private _createRandomTexture;
  71806. }
  71807. }
  71808. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  71809. /** @hidden */
  71810. export var screenSpaceReflectionPixelShader: {
  71811. name: string;
  71812. shader: string;
  71813. };
  71814. }
  71815. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  71816. import { Nullable } from "babylonjs/types";
  71817. import { Camera } from "babylonjs/Cameras/camera";
  71818. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71819. import { Scene } from "babylonjs/scene";
  71820. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  71821. import { Engine } from "babylonjs/Engines/engine";
  71822. /**
  71823. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71824. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71825. */
  71826. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71827. /**
  71828. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71829. */
  71830. threshold: number;
  71831. /**
  71832. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71833. */
  71834. strength: number;
  71835. /**
  71836. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71837. */
  71838. reflectionSpecularFalloffExponent: number;
  71839. /**
  71840. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  71841. */
  71842. step: number;
  71843. /**
  71844. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71845. */
  71846. roughnessFactor: number;
  71847. private _geometryBufferRenderer;
  71848. private _enableSmoothReflections;
  71849. private _reflectionSamples;
  71850. private _smoothSteps;
  71851. /**
  71852. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71853. * @param name The name of the effect.
  71854. * @param scene The scene containing the objects to calculate reflections.
  71855. * @param options The required width/height ratio to downsize to before computing the render pass.
  71856. * @param camera The camera to apply the render pass to.
  71857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71858. * @param engine The engine which the post process will be applied. (default: current engine)
  71859. * @param reusable If the post process can be reused on the same frame. (default: false)
  71860. * @param textureType Type of textures used when performing the post process. (default: 0)
  71861. * @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)
  71862. */
  71863. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71864. /**
  71865. * Gets wether or not smoothing reflections is enabled.
  71866. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71867. */
  71868. get enableSmoothReflections(): boolean;
  71869. /**
  71870. * Sets wether or not smoothing reflections is enabled.
  71871. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71872. */
  71873. set enableSmoothReflections(enabled: boolean);
  71874. /**
  71875. * Gets the number of samples taken while computing reflections. More samples count is high,
  71876. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71877. */
  71878. get reflectionSamples(): number;
  71879. /**
  71880. * Sets the number of samples taken while computing reflections. More samples count is high,
  71881. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71882. */
  71883. set reflectionSamples(samples: number);
  71884. /**
  71885. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71886. * more the post-process will require GPU power and can generate a drop in FPS.
  71887. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71888. */
  71889. get smoothSteps(): number;
  71890. set smoothSteps(steps: number);
  71891. private _updateEffectDefines;
  71892. }
  71893. }
  71894. declare module "babylonjs/Shaders/standard.fragment" {
  71895. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  71896. /** @hidden */
  71897. export var standardPixelShader: {
  71898. name: string;
  71899. shader: string;
  71900. };
  71901. }
  71902. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  71903. import { Nullable } from "babylonjs/types";
  71904. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71905. import { Camera } from "babylonjs/Cameras/camera";
  71906. import { Texture } from "babylonjs/Materials/Textures/texture";
  71907. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71908. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71909. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71910. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71911. import { IDisposable } from "babylonjs/scene";
  71912. import { SpotLight } from "babylonjs/Lights/spotLight";
  71913. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  71914. import { Scene } from "babylonjs/scene";
  71915. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71916. import { Animation } from "babylonjs/Animations/animation";
  71917. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71918. import "babylonjs/Shaders/standard.fragment";
  71919. /**
  71920. * Standard rendering pipeline
  71921. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71922. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71923. */
  71924. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71925. /**
  71926. * Public members
  71927. */
  71928. /**
  71929. * Post-process which contains the original scene color before the pipeline applies all the effects
  71930. */
  71931. originalPostProcess: Nullable<PostProcess>;
  71932. /**
  71933. * Post-process used to down scale an image x4
  71934. */
  71935. downSampleX4PostProcess: Nullable<PostProcess>;
  71936. /**
  71937. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71938. */
  71939. brightPassPostProcess: Nullable<PostProcess>;
  71940. /**
  71941. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71942. */
  71943. blurHPostProcesses: PostProcess[];
  71944. /**
  71945. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71946. */
  71947. blurVPostProcesses: PostProcess[];
  71948. /**
  71949. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71950. */
  71951. textureAdderPostProcess: Nullable<PostProcess>;
  71952. /**
  71953. * Post-process used to create volumetric lighting effect
  71954. */
  71955. volumetricLightPostProcess: Nullable<PostProcess>;
  71956. /**
  71957. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71958. */
  71959. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71960. /**
  71961. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71962. */
  71963. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71964. /**
  71965. * Post-process used to merge the volumetric light effect and the real scene color
  71966. */
  71967. volumetricLightMergePostProces: Nullable<PostProcess>;
  71968. /**
  71969. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71970. */
  71971. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71972. /**
  71973. * Base post-process used to calculate the average luminance of the final image for HDR
  71974. */
  71975. luminancePostProcess: Nullable<PostProcess>;
  71976. /**
  71977. * Post-processes used to create down sample post-processes in order to get
  71978. * the average luminance of the final image for HDR
  71979. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71980. */
  71981. luminanceDownSamplePostProcesses: PostProcess[];
  71982. /**
  71983. * Post-process used to create a HDR effect (light adaptation)
  71984. */
  71985. hdrPostProcess: Nullable<PostProcess>;
  71986. /**
  71987. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71988. */
  71989. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71990. /**
  71991. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71992. */
  71993. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71994. /**
  71995. * Post-process used to merge the final HDR post-process and the real scene color
  71996. */
  71997. hdrFinalPostProcess: Nullable<PostProcess>;
  71998. /**
  71999. * Post-process used to create a lens flare effect
  72000. */
  72001. lensFlarePostProcess: Nullable<PostProcess>;
  72002. /**
  72003. * Post-process that merges the result of the lens flare post-process and the real scene color
  72004. */
  72005. lensFlareComposePostProcess: Nullable<PostProcess>;
  72006. /**
  72007. * Post-process used to create a motion blur effect
  72008. */
  72009. motionBlurPostProcess: Nullable<PostProcess>;
  72010. /**
  72011. * Post-process used to create a depth of field effect
  72012. */
  72013. depthOfFieldPostProcess: Nullable<PostProcess>;
  72014. /**
  72015. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72016. */
  72017. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72018. /**
  72019. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72020. */
  72021. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72022. /**
  72023. * Represents the brightness threshold in order to configure the illuminated surfaces
  72024. */
  72025. brightThreshold: number;
  72026. /**
  72027. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72028. */
  72029. blurWidth: number;
  72030. /**
  72031. * Sets if the blur for highlighted surfaces must be only horizontal
  72032. */
  72033. horizontalBlur: boolean;
  72034. /**
  72035. * Gets the overall exposure used by the pipeline
  72036. */
  72037. get exposure(): number;
  72038. /**
  72039. * Sets the overall exposure used by the pipeline
  72040. */
  72041. set exposure(value: number);
  72042. /**
  72043. * Texture used typically to simulate "dirty" on camera lens
  72044. */
  72045. lensTexture: Nullable<Texture>;
  72046. /**
  72047. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72048. */
  72049. volumetricLightCoefficient: number;
  72050. /**
  72051. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72052. */
  72053. volumetricLightPower: number;
  72054. /**
  72055. * Used the set the blur intensity to smooth the volumetric lights
  72056. */
  72057. volumetricLightBlurScale: number;
  72058. /**
  72059. * Light (spot or directional) used to generate the volumetric lights rays
  72060. * The source light must have a shadow generate so the pipeline can get its
  72061. * depth map
  72062. */
  72063. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72064. /**
  72065. * For eye adaptation, represents the minimum luminance the eye can see
  72066. */
  72067. hdrMinimumLuminance: number;
  72068. /**
  72069. * For eye adaptation, represents the decrease luminance speed
  72070. */
  72071. hdrDecreaseRate: number;
  72072. /**
  72073. * For eye adaptation, represents the increase luminance speed
  72074. */
  72075. hdrIncreaseRate: number;
  72076. /**
  72077. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72078. */
  72079. get hdrAutoExposure(): boolean;
  72080. /**
  72081. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72082. */
  72083. set hdrAutoExposure(value: boolean);
  72084. /**
  72085. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72086. */
  72087. lensColorTexture: Nullable<Texture>;
  72088. /**
  72089. * The overall strengh for the lens flare effect
  72090. */
  72091. lensFlareStrength: number;
  72092. /**
  72093. * Dispersion coefficient for lens flare ghosts
  72094. */
  72095. lensFlareGhostDispersal: number;
  72096. /**
  72097. * Main lens flare halo width
  72098. */
  72099. lensFlareHaloWidth: number;
  72100. /**
  72101. * Based on the lens distortion effect, defines how much the lens flare result
  72102. * is distorted
  72103. */
  72104. lensFlareDistortionStrength: number;
  72105. /**
  72106. * Configures the blur intensity used for for lens flare (halo)
  72107. */
  72108. lensFlareBlurWidth: number;
  72109. /**
  72110. * Lens star texture must be used to simulate rays on the flares and is available
  72111. * in the documentation
  72112. */
  72113. lensStarTexture: Nullable<Texture>;
  72114. /**
  72115. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72116. * flare effect by taking account of the dirt texture
  72117. */
  72118. lensFlareDirtTexture: Nullable<Texture>;
  72119. /**
  72120. * Represents the focal length for the depth of field effect
  72121. */
  72122. depthOfFieldDistance: number;
  72123. /**
  72124. * Represents the blur intensity for the blurred part of the depth of field effect
  72125. */
  72126. depthOfFieldBlurWidth: number;
  72127. /**
  72128. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72129. */
  72130. get motionStrength(): number;
  72131. /**
  72132. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72133. */
  72134. set motionStrength(strength: number);
  72135. /**
  72136. * Gets wether or not the motion blur post-process is object based or screen based.
  72137. */
  72138. get objectBasedMotionBlur(): boolean;
  72139. /**
  72140. * Sets wether or not the motion blur post-process should be object based or screen based
  72141. */
  72142. set objectBasedMotionBlur(value: boolean);
  72143. /**
  72144. * List of animations for the pipeline (IAnimatable implementation)
  72145. */
  72146. animations: Animation[];
  72147. /**
  72148. * Private members
  72149. */
  72150. private _scene;
  72151. private _currentDepthOfFieldSource;
  72152. private _basePostProcess;
  72153. private _fixedExposure;
  72154. private _currentExposure;
  72155. private _hdrAutoExposure;
  72156. private _hdrCurrentLuminance;
  72157. private _motionStrength;
  72158. private _isObjectBasedMotionBlur;
  72159. private _floatTextureType;
  72160. private _camerasToBeAttached;
  72161. private _ratio;
  72162. private _bloomEnabled;
  72163. private _depthOfFieldEnabled;
  72164. private _vlsEnabled;
  72165. private _lensFlareEnabled;
  72166. private _hdrEnabled;
  72167. private _motionBlurEnabled;
  72168. private _fxaaEnabled;
  72169. private _screenSpaceReflectionsEnabled;
  72170. private _motionBlurSamples;
  72171. private _volumetricLightStepsCount;
  72172. private _samples;
  72173. /**
  72174. * @ignore
  72175. * Specifies if the bloom pipeline is enabled
  72176. */
  72177. get BloomEnabled(): boolean;
  72178. set BloomEnabled(enabled: boolean);
  72179. /**
  72180. * @ignore
  72181. * Specifies if the depth of field pipeline is enabed
  72182. */
  72183. get DepthOfFieldEnabled(): boolean;
  72184. set DepthOfFieldEnabled(enabled: boolean);
  72185. /**
  72186. * @ignore
  72187. * Specifies if the lens flare pipeline is enabed
  72188. */
  72189. get LensFlareEnabled(): boolean;
  72190. set LensFlareEnabled(enabled: boolean);
  72191. /**
  72192. * @ignore
  72193. * Specifies if the HDR pipeline is enabled
  72194. */
  72195. get HDREnabled(): boolean;
  72196. set HDREnabled(enabled: boolean);
  72197. /**
  72198. * @ignore
  72199. * Specifies if the volumetric lights scattering effect is enabled
  72200. */
  72201. get VLSEnabled(): boolean;
  72202. set VLSEnabled(enabled: boolean);
  72203. /**
  72204. * @ignore
  72205. * Specifies if the motion blur effect is enabled
  72206. */
  72207. get MotionBlurEnabled(): boolean;
  72208. set MotionBlurEnabled(enabled: boolean);
  72209. /**
  72210. * Specifies if anti-aliasing is enabled
  72211. */
  72212. get fxaaEnabled(): boolean;
  72213. set fxaaEnabled(enabled: boolean);
  72214. /**
  72215. * Specifies if screen space reflections are enabled.
  72216. */
  72217. get screenSpaceReflectionsEnabled(): boolean;
  72218. set screenSpaceReflectionsEnabled(enabled: boolean);
  72219. /**
  72220. * Specifies the number of steps used to calculate the volumetric lights
  72221. * Typically in interval [50, 200]
  72222. */
  72223. get volumetricLightStepsCount(): number;
  72224. set volumetricLightStepsCount(count: number);
  72225. /**
  72226. * Specifies the number of samples used for the motion blur effect
  72227. * Typically in interval [16, 64]
  72228. */
  72229. get motionBlurSamples(): number;
  72230. set motionBlurSamples(samples: number);
  72231. /**
  72232. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72233. */
  72234. get samples(): number;
  72235. set samples(sampleCount: number);
  72236. /**
  72237. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72238. * @constructor
  72239. * @param name The rendering pipeline name
  72240. * @param scene The scene linked to this pipeline
  72241. * @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)
  72242. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72243. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72244. */
  72245. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72246. private _buildPipeline;
  72247. private _createDownSampleX4PostProcess;
  72248. private _createBrightPassPostProcess;
  72249. private _createBlurPostProcesses;
  72250. private _createTextureAdderPostProcess;
  72251. private _createVolumetricLightPostProcess;
  72252. private _createLuminancePostProcesses;
  72253. private _createHdrPostProcess;
  72254. private _createLensFlarePostProcess;
  72255. private _createDepthOfFieldPostProcess;
  72256. private _createMotionBlurPostProcess;
  72257. private _getDepthTexture;
  72258. private _disposePostProcesses;
  72259. /**
  72260. * Dispose of the pipeline and stop all post processes
  72261. */
  72262. dispose(): void;
  72263. /**
  72264. * Serialize the rendering pipeline (Used when exporting)
  72265. * @returns the serialized object
  72266. */
  72267. serialize(): any;
  72268. /**
  72269. * Parse the serialized pipeline
  72270. * @param source Source pipeline.
  72271. * @param scene The scene to load the pipeline to.
  72272. * @param rootUrl The URL of the serialized pipeline.
  72273. * @returns An instantiated pipeline from the serialized object.
  72274. */
  72275. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72276. /**
  72277. * Luminance steps
  72278. */
  72279. static LuminanceSteps: number;
  72280. }
  72281. }
  72282. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  72283. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  72284. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  72285. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  72286. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  72287. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  72288. }
  72289. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  72290. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  72291. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72292. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72293. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72294. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72295. }
  72296. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  72297. /** @hidden */
  72298. export var stereoscopicInterlacePixelShader: {
  72299. name: string;
  72300. shader: string;
  72301. };
  72302. }
  72303. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  72304. import { Camera } from "babylonjs/Cameras/camera";
  72305. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72306. import { Engine } from "babylonjs/Engines/engine";
  72307. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  72308. /**
  72309. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72310. */
  72311. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72312. private _stepSize;
  72313. private _passedProcess;
  72314. /**
  72315. * Initializes a StereoscopicInterlacePostProcessI
  72316. * @param name The name of the effect.
  72317. * @param rigCameras The rig cameras to be appled to the post process
  72318. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72319. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72321. * @param engine The engine which the post process will be applied. (default: current engine)
  72322. * @param reusable If the post process can be reused on the same frame. (default: false)
  72323. */
  72324. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72325. }
  72326. /**
  72327. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72328. */
  72329. export class StereoscopicInterlacePostProcess extends PostProcess {
  72330. private _stepSize;
  72331. private _passedProcess;
  72332. /**
  72333. * Initializes a StereoscopicInterlacePostProcess
  72334. * @param name The name of the effect.
  72335. * @param rigCameras The rig cameras to be appled to the post process
  72336. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72338. * @param engine The engine which the post process will be applied. (default: current engine)
  72339. * @param reusable If the post process can be reused on the same frame. (default: false)
  72340. */
  72341. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72342. }
  72343. }
  72344. declare module "babylonjs/Shaders/tonemap.fragment" {
  72345. /** @hidden */
  72346. export var tonemapPixelShader: {
  72347. name: string;
  72348. shader: string;
  72349. };
  72350. }
  72351. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  72352. import { Camera } from "babylonjs/Cameras/camera";
  72353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72354. import "babylonjs/Shaders/tonemap.fragment";
  72355. import { Engine } from "babylonjs/Engines/engine";
  72356. /** Defines operator used for tonemapping */
  72357. export enum TonemappingOperator {
  72358. /** Hable */
  72359. Hable = 0,
  72360. /** Reinhard */
  72361. Reinhard = 1,
  72362. /** HejiDawson */
  72363. HejiDawson = 2,
  72364. /** Photographic */
  72365. Photographic = 3
  72366. }
  72367. /**
  72368. * Defines a post process to apply tone mapping
  72369. */
  72370. export class TonemapPostProcess extends PostProcess {
  72371. private _operator;
  72372. /** Defines the required exposure adjustement */
  72373. exposureAdjustment: number;
  72374. /**
  72375. * Creates a new TonemapPostProcess
  72376. * @param name defines the name of the postprocess
  72377. * @param _operator defines the operator to use
  72378. * @param exposureAdjustment defines the required exposure adjustement
  72379. * @param camera defines the camera to use (can be null)
  72380. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72381. * @param engine defines the hosting engine (can be ignore if camera is set)
  72382. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72383. */
  72384. constructor(name: string, _operator: TonemappingOperator,
  72385. /** Defines the required exposure adjustement */
  72386. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72387. }
  72388. }
  72389. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  72390. /** @hidden */
  72391. export var volumetricLightScatteringPixelShader: {
  72392. name: string;
  72393. shader: string;
  72394. };
  72395. }
  72396. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  72397. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72399. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72400. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72402. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72403. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72404. /** @hidden */
  72405. export var volumetricLightScatteringPassVertexShader: {
  72406. name: string;
  72407. shader: string;
  72408. };
  72409. }
  72410. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  72411. /** @hidden */
  72412. export var volumetricLightScatteringPassPixelShader: {
  72413. name: string;
  72414. shader: string;
  72415. };
  72416. }
  72417. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  72418. import { Vector3 } from "babylonjs/Maths/math.vector";
  72419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72420. import { Mesh } from "babylonjs/Meshes/mesh";
  72421. import { Camera } from "babylonjs/Cameras/camera";
  72422. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72424. import { Scene } from "babylonjs/scene";
  72425. import "babylonjs/Meshes/Builders/planeBuilder";
  72426. import "babylonjs/Shaders/depth.vertex";
  72427. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  72428. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  72429. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  72430. import { Engine } from "babylonjs/Engines/engine";
  72431. /**
  72432. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72433. */
  72434. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72435. private _volumetricLightScatteringPass;
  72436. private _volumetricLightScatteringRTT;
  72437. private _viewPort;
  72438. private _screenCoordinates;
  72439. private _cachedDefines;
  72440. /**
  72441. * If not undefined, the mesh position is computed from the attached node position
  72442. */
  72443. attachedNode: {
  72444. position: Vector3;
  72445. };
  72446. /**
  72447. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72448. */
  72449. customMeshPosition: Vector3;
  72450. /**
  72451. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72452. */
  72453. useCustomMeshPosition: boolean;
  72454. /**
  72455. * If the post-process should inverse the light scattering direction
  72456. */
  72457. invert: boolean;
  72458. /**
  72459. * The internal mesh used by the post-process
  72460. */
  72461. mesh: Mesh;
  72462. /**
  72463. * @hidden
  72464. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72465. */
  72466. get useDiffuseColor(): boolean;
  72467. set useDiffuseColor(useDiffuseColor: boolean);
  72468. /**
  72469. * Array containing the excluded meshes not rendered in the internal pass
  72470. */
  72471. excludedMeshes: AbstractMesh[];
  72472. /**
  72473. * Controls the overall intensity of the post-process
  72474. */
  72475. exposure: number;
  72476. /**
  72477. * Dissipates each sample's contribution in range [0, 1]
  72478. */
  72479. decay: number;
  72480. /**
  72481. * Controls the overall intensity of each sample
  72482. */
  72483. weight: number;
  72484. /**
  72485. * Controls the density of each sample
  72486. */
  72487. density: number;
  72488. /**
  72489. * @constructor
  72490. * @param name The post-process name
  72491. * @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)
  72492. * @param camera The camera that the post-process will be attached to
  72493. * @param mesh The mesh used to create the light scattering
  72494. * @param samples The post-process quality, default 100
  72495. * @param samplingModeThe post-process filtering mode
  72496. * @param engine The babylon engine
  72497. * @param reusable If the post-process is reusable
  72498. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72499. */
  72500. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72501. /**
  72502. * Returns the string "VolumetricLightScatteringPostProcess"
  72503. * @returns "VolumetricLightScatteringPostProcess"
  72504. */
  72505. getClassName(): string;
  72506. private _isReady;
  72507. /**
  72508. * Sets the new light position for light scattering effect
  72509. * @param position The new custom light position
  72510. */
  72511. setCustomMeshPosition(position: Vector3): void;
  72512. /**
  72513. * Returns the light position for light scattering effect
  72514. * @return Vector3 The custom light position
  72515. */
  72516. getCustomMeshPosition(): Vector3;
  72517. /**
  72518. * Disposes the internal assets and detaches the post-process from the camera
  72519. */
  72520. dispose(camera: Camera): void;
  72521. /**
  72522. * Returns the render target texture used by the post-process
  72523. * @return the render target texture used by the post-process
  72524. */
  72525. getPass(): RenderTargetTexture;
  72526. private _meshExcluded;
  72527. private _createPass;
  72528. private _updateMeshScreenCoordinates;
  72529. /**
  72530. * Creates a default mesh for the Volumeric Light Scattering post-process
  72531. * @param name The mesh name
  72532. * @param scene The scene where to create the mesh
  72533. * @return the default mesh
  72534. */
  72535. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72536. }
  72537. }
  72538. declare module "babylonjs/PostProcesses/index" {
  72539. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  72540. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  72541. export * from "babylonjs/PostProcesses/bloomEffect";
  72542. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  72543. export * from "babylonjs/PostProcesses/blurPostProcess";
  72544. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72545. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  72546. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  72547. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  72548. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72549. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  72550. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  72551. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  72552. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72553. export * from "babylonjs/PostProcesses/filterPostProcess";
  72554. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  72555. export * from "babylonjs/PostProcesses/grainPostProcess";
  72556. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  72557. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72558. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  72559. export * from "babylonjs/PostProcesses/passPostProcess";
  72560. export * from "babylonjs/PostProcesses/postProcess";
  72561. export * from "babylonjs/PostProcesses/postProcessManager";
  72562. export * from "babylonjs/PostProcesses/refractionPostProcess";
  72563. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  72564. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  72565. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  72566. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  72567. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  72568. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  72569. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  72570. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72571. }
  72572. declare module "babylonjs/Probes/index" {
  72573. export * from "babylonjs/Probes/reflectionProbe";
  72574. }
  72575. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  72576. import { Scene } from "babylonjs/scene";
  72577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72578. import { SmartArray } from "babylonjs/Misc/smartArray";
  72579. import { ISceneComponent } from "babylonjs/sceneComponent";
  72580. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  72581. import "babylonjs/Meshes/Builders/boxBuilder";
  72582. import "babylonjs/Shaders/color.fragment";
  72583. import "babylonjs/Shaders/color.vertex";
  72584. import { Color3 } from "babylonjs/Maths/math.color";
  72585. module "babylonjs/scene" {
  72586. interface Scene {
  72587. /** @hidden (Backing field) */
  72588. _boundingBoxRenderer: BoundingBoxRenderer;
  72589. /** @hidden (Backing field) */
  72590. _forceShowBoundingBoxes: boolean;
  72591. /**
  72592. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72593. */
  72594. forceShowBoundingBoxes: boolean;
  72595. /**
  72596. * Gets the bounding box renderer associated with the scene
  72597. * @returns a BoundingBoxRenderer
  72598. */
  72599. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72600. }
  72601. }
  72602. module "babylonjs/Meshes/abstractMesh" {
  72603. interface AbstractMesh {
  72604. /** @hidden (Backing field) */
  72605. _showBoundingBox: boolean;
  72606. /**
  72607. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72608. */
  72609. showBoundingBox: boolean;
  72610. }
  72611. }
  72612. /**
  72613. * Component responsible of rendering the bounding box of the meshes in a scene.
  72614. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72615. */
  72616. export class BoundingBoxRenderer implements ISceneComponent {
  72617. /**
  72618. * The component name helpfull to identify the component in the list of scene components.
  72619. */
  72620. readonly name: string;
  72621. /**
  72622. * The scene the component belongs to.
  72623. */
  72624. scene: Scene;
  72625. /**
  72626. * Color of the bounding box lines placed in front of an object
  72627. */
  72628. frontColor: Color3;
  72629. /**
  72630. * Color of the bounding box lines placed behind an object
  72631. */
  72632. backColor: Color3;
  72633. /**
  72634. * Defines if the renderer should show the back lines or not
  72635. */
  72636. showBackLines: boolean;
  72637. /**
  72638. * @hidden
  72639. */
  72640. renderList: SmartArray<BoundingBox>;
  72641. private _colorShader;
  72642. private _vertexBuffers;
  72643. private _indexBuffer;
  72644. private _fillIndexBuffer;
  72645. private _fillIndexData;
  72646. /**
  72647. * Instantiates a new bounding box renderer in a scene.
  72648. * @param scene the scene the renderer renders in
  72649. */
  72650. constructor(scene: Scene);
  72651. /**
  72652. * Registers the component in a given scene
  72653. */
  72654. register(): void;
  72655. private _evaluateSubMesh;
  72656. private _activeMesh;
  72657. private _prepareRessources;
  72658. private _createIndexBuffer;
  72659. /**
  72660. * Rebuilds the elements related to this component in case of
  72661. * context lost for instance.
  72662. */
  72663. rebuild(): void;
  72664. /**
  72665. * @hidden
  72666. */
  72667. reset(): void;
  72668. /**
  72669. * Render the bounding boxes of a specific rendering group
  72670. * @param renderingGroupId defines the rendering group to render
  72671. */
  72672. render(renderingGroupId: number): void;
  72673. /**
  72674. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72675. * @param mesh Define the mesh to render the occlusion bounding box for
  72676. */
  72677. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72678. /**
  72679. * Dispose and release the resources attached to this renderer.
  72680. */
  72681. dispose(): void;
  72682. }
  72683. }
  72684. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  72685. import { Nullable } from "babylonjs/types";
  72686. import { Scene } from "babylonjs/scene";
  72687. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  72688. import { Camera } from "babylonjs/Cameras/camera";
  72689. import { ISceneComponent } from "babylonjs/sceneComponent";
  72690. module "babylonjs/scene" {
  72691. interface Scene {
  72692. /** @hidden (Backing field) */
  72693. _depthRenderer: {
  72694. [id: string]: DepthRenderer;
  72695. };
  72696. /**
  72697. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72698. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72699. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72700. * @returns the created depth renderer
  72701. */
  72702. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72703. /**
  72704. * Disables a depth renderer for a given camera
  72705. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72706. */
  72707. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72708. }
  72709. }
  72710. /**
  72711. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72712. * in several rendering techniques.
  72713. */
  72714. export class DepthRendererSceneComponent implements ISceneComponent {
  72715. /**
  72716. * The component name helpfull to identify the component in the list of scene components.
  72717. */
  72718. readonly name: string;
  72719. /**
  72720. * The scene the component belongs to.
  72721. */
  72722. scene: Scene;
  72723. /**
  72724. * Creates a new instance of the component for the given scene
  72725. * @param scene Defines the scene to register the component in
  72726. */
  72727. constructor(scene: Scene);
  72728. /**
  72729. * Registers the component in a given scene
  72730. */
  72731. register(): void;
  72732. /**
  72733. * Rebuilds the elements related to this component in case of
  72734. * context lost for instance.
  72735. */
  72736. rebuild(): void;
  72737. /**
  72738. * Disposes the component and the associated ressources
  72739. */
  72740. dispose(): void;
  72741. private _gatherRenderTargets;
  72742. private _gatherActiveCameraRenderTargets;
  72743. }
  72744. }
  72745. declare module "babylonjs/Shaders/outline.fragment" {
  72746. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72747. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  72748. /** @hidden */
  72749. export var outlinePixelShader: {
  72750. name: string;
  72751. shader: string;
  72752. };
  72753. }
  72754. declare module "babylonjs/Shaders/outline.vertex" {
  72755. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72756. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72757. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72758. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72759. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72760. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72761. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72762. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72763. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  72764. /** @hidden */
  72765. export var outlineVertexShader: {
  72766. name: string;
  72767. shader: string;
  72768. };
  72769. }
  72770. declare module "babylonjs/Rendering/outlineRenderer" {
  72771. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72772. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  72773. import { Scene } from "babylonjs/scene";
  72774. import { ISceneComponent } from "babylonjs/sceneComponent";
  72775. import "babylonjs/Shaders/outline.fragment";
  72776. import "babylonjs/Shaders/outline.vertex";
  72777. module "babylonjs/scene" {
  72778. interface Scene {
  72779. /** @hidden */
  72780. _outlineRenderer: OutlineRenderer;
  72781. /**
  72782. * Gets the outline renderer associated with the scene
  72783. * @returns a OutlineRenderer
  72784. */
  72785. getOutlineRenderer(): OutlineRenderer;
  72786. }
  72787. }
  72788. module "babylonjs/Meshes/abstractMesh" {
  72789. interface AbstractMesh {
  72790. /** @hidden (Backing field) */
  72791. _renderOutline: boolean;
  72792. /**
  72793. * Gets or sets a boolean indicating if the outline must be rendered as well
  72794. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72795. */
  72796. renderOutline: boolean;
  72797. /** @hidden (Backing field) */
  72798. _renderOverlay: boolean;
  72799. /**
  72800. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72801. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72802. */
  72803. renderOverlay: boolean;
  72804. }
  72805. }
  72806. /**
  72807. * This class is responsible to draw bothe outline/overlay of meshes.
  72808. * It should not be used directly but through the available method on mesh.
  72809. */
  72810. export class OutlineRenderer implements ISceneComponent {
  72811. /**
  72812. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72813. */
  72814. private static _StencilReference;
  72815. /**
  72816. * The name of the component. Each component must have a unique name.
  72817. */
  72818. name: string;
  72819. /**
  72820. * The scene the component belongs to.
  72821. */
  72822. scene: Scene;
  72823. /**
  72824. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72825. */
  72826. zOffset: number;
  72827. private _engine;
  72828. private _effect;
  72829. private _cachedDefines;
  72830. private _savedDepthWrite;
  72831. /**
  72832. * Instantiates a new outline renderer. (There could be only one per scene).
  72833. * @param scene Defines the scene it belongs to
  72834. */
  72835. constructor(scene: Scene);
  72836. /**
  72837. * Register the component to one instance of a scene.
  72838. */
  72839. register(): void;
  72840. /**
  72841. * Rebuilds the elements related to this component in case of
  72842. * context lost for instance.
  72843. */
  72844. rebuild(): void;
  72845. /**
  72846. * Disposes the component and the associated ressources.
  72847. */
  72848. dispose(): void;
  72849. /**
  72850. * Renders the outline in the canvas.
  72851. * @param subMesh Defines the sumesh to render
  72852. * @param batch Defines the batch of meshes in case of instances
  72853. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72854. */
  72855. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72856. /**
  72857. * Returns whether or not the outline renderer is ready for a given submesh.
  72858. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72859. * @param subMesh Defines the submesh to check readyness for
  72860. * @param useInstances Defines wheter wee are trying to render instances or not
  72861. * @returns true if ready otherwise false
  72862. */
  72863. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72864. private _beforeRenderingMesh;
  72865. private _afterRenderingMesh;
  72866. }
  72867. }
  72868. declare module "babylonjs/Rendering/index" {
  72869. export * from "babylonjs/Rendering/boundingBoxRenderer";
  72870. export * from "babylonjs/Rendering/depthRenderer";
  72871. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  72872. export * from "babylonjs/Rendering/edgesRenderer";
  72873. export * from "babylonjs/Rendering/geometryBufferRenderer";
  72874. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72875. export * from "babylonjs/Rendering/outlineRenderer";
  72876. export * from "babylonjs/Rendering/renderingGroup";
  72877. export * from "babylonjs/Rendering/renderingManager";
  72878. export * from "babylonjs/Rendering/utilityLayerRenderer";
  72879. }
  72880. declare module "babylonjs/Sprites/ISprites" {
  72881. /**
  72882. * Defines the basic options interface of a Sprite Frame Source Size.
  72883. */
  72884. export interface ISpriteJSONSpriteSourceSize {
  72885. /**
  72886. * number of the original width of the Frame
  72887. */
  72888. w: number;
  72889. /**
  72890. * number of the original height of the Frame
  72891. */
  72892. h: number;
  72893. }
  72894. /**
  72895. * Defines the basic options interface of a Sprite Frame Data.
  72896. */
  72897. export interface ISpriteJSONSpriteFrameData {
  72898. /**
  72899. * number of the x offset of the Frame
  72900. */
  72901. x: number;
  72902. /**
  72903. * number of the y offset of the Frame
  72904. */
  72905. y: number;
  72906. /**
  72907. * number of the width of the Frame
  72908. */
  72909. w: number;
  72910. /**
  72911. * number of the height of the Frame
  72912. */
  72913. h: number;
  72914. }
  72915. /**
  72916. * Defines the basic options interface of a JSON Sprite.
  72917. */
  72918. export interface ISpriteJSONSprite {
  72919. /**
  72920. * string name of the Frame
  72921. */
  72922. filename: string;
  72923. /**
  72924. * ISpriteJSONSpriteFrame basic object of the frame data
  72925. */
  72926. frame: ISpriteJSONSpriteFrameData;
  72927. /**
  72928. * boolean to flag is the frame was rotated.
  72929. */
  72930. rotated: boolean;
  72931. /**
  72932. * boolean to flag is the frame was trimmed.
  72933. */
  72934. trimmed: boolean;
  72935. /**
  72936. * ISpriteJSONSpriteFrame basic object of the source data
  72937. */
  72938. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72939. /**
  72940. * ISpriteJSONSpriteFrame basic object of the source data
  72941. */
  72942. sourceSize: ISpriteJSONSpriteSourceSize;
  72943. }
  72944. /**
  72945. * Defines the basic options interface of a JSON atlas.
  72946. */
  72947. export interface ISpriteJSONAtlas {
  72948. /**
  72949. * Array of objects that contain the frame data.
  72950. */
  72951. frames: Array<ISpriteJSONSprite>;
  72952. /**
  72953. * object basic object containing the sprite meta data.
  72954. */
  72955. meta?: object;
  72956. }
  72957. }
  72958. declare module "babylonjs/Shaders/spriteMap.fragment" {
  72959. /** @hidden */
  72960. export var spriteMapPixelShader: {
  72961. name: string;
  72962. shader: string;
  72963. };
  72964. }
  72965. declare module "babylonjs/Shaders/spriteMap.vertex" {
  72966. /** @hidden */
  72967. export var spriteMapVertexShader: {
  72968. name: string;
  72969. shader: string;
  72970. };
  72971. }
  72972. declare module "babylonjs/Sprites/spriteMap" {
  72973. import { IDisposable, Scene } from "babylonjs/scene";
  72974. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  72975. import { Texture } from "babylonjs/Materials/Textures/texture";
  72976. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72977. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  72978. import "babylonjs/Meshes/Builders/planeBuilder";
  72979. import "babylonjs/Shaders/spriteMap.fragment";
  72980. import "babylonjs/Shaders/spriteMap.vertex";
  72981. /**
  72982. * Defines the basic options interface of a SpriteMap
  72983. */
  72984. export interface ISpriteMapOptions {
  72985. /**
  72986. * Vector2 of the number of cells in the grid.
  72987. */
  72988. stageSize?: Vector2;
  72989. /**
  72990. * Vector2 of the size of the output plane in World Units.
  72991. */
  72992. outputSize?: Vector2;
  72993. /**
  72994. * Vector3 of the position of the output plane in World Units.
  72995. */
  72996. outputPosition?: Vector3;
  72997. /**
  72998. * Vector3 of the rotation of the output plane.
  72999. */
  73000. outputRotation?: Vector3;
  73001. /**
  73002. * number of layers that the system will reserve in resources.
  73003. */
  73004. layerCount?: number;
  73005. /**
  73006. * number of max animation frames a single cell will reserve in resources.
  73007. */
  73008. maxAnimationFrames?: number;
  73009. /**
  73010. * number cell index of the base tile when the system compiles.
  73011. */
  73012. baseTile?: number;
  73013. /**
  73014. * boolean flip the sprite after its been repositioned by the framing data.
  73015. */
  73016. flipU?: boolean;
  73017. /**
  73018. * Vector3 scalar of the global RGB values of the SpriteMap.
  73019. */
  73020. colorMultiply?: Vector3;
  73021. }
  73022. /**
  73023. * Defines the IDisposable interface in order to be cleanable from resources.
  73024. */
  73025. export interface ISpriteMap extends IDisposable {
  73026. /**
  73027. * String name of the SpriteMap.
  73028. */
  73029. name: string;
  73030. /**
  73031. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73032. */
  73033. atlasJSON: ISpriteJSONAtlas;
  73034. /**
  73035. * Texture of the SpriteMap.
  73036. */
  73037. spriteSheet: Texture;
  73038. /**
  73039. * The parameters to initialize the SpriteMap with.
  73040. */
  73041. options: ISpriteMapOptions;
  73042. }
  73043. /**
  73044. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73045. */
  73046. export class SpriteMap implements ISpriteMap {
  73047. /** The Name of the spriteMap */
  73048. name: string;
  73049. /** The JSON file with the frame and meta data */
  73050. atlasJSON: ISpriteJSONAtlas;
  73051. /** The systems Sprite Sheet Texture */
  73052. spriteSheet: Texture;
  73053. /** Arguments passed with the Constructor */
  73054. options: ISpriteMapOptions;
  73055. /** Public Sprite Storage array, parsed from atlasJSON */
  73056. sprites: Array<ISpriteJSONSprite>;
  73057. /** Returns the Number of Sprites in the System */
  73058. get spriteCount(): number;
  73059. /** Returns the Position of Output Plane*/
  73060. get position(): Vector3;
  73061. /** Returns the Position of Output Plane*/
  73062. set position(v: Vector3);
  73063. /** Returns the Rotation of Output Plane*/
  73064. get rotation(): Vector3;
  73065. /** Returns the Rotation of Output Plane*/
  73066. set rotation(v: Vector3);
  73067. /** Sets the AnimationMap*/
  73068. get animationMap(): RawTexture;
  73069. /** Sets the AnimationMap*/
  73070. set animationMap(v: RawTexture);
  73071. /** Scene that the SpriteMap was created in */
  73072. private _scene;
  73073. /** Texture Buffer of Float32 that holds tile frame data*/
  73074. private _frameMap;
  73075. /** Texture Buffers of Float32 that holds tileMap data*/
  73076. private _tileMaps;
  73077. /** Texture Buffer of Float32 that holds Animation Data*/
  73078. private _animationMap;
  73079. /** Custom ShaderMaterial Central to the System*/
  73080. private _material;
  73081. /** Custom ShaderMaterial Central to the System*/
  73082. private _output;
  73083. /** Systems Time Ticker*/
  73084. private _time;
  73085. /**
  73086. * Creates a new SpriteMap
  73087. * @param name defines the SpriteMaps Name
  73088. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73089. * @param spriteSheet is the Texture that the Sprites are on.
  73090. * @param options a basic deployment configuration
  73091. * @param scene The Scene that the map is deployed on
  73092. */
  73093. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73094. /**
  73095. * Returns tileID location
  73096. * @returns Vector2 the cell position ID
  73097. */
  73098. getTileID(): Vector2;
  73099. /**
  73100. * Gets the UV location of the mouse over the SpriteMap.
  73101. * @returns Vector2 the UV position of the mouse interaction
  73102. */
  73103. getMousePosition(): Vector2;
  73104. /**
  73105. * Creates the "frame" texture Buffer
  73106. * -------------------------------------
  73107. * Structure of frames
  73108. * "filename": "Falling-Water-2.png",
  73109. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73110. * "rotated": true,
  73111. * "trimmed": true,
  73112. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73113. * "sourceSize": {"w":32,"h":32}
  73114. * @returns RawTexture of the frameMap
  73115. */
  73116. private _createFrameBuffer;
  73117. /**
  73118. * Creates the tileMap texture Buffer
  73119. * @param buffer normally and array of numbers, or a false to generate from scratch
  73120. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73121. * @returns RawTexture of the tileMap
  73122. */
  73123. private _createTileBuffer;
  73124. /**
  73125. * Modifies the data of the tileMaps
  73126. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73127. * @param pos is the iVector2 Coordinates of the Tile
  73128. * @param tile The SpriteIndex of the new Tile
  73129. */
  73130. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73131. /**
  73132. * Creates the animationMap texture Buffer
  73133. * @param buffer normally and array of numbers, or a false to generate from scratch
  73134. * @returns RawTexture of the animationMap
  73135. */
  73136. private _createTileAnimationBuffer;
  73137. /**
  73138. * Modifies the data of the animationMap
  73139. * @param cellID is the Index of the Sprite
  73140. * @param _frame is the target Animation frame
  73141. * @param toCell is the Target Index of the next frame of the animation
  73142. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73143. * @param speed is a global scalar of the time variable on the map.
  73144. */
  73145. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73146. /**
  73147. * Exports the .tilemaps file
  73148. */
  73149. saveTileMaps(): void;
  73150. /**
  73151. * Imports the .tilemaps file
  73152. * @param url of the .tilemaps file
  73153. */
  73154. loadTileMaps(url: string): void;
  73155. /**
  73156. * Release associated resources
  73157. */
  73158. dispose(): void;
  73159. }
  73160. }
  73161. declare module "babylonjs/Sprites/spritePackedManager" {
  73162. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  73163. import { Scene } from "babylonjs/scene";
  73164. /**
  73165. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73166. * @see http://doc.babylonjs.com/babylon101/sprites
  73167. */
  73168. export class SpritePackedManager extends SpriteManager {
  73169. /** defines the packed manager's name */
  73170. name: string;
  73171. /**
  73172. * Creates a new sprite manager from a packed sprite sheet
  73173. * @param name defines the manager's name
  73174. * @param imgUrl defines the sprite sheet url
  73175. * @param capacity defines the maximum allowed number of sprites
  73176. * @param scene defines the hosting scene
  73177. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73178. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73179. * @param samplingMode defines the smapling mode to use with spritesheet
  73180. * @param fromPacked set to true; do not alter
  73181. */
  73182. constructor(
  73183. /** defines the packed manager's name */
  73184. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73185. }
  73186. }
  73187. declare module "babylonjs/Sprites/index" {
  73188. export * from "babylonjs/Sprites/sprite";
  73189. export * from "babylonjs/Sprites/ISprites";
  73190. export * from "babylonjs/Sprites/spriteManager";
  73191. export * from "babylonjs/Sprites/spriteMap";
  73192. export * from "babylonjs/Sprites/spritePackedManager";
  73193. export * from "babylonjs/Sprites/spriteSceneComponent";
  73194. }
  73195. declare module "babylonjs/States/index" {
  73196. export * from "babylonjs/States/alphaCullingState";
  73197. export * from "babylonjs/States/depthCullingState";
  73198. export * from "babylonjs/States/stencilState";
  73199. }
  73200. declare module "babylonjs/Misc/assetsManager" {
  73201. import { Scene } from "babylonjs/scene";
  73202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73203. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73204. import { Skeleton } from "babylonjs/Bones/skeleton";
  73205. import { Observable } from "babylonjs/Misc/observable";
  73206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  73207. import { Texture } from "babylonjs/Materials/Textures/texture";
  73208. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  73209. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  73210. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  73211. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  73212. /**
  73213. * Defines the list of states available for a task inside a AssetsManager
  73214. */
  73215. export enum AssetTaskState {
  73216. /**
  73217. * Initialization
  73218. */
  73219. INIT = 0,
  73220. /**
  73221. * Running
  73222. */
  73223. RUNNING = 1,
  73224. /**
  73225. * Done
  73226. */
  73227. DONE = 2,
  73228. /**
  73229. * Error
  73230. */
  73231. ERROR = 3
  73232. }
  73233. /**
  73234. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73235. */
  73236. export abstract class AbstractAssetTask {
  73237. /**
  73238. * Task name
  73239. */ name: string;
  73240. /**
  73241. * Callback called when the task is successful
  73242. */
  73243. onSuccess: (task: any) => void;
  73244. /**
  73245. * Callback called when the task is not successful
  73246. */
  73247. onError: (task: any, message?: string, exception?: any) => void;
  73248. /**
  73249. * Creates a new AssetsManager
  73250. * @param name defines the name of the task
  73251. */
  73252. constructor(
  73253. /**
  73254. * Task name
  73255. */ name: string);
  73256. private _isCompleted;
  73257. private _taskState;
  73258. private _errorObject;
  73259. /**
  73260. * Get if the task is completed
  73261. */
  73262. get isCompleted(): boolean;
  73263. /**
  73264. * Gets the current state of the task
  73265. */
  73266. get taskState(): AssetTaskState;
  73267. /**
  73268. * Gets the current error object (if task is in error)
  73269. */
  73270. get errorObject(): {
  73271. message?: string;
  73272. exception?: any;
  73273. };
  73274. /**
  73275. * Internal only
  73276. * @hidden
  73277. */
  73278. _setErrorObject(message?: string, exception?: any): void;
  73279. /**
  73280. * Execute the current task
  73281. * @param scene defines the scene where you want your assets to be loaded
  73282. * @param onSuccess is a callback called when the task is successfully executed
  73283. * @param onError is a callback called if an error occurs
  73284. */
  73285. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73286. /**
  73287. * Execute the current task
  73288. * @param scene defines the scene where you want your assets to be loaded
  73289. * @param onSuccess is a callback called when the task is successfully executed
  73290. * @param onError is a callback called if an error occurs
  73291. */
  73292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73293. /**
  73294. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73295. * This can be used with failed tasks that have the reason for failure fixed.
  73296. */
  73297. reset(): void;
  73298. private onErrorCallback;
  73299. private onDoneCallback;
  73300. }
  73301. /**
  73302. * Define the interface used by progress events raised during assets loading
  73303. */
  73304. export interface IAssetsProgressEvent {
  73305. /**
  73306. * Defines the number of remaining tasks to process
  73307. */
  73308. remainingCount: number;
  73309. /**
  73310. * Defines the total number of tasks
  73311. */
  73312. totalCount: number;
  73313. /**
  73314. * Defines the task that was just processed
  73315. */
  73316. task: AbstractAssetTask;
  73317. }
  73318. /**
  73319. * Class used to share progress information about assets loading
  73320. */
  73321. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73322. /**
  73323. * Defines the number of remaining tasks to process
  73324. */
  73325. remainingCount: number;
  73326. /**
  73327. * Defines the total number of tasks
  73328. */
  73329. totalCount: number;
  73330. /**
  73331. * Defines the task that was just processed
  73332. */
  73333. task: AbstractAssetTask;
  73334. /**
  73335. * Creates a AssetsProgressEvent
  73336. * @param remainingCount defines the number of remaining tasks to process
  73337. * @param totalCount defines the total number of tasks
  73338. * @param task defines the task that was just processed
  73339. */
  73340. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73341. }
  73342. /**
  73343. * Define a task used by AssetsManager to load meshes
  73344. */
  73345. export class MeshAssetTask extends AbstractAssetTask {
  73346. /**
  73347. * Defines the name of the task
  73348. */
  73349. name: string;
  73350. /**
  73351. * Defines the list of mesh's names you want to load
  73352. */
  73353. meshesNames: any;
  73354. /**
  73355. * Defines the root url to use as a base to load your meshes and associated resources
  73356. */
  73357. rootUrl: string;
  73358. /**
  73359. * Defines the filename or File of the scene to load from
  73360. */
  73361. sceneFilename: string | File;
  73362. /**
  73363. * Gets the list of loaded meshes
  73364. */
  73365. loadedMeshes: Array<AbstractMesh>;
  73366. /**
  73367. * Gets the list of loaded particle systems
  73368. */
  73369. loadedParticleSystems: Array<IParticleSystem>;
  73370. /**
  73371. * Gets the list of loaded skeletons
  73372. */
  73373. loadedSkeletons: Array<Skeleton>;
  73374. /**
  73375. * Gets the list of loaded animation groups
  73376. */
  73377. loadedAnimationGroups: Array<AnimationGroup>;
  73378. /**
  73379. * Callback called when the task is successful
  73380. */
  73381. onSuccess: (task: MeshAssetTask) => void;
  73382. /**
  73383. * Callback called when the task is successful
  73384. */
  73385. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73386. /**
  73387. * Creates a new MeshAssetTask
  73388. * @param name defines the name of the task
  73389. * @param meshesNames defines the list of mesh's names you want to load
  73390. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73391. * @param sceneFilename defines the filename or File of the scene to load from
  73392. */
  73393. constructor(
  73394. /**
  73395. * Defines the name of the task
  73396. */
  73397. name: string,
  73398. /**
  73399. * Defines the list of mesh's names you want to load
  73400. */
  73401. meshesNames: any,
  73402. /**
  73403. * Defines the root url to use as a base to load your meshes and associated resources
  73404. */
  73405. rootUrl: string,
  73406. /**
  73407. * Defines the filename or File of the scene to load from
  73408. */
  73409. sceneFilename: string | File);
  73410. /**
  73411. * Execute the current task
  73412. * @param scene defines the scene where you want your assets to be loaded
  73413. * @param onSuccess is a callback called when the task is successfully executed
  73414. * @param onError is a callback called if an error occurs
  73415. */
  73416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73417. }
  73418. /**
  73419. * Define a task used by AssetsManager to load text content
  73420. */
  73421. export class TextFileAssetTask extends AbstractAssetTask {
  73422. /**
  73423. * Defines the name of the task
  73424. */
  73425. name: string;
  73426. /**
  73427. * Defines the location of the file to load
  73428. */
  73429. url: string;
  73430. /**
  73431. * Gets the loaded text string
  73432. */
  73433. text: string;
  73434. /**
  73435. * Callback called when the task is successful
  73436. */
  73437. onSuccess: (task: TextFileAssetTask) => void;
  73438. /**
  73439. * Callback called when the task is successful
  73440. */
  73441. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73442. /**
  73443. * Creates a new TextFileAssetTask object
  73444. * @param name defines the name of the task
  73445. * @param url defines the location of the file to load
  73446. */
  73447. constructor(
  73448. /**
  73449. * Defines the name of the task
  73450. */
  73451. name: string,
  73452. /**
  73453. * Defines the location of the file to load
  73454. */
  73455. url: string);
  73456. /**
  73457. * Execute the current task
  73458. * @param scene defines the scene where you want your assets to be loaded
  73459. * @param onSuccess is a callback called when the task is successfully executed
  73460. * @param onError is a callback called if an error occurs
  73461. */
  73462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73463. }
  73464. /**
  73465. * Define a task used by AssetsManager to load binary data
  73466. */
  73467. export class BinaryFileAssetTask extends AbstractAssetTask {
  73468. /**
  73469. * Defines the name of the task
  73470. */
  73471. name: string;
  73472. /**
  73473. * Defines the location of the file to load
  73474. */
  73475. url: string;
  73476. /**
  73477. * Gets the lodaded data (as an array buffer)
  73478. */
  73479. data: ArrayBuffer;
  73480. /**
  73481. * Callback called when the task is successful
  73482. */
  73483. onSuccess: (task: BinaryFileAssetTask) => void;
  73484. /**
  73485. * Callback called when the task is successful
  73486. */
  73487. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73488. /**
  73489. * Creates a new BinaryFileAssetTask object
  73490. * @param name defines the name of the new task
  73491. * @param url defines the location of the file to load
  73492. */
  73493. constructor(
  73494. /**
  73495. * Defines the name of the task
  73496. */
  73497. name: string,
  73498. /**
  73499. * Defines the location of the file to load
  73500. */
  73501. url: string);
  73502. /**
  73503. * Execute the current task
  73504. * @param scene defines the scene where you want your assets to be loaded
  73505. * @param onSuccess is a callback called when the task is successfully executed
  73506. * @param onError is a callback called if an error occurs
  73507. */
  73508. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73509. }
  73510. /**
  73511. * Define a task used by AssetsManager to load images
  73512. */
  73513. export class ImageAssetTask extends AbstractAssetTask {
  73514. /**
  73515. * Defines the name of the task
  73516. */
  73517. name: string;
  73518. /**
  73519. * Defines the location of the image to load
  73520. */
  73521. url: string;
  73522. /**
  73523. * Gets the loaded images
  73524. */
  73525. image: HTMLImageElement;
  73526. /**
  73527. * Callback called when the task is successful
  73528. */
  73529. onSuccess: (task: ImageAssetTask) => void;
  73530. /**
  73531. * Callback called when the task is successful
  73532. */
  73533. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73534. /**
  73535. * Creates a new ImageAssetTask
  73536. * @param name defines the name of the task
  73537. * @param url defines the location of the image to load
  73538. */
  73539. constructor(
  73540. /**
  73541. * Defines the name of the task
  73542. */
  73543. name: string,
  73544. /**
  73545. * Defines the location of the image to load
  73546. */
  73547. url: string);
  73548. /**
  73549. * Execute the current task
  73550. * @param scene defines the scene where you want your assets to be loaded
  73551. * @param onSuccess is a callback called when the task is successfully executed
  73552. * @param onError is a callback called if an error occurs
  73553. */
  73554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73555. }
  73556. /**
  73557. * Defines the interface used by texture loading tasks
  73558. */
  73559. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73560. /**
  73561. * Gets the loaded texture
  73562. */
  73563. texture: TEX;
  73564. }
  73565. /**
  73566. * Define a task used by AssetsManager to load 2D textures
  73567. */
  73568. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73569. /**
  73570. * Defines the name of the task
  73571. */
  73572. name: string;
  73573. /**
  73574. * Defines the location of the file to load
  73575. */
  73576. url: string;
  73577. /**
  73578. * Defines if mipmap should not be generated (default is false)
  73579. */
  73580. noMipmap?: boolean | undefined;
  73581. /**
  73582. * Defines if texture must be inverted on Y axis (default is true)
  73583. */
  73584. invertY: boolean;
  73585. /**
  73586. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73587. */
  73588. samplingMode: number;
  73589. /**
  73590. * Gets the loaded texture
  73591. */
  73592. texture: Texture;
  73593. /**
  73594. * Callback called when the task is successful
  73595. */
  73596. onSuccess: (task: TextureAssetTask) => void;
  73597. /**
  73598. * Callback called when the task is successful
  73599. */
  73600. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73601. /**
  73602. * Creates a new TextureAssetTask object
  73603. * @param name defines the name of the task
  73604. * @param url defines the location of the file to load
  73605. * @param noMipmap defines if mipmap should not be generated (default is false)
  73606. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73607. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73608. */
  73609. constructor(
  73610. /**
  73611. * Defines the name of the task
  73612. */
  73613. name: string,
  73614. /**
  73615. * Defines the location of the file to load
  73616. */
  73617. url: string,
  73618. /**
  73619. * Defines if mipmap should not be generated (default is false)
  73620. */
  73621. noMipmap?: boolean | undefined,
  73622. /**
  73623. * Defines if texture must be inverted on Y axis (default is true)
  73624. */
  73625. invertY?: boolean,
  73626. /**
  73627. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73628. */
  73629. samplingMode?: number);
  73630. /**
  73631. * Execute the current task
  73632. * @param scene defines the scene where you want your assets to be loaded
  73633. * @param onSuccess is a callback called when the task is successfully executed
  73634. * @param onError is a callback called if an error occurs
  73635. */
  73636. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73637. }
  73638. /**
  73639. * Define a task used by AssetsManager to load cube textures
  73640. */
  73641. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73642. /**
  73643. * Defines the name of the task
  73644. */
  73645. name: string;
  73646. /**
  73647. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73648. */
  73649. url: string;
  73650. /**
  73651. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73652. */
  73653. extensions?: string[] | undefined;
  73654. /**
  73655. * Defines if mipmaps should not be generated (default is false)
  73656. */
  73657. noMipmap?: boolean | undefined;
  73658. /**
  73659. * Defines the explicit list of files (undefined by default)
  73660. */
  73661. files?: string[] | undefined;
  73662. /**
  73663. * Gets the loaded texture
  73664. */
  73665. texture: CubeTexture;
  73666. /**
  73667. * Callback called when the task is successful
  73668. */
  73669. onSuccess: (task: CubeTextureAssetTask) => void;
  73670. /**
  73671. * Callback called when the task is successful
  73672. */
  73673. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73674. /**
  73675. * Creates a new CubeTextureAssetTask
  73676. * @param name defines the name of the task
  73677. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73678. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73679. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73680. * @param files defines the explicit list of files (undefined by default)
  73681. */
  73682. constructor(
  73683. /**
  73684. * Defines the name of the task
  73685. */
  73686. name: string,
  73687. /**
  73688. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73689. */
  73690. url: string,
  73691. /**
  73692. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73693. */
  73694. extensions?: string[] | undefined,
  73695. /**
  73696. * Defines if mipmaps should not be generated (default is false)
  73697. */
  73698. noMipmap?: boolean | undefined,
  73699. /**
  73700. * Defines the explicit list of files (undefined by default)
  73701. */
  73702. files?: string[] | undefined);
  73703. /**
  73704. * Execute the current task
  73705. * @param scene defines the scene where you want your assets to be loaded
  73706. * @param onSuccess is a callback called when the task is successfully executed
  73707. * @param onError is a callback called if an error occurs
  73708. */
  73709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73710. }
  73711. /**
  73712. * Define a task used by AssetsManager to load HDR cube textures
  73713. */
  73714. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73715. /**
  73716. * Defines the name of the task
  73717. */
  73718. name: string;
  73719. /**
  73720. * Defines the location of the file to load
  73721. */
  73722. url: string;
  73723. /**
  73724. * Defines the desired size (the more it increases the longer the generation will be)
  73725. */
  73726. size: number;
  73727. /**
  73728. * Defines if mipmaps should not be generated (default is false)
  73729. */
  73730. noMipmap: boolean;
  73731. /**
  73732. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73733. */
  73734. generateHarmonics: boolean;
  73735. /**
  73736. * 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)
  73737. */
  73738. gammaSpace: boolean;
  73739. /**
  73740. * Internal Use Only
  73741. */
  73742. reserved: boolean;
  73743. /**
  73744. * Gets the loaded texture
  73745. */
  73746. texture: HDRCubeTexture;
  73747. /**
  73748. * Callback called when the task is successful
  73749. */
  73750. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73751. /**
  73752. * Callback called when the task is successful
  73753. */
  73754. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73755. /**
  73756. * Creates a new HDRCubeTextureAssetTask object
  73757. * @param name defines the name of the task
  73758. * @param url defines the location of the file to load
  73759. * @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.
  73760. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73761. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73762. * @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)
  73763. * @param reserved Internal use only
  73764. */
  73765. constructor(
  73766. /**
  73767. * Defines the name of the task
  73768. */
  73769. name: string,
  73770. /**
  73771. * Defines the location of the file to load
  73772. */
  73773. url: string,
  73774. /**
  73775. * Defines the desired size (the more it increases the longer the generation will be)
  73776. */
  73777. size: number,
  73778. /**
  73779. * Defines if mipmaps should not be generated (default is false)
  73780. */
  73781. noMipmap?: boolean,
  73782. /**
  73783. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73784. */
  73785. generateHarmonics?: boolean,
  73786. /**
  73787. * 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)
  73788. */
  73789. gammaSpace?: boolean,
  73790. /**
  73791. * Internal Use Only
  73792. */
  73793. reserved?: boolean);
  73794. /**
  73795. * Execute the current task
  73796. * @param scene defines the scene where you want your assets to be loaded
  73797. * @param onSuccess is a callback called when the task is successfully executed
  73798. * @param onError is a callback called if an error occurs
  73799. */
  73800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73801. }
  73802. /**
  73803. * Define a task used by AssetsManager to load Equirectangular cube textures
  73804. */
  73805. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73806. /**
  73807. * Defines the name of the task
  73808. */
  73809. name: string;
  73810. /**
  73811. * Defines the location of the file to load
  73812. */
  73813. url: string;
  73814. /**
  73815. * Defines the desired size (the more it increases the longer the generation will be)
  73816. */
  73817. size: number;
  73818. /**
  73819. * Defines if mipmaps should not be generated (default is false)
  73820. */
  73821. noMipmap: boolean;
  73822. /**
  73823. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73824. * but the standard material would require them in Gamma space) (default is true)
  73825. */
  73826. gammaSpace: boolean;
  73827. /**
  73828. * Gets the loaded texture
  73829. */
  73830. texture: EquiRectangularCubeTexture;
  73831. /**
  73832. * Callback called when the task is successful
  73833. */
  73834. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73835. /**
  73836. * Callback called when the task is successful
  73837. */
  73838. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73839. /**
  73840. * Creates a new EquiRectangularCubeTextureAssetTask object
  73841. * @param name defines the name of the task
  73842. * @param url defines the location of the file to load
  73843. * @param size defines the desired size (the more it increases the longer the generation will be)
  73844. * If the size is omitted this implies you are using a preprocessed cubemap.
  73845. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73846. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73847. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73848. * (default is true)
  73849. */
  73850. constructor(
  73851. /**
  73852. * Defines the name of the task
  73853. */
  73854. name: string,
  73855. /**
  73856. * Defines the location of the file to load
  73857. */
  73858. url: string,
  73859. /**
  73860. * Defines the desired size (the more it increases the longer the generation will be)
  73861. */
  73862. size: number,
  73863. /**
  73864. * Defines if mipmaps should not be generated (default is false)
  73865. */
  73866. noMipmap?: boolean,
  73867. /**
  73868. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73869. * but the standard material would require them in Gamma space) (default is true)
  73870. */
  73871. gammaSpace?: boolean);
  73872. /**
  73873. * Execute the current task
  73874. * @param scene defines the scene where you want your assets to be loaded
  73875. * @param onSuccess is a callback called when the task is successfully executed
  73876. * @param onError is a callback called if an error occurs
  73877. */
  73878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73879. }
  73880. /**
  73881. * This class can be used to easily import assets into a scene
  73882. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73883. */
  73884. export class AssetsManager {
  73885. private _scene;
  73886. private _isLoading;
  73887. protected _tasks: AbstractAssetTask[];
  73888. protected _waitingTasksCount: number;
  73889. protected _totalTasksCount: number;
  73890. /**
  73891. * Callback called when all tasks are processed
  73892. */
  73893. onFinish: (tasks: AbstractAssetTask[]) => void;
  73894. /**
  73895. * Callback called when a task is successful
  73896. */
  73897. onTaskSuccess: (task: AbstractAssetTask) => void;
  73898. /**
  73899. * Callback called when a task had an error
  73900. */
  73901. onTaskError: (task: AbstractAssetTask) => void;
  73902. /**
  73903. * Callback called when a task is done (whatever the result is)
  73904. */
  73905. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73906. /**
  73907. * Observable called when all tasks are processed
  73908. */
  73909. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73910. /**
  73911. * Observable called when a task had an error
  73912. */
  73913. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73914. /**
  73915. * Observable called when all tasks were executed
  73916. */
  73917. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73918. /**
  73919. * Observable called when a task is done (whatever the result is)
  73920. */
  73921. onProgressObservable: Observable<IAssetsProgressEvent>;
  73922. /**
  73923. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73924. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73925. */
  73926. useDefaultLoadingScreen: boolean;
  73927. /**
  73928. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73929. * when all assets have been downloaded.
  73930. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73931. */
  73932. autoHideLoadingUI: boolean;
  73933. /**
  73934. * Creates a new AssetsManager
  73935. * @param scene defines the scene to work on
  73936. */
  73937. constructor(scene: Scene);
  73938. /**
  73939. * Add a MeshAssetTask to the list of active tasks
  73940. * @param taskName defines the name of the new task
  73941. * @param meshesNames defines the name of meshes to load
  73942. * @param rootUrl defines the root url to use to locate files
  73943. * @param sceneFilename defines the filename of the scene file
  73944. * @returns a new MeshAssetTask object
  73945. */
  73946. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73947. /**
  73948. * Add a TextFileAssetTask to the list of active tasks
  73949. * @param taskName defines the name of the new task
  73950. * @param url defines the url of the file to load
  73951. * @returns a new TextFileAssetTask object
  73952. */
  73953. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73954. /**
  73955. * Add a BinaryFileAssetTask to the list of active tasks
  73956. * @param taskName defines the name of the new task
  73957. * @param url defines the url of the file to load
  73958. * @returns a new BinaryFileAssetTask object
  73959. */
  73960. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73961. /**
  73962. * Add a ImageAssetTask to the list of active tasks
  73963. * @param taskName defines the name of the new task
  73964. * @param url defines the url of the file to load
  73965. * @returns a new ImageAssetTask object
  73966. */
  73967. addImageTask(taskName: string, url: string): ImageAssetTask;
  73968. /**
  73969. * Add a TextureAssetTask to the list of active tasks
  73970. * @param taskName defines the name of the new task
  73971. * @param url defines the url of the file to load
  73972. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73973. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73974. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73975. * @returns a new TextureAssetTask object
  73976. */
  73977. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73978. /**
  73979. * Add a CubeTextureAssetTask to the list of active tasks
  73980. * @param taskName defines the name of the new task
  73981. * @param url defines the url of the file to load
  73982. * @param extensions defines the extension to use to load the cube map (can be null)
  73983. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73984. * @param files defines the list of files to load (can be null)
  73985. * @returns a new CubeTextureAssetTask object
  73986. */
  73987. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73988. /**
  73989. *
  73990. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73991. * @param taskName defines the name of the new task
  73992. * @param url defines the url of the file to load
  73993. * @param size defines the size you want for the cubemap (can be null)
  73994. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73995. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73996. * @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)
  73997. * @param reserved Internal use only
  73998. * @returns a new HDRCubeTextureAssetTask object
  73999. */
  74000. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74001. /**
  74002. *
  74003. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74004. * @param taskName defines the name of the new task
  74005. * @param url defines the url of the file to load
  74006. * @param size defines the size you want for the cubemap (can be null)
  74007. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74008. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74009. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74010. * @returns a new EquiRectangularCubeTextureAssetTask object
  74011. */
  74012. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74013. /**
  74014. * Remove a task from the assets manager.
  74015. * @param task the task to remove
  74016. */
  74017. removeTask(task: AbstractAssetTask): void;
  74018. private _decreaseWaitingTasksCount;
  74019. private _runTask;
  74020. /**
  74021. * Reset the AssetsManager and remove all tasks
  74022. * @return the current instance of the AssetsManager
  74023. */
  74024. reset(): AssetsManager;
  74025. /**
  74026. * Start the loading process
  74027. * @return the current instance of the AssetsManager
  74028. */
  74029. load(): AssetsManager;
  74030. /**
  74031. * Start the loading process as an async operation
  74032. * @return a promise returning the list of failed tasks
  74033. */
  74034. loadAsync(): Promise<void>;
  74035. }
  74036. }
  74037. declare module "babylonjs/Misc/deferred" {
  74038. /**
  74039. * Wrapper class for promise with external resolve and reject.
  74040. */
  74041. export class Deferred<T> {
  74042. /**
  74043. * The promise associated with this deferred object.
  74044. */
  74045. readonly promise: Promise<T>;
  74046. private _resolve;
  74047. private _reject;
  74048. /**
  74049. * The resolve method of the promise associated with this deferred object.
  74050. */
  74051. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74052. /**
  74053. * The reject method of the promise associated with this deferred object.
  74054. */
  74055. get reject(): (reason?: any) => void;
  74056. /**
  74057. * Constructor for this deferred object.
  74058. */
  74059. constructor();
  74060. }
  74061. }
  74062. declare module "babylonjs/Misc/meshExploder" {
  74063. import { Mesh } from "babylonjs/Meshes/mesh";
  74064. /**
  74065. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74066. */
  74067. export class MeshExploder {
  74068. private _centerMesh;
  74069. private _meshes;
  74070. private _meshesOrigins;
  74071. private _toCenterVectors;
  74072. private _scaledDirection;
  74073. private _newPosition;
  74074. private _centerPosition;
  74075. /**
  74076. * Explodes meshes from a center mesh.
  74077. * @param meshes The meshes to explode.
  74078. * @param centerMesh The mesh to be center of explosion.
  74079. */
  74080. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74081. private _setCenterMesh;
  74082. /**
  74083. * Get class name
  74084. * @returns "MeshExploder"
  74085. */
  74086. getClassName(): string;
  74087. /**
  74088. * "Exploded meshes"
  74089. * @returns Array of meshes with the centerMesh at index 0.
  74090. */
  74091. getMeshes(): Array<Mesh>;
  74092. /**
  74093. * Explodes meshes giving a specific direction
  74094. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74095. */
  74096. explode(direction?: number): void;
  74097. }
  74098. }
  74099. declare module "babylonjs/Misc/filesInput" {
  74100. import { Engine } from "babylonjs/Engines/engine";
  74101. import { Scene } from "babylonjs/scene";
  74102. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  74103. /**
  74104. * Class used to help managing file picking and drag'n'drop
  74105. */
  74106. export class FilesInput {
  74107. /**
  74108. * List of files ready to be loaded
  74109. */
  74110. static get FilesToLoad(): {
  74111. [key: string]: File;
  74112. };
  74113. /**
  74114. * Callback called when a file is processed
  74115. */
  74116. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  74117. private _engine;
  74118. private _currentScene;
  74119. private _sceneLoadedCallback;
  74120. private _progressCallback;
  74121. private _additionalRenderLoopLogicCallback;
  74122. private _textureLoadingCallback;
  74123. private _startingProcessingFilesCallback;
  74124. private _onReloadCallback;
  74125. private _errorCallback;
  74126. private _elementToMonitor;
  74127. private _sceneFileToLoad;
  74128. private _filesToLoad;
  74129. /**
  74130. * Creates a new FilesInput
  74131. * @param engine defines the rendering engine
  74132. * @param scene defines the hosting scene
  74133. * @param sceneLoadedCallback callback called when scene is loaded
  74134. * @param progressCallback callback called to track progress
  74135. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74136. * @param textureLoadingCallback callback called when a texture is loading
  74137. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74138. * @param onReloadCallback callback called when a reload is requested
  74139. * @param errorCallback callback call if an error occurs
  74140. */
  74141. 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);
  74142. private _dragEnterHandler;
  74143. private _dragOverHandler;
  74144. private _dropHandler;
  74145. /**
  74146. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74147. * @param elementToMonitor defines the DOM element to track
  74148. */
  74149. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74150. /**
  74151. * Release all associated resources
  74152. */
  74153. dispose(): void;
  74154. private renderFunction;
  74155. private drag;
  74156. private drop;
  74157. private _traverseFolder;
  74158. private _processFiles;
  74159. /**
  74160. * Load files from a drop event
  74161. * @param event defines the drop event to use as source
  74162. */
  74163. loadFiles(event: any): void;
  74164. private _processReload;
  74165. /**
  74166. * Reload the current scene from the loaded files
  74167. */
  74168. reload(): void;
  74169. }
  74170. }
  74171. declare module "babylonjs/Misc/HighDynamicRange/index" {
  74172. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  74173. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  74174. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  74175. }
  74176. declare module "babylonjs/Misc/sceneOptimizer" {
  74177. import { Scene, IDisposable } from "babylonjs/scene";
  74178. import { Observable } from "babylonjs/Misc/observable";
  74179. /**
  74180. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74182. */
  74183. export class SceneOptimization {
  74184. /**
  74185. * Defines the priority of this optimization (0 by default which means first in the list)
  74186. */
  74187. priority: number;
  74188. /**
  74189. * Gets a string describing the action executed by the current optimization
  74190. * @returns description string
  74191. */
  74192. getDescription(): string;
  74193. /**
  74194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74195. * @param scene defines the current scene where to apply this optimization
  74196. * @param optimizer defines the current optimizer
  74197. * @returns true if everything that can be done was applied
  74198. */
  74199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74200. /**
  74201. * Creates the SceneOptimization object
  74202. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74203. * @param desc defines the description associated with the optimization
  74204. */
  74205. constructor(
  74206. /**
  74207. * Defines the priority of this optimization (0 by default which means first in the list)
  74208. */
  74209. priority?: number);
  74210. }
  74211. /**
  74212. * Defines an optimization used to reduce the size of render target textures
  74213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74214. */
  74215. export class TextureOptimization extends SceneOptimization {
  74216. /**
  74217. * Defines the priority of this optimization (0 by default which means first in the list)
  74218. */
  74219. priority: number;
  74220. /**
  74221. * 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
  74222. */
  74223. maximumSize: number;
  74224. /**
  74225. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74226. */
  74227. step: number;
  74228. /**
  74229. * Gets a string describing the action executed by the current optimization
  74230. * @returns description string
  74231. */
  74232. getDescription(): string;
  74233. /**
  74234. * Creates the TextureOptimization object
  74235. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74236. * @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
  74237. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74238. */
  74239. constructor(
  74240. /**
  74241. * Defines the priority of this optimization (0 by default which means first in the list)
  74242. */
  74243. priority?: number,
  74244. /**
  74245. * 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
  74246. */
  74247. maximumSize?: number,
  74248. /**
  74249. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74250. */
  74251. step?: number);
  74252. /**
  74253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74254. * @param scene defines the current scene where to apply this optimization
  74255. * @param optimizer defines the current optimizer
  74256. * @returns true if everything that can be done was applied
  74257. */
  74258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74259. }
  74260. /**
  74261. * Defines an optimization used to increase or decrease the rendering resolution
  74262. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74263. */
  74264. export class HardwareScalingOptimization extends SceneOptimization {
  74265. /**
  74266. * Defines the priority of this optimization (0 by default which means first in the list)
  74267. */
  74268. priority: number;
  74269. /**
  74270. * Defines the maximum scale to use (2 by default)
  74271. */
  74272. maximumScale: number;
  74273. /**
  74274. * Defines the step to use between two passes (0.5 by default)
  74275. */
  74276. step: number;
  74277. private _currentScale;
  74278. private _directionOffset;
  74279. /**
  74280. * Gets a string describing the action executed by the current optimization
  74281. * @return description string
  74282. */
  74283. getDescription(): string;
  74284. /**
  74285. * Creates the HardwareScalingOptimization object
  74286. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74287. * @param maximumScale defines the maximum scale to use (2 by default)
  74288. * @param step defines the step to use between two passes (0.5 by default)
  74289. */
  74290. constructor(
  74291. /**
  74292. * Defines the priority of this optimization (0 by default which means first in the list)
  74293. */
  74294. priority?: number,
  74295. /**
  74296. * Defines the maximum scale to use (2 by default)
  74297. */
  74298. maximumScale?: number,
  74299. /**
  74300. * Defines the step to use between two passes (0.5 by default)
  74301. */
  74302. step?: number);
  74303. /**
  74304. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74305. * @param scene defines the current scene where to apply this optimization
  74306. * @param optimizer defines the current optimizer
  74307. * @returns true if everything that can be done was applied
  74308. */
  74309. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74310. }
  74311. /**
  74312. * Defines an optimization used to remove shadows
  74313. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74314. */
  74315. export class ShadowsOptimization extends SceneOptimization {
  74316. /**
  74317. * Gets a string describing the action executed by the current optimization
  74318. * @return description string
  74319. */
  74320. getDescription(): string;
  74321. /**
  74322. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74323. * @param scene defines the current scene where to apply this optimization
  74324. * @param optimizer defines the current optimizer
  74325. * @returns true if everything that can be done was applied
  74326. */
  74327. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74328. }
  74329. /**
  74330. * Defines an optimization used to turn post-processes off
  74331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74332. */
  74333. export class PostProcessesOptimization extends SceneOptimization {
  74334. /**
  74335. * Gets a string describing the action executed by the current optimization
  74336. * @return description string
  74337. */
  74338. getDescription(): string;
  74339. /**
  74340. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74341. * @param scene defines the current scene where to apply this optimization
  74342. * @param optimizer defines the current optimizer
  74343. * @returns true if everything that can be done was applied
  74344. */
  74345. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74346. }
  74347. /**
  74348. * Defines an optimization used to turn lens flares off
  74349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74350. */
  74351. export class LensFlaresOptimization extends SceneOptimization {
  74352. /**
  74353. * Gets a string describing the action executed by the current optimization
  74354. * @return description string
  74355. */
  74356. getDescription(): string;
  74357. /**
  74358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74359. * @param scene defines the current scene where to apply this optimization
  74360. * @param optimizer defines the current optimizer
  74361. * @returns true if everything that can be done was applied
  74362. */
  74363. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74364. }
  74365. /**
  74366. * Defines an optimization based on user defined callback.
  74367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74368. */
  74369. export class CustomOptimization extends SceneOptimization {
  74370. /**
  74371. * Callback called to apply the custom optimization.
  74372. */
  74373. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74374. /**
  74375. * Callback called to get custom description
  74376. */
  74377. onGetDescription: () => string;
  74378. /**
  74379. * Gets a string describing the action executed by the current optimization
  74380. * @returns description string
  74381. */
  74382. getDescription(): string;
  74383. /**
  74384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74385. * @param scene defines the current scene where to apply this optimization
  74386. * @param optimizer defines the current optimizer
  74387. * @returns true if everything that can be done was applied
  74388. */
  74389. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74390. }
  74391. /**
  74392. * Defines an optimization used to turn particles off
  74393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74394. */
  74395. export class ParticlesOptimization extends SceneOptimization {
  74396. /**
  74397. * Gets a string describing the action executed by the current optimization
  74398. * @return description string
  74399. */
  74400. getDescription(): string;
  74401. /**
  74402. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74403. * @param scene defines the current scene where to apply this optimization
  74404. * @param optimizer defines the current optimizer
  74405. * @returns true if everything that can be done was applied
  74406. */
  74407. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74408. }
  74409. /**
  74410. * Defines an optimization used to turn render targets off
  74411. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74412. */
  74413. export class RenderTargetsOptimization extends SceneOptimization {
  74414. /**
  74415. * Gets a string describing the action executed by the current optimization
  74416. * @return description string
  74417. */
  74418. getDescription(): string;
  74419. /**
  74420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74421. * @param scene defines the current scene where to apply this optimization
  74422. * @param optimizer defines the current optimizer
  74423. * @returns true if everything that can be done was applied
  74424. */
  74425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74426. }
  74427. /**
  74428. * Defines an optimization used to merge meshes with compatible materials
  74429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74430. */
  74431. export class MergeMeshesOptimization extends SceneOptimization {
  74432. private static _UpdateSelectionTree;
  74433. /**
  74434. * Gets or sets a boolean which defines if optimization octree has to be updated
  74435. */
  74436. static get UpdateSelectionTree(): boolean;
  74437. /**
  74438. * Gets or sets a boolean which defines if optimization octree has to be updated
  74439. */
  74440. static set UpdateSelectionTree(value: boolean);
  74441. /**
  74442. * Gets a string describing the action executed by the current optimization
  74443. * @return description string
  74444. */
  74445. getDescription(): string;
  74446. private _canBeMerged;
  74447. /**
  74448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74449. * @param scene defines the current scene where to apply this optimization
  74450. * @param optimizer defines the current optimizer
  74451. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74452. * @returns true if everything that can be done was applied
  74453. */
  74454. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74455. }
  74456. /**
  74457. * Defines a list of options used by SceneOptimizer
  74458. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74459. */
  74460. export class SceneOptimizerOptions {
  74461. /**
  74462. * Defines the target frame rate to reach (60 by default)
  74463. */
  74464. targetFrameRate: number;
  74465. /**
  74466. * Defines the interval between two checkes (2000ms by default)
  74467. */
  74468. trackerDuration: number;
  74469. /**
  74470. * Gets the list of optimizations to apply
  74471. */
  74472. optimizations: SceneOptimization[];
  74473. /**
  74474. * Creates a new list of options used by SceneOptimizer
  74475. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74476. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74477. */
  74478. constructor(
  74479. /**
  74480. * Defines the target frame rate to reach (60 by default)
  74481. */
  74482. targetFrameRate?: number,
  74483. /**
  74484. * Defines the interval between two checkes (2000ms by default)
  74485. */
  74486. trackerDuration?: number);
  74487. /**
  74488. * Add a new optimization
  74489. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74490. * @returns the current SceneOptimizerOptions
  74491. */
  74492. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74493. /**
  74494. * Add a new custom optimization
  74495. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74496. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74497. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74498. * @returns the current SceneOptimizerOptions
  74499. */
  74500. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74501. /**
  74502. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74503. * @param targetFrameRate defines the target frame rate (60 by default)
  74504. * @returns a SceneOptimizerOptions object
  74505. */
  74506. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74507. /**
  74508. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74509. * @param targetFrameRate defines the target frame rate (60 by default)
  74510. * @returns a SceneOptimizerOptions object
  74511. */
  74512. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74513. /**
  74514. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74515. * @param targetFrameRate defines the target frame rate (60 by default)
  74516. * @returns a SceneOptimizerOptions object
  74517. */
  74518. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74519. }
  74520. /**
  74521. * Class used to run optimizations in order to reach a target frame rate
  74522. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74523. */
  74524. export class SceneOptimizer implements IDisposable {
  74525. private _isRunning;
  74526. private _options;
  74527. private _scene;
  74528. private _currentPriorityLevel;
  74529. private _targetFrameRate;
  74530. private _trackerDuration;
  74531. private _currentFrameRate;
  74532. private _sceneDisposeObserver;
  74533. private _improvementMode;
  74534. /**
  74535. * Defines an observable called when the optimizer reaches the target frame rate
  74536. */
  74537. onSuccessObservable: Observable<SceneOptimizer>;
  74538. /**
  74539. * Defines an observable called when the optimizer enables an optimization
  74540. */
  74541. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74542. /**
  74543. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74544. */
  74545. onFailureObservable: Observable<SceneOptimizer>;
  74546. /**
  74547. * Gets a boolean indicating if the optimizer is in improvement mode
  74548. */
  74549. get isInImprovementMode(): boolean;
  74550. /**
  74551. * Gets the current priority level (0 at start)
  74552. */
  74553. get currentPriorityLevel(): number;
  74554. /**
  74555. * Gets the current frame rate checked by the SceneOptimizer
  74556. */
  74557. get currentFrameRate(): number;
  74558. /**
  74559. * Gets or sets the current target frame rate (60 by default)
  74560. */
  74561. get targetFrameRate(): number;
  74562. /**
  74563. * Gets or sets the current target frame rate (60 by default)
  74564. */
  74565. set targetFrameRate(value: number);
  74566. /**
  74567. * Gets or sets the current interval between two checks (every 2000ms by default)
  74568. */
  74569. get trackerDuration(): number;
  74570. /**
  74571. * Gets or sets the current interval between two checks (every 2000ms by default)
  74572. */
  74573. set trackerDuration(value: number);
  74574. /**
  74575. * Gets the list of active optimizations
  74576. */
  74577. get optimizations(): SceneOptimization[];
  74578. /**
  74579. * Creates a new SceneOptimizer
  74580. * @param scene defines the scene to work on
  74581. * @param options defines the options to use with the SceneOptimizer
  74582. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74583. * @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)
  74584. */
  74585. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74586. /**
  74587. * Stops the current optimizer
  74588. */
  74589. stop(): void;
  74590. /**
  74591. * Reset the optimizer to initial step (current priority level = 0)
  74592. */
  74593. reset(): void;
  74594. /**
  74595. * Start the optimizer. By default it will try to reach a specific framerate
  74596. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74597. */
  74598. start(): void;
  74599. private _checkCurrentState;
  74600. /**
  74601. * Release all resources
  74602. */
  74603. dispose(): void;
  74604. /**
  74605. * Helper function to create a SceneOptimizer with one single line of code
  74606. * @param scene defines the scene to work on
  74607. * @param options defines the options to use with the SceneOptimizer
  74608. * @param onSuccess defines a callback to call on success
  74609. * @param onFailure defines a callback to call on failure
  74610. * @returns the new SceneOptimizer object
  74611. */
  74612. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74613. }
  74614. }
  74615. declare module "babylonjs/Misc/sceneSerializer" {
  74616. import { Scene } from "babylonjs/scene";
  74617. /**
  74618. * Class used to serialize a scene into a string
  74619. */
  74620. export class SceneSerializer {
  74621. /**
  74622. * Clear cache used by a previous serialization
  74623. */
  74624. static ClearCache(): void;
  74625. /**
  74626. * Serialize a scene into a JSON compatible object
  74627. * @param scene defines the scene to serialize
  74628. * @returns a JSON compatible object
  74629. */
  74630. static Serialize(scene: Scene): any;
  74631. /**
  74632. * Serialize a mesh into a JSON compatible object
  74633. * @param toSerialize defines the mesh to serialize
  74634. * @param withParents defines if parents must be serialized as well
  74635. * @param withChildren defines if children must be serialized as well
  74636. * @returns a JSON compatible object
  74637. */
  74638. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74639. }
  74640. }
  74641. declare module "babylonjs/Misc/textureTools" {
  74642. import { Texture } from "babylonjs/Materials/Textures/texture";
  74643. /**
  74644. * Class used to host texture specific utilities
  74645. */
  74646. export class TextureTools {
  74647. /**
  74648. * Uses the GPU to create a copy texture rescaled at a given size
  74649. * @param texture Texture to copy from
  74650. * @param width defines the desired width
  74651. * @param height defines the desired height
  74652. * @param useBilinearMode defines if bilinear mode has to be used
  74653. * @return the generated texture
  74654. */
  74655. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74656. }
  74657. }
  74658. declare module "babylonjs/Misc/videoRecorder" {
  74659. import { Nullable } from "babylonjs/types";
  74660. import { Engine } from "babylonjs/Engines/engine";
  74661. /**
  74662. * This represents the different options available for the video capture.
  74663. */
  74664. export interface VideoRecorderOptions {
  74665. /** Defines the mime type of the video. */
  74666. mimeType: string;
  74667. /** Defines the FPS the video should be recorded at. */
  74668. fps: number;
  74669. /** Defines the chunk size for the recording data. */
  74670. recordChunckSize: number;
  74671. /** The audio tracks to attach to the recording. */
  74672. audioTracks?: MediaStreamTrack[];
  74673. }
  74674. /**
  74675. * This can help with recording videos from BabylonJS.
  74676. * This is based on the available WebRTC functionalities of the browser.
  74677. *
  74678. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  74679. */
  74680. export class VideoRecorder {
  74681. private static readonly _defaultOptions;
  74682. /**
  74683. * Returns whether or not the VideoRecorder is available in your browser.
  74684. * @param engine Defines the Babylon Engine.
  74685. * @returns true if supported otherwise false.
  74686. */
  74687. static IsSupported(engine: Engine): boolean;
  74688. private readonly _options;
  74689. private _canvas;
  74690. private _mediaRecorder;
  74691. private _recordedChunks;
  74692. private _fileName;
  74693. private _resolve;
  74694. private _reject;
  74695. /**
  74696. * True when a recording is already in progress.
  74697. */
  74698. get isRecording(): boolean;
  74699. /**
  74700. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74701. * @param engine Defines the BabylonJS Engine you wish to record.
  74702. * @param options Defines options that can be used to customize the capture.
  74703. */
  74704. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74705. /**
  74706. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74707. */
  74708. stopRecording(): void;
  74709. /**
  74710. * Starts recording the canvas for a max duration specified in parameters.
  74711. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74712. * If null no automatic download will start and you can rely on the promise to get the data back.
  74713. * @param maxDuration Defines the maximum recording time in seconds.
  74714. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74715. * @return A promise callback at the end of the recording with the video data in Blob.
  74716. */
  74717. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74718. /**
  74719. * Releases internal resources used during the recording.
  74720. */
  74721. dispose(): void;
  74722. private _handleDataAvailable;
  74723. private _handleError;
  74724. private _handleStop;
  74725. }
  74726. }
  74727. declare module "babylonjs/Misc/screenshotTools" {
  74728. import { Camera } from "babylonjs/Cameras/camera";
  74729. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  74730. import { Engine } from "babylonjs/Engines/engine";
  74731. /**
  74732. * Class containing a set of static utilities functions for screenshots
  74733. */
  74734. export class ScreenshotTools {
  74735. /**
  74736. * Captures a screenshot of the current rendering
  74737. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74738. * @param engine defines the rendering engine
  74739. * @param camera defines the source camera
  74740. * @param size This parameter can be set to a single number or to an object with the
  74741. * following (optional) properties: precision, width, height. If a single number is passed,
  74742. * it will be used for both width and height. If an object is passed, the screenshot size
  74743. * will be derived from the parameters. The precision property is a multiplier allowing
  74744. * rendering at a higher or lower resolution
  74745. * @param successCallback defines the callback receives a single parameter which contains the
  74746. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74747. * src parameter of an <img> to display it
  74748. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74749. * Check your browser for supported MIME types
  74750. */
  74751. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74752. /**
  74753. * Captures a screenshot of the current rendering
  74754. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74755. * @param engine defines the rendering engine
  74756. * @param camera defines the source camera
  74757. * @param size This parameter can be set to a single number or to an object with the
  74758. * following (optional) properties: precision, width, height. If a single number is passed,
  74759. * it will be used for both width and height. If an object is passed, the screenshot size
  74760. * will be derived from the parameters. The precision property is a multiplier allowing
  74761. * rendering at a higher or lower resolution
  74762. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74763. * Check your browser for supported MIME types
  74764. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74765. * to the src parameter of an <img> to display it
  74766. */
  74767. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74768. /**
  74769. * Generates an image screenshot from the specified camera.
  74770. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74771. * @param engine The engine to use for rendering
  74772. * @param camera The camera to use for rendering
  74773. * @param size This parameter can be set to a single number or to an object with the
  74774. * following (optional) properties: precision, width, height. If a single number is passed,
  74775. * it will be used for both width and height. If an object is passed, the screenshot size
  74776. * will be derived from the parameters. The precision property is a multiplier allowing
  74777. * rendering at a higher or lower resolution
  74778. * @param successCallback The callback receives a single parameter which contains the
  74779. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74780. * src parameter of an <img> to display it
  74781. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74782. * Check your browser for supported MIME types
  74783. * @param samples Texture samples (default: 1)
  74784. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74785. * @param fileName A name for for the downloaded file.
  74786. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74787. */
  74788. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  74789. /**
  74790. * Generates an image screenshot from the specified camera.
  74791. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74792. * @param engine The engine to use for rendering
  74793. * @param camera The camera to use for rendering
  74794. * @param size This parameter can be set to a single number or to an object with the
  74795. * following (optional) properties: precision, width, height. If a single number is passed,
  74796. * it will be used for both width and height. If an object is passed, the screenshot size
  74797. * will be derived from the parameters. The precision property is a multiplier allowing
  74798. * rendering at a higher or lower resolution
  74799. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74800. * Check your browser for supported MIME types
  74801. * @param samples Texture samples (default: 1)
  74802. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74803. * @param fileName A name for for the downloaded file.
  74804. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74805. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74806. * to the src parameter of an <img> to display it
  74807. */
  74808. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74809. /**
  74810. * Gets height and width for screenshot size
  74811. * @private
  74812. */
  74813. private static _getScreenshotSize;
  74814. }
  74815. }
  74816. declare module "babylonjs/Misc/dataReader" {
  74817. /**
  74818. * Interface for a data buffer
  74819. */
  74820. export interface IDataBuffer {
  74821. /**
  74822. * Reads bytes from the data buffer.
  74823. * @param byteOffset The byte offset to read
  74824. * @param byteLength The byte length to read
  74825. * @returns A promise that resolves when the bytes are read
  74826. */
  74827. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74828. /**
  74829. * The byte length of the buffer.
  74830. */
  74831. readonly byteLength: number;
  74832. }
  74833. /**
  74834. * Utility class for reading from a data buffer
  74835. */
  74836. export class DataReader {
  74837. /**
  74838. * The data buffer associated with this data reader.
  74839. */
  74840. readonly buffer: IDataBuffer;
  74841. /**
  74842. * The current byte offset from the beginning of the data buffer.
  74843. */
  74844. byteOffset: number;
  74845. private _dataView;
  74846. private _dataByteOffset;
  74847. /**
  74848. * Constructor
  74849. * @param buffer The buffer to read
  74850. */
  74851. constructor(buffer: IDataBuffer);
  74852. /**
  74853. * Loads the given byte length.
  74854. * @param byteLength The byte length to load
  74855. * @returns A promise that resolves when the load is complete
  74856. */
  74857. loadAsync(byteLength: number): Promise<void>;
  74858. /**
  74859. * Read a unsigned 32-bit integer from the currently loaded data range.
  74860. * @returns The 32-bit integer read
  74861. */
  74862. readUint32(): number;
  74863. /**
  74864. * Read a byte array from the currently loaded data range.
  74865. * @param byteLength The byte length to read
  74866. * @returns The byte array read
  74867. */
  74868. readUint8Array(byteLength: number): Uint8Array;
  74869. /**
  74870. * Read a string from the currently loaded data range.
  74871. * @param byteLength The byte length to read
  74872. * @returns The string read
  74873. */
  74874. readString(byteLength: number): string;
  74875. /**
  74876. * Skips the given byte length the currently loaded data range.
  74877. * @param byteLength The byte length to skip
  74878. */
  74879. skipBytes(byteLength: number): void;
  74880. }
  74881. }
  74882. declare module "babylonjs/Misc/dataStorage" {
  74883. /**
  74884. * Class for storing data to local storage if available or in-memory storage otherwise
  74885. */
  74886. export class DataStorage {
  74887. private static _Storage;
  74888. private static _GetStorage;
  74889. /**
  74890. * Reads a string from the data storage
  74891. * @param key The key to read
  74892. * @param defaultValue The value if the key doesn't exist
  74893. * @returns The string value
  74894. */
  74895. static ReadString(key: string, defaultValue: string): string;
  74896. /**
  74897. * Writes a string to the data storage
  74898. * @param key The key to write
  74899. * @param value The value to write
  74900. */
  74901. static WriteString(key: string, value: string): void;
  74902. /**
  74903. * Reads a boolean from the data storage
  74904. * @param key The key to read
  74905. * @param defaultValue The value if the key doesn't exist
  74906. * @returns The boolean value
  74907. */
  74908. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74909. /**
  74910. * Writes a boolean to the data storage
  74911. * @param key The key to write
  74912. * @param value The value to write
  74913. */
  74914. static WriteBoolean(key: string, value: boolean): void;
  74915. /**
  74916. * Reads a number from the data storage
  74917. * @param key The key to read
  74918. * @param defaultValue The value if the key doesn't exist
  74919. * @returns The number value
  74920. */
  74921. static ReadNumber(key: string, defaultValue: number): number;
  74922. /**
  74923. * Writes a number to the data storage
  74924. * @param key The key to write
  74925. * @param value The value to write
  74926. */
  74927. static WriteNumber(key: string, value: number): void;
  74928. }
  74929. }
  74930. declare module "babylonjs/Misc/index" {
  74931. export * from "babylonjs/Misc/andOrNotEvaluator";
  74932. export * from "babylonjs/Misc/assetsManager";
  74933. export * from "babylonjs/Misc/basis";
  74934. export * from "babylonjs/Misc/dds";
  74935. export * from "babylonjs/Misc/decorators";
  74936. export * from "babylonjs/Misc/deferred";
  74937. export * from "babylonjs/Misc/environmentTextureTools";
  74938. export * from "babylonjs/Misc/meshExploder";
  74939. export * from "babylonjs/Misc/filesInput";
  74940. export * from "babylonjs/Misc/HighDynamicRange/index";
  74941. export * from "babylonjs/Misc/khronosTextureContainer";
  74942. export * from "babylonjs/Misc/observable";
  74943. export * from "babylonjs/Misc/performanceMonitor";
  74944. export * from "babylonjs/Misc/promise";
  74945. export * from "babylonjs/Misc/sceneOptimizer";
  74946. export * from "babylonjs/Misc/sceneSerializer";
  74947. export * from "babylonjs/Misc/smartArray";
  74948. export * from "babylonjs/Misc/stringDictionary";
  74949. export * from "babylonjs/Misc/tags";
  74950. export * from "babylonjs/Misc/textureTools";
  74951. export * from "babylonjs/Misc/tga";
  74952. export * from "babylonjs/Misc/tools";
  74953. export * from "babylonjs/Misc/videoRecorder";
  74954. export * from "babylonjs/Misc/virtualJoystick";
  74955. export * from "babylonjs/Misc/workerPool";
  74956. export * from "babylonjs/Misc/logger";
  74957. export * from "babylonjs/Misc/typeStore";
  74958. export * from "babylonjs/Misc/filesInputStore";
  74959. export * from "babylonjs/Misc/deepCopier";
  74960. export * from "babylonjs/Misc/pivotTools";
  74961. export * from "babylonjs/Misc/precisionDate";
  74962. export * from "babylonjs/Misc/screenshotTools";
  74963. export * from "babylonjs/Misc/typeStore";
  74964. export * from "babylonjs/Misc/webRequest";
  74965. export * from "babylonjs/Misc/iInspectable";
  74966. export * from "babylonjs/Misc/brdfTextureTools";
  74967. export * from "babylonjs/Misc/rgbdTextureTools";
  74968. export * from "babylonjs/Misc/gradients";
  74969. export * from "babylonjs/Misc/perfCounter";
  74970. export * from "babylonjs/Misc/fileRequest";
  74971. export * from "babylonjs/Misc/customAnimationFrameRequester";
  74972. export * from "babylonjs/Misc/retryStrategy";
  74973. export * from "babylonjs/Misc/interfaces/screenshotSize";
  74974. export * from "babylonjs/Misc/canvasGenerator";
  74975. export * from "babylonjs/Misc/fileTools";
  74976. export * from "babylonjs/Misc/stringTools";
  74977. export * from "babylonjs/Misc/dataReader";
  74978. export * from "babylonjs/Misc/minMaxReducer";
  74979. export * from "babylonjs/Misc/depthReducer";
  74980. export * from "babylonjs/Misc/dataStorage";
  74981. }
  74982. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  74983. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74984. import { Observable } from "babylonjs/Misc/observable";
  74985. import { Matrix } from "babylonjs/Maths/math.vector";
  74986. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74987. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74988. /**
  74989. * Options used for hit testing
  74990. */
  74991. export interface IWebXRLegacyHitTestOptions {
  74992. /**
  74993. * Only test when user interacted with the scene. Default - hit test every frame
  74994. */
  74995. testOnPointerDownOnly?: boolean;
  74996. /**
  74997. * The node to use to transform the local results to world coordinates
  74998. */
  74999. worldParentNode?: TransformNode;
  75000. }
  75001. /**
  75002. * Interface defining the babylon result of raycasting/hit-test
  75003. */
  75004. export interface IWebXRLegacyHitResult {
  75005. /**
  75006. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75007. */
  75008. transformationMatrix: Matrix;
  75009. /**
  75010. * The native hit test result
  75011. */
  75012. xrHitResult: XRHitResult | XRHitTestResult;
  75013. }
  75014. /**
  75015. * The currently-working hit-test module.
  75016. * Hit test (or Ray-casting) is used to interact with the real world.
  75017. * For further information read here - https://github.com/immersive-web/hit-test
  75018. */
  75019. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  75020. /**
  75021. * options to use when constructing this feature
  75022. */
  75023. readonly options: IWebXRLegacyHitTestOptions;
  75024. private _direction;
  75025. private _mat;
  75026. private _onSelectEnabled;
  75027. private _origin;
  75028. /**
  75029. * The module's name
  75030. */
  75031. static readonly Name: string;
  75032. /**
  75033. * The (Babylon) version of this module.
  75034. * This is an integer representing the implementation version.
  75035. * This number does not correspond to the WebXR specs version
  75036. */
  75037. static readonly Version: number;
  75038. /**
  75039. * Populated with the last native XR Hit Results
  75040. */
  75041. lastNativeXRHitResults: XRHitResult[];
  75042. /**
  75043. * Triggered when new babylon (transformed) hit test results are available
  75044. */
  75045. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75046. /**
  75047. * Creates a new instance of the (legacy version) hit test feature
  75048. * @param _xrSessionManager an instance of WebXRSessionManager
  75049. * @param options options to use when constructing this feature
  75050. */
  75051. constructor(_xrSessionManager: WebXRSessionManager,
  75052. /**
  75053. * options to use when constructing this feature
  75054. */
  75055. options?: IWebXRLegacyHitTestOptions);
  75056. /**
  75057. * execute a hit test with an XR Ray
  75058. *
  75059. * @param xrSession a native xrSession that will execute this hit test
  75060. * @param xrRay the ray (position and direction) to use for ray-casting
  75061. * @param referenceSpace native XR reference space to use for the hit-test
  75062. * @param filter filter function that will filter the results
  75063. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75064. */
  75065. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75066. /**
  75067. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75068. * @param event the (select) event to use to select with
  75069. * @param referenceSpace the reference space to use for this hit test
  75070. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75071. */
  75072. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75073. /**
  75074. * attach this feature
  75075. * Will usually be called by the features manager
  75076. *
  75077. * @returns true if successful.
  75078. */
  75079. attach(): boolean;
  75080. /**
  75081. * detach this feature.
  75082. * Will usually be called by the features manager
  75083. *
  75084. * @returns true if successful.
  75085. */
  75086. detach(): boolean;
  75087. /**
  75088. * Dispose this feature and all of the resources attached
  75089. */
  75090. dispose(): void;
  75091. protected _onXRFrame(frame: XRFrame): void;
  75092. private _onHitTestResults;
  75093. private _onSelect;
  75094. }
  75095. }
  75096. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  75097. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75098. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75099. import { Observable } from "babylonjs/Misc/observable";
  75100. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  75101. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75102. /**
  75103. * Options used in the plane detector module
  75104. */
  75105. export interface IWebXRPlaneDetectorOptions {
  75106. /**
  75107. * The node to use to transform the local results to world coordinates
  75108. */
  75109. worldParentNode?: TransformNode;
  75110. }
  75111. /**
  75112. * A babylon interface for a WebXR plane.
  75113. * A Plane is actually a polygon, built from N points in space
  75114. *
  75115. * Supported in chrome 79, not supported in canary 81 ATM
  75116. */
  75117. export interface IWebXRPlane {
  75118. /**
  75119. * a babylon-assigned ID for this polygon
  75120. */
  75121. id: number;
  75122. /**
  75123. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75124. */
  75125. polygonDefinition: Array<Vector3>;
  75126. /**
  75127. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75128. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75129. */
  75130. transformationMatrix: Matrix;
  75131. /**
  75132. * the native xr-plane object
  75133. */
  75134. xrPlane: XRPlane;
  75135. }
  75136. /**
  75137. * The plane detector is used to detect planes in the real world when in AR
  75138. * For more information see https://github.com/immersive-web/real-world-geometry/
  75139. */
  75140. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75141. private _options;
  75142. private _detectedPlanes;
  75143. private _enabled;
  75144. private _lastFrameDetected;
  75145. /**
  75146. * The module's name
  75147. */
  75148. static readonly Name: string;
  75149. /**
  75150. * The (Babylon) version of this module.
  75151. * This is an integer representing the implementation version.
  75152. * This number does not correspond to the WebXR specs version
  75153. */
  75154. static readonly Version: number;
  75155. /**
  75156. * Observers registered here will be executed when a new plane was added to the session
  75157. */
  75158. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75159. /**
  75160. * Observers registered here will be executed when a plane is no longer detected in the session
  75161. */
  75162. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75163. /**
  75164. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75165. * This can execute N times every frame
  75166. */
  75167. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75168. /**
  75169. * construct a new Plane Detector
  75170. * @param _xrSessionManager an instance of xr Session manager
  75171. * @param _options configuration to use when constructing this feature
  75172. */
  75173. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75174. /**
  75175. * Dispose this feature and all of the resources attached
  75176. */
  75177. dispose(): void;
  75178. protected _onXRFrame(frame: XRFrame): void;
  75179. private _init;
  75180. private _updatePlaneWithXRPlane;
  75181. /**
  75182. * avoiding using Array.find for global support.
  75183. * @param xrPlane the plane to find in the array
  75184. */
  75185. private findIndexInPlaneArray;
  75186. }
  75187. }
  75188. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  75189. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75190. import { Observable } from "babylonjs/Misc/observable";
  75191. import { Matrix } from "babylonjs/Maths/math.vector";
  75192. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75193. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  75194. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75195. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75196. /**
  75197. * Configuration options of the anchor system
  75198. */
  75199. export interface IWebXRAnchorSystemOptions {
  75200. /**
  75201. * Should a new anchor be added every time a select event is triggered
  75202. */
  75203. addAnchorOnSelect?: boolean;
  75204. /**
  75205. * should the anchor system use plane detection.
  75206. * If set to true, the plane-detection feature should be set using setPlaneDetector
  75207. */
  75208. usePlaneDetection?: boolean;
  75209. /**
  75210. * a node that will be used to convert local to world coordinates
  75211. */
  75212. worldParentNode?: TransformNode;
  75213. }
  75214. /**
  75215. * A babylon container for an XR Anchor
  75216. */
  75217. export interface IWebXRAnchor {
  75218. /**
  75219. * A babylon-assigned ID for this anchor
  75220. */
  75221. id: number;
  75222. /**
  75223. * Transformation matrix to apply to an object attached to this anchor
  75224. */
  75225. transformationMatrix: Matrix;
  75226. /**
  75227. * The native anchor object
  75228. */
  75229. xrAnchor: XRAnchor;
  75230. }
  75231. /**
  75232. * An implementation of the anchor system of WebXR.
  75233. * Note that the current documented implementation is not available in any browser. Future implementations
  75234. * will use the frame to create an anchor and not the session or a detected plane
  75235. * For further information see https://github.com/immersive-web/anchors/
  75236. */
  75237. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75238. private _options;
  75239. private _enabled;
  75240. private _hitTestModule;
  75241. private _lastFrameDetected;
  75242. private _onSelect;
  75243. private _planeDetector;
  75244. private _trackedAnchors;
  75245. /**
  75246. * The module's name
  75247. */
  75248. static readonly Name: string;
  75249. /**
  75250. * The (Babylon) version of this module.
  75251. * This is an integer representing the implementation version.
  75252. * This number does not correspond to the WebXR specs version
  75253. */
  75254. static readonly Version: number;
  75255. /**
  75256. * Observers registered here will be executed when a new anchor was added to the session
  75257. */
  75258. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75259. /**
  75260. * Observers registered here will be executed when an anchor was removed from the session
  75261. */
  75262. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75263. /**
  75264. * Observers registered here will be executed when an existing anchor updates
  75265. * This can execute N times every frame
  75266. */
  75267. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75268. /**
  75269. * constructs a new anchor system
  75270. * @param _xrSessionManager an instance of WebXRSessionManager
  75271. * @param _options configuration object for this feature
  75272. */
  75273. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75274. /**
  75275. * Add anchor at a specific XR point.
  75276. *
  75277. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  75278. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  75279. * @returns a promise the fulfills when the anchor was created
  75280. */
  75281. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  75282. /**
  75283. * attach this feature
  75284. * Will usually be called by the features manager
  75285. *
  75286. * @returns true if successful.
  75287. */
  75288. attach(): boolean;
  75289. /**
  75290. * detach this feature.
  75291. * Will usually be called by the features manager
  75292. *
  75293. * @returns true if successful.
  75294. */
  75295. detach(): boolean;
  75296. /**
  75297. * Dispose this feature and all of the resources attached
  75298. */
  75299. dispose(): void;
  75300. /**
  75301. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  75302. * @param hitTestModule the hit-test module to use.
  75303. */
  75304. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  75305. /**
  75306. * set the plane detector to use in order to create anchors from frames
  75307. * @param planeDetector the plane-detector module to use
  75308. * @param enable enable plane-anchors. default is true
  75309. */
  75310. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  75311. protected _onXRFrame(frame: XRFrame): void;
  75312. /**
  75313. * avoiding using Array.find for global support.
  75314. * @param xrAnchor the plane to find in the array
  75315. */
  75316. private _findIndexInAnchorArray;
  75317. private _updateAnchorWithXRFrame;
  75318. }
  75319. }
  75320. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  75321. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75323. import { Observable } from "babylonjs/Misc/observable";
  75324. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75325. /**
  75326. * Options interface for the background remover plugin
  75327. */
  75328. export interface IWebXRBackgroundRemoverOptions {
  75329. /**
  75330. * Further background meshes to disable when entering AR
  75331. */
  75332. backgroundMeshes?: AbstractMesh[];
  75333. /**
  75334. * flags to configure the removal of the environment helper.
  75335. * If not set, the entire background will be removed. If set, flags should be set as well.
  75336. */
  75337. environmentHelperRemovalFlags?: {
  75338. /**
  75339. * Should the skybox be removed (default false)
  75340. */
  75341. skyBox?: boolean;
  75342. /**
  75343. * Should the ground be removed (default false)
  75344. */
  75345. ground?: boolean;
  75346. };
  75347. /**
  75348. * don't disable the environment helper
  75349. */
  75350. ignoreEnvironmentHelper?: boolean;
  75351. }
  75352. /**
  75353. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75354. */
  75355. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75356. /**
  75357. * read-only options to be used in this module
  75358. */
  75359. readonly options: IWebXRBackgroundRemoverOptions;
  75360. /**
  75361. * The module's name
  75362. */
  75363. static readonly Name: string;
  75364. /**
  75365. * The (Babylon) version of this module.
  75366. * This is an integer representing the implementation version.
  75367. * This number does not correspond to the WebXR specs version
  75368. */
  75369. static readonly Version: number;
  75370. /**
  75371. * registered observers will be triggered when the background state changes
  75372. */
  75373. onBackgroundStateChangedObservable: Observable<boolean>;
  75374. /**
  75375. * constructs a new background remover module
  75376. * @param _xrSessionManager the session manager for this module
  75377. * @param options read-only options to be used in this module
  75378. */
  75379. constructor(_xrSessionManager: WebXRSessionManager,
  75380. /**
  75381. * read-only options to be used in this module
  75382. */
  75383. options?: IWebXRBackgroundRemoverOptions);
  75384. /**
  75385. * attach this feature
  75386. * Will usually be called by the features manager
  75387. *
  75388. * @returns true if successful.
  75389. */
  75390. attach(): boolean;
  75391. /**
  75392. * detach this feature.
  75393. * Will usually be called by the features manager
  75394. *
  75395. * @returns true if successful.
  75396. */
  75397. detach(): boolean;
  75398. /**
  75399. * Dispose this feature and all of the resources attached
  75400. */
  75401. dispose(): void;
  75402. protected _onXRFrame(_xrFrame: XRFrame): void;
  75403. private _setBackgroundState;
  75404. }
  75405. }
  75406. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  75407. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75408. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  75409. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  75410. import { WebXRInput } from "babylonjs/XR/webXRInput";
  75411. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75412. import { Nullable } from "babylonjs/types";
  75413. /**
  75414. * Options for the controller physics feature
  75415. */
  75416. export class IWebXRControllerPhysicsOptions {
  75417. /**
  75418. * Should the headset get its own impostor
  75419. */
  75420. enableHeadsetImpostor?: boolean;
  75421. /**
  75422. * Optional parameters for the headset impostor
  75423. */
  75424. headsetImpostorParams?: {
  75425. /**
  75426. * The type of impostor to create. Default is sphere
  75427. */
  75428. impostorType: number;
  75429. /**
  75430. * the size of the impostor. Defaults to 10cm
  75431. */
  75432. impostorSize?: number | {
  75433. width: number;
  75434. height: number;
  75435. depth: number;
  75436. };
  75437. /**
  75438. * Friction definitions
  75439. */
  75440. friction?: number;
  75441. /**
  75442. * Restitution
  75443. */
  75444. restitution?: number;
  75445. };
  75446. /**
  75447. * The physics properties of the future impostors
  75448. */
  75449. physicsProperties?: {
  75450. /**
  75451. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75452. * Note that this requires a physics engine that supports mesh impostors!
  75453. */
  75454. useControllerMesh?: boolean;
  75455. /**
  75456. * The type of impostor to create. Default is sphere
  75457. */
  75458. impostorType?: number;
  75459. /**
  75460. * the size of the impostor. Defaults to 10cm
  75461. */
  75462. impostorSize?: number | {
  75463. width: number;
  75464. height: number;
  75465. depth: number;
  75466. };
  75467. /**
  75468. * Friction definitions
  75469. */
  75470. friction?: number;
  75471. /**
  75472. * Restitution
  75473. */
  75474. restitution?: number;
  75475. };
  75476. /**
  75477. * the xr input to use with this pointer selection
  75478. */
  75479. xrInput: WebXRInput;
  75480. }
  75481. /**
  75482. * Add physics impostor to your webxr controllers,
  75483. * including naive calculation of their linear and angular velocity
  75484. */
  75485. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75486. private readonly _options;
  75487. private _attachController;
  75488. private _controllers;
  75489. private _debugMode;
  75490. private _delta;
  75491. private _headsetImpostor?;
  75492. private _headsetMesh?;
  75493. private _lastTimestamp;
  75494. private _tmpQuaternion;
  75495. private _tmpVector;
  75496. /**
  75497. * The module's name
  75498. */
  75499. static readonly Name: string;
  75500. /**
  75501. * The (Babylon) version of this module.
  75502. * This is an integer representing the implementation version.
  75503. * This number does not correspond to the webxr specs version
  75504. */
  75505. static readonly Version: number;
  75506. /**
  75507. * Construct a new Controller Physics Feature
  75508. * @param _xrSessionManager the corresponding xr session manager
  75509. * @param _options options to create this feature with
  75510. */
  75511. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75512. /**
  75513. * @hidden
  75514. * enable debugging - will show console outputs and the impostor mesh
  75515. */
  75516. _enablePhysicsDebug(): void;
  75517. /**
  75518. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75519. * @param xrController the controller to add
  75520. */
  75521. addController(xrController: WebXRInputSource): void;
  75522. /**
  75523. * attach this feature
  75524. * Will usually be called by the features manager
  75525. *
  75526. * @returns true if successful.
  75527. */
  75528. attach(): boolean;
  75529. /**
  75530. * detach this feature.
  75531. * Will usually be called by the features manager
  75532. *
  75533. * @returns true if successful.
  75534. */
  75535. detach(): boolean;
  75536. /**
  75537. * Get the headset impostor, if enabled
  75538. * @returns the impostor
  75539. */
  75540. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75541. /**
  75542. * Get the physics impostor of a specific controller.
  75543. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75544. * @param controller the controller or the controller id of which to get the impostor
  75545. * @returns the impostor or null
  75546. */
  75547. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75548. /**
  75549. * Update the physics properties provided in the constructor
  75550. * @param newProperties the new properties object
  75551. */
  75552. setPhysicsProperties(newProperties: {
  75553. impostorType?: number;
  75554. impostorSize?: number | {
  75555. width: number;
  75556. height: number;
  75557. depth: number;
  75558. };
  75559. friction?: number;
  75560. restitution?: number;
  75561. }): void;
  75562. protected _onXRFrame(_xrFrame: any): void;
  75563. private _detachController;
  75564. }
  75565. }
  75566. declare module "babylonjs/XR/features/WebXRHitTest" {
  75567. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75568. import { Observable } from "babylonjs/Misc/observable";
  75569. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  75570. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75571. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75572. /**
  75573. * Options used for hit testing (version 2)
  75574. */
  75575. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75576. /**
  75577. * Do not create a permanent hit test. Will usually be used when only
  75578. * transient inputs are needed.
  75579. */
  75580. disablePermanentHitTest?: boolean;
  75581. /**
  75582. * Enable transient (for example touch-based) hit test inspections
  75583. */
  75584. enableTransientHitTest?: boolean;
  75585. /**
  75586. * Offset ray for the permanent hit test
  75587. */
  75588. offsetRay?: Vector3;
  75589. /**
  75590. * Offset ray for the transient hit test
  75591. */
  75592. transientOffsetRay?: Vector3;
  75593. /**
  75594. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75595. */
  75596. useReferenceSpace?: boolean;
  75597. }
  75598. /**
  75599. * Interface defining the babylon result of hit-test
  75600. */
  75601. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75602. /**
  75603. * The input source that generated this hit test (if transient)
  75604. */
  75605. inputSource?: XRInputSource;
  75606. /**
  75607. * Is this a transient hit test
  75608. */
  75609. isTransient?: boolean;
  75610. /**
  75611. * Position of the hit test result
  75612. */
  75613. position: Vector3;
  75614. /**
  75615. * Rotation of the hit test result
  75616. */
  75617. rotationQuaternion: Quaternion;
  75618. }
  75619. /**
  75620. * The currently-working hit-test module.
  75621. * Hit test (or Ray-casting) is used to interact with the real world.
  75622. * For further information read here - https://github.com/immersive-web/hit-test
  75623. *
  75624. * Tested on chrome (mobile) 80.
  75625. */
  75626. export class WebXRHitTest extends WebXRAbstractFeature {
  75627. /**
  75628. * options to use when constructing this feature
  75629. */
  75630. readonly options: IWebXRHitTestOptions;
  75631. private _tmpMat;
  75632. private _tmpPos;
  75633. private _tmpQuat;
  75634. private _transientXrHitTestSource;
  75635. private _xrHitTestSource;
  75636. private initHitTestSource;
  75637. /**
  75638. * The module's name
  75639. */
  75640. static readonly Name: string;
  75641. /**
  75642. * The (Babylon) version of this module.
  75643. * This is an integer representing the implementation version.
  75644. * This number does not correspond to the WebXR specs version
  75645. */
  75646. static readonly Version: number;
  75647. /**
  75648. * When set to true, each hit test will have its own position/rotation objects
  75649. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75650. * the developers will clone them or copy them as they see fit.
  75651. */
  75652. autoCloneTransformation: boolean;
  75653. /**
  75654. * Populated with the last native XR Hit Results
  75655. */
  75656. lastNativeXRHitResults: XRHitResult[];
  75657. /**
  75658. * Triggered when new babylon (transformed) hit test results are available
  75659. */
  75660. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75661. /**
  75662. * Use this to temporarily pause hit test checks.
  75663. */
  75664. paused: boolean;
  75665. /**
  75666. * Creates a new instance of the hit test feature
  75667. * @param _xrSessionManager an instance of WebXRSessionManager
  75668. * @param options options to use when constructing this feature
  75669. */
  75670. constructor(_xrSessionManager: WebXRSessionManager,
  75671. /**
  75672. * options to use when constructing this feature
  75673. */
  75674. options?: IWebXRHitTestOptions);
  75675. /**
  75676. * attach this feature
  75677. * Will usually be called by the features manager
  75678. *
  75679. * @returns true if successful.
  75680. */
  75681. attach(): boolean;
  75682. /**
  75683. * detach this feature.
  75684. * Will usually be called by the features manager
  75685. *
  75686. * @returns true if successful.
  75687. */
  75688. detach(): boolean;
  75689. /**
  75690. * Dispose this feature and all of the resources attached
  75691. */
  75692. dispose(): void;
  75693. protected _onXRFrame(frame: XRFrame): void;
  75694. private _processWebXRHitTestResult;
  75695. }
  75696. }
  75697. declare module "babylonjs/XR/features/index" {
  75698. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  75699. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  75700. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  75701. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  75702. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  75703. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  75704. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  75705. export * from "babylonjs/XR/features/WebXRHitTest";
  75706. }
  75707. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  75708. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75710. import { Scene } from "babylonjs/scene";
  75711. /**
  75712. * The motion controller class for all microsoft mixed reality controllers
  75713. */
  75714. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75715. protected readonly _mapping: {
  75716. defaultButton: {
  75717. valueNodeName: string;
  75718. unpressedNodeName: string;
  75719. pressedNodeName: string;
  75720. };
  75721. defaultAxis: {
  75722. valueNodeName: string;
  75723. minNodeName: string;
  75724. maxNodeName: string;
  75725. };
  75726. buttons: {
  75727. "xr-standard-trigger": {
  75728. rootNodeName: string;
  75729. componentProperty: string;
  75730. states: string[];
  75731. };
  75732. "xr-standard-squeeze": {
  75733. rootNodeName: string;
  75734. componentProperty: string;
  75735. states: string[];
  75736. };
  75737. "xr-standard-touchpad": {
  75738. rootNodeName: string;
  75739. labelAnchorNodeName: string;
  75740. touchPointNodeName: string;
  75741. };
  75742. "xr-standard-thumbstick": {
  75743. rootNodeName: string;
  75744. componentProperty: string;
  75745. states: string[];
  75746. };
  75747. };
  75748. axes: {
  75749. "xr-standard-touchpad": {
  75750. "x-axis": {
  75751. rootNodeName: string;
  75752. };
  75753. "y-axis": {
  75754. rootNodeName: string;
  75755. };
  75756. };
  75757. "xr-standard-thumbstick": {
  75758. "x-axis": {
  75759. rootNodeName: string;
  75760. };
  75761. "y-axis": {
  75762. rootNodeName: string;
  75763. };
  75764. };
  75765. };
  75766. };
  75767. /**
  75768. * The base url used to load the left and right controller models
  75769. */
  75770. static MODEL_BASE_URL: string;
  75771. /**
  75772. * The name of the left controller model file
  75773. */
  75774. static MODEL_LEFT_FILENAME: string;
  75775. /**
  75776. * The name of the right controller model file
  75777. */
  75778. static MODEL_RIGHT_FILENAME: string;
  75779. profileId: string;
  75780. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75781. protected _getFilenameAndPath(): {
  75782. filename: string;
  75783. path: string;
  75784. };
  75785. protected _getModelLoadingConstraints(): boolean;
  75786. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75787. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75788. protected _updateModel(): void;
  75789. }
  75790. }
  75791. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  75792. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75794. import { Scene } from "babylonjs/scene";
  75795. /**
  75796. * The motion controller class for oculus touch (quest, rift).
  75797. * This class supports legacy mapping as well the standard xr mapping
  75798. */
  75799. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75800. private _forceLegacyControllers;
  75801. private _modelRootNode;
  75802. /**
  75803. * The base url used to load the left and right controller models
  75804. */
  75805. static MODEL_BASE_URL: string;
  75806. /**
  75807. * The name of the left controller model file
  75808. */
  75809. static MODEL_LEFT_FILENAME: string;
  75810. /**
  75811. * The name of the right controller model file
  75812. */
  75813. static MODEL_RIGHT_FILENAME: string;
  75814. /**
  75815. * Base Url for the Quest controller model.
  75816. */
  75817. static QUEST_MODEL_BASE_URL: string;
  75818. profileId: string;
  75819. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75820. protected _getFilenameAndPath(): {
  75821. filename: string;
  75822. path: string;
  75823. };
  75824. protected _getModelLoadingConstraints(): boolean;
  75825. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75826. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75827. protected _updateModel(): void;
  75828. /**
  75829. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75830. * between the touch and touch 2.
  75831. */
  75832. private _isQuest;
  75833. }
  75834. }
  75835. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  75836. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75837. import { Scene } from "babylonjs/scene";
  75838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75839. /**
  75840. * The motion controller class for the standard HTC-Vive controllers
  75841. */
  75842. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75843. private _modelRootNode;
  75844. /**
  75845. * The base url used to load the left and right controller models
  75846. */
  75847. static MODEL_BASE_URL: string;
  75848. /**
  75849. * File name for the controller model.
  75850. */
  75851. static MODEL_FILENAME: string;
  75852. profileId: string;
  75853. /**
  75854. * Create a new Vive motion controller object
  75855. * @param scene the scene to use to create this controller
  75856. * @param gamepadObject the corresponding gamepad object
  75857. * @param handedness the handedness of the controller
  75858. */
  75859. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75860. protected _getFilenameAndPath(): {
  75861. filename: string;
  75862. path: string;
  75863. };
  75864. protected _getModelLoadingConstraints(): boolean;
  75865. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75866. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75867. protected _updateModel(): void;
  75868. }
  75869. }
  75870. declare module "babylonjs/XR/motionController/index" {
  75871. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75872. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  75873. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  75874. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  75875. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  75876. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  75877. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  75878. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  75879. }
  75880. declare module "babylonjs/XR/index" {
  75881. export * from "babylonjs/XR/webXRCamera";
  75882. export * from "babylonjs/XR/webXREnterExitUI";
  75883. export * from "babylonjs/XR/webXRExperienceHelper";
  75884. export * from "babylonjs/XR/webXRInput";
  75885. export * from "babylonjs/XR/webXRInputSource";
  75886. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  75887. export * from "babylonjs/XR/webXRTypes";
  75888. export * from "babylonjs/XR/webXRSessionManager";
  75889. export * from "babylonjs/XR/webXRDefaultExperience";
  75890. export * from "babylonjs/XR/webXRFeaturesManager";
  75891. export * from "babylonjs/XR/features/index";
  75892. export * from "babylonjs/XR/motionController/index";
  75893. }
  75894. declare module "babylonjs/index" {
  75895. export * from "babylonjs/abstractScene";
  75896. export * from "babylonjs/Actions/index";
  75897. export * from "babylonjs/Animations/index";
  75898. export * from "babylonjs/assetContainer";
  75899. export * from "babylonjs/Audio/index";
  75900. export * from "babylonjs/Behaviors/index";
  75901. export * from "babylonjs/Bones/index";
  75902. export * from "babylonjs/Cameras/index";
  75903. export * from "babylonjs/Collisions/index";
  75904. export * from "babylonjs/Culling/index";
  75905. export * from "babylonjs/Debug/index";
  75906. export * from "babylonjs/DeviceInput/index";
  75907. export * from "babylonjs/Engines/index";
  75908. export * from "babylonjs/Events/index";
  75909. export * from "babylonjs/Gamepads/index";
  75910. export * from "babylonjs/Gizmos/index";
  75911. export * from "babylonjs/Helpers/index";
  75912. export * from "babylonjs/Instrumentation/index";
  75913. export * from "babylonjs/Layers/index";
  75914. export * from "babylonjs/LensFlares/index";
  75915. export * from "babylonjs/Lights/index";
  75916. export * from "babylonjs/Loading/index";
  75917. export * from "babylonjs/Materials/index";
  75918. export * from "babylonjs/Maths/index";
  75919. export * from "babylonjs/Meshes/index";
  75920. export * from "babylonjs/Morph/index";
  75921. export * from "babylonjs/Navigation/index";
  75922. export * from "babylonjs/node";
  75923. export * from "babylonjs/Offline/index";
  75924. export * from "babylonjs/Particles/index";
  75925. export * from "babylonjs/Physics/index";
  75926. export * from "babylonjs/PostProcesses/index";
  75927. export * from "babylonjs/Probes/index";
  75928. export * from "babylonjs/Rendering/index";
  75929. export * from "babylonjs/scene";
  75930. export * from "babylonjs/sceneComponent";
  75931. export * from "babylonjs/Sprites/index";
  75932. export * from "babylonjs/States/index";
  75933. export * from "babylonjs/Misc/index";
  75934. export * from "babylonjs/XR/index";
  75935. export * from "babylonjs/types";
  75936. }
  75937. declare module "babylonjs/Animations/pathCursor" {
  75938. import { Vector3 } from "babylonjs/Maths/math.vector";
  75939. import { Path2 } from "babylonjs/Maths/math.path";
  75940. /**
  75941. * A cursor which tracks a point on a path
  75942. */
  75943. export class PathCursor {
  75944. private path;
  75945. /**
  75946. * Stores path cursor callbacks for when an onchange event is triggered
  75947. */
  75948. private _onchange;
  75949. /**
  75950. * The value of the path cursor
  75951. */
  75952. value: number;
  75953. /**
  75954. * The animation array of the path cursor
  75955. */
  75956. animations: Animation[];
  75957. /**
  75958. * Initializes the path cursor
  75959. * @param path The path to track
  75960. */
  75961. constructor(path: Path2);
  75962. /**
  75963. * Gets the cursor point on the path
  75964. * @returns A point on the path cursor at the cursor location
  75965. */
  75966. getPoint(): Vector3;
  75967. /**
  75968. * Moves the cursor ahead by the step amount
  75969. * @param step The amount to move the cursor forward
  75970. * @returns This path cursor
  75971. */
  75972. moveAhead(step?: number): PathCursor;
  75973. /**
  75974. * Moves the cursor behind by the step amount
  75975. * @param step The amount to move the cursor back
  75976. * @returns This path cursor
  75977. */
  75978. moveBack(step?: number): PathCursor;
  75979. /**
  75980. * Moves the cursor by the step amount
  75981. * If the step amount is greater than one, an exception is thrown
  75982. * @param step The amount to move the cursor
  75983. * @returns This path cursor
  75984. */
  75985. move(step: number): PathCursor;
  75986. /**
  75987. * Ensures that the value is limited between zero and one
  75988. * @returns This path cursor
  75989. */
  75990. private ensureLimits;
  75991. /**
  75992. * Runs onchange callbacks on change (used by the animation engine)
  75993. * @returns This path cursor
  75994. */
  75995. private raiseOnChange;
  75996. /**
  75997. * Executes a function on change
  75998. * @param f A path cursor onchange callback
  75999. * @returns This path cursor
  76000. */
  76001. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76002. }
  76003. }
  76004. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  76005. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  76006. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  76007. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  76008. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  76009. }
  76010. declare module "babylonjs/Engines/Processors/Expressions/index" {
  76011. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  76012. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  76013. }
  76014. declare module "babylonjs/Engines/Processors/index" {
  76015. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  76016. export * from "babylonjs/Engines/Processors/Expressions/index";
  76017. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  76018. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  76019. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  76020. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  76021. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  76022. export * from "babylonjs/Engines/Processors/shaderProcessor";
  76023. }
  76024. declare module "babylonjs/Legacy/legacy" {
  76025. import * as Babylon from "babylonjs/index";
  76026. export * from "babylonjs/index";
  76027. }
  76028. declare module "babylonjs/Shaders/blur.fragment" {
  76029. /** @hidden */
  76030. export var blurPixelShader: {
  76031. name: string;
  76032. shader: string;
  76033. };
  76034. }
  76035. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  76036. /** @hidden */
  76037. export var pointCloudVertexDeclaration: {
  76038. name: string;
  76039. shader: string;
  76040. };
  76041. }
  76042. declare module "babylonjs" {
  76043. export * from "babylonjs/Legacy/legacy";
  76044. }
  76045. declare module BABYLON {
  76046. /** Alias type for value that can be null */
  76047. export type Nullable<T> = T | null;
  76048. /**
  76049. * Alias type for number that are floats
  76050. * @ignorenaming
  76051. */
  76052. export type float = number;
  76053. /**
  76054. * Alias type for number that are doubles.
  76055. * @ignorenaming
  76056. */
  76057. export type double = number;
  76058. /**
  76059. * Alias type for number that are integer
  76060. * @ignorenaming
  76061. */
  76062. export type int = number;
  76063. /** Alias type for number array or Float32Array */
  76064. export type FloatArray = number[] | Float32Array;
  76065. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  76066. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  76067. /**
  76068. * Alias for types that can be used by a Buffer or VertexBuffer.
  76069. */
  76070. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  76071. /**
  76072. * Alias type for primitive types
  76073. * @ignorenaming
  76074. */
  76075. type Primitive = undefined | null | boolean | string | number | Function;
  76076. /**
  76077. * Type modifier to make all the properties of an object Readonly
  76078. */
  76079. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  76080. /**
  76081. * Type modifier to make all the properties of an object Readonly recursively
  76082. */
  76083. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  76084. /**
  76085. * Type modifier to make object properties readonly.
  76086. */
  76087. export type DeepImmutableObject<T> = {
  76088. readonly [K in keyof T]: DeepImmutable<T[K]>;
  76089. };
  76090. /** @hidden */
  76091. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  76092. }
  76093. }
  76094. declare module BABYLON {
  76095. /**
  76096. * A class serves as a medium between the observable and its observers
  76097. */
  76098. export class EventState {
  76099. /**
  76100. * Create a new EventState
  76101. * @param mask defines the mask associated with this state
  76102. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76103. * @param target defines the original target of the state
  76104. * @param currentTarget defines the current target of the state
  76105. */
  76106. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  76107. /**
  76108. * Initialize the current event state
  76109. * @param mask defines the mask associated with this state
  76110. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76111. * @param target defines the original target of the state
  76112. * @param currentTarget defines the current target of the state
  76113. * @returns the current event state
  76114. */
  76115. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  76116. /**
  76117. * An Observer can set this property to true to prevent subsequent observers of being notified
  76118. */
  76119. skipNextObservers: boolean;
  76120. /**
  76121. * Get the mask value that were used to trigger the event corresponding to this EventState object
  76122. */
  76123. mask: number;
  76124. /**
  76125. * The object that originally notified the event
  76126. */
  76127. target?: any;
  76128. /**
  76129. * The current object in the bubbling phase
  76130. */
  76131. currentTarget?: any;
  76132. /**
  76133. * This will be populated with the return value of the last function that was executed.
  76134. * If it is the first function in the callback chain it will be the event data.
  76135. */
  76136. lastReturnValue?: any;
  76137. }
  76138. /**
  76139. * Represent an Observer registered to a given Observable object.
  76140. */
  76141. export class Observer<T> {
  76142. /**
  76143. * Defines the callback to call when the observer is notified
  76144. */
  76145. callback: (eventData: T, eventState: EventState) => void;
  76146. /**
  76147. * Defines the mask of the observer (used to filter notifications)
  76148. */
  76149. mask: number;
  76150. /**
  76151. * Defines the current scope used to restore the JS context
  76152. */
  76153. scope: any;
  76154. /** @hidden */
  76155. _willBeUnregistered: boolean;
  76156. /**
  76157. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  76158. */
  76159. unregisterOnNextCall: boolean;
  76160. /**
  76161. * Creates a new observer
  76162. * @param callback defines the callback to call when the observer is notified
  76163. * @param mask defines the mask of the observer (used to filter notifications)
  76164. * @param scope defines the current scope used to restore the JS context
  76165. */
  76166. constructor(
  76167. /**
  76168. * Defines the callback to call when the observer is notified
  76169. */
  76170. callback: (eventData: T, eventState: EventState) => void,
  76171. /**
  76172. * Defines the mask of the observer (used to filter notifications)
  76173. */
  76174. mask: number,
  76175. /**
  76176. * Defines the current scope used to restore the JS context
  76177. */
  76178. scope?: any);
  76179. }
  76180. /**
  76181. * Represent a list of observers registered to multiple Observables object.
  76182. */
  76183. export class MultiObserver<T> {
  76184. private _observers;
  76185. private _observables;
  76186. /**
  76187. * Release associated resources
  76188. */
  76189. dispose(): void;
  76190. /**
  76191. * Raise a callback when one of the observable will notify
  76192. * @param observables defines a list of observables to watch
  76193. * @param callback defines the callback to call on notification
  76194. * @param mask defines the mask used to filter notifications
  76195. * @param scope defines the current scope used to restore the JS context
  76196. * @returns the new MultiObserver
  76197. */
  76198. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  76199. }
  76200. /**
  76201. * The Observable class is a simple implementation of the Observable pattern.
  76202. *
  76203. * 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.
  76204. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  76205. * 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).
  76206. * 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.
  76207. */
  76208. export class Observable<T> {
  76209. private _observers;
  76210. private _eventState;
  76211. private _onObserverAdded;
  76212. /**
  76213. * Gets the list of observers
  76214. */
  76215. get observers(): Array<Observer<T>>;
  76216. /**
  76217. * Creates a new observable
  76218. * @param onObserverAdded defines a callback to call when a new observer is added
  76219. */
  76220. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  76221. /**
  76222. * Create a new Observer with the specified callback
  76223. * @param callback the callback that will be executed for that Observer
  76224. * @param mask the mask used to filter observers
  76225. * @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.
  76226. * @param scope optional scope for the callback to be called from
  76227. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  76228. * @returns the new observer created for the callback
  76229. */
  76230. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  76231. /**
  76232. * Create a new Observer with the specified callback and unregisters after the next notification
  76233. * @param callback the callback that will be executed for that Observer
  76234. * @returns the new observer created for the callback
  76235. */
  76236. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  76237. /**
  76238. * Remove an Observer from the Observable object
  76239. * @param observer the instance of the Observer to remove
  76240. * @returns false if it doesn't belong to this Observable
  76241. */
  76242. remove(observer: Nullable<Observer<T>>): boolean;
  76243. /**
  76244. * Remove a callback from the Observable object
  76245. * @param callback the callback to remove
  76246. * @param scope optional scope. If used only the callbacks with this scope will be removed
  76247. * @returns false if it doesn't belong to this Observable
  76248. */
  76249. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  76250. private _deferUnregister;
  76251. private _remove;
  76252. /**
  76253. * Moves the observable to the top of the observer list making it get called first when notified
  76254. * @param observer the observer to move
  76255. */
  76256. makeObserverTopPriority(observer: Observer<T>): void;
  76257. /**
  76258. * Moves the observable to the bottom of the observer list making it get called last when notified
  76259. * @param observer the observer to move
  76260. */
  76261. makeObserverBottomPriority(observer: Observer<T>): void;
  76262. /**
  76263. * Notify all Observers by calling their respective callback with the given data
  76264. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  76265. * @param eventData defines the data to send to all observers
  76266. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  76267. * @param target defines the original target of the state
  76268. * @param currentTarget defines the current target of the state
  76269. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  76270. */
  76271. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  76272. /**
  76273. * Calling this will execute each callback, expecting it to be a promise or return a value.
  76274. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  76275. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  76276. * and it is crucial that all callbacks will be executed.
  76277. * The order of the callbacks is kept, callbacks are not executed parallel.
  76278. *
  76279. * @param eventData The data to be sent to each callback
  76280. * @param mask is used to filter observers defaults to -1
  76281. * @param target defines the callback target (see EventState)
  76282. * @param currentTarget defines he current object in the bubbling phase
  76283. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  76284. */
  76285. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  76286. /**
  76287. * Notify a specific observer
  76288. * @param observer defines the observer to notify
  76289. * @param eventData defines the data to be sent to each callback
  76290. * @param mask is used to filter observers defaults to -1
  76291. */
  76292. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  76293. /**
  76294. * Gets a boolean indicating if the observable has at least one observer
  76295. * @returns true is the Observable has at least one Observer registered
  76296. */
  76297. hasObservers(): boolean;
  76298. /**
  76299. * Clear the list of observers
  76300. */
  76301. clear(): void;
  76302. /**
  76303. * Clone the current observable
  76304. * @returns a new observable
  76305. */
  76306. clone(): Observable<T>;
  76307. /**
  76308. * Does this observable handles observer registered with a given mask
  76309. * @param mask defines the mask to be tested
  76310. * @return whether or not one observer registered with the given mask is handeled
  76311. **/
  76312. hasSpecificMask(mask?: number): boolean;
  76313. }
  76314. }
  76315. declare module BABYLON {
  76316. /**
  76317. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  76318. * Babylon.js
  76319. */
  76320. export class DomManagement {
  76321. /**
  76322. * Checks if the window object exists
  76323. * @returns true if the window object exists
  76324. */
  76325. static IsWindowObjectExist(): boolean;
  76326. /**
  76327. * Checks if the navigator object exists
  76328. * @returns true if the navigator object exists
  76329. */
  76330. static IsNavigatorAvailable(): boolean;
  76331. /**
  76332. * Check if the document object exists
  76333. * @returns true if the document object exists
  76334. */
  76335. static IsDocumentAvailable(): boolean;
  76336. /**
  76337. * Extracts text content from a DOM element hierarchy
  76338. * @param element defines the root element
  76339. * @returns a string
  76340. */
  76341. static GetDOMTextContent(element: HTMLElement): string;
  76342. }
  76343. }
  76344. declare module BABYLON {
  76345. /**
  76346. * Logger used througouht the application to allow configuration of
  76347. * the log level required for the messages.
  76348. */
  76349. export class Logger {
  76350. /**
  76351. * No log
  76352. */
  76353. static readonly NoneLogLevel: number;
  76354. /**
  76355. * Only message logs
  76356. */
  76357. static readonly MessageLogLevel: number;
  76358. /**
  76359. * Only warning logs
  76360. */
  76361. static readonly WarningLogLevel: number;
  76362. /**
  76363. * Only error logs
  76364. */
  76365. static readonly ErrorLogLevel: number;
  76366. /**
  76367. * All logs
  76368. */
  76369. static readonly AllLogLevel: number;
  76370. private static _LogCache;
  76371. /**
  76372. * Gets a value indicating the number of loading errors
  76373. * @ignorenaming
  76374. */
  76375. static errorsCount: number;
  76376. /**
  76377. * Callback called when a new log is added
  76378. */
  76379. static OnNewCacheEntry: (entry: string) => void;
  76380. private static _AddLogEntry;
  76381. private static _FormatMessage;
  76382. private static _LogDisabled;
  76383. private static _LogEnabled;
  76384. private static _WarnDisabled;
  76385. private static _WarnEnabled;
  76386. private static _ErrorDisabled;
  76387. private static _ErrorEnabled;
  76388. /**
  76389. * Log a message to the console
  76390. */
  76391. static Log: (message: string) => void;
  76392. /**
  76393. * Write a warning message to the console
  76394. */
  76395. static Warn: (message: string) => void;
  76396. /**
  76397. * Write an error message to the console
  76398. */
  76399. static Error: (message: string) => void;
  76400. /**
  76401. * Gets current log cache (list of logs)
  76402. */
  76403. static get LogCache(): string;
  76404. /**
  76405. * Clears the log cache
  76406. */
  76407. static ClearLogCache(): void;
  76408. /**
  76409. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  76410. */
  76411. static set LogLevels(level: number);
  76412. }
  76413. }
  76414. declare module BABYLON {
  76415. /** @hidden */
  76416. export class _TypeStore {
  76417. /** @hidden */
  76418. static RegisteredTypes: {
  76419. [key: string]: Object;
  76420. };
  76421. /** @hidden */
  76422. static GetClass(fqdn: string): any;
  76423. }
  76424. }
  76425. declare module BABYLON {
  76426. /**
  76427. * Helper to manipulate strings
  76428. */
  76429. export class StringTools {
  76430. /**
  76431. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  76432. * @param str Source string
  76433. * @param suffix Suffix to search for in the source string
  76434. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76435. */
  76436. static EndsWith(str: string, suffix: string): boolean;
  76437. /**
  76438. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  76439. * @param str Source string
  76440. * @param suffix Suffix to search for in the source string
  76441. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76442. */
  76443. static StartsWith(str: string, suffix: string): boolean;
  76444. /**
  76445. * Decodes a buffer into a string
  76446. * @param buffer The buffer to decode
  76447. * @returns The decoded string
  76448. */
  76449. static Decode(buffer: Uint8Array | Uint16Array): string;
  76450. /**
  76451. * Encode a buffer to a base64 string
  76452. * @param buffer defines the buffer to encode
  76453. * @returns the encoded string
  76454. */
  76455. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  76456. /**
  76457. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  76458. * @param num the number to convert and pad
  76459. * @param length the expected length of the string
  76460. * @returns the padded string
  76461. */
  76462. static PadNumber(num: number, length: number): string;
  76463. }
  76464. }
  76465. declare module BABYLON {
  76466. /**
  76467. * Class containing a set of static utilities functions for deep copy.
  76468. */
  76469. export class DeepCopier {
  76470. /**
  76471. * Tries to copy an object by duplicating every property
  76472. * @param source defines the source object
  76473. * @param destination defines the target object
  76474. * @param doNotCopyList defines a list of properties to avoid
  76475. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  76476. */
  76477. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  76478. }
  76479. }
  76480. declare module BABYLON {
  76481. /**
  76482. * Class containing a set of static utilities functions for precision date
  76483. */
  76484. export class PrecisionDate {
  76485. /**
  76486. * Gets either window.performance.now() if supported or Date.now() else
  76487. */
  76488. static get Now(): number;
  76489. }
  76490. }
  76491. declare module BABYLON {
  76492. /** @hidden */
  76493. export class _DevTools {
  76494. static WarnImport(name: string): string;
  76495. }
  76496. }
  76497. declare module BABYLON {
  76498. /**
  76499. * Interface used to define the mechanism to get data from the network
  76500. */
  76501. export interface IWebRequest {
  76502. /**
  76503. * Returns client's response url
  76504. */
  76505. responseURL: string;
  76506. /**
  76507. * Returns client's status
  76508. */
  76509. status: number;
  76510. /**
  76511. * Returns client's status as a text
  76512. */
  76513. statusText: string;
  76514. }
  76515. }
  76516. declare module BABYLON {
  76517. /**
  76518. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  76519. */
  76520. export class WebRequest implements IWebRequest {
  76521. private _xhr;
  76522. /**
  76523. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  76524. * i.e. when loading files, where the server/service expects an Authorization header
  76525. */
  76526. static CustomRequestHeaders: {
  76527. [key: string]: string;
  76528. };
  76529. /**
  76530. * Add callback functions in this array to update all the requests before they get sent to the network
  76531. */
  76532. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  76533. private _injectCustomRequestHeaders;
  76534. /**
  76535. * Gets or sets a function to be called when loading progress changes
  76536. */
  76537. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  76538. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  76539. /**
  76540. * Returns client's state
  76541. */
  76542. get readyState(): number;
  76543. /**
  76544. * Returns client's status
  76545. */
  76546. get status(): number;
  76547. /**
  76548. * Returns client's status as a text
  76549. */
  76550. get statusText(): string;
  76551. /**
  76552. * Returns client's response
  76553. */
  76554. get response(): any;
  76555. /**
  76556. * Returns client's response url
  76557. */
  76558. get responseURL(): string;
  76559. /**
  76560. * Returns client's response as text
  76561. */
  76562. get responseText(): string;
  76563. /**
  76564. * Gets or sets the expected response type
  76565. */
  76566. get responseType(): XMLHttpRequestResponseType;
  76567. set responseType(value: XMLHttpRequestResponseType);
  76568. /** @hidden */
  76569. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  76570. /** @hidden */
  76571. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  76572. /**
  76573. * Cancels any network activity
  76574. */
  76575. abort(): void;
  76576. /**
  76577. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  76578. * @param body defines an optional request body
  76579. */
  76580. send(body?: Document | BodyInit | null): void;
  76581. /**
  76582. * Sets the request method, request URL
  76583. * @param method defines the method to use (GET, POST, etc..)
  76584. * @param url defines the url to connect with
  76585. */
  76586. open(method: string, url: string): void;
  76587. /**
  76588. * Sets the value of a request header.
  76589. * @param name The name of the header whose value is to be set
  76590. * @param value The value to set as the body of the header
  76591. */
  76592. setRequestHeader(name: string, value: string): void;
  76593. /**
  76594. * Get the string containing the text of a particular header's value.
  76595. * @param name The name of the header
  76596. * @returns The string containing the text of the given header name
  76597. */
  76598. getResponseHeader(name: string): Nullable<string>;
  76599. }
  76600. }
  76601. declare module BABYLON {
  76602. /**
  76603. * File request interface
  76604. */
  76605. export interface IFileRequest {
  76606. /**
  76607. * Raised when the request is complete (success or error).
  76608. */
  76609. onCompleteObservable: Observable<IFileRequest>;
  76610. /**
  76611. * Aborts the request for a file.
  76612. */
  76613. abort: () => void;
  76614. }
  76615. }
  76616. declare module BABYLON {
  76617. /**
  76618. * Define options used to create a render target texture
  76619. */
  76620. export class RenderTargetCreationOptions {
  76621. /**
  76622. * Specifies is mipmaps must be generated
  76623. */
  76624. generateMipMaps?: boolean;
  76625. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  76626. generateDepthBuffer?: boolean;
  76627. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  76628. generateStencilBuffer?: boolean;
  76629. /** Defines texture type (int by default) */
  76630. type?: number;
  76631. /** Defines sampling mode (trilinear by default) */
  76632. samplingMode?: number;
  76633. /** Defines format (RGBA by default) */
  76634. format?: number;
  76635. }
  76636. }
  76637. declare module BABYLON {
  76638. /** Defines the cross module used constants to avoid circular dependncies */
  76639. export class Constants {
  76640. /** Defines that alpha blending is disabled */
  76641. static readonly ALPHA_DISABLE: number;
  76642. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  76643. static readonly ALPHA_ADD: number;
  76644. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  76645. static readonly ALPHA_COMBINE: number;
  76646. /** Defines that alpha blending is DEST - SRC * DEST */
  76647. static readonly ALPHA_SUBTRACT: number;
  76648. /** Defines that alpha blending is SRC * DEST */
  76649. static readonly ALPHA_MULTIPLY: number;
  76650. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  76651. static readonly ALPHA_MAXIMIZED: number;
  76652. /** Defines that alpha blending is SRC + DEST */
  76653. static readonly ALPHA_ONEONE: number;
  76654. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  76655. static readonly ALPHA_PREMULTIPLIED: number;
  76656. /**
  76657. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  76658. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  76659. */
  76660. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  76661. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  76662. static readonly ALPHA_INTERPOLATE: number;
  76663. /**
  76664. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  76665. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  76666. */
  76667. static readonly ALPHA_SCREENMODE: number;
  76668. /**
  76669. * Defines that alpha blending is SRC + DST
  76670. * Alpha will be set to SRC ALPHA + DST ALPHA
  76671. */
  76672. static readonly ALPHA_ONEONE_ONEONE: number;
  76673. /**
  76674. * Defines that alpha blending is SRC * DST ALPHA + DST
  76675. * Alpha will be set to 0
  76676. */
  76677. static readonly ALPHA_ALPHATOCOLOR: number;
  76678. /**
  76679. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76680. */
  76681. static readonly ALPHA_REVERSEONEMINUS: number;
  76682. /**
  76683. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  76684. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  76685. */
  76686. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  76687. /**
  76688. * Defines that alpha blending is SRC + DST
  76689. * Alpha will be set to SRC ALPHA
  76690. */
  76691. static readonly ALPHA_ONEONE_ONEZERO: number;
  76692. /**
  76693. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76694. * Alpha will be set to DST ALPHA
  76695. */
  76696. static readonly ALPHA_EXCLUSION: number;
  76697. /** Defines that alpha blending equation a SUM */
  76698. static readonly ALPHA_EQUATION_ADD: number;
  76699. /** Defines that alpha blending equation a SUBSTRACTION */
  76700. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  76701. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  76702. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  76703. /** Defines that alpha blending equation a MAX operation */
  76704. static readonly ALPHA_EQUATION_MAX: number;
  76705. /** Defines that alpha blending equation a MIN operation */
  76706. static readonly ALPHA_EQUATION_MIN: number;
  76707. /**
  76708. * Defines that alpha blending equation a DARKEN operation:
  76709. * It takes the min of the src and sums the alpha channels.
  76710. */
  76711. static readonly ALPHA_EQUATION_DARKEN: number;
  76712. /** Defines that the ressource is not delayed*/
  76713. static readonly DELAYLOADSTATE_NONE: number;
  76714. /** Defines that the ressource was successfully delay loaded */
  76715. static readonly DELAYLOADSTATE_LOADED: number;
  76716. /** Defines that the ressource is currently delay loading */
  76717. static readonly DELAYLOADSTATE_LOADING: number;
  76718. /** Defines that the ressource is delayed and has not started loading */
  76719. static readonly DELAYLOADSTATE_NOTLOADED: number;
  76720. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  76721. static readonly NEVER: number;
  76722. /** 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 */
  76723. static readonly ALWAYS: number;
  76724. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  76725. static readonly LESS: number;
  76726. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  76727. static readonly EQUAL: number;
  76728. /** 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 */
  76729. static readonly LEQUAL: number;
  76730. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  76731. static readonly GREATER: number;
  76732. /** 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 */
  76733. static readonly GEQUAL: number;
  76734. /** 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 */
  76735. static readonly NOTEQUAL: number;
  76736. /** Passed to stencilOperation to specify that stencil value must be kept */
  76737. static readonly KEEP: number;
  76738. /** Passed to stencilOperation to specify that stencil value must be replaced */
  76739. static readonly REPLACE: number;
  76740. /** Passed to stencilOperation to specify that stencil value must be incremented */
  76741. static readonly INCR: number;
  76742. /** Passed to stencilOperation to specify that stencil value must be decremented */
  76743. static readonly DECR: number;
  76744. /** Passed to stencilOperation to specify that stencil value must be inverted */
  76745. static readonly INVERT: number;
  76746. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  76747. static readonly INCR_WRAP: number;
  76748. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  76749. static readonly DECR_WRAP: number;
  76750. /** Texture is not repeating outside of 0..1 UVs */
  76751. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  76752. /** Texture is repeating outside of 0..1 UVs */
  76753. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  76754. /** Texture is repeating and mirrored */
  76755. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  76756. /** ALPHA */
  76757. static readonly TEXTUREFORMAT_ALPHA: number;
  76758. /** LUMINANCE */
  76759. static readonly TEXTUREFORMAT_LUMINANCE: number;
  76760. /** LUMINANCE_ALPHA */
  76761. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  76762. /** RGB */
  76763. static readonly TEXTUREFORMAT_RGB: number;
  76764. /** RGBA */
  76765. static readonly TEXTUREFORMAT_RGBA: number;
  76766. /** RED */
  76767. static readonly TEXTUREFORMAT_RED: number;
  76768. /** RED (2nd reference) */
  76769. static readonly TEXTUREFORMAT_R: number;
  76770. /** RG */
  76771. static readonly TEXTUREFORMAT_RG: number;
  76772. /** RED_INTEGER */
  76773. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  76774. /** RED_INTEGER (2nd reference) */
  76775. static readonly TEXTUREFORMAT_R_INTEGER: number;
  76776. /** RG_INTEGER */
  76777. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  76778. /** RGB_INTEGER */
  76779. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  76780. /** RGBA_INTEGER */
  76781. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  76782. /** UNSIGNED_BYTE */
  76783. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  76784. /** UNSIGNED_BYTE (2nd reference) */
  76785. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  76786. /** FLOAT */
  76787. static readonly TEXTURETYPE_FLOAT: number;
  76788. /** HALF_FLOAT */
  76789. static readonly TEXTURETYPE_HALF_FLOAT: number;
  76790. /** BYTE */
  76791. static readonly TEXTURETYPE_BYTE: number;
  76792. /** SHORT */
  76793. static readonly TEXTURETYPE_SHORT: number;
  76794. /** UNSIGNED_SHORT */
  76795. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  76796. /** INT */
  76797. static readonly TEXTURETYPE_INT: number;
  76798. /** UNSIGNED_INT */
  76799. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  76800. /** UNSIGNED_SHORT_4_4_4_4 */
  76801. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  76802. /** UNSIGNED_SHORT_5_5_5_1 */
  76803. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  76804. /** UNSIGNED_SHORT_5_6_5 */
  76805. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  76806. /** UNSIGNED_INT_2_10_10_10_REV */
  76807. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  76808. /** UNSIGNED_INT_24_8 */
  76809. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  76810. /** UNSIGNED_INT_10F_11F_11F_REV */
  76811. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  76812. /** UNSIGNED_INT_5_9_9_9_REV */
  76813. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  76814. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  76815. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76816. /** nearest is mag = nearest and min = nearest and no mip */
  76817. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  76818. /** mag = nearest and min = nearest and mip = none */
  76819. static readonly TEXTURE_NEAREST_NEAREST: number;
  76820. /** Bilinear is mag = linear and min = linear and no mip */
  76821. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  76822. /** mag = linear and min = linear and mip = none */
  76823. static readonly TEXTURE_LINEAR_LINEAR: number;
  76824. /** Trilinear is mag = linear and min = linear and mip = linear */
  76825. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  76826. /** Trilinear is mag = linear and min = linear and mip = linear */
  76827. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  76828. /** mag = nearest and min = nearest and mip = nearest */
  76829. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  76830. /** mag = nearest and min = linear and mip = nearest */
  76831. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  76832. /** mag = nearest and min = linear and mip = linear */
  76833. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  76834. /** mag = nearest and min = linear and mip = none */
  76835. static readonly TEXTURE_NEAREST_LINEAR: number;
  76836. /** nearest is mag = nearest and min = nearest and mip = linear */
  76837. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  76838. /** mag = linear and min = nearest and mip = nearest */
  76839. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  76840. /** mag = linear and min = nearest and mip = linear */
  76841. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  76842. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76843. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  76844. /** mag = linear and min = nearest and mip = none */
  76845. static readonly TEXTURE_LINEAR_NEAREST: number;
  76846. /** Explicit coordinates mode */
  76847. static readonly TEXTURE_EXPLICIT_MODE: number;
  76848. /** Spherical coordinates mode */
  76849. static readonly TEXTURE_SPHERICAL_MODE: number;
  76850. /** Planar coordinates mode */
  76851. static readonly TEXTURE_PLANAR_MODE: number;
  76852. /** Cubic coordinates mode */
  76853. static readonly TEXTURE_CUBIC_MODE: number;
  76854. /** Projection coordinates mode */
  76855. static readonly TEXTURE_PROJECTION_MODE: number;
  76856. /** Skybox coordinates mode */
  76857. static readonly TEXTURE_SKYBOX_MODE: number;
  76858. /** Inverse Cubic coordinates mode */
  76859. static readonly TEXTURE_INVCUBIC_MODE: number;
  76860. /** Equirectangular coordinates mode */
  76861. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  76862. /** Equirectangular Fixed coordinates mode */
  76863. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  76864. /** Equirectangular Fixed Mirrored coordinates mode */
  76865. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76866. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  76867. static readonly SCALEMODE_FLOOR: number;
  76868. /** Defines that texture rescaling will look for the nearest power of 2 size */
  76869. static readonly SCALEMODE_NEAREST: number;
  76870. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  76871. static readonly SCALEMODE_CEILING: number;
  76872. /**
  76873. * The dirty texture flag value
  76874. */
  76875. static readonly MATERIAL_TextureDirtyFlag: number;
  76876. /**
  76877. * The dirty light flag value
  76878. */
  76879. static readonly MATERIAL_LightDirtyFlag: number;
  76880. /**
  76881. * The dirty fresnel flag value
  76882. */
  76883. static readonly MATERIAL_FresnelDirtyFlag: number;
  76884. /**
  76885. * The dirty attribute flag value
  76886. */
  76887. static readonly MATERIAL_AttributesDirtyFlag: number;
  76888. /**
  76889. * The dirty misc flag value
  76890. */
  76891. static readonly MATERIAL_MiscDirtyFlag: number;
  76892. /**
  76893. * The all dirty flag value
  76894. */
  76895. static readonly MATERIAL_AllDirtyFlag: number;
  76896. /**
  76897. * Returns the triangle fill mode
  76898. */
  76899. static readonly MATERIAL_TriangleFillMode: number;
  76900. /**
  76901. * Returns the wireframe mode
  76902. */
  76903. static readonly MATERIAL_WireFrameFillMode: number;
  76904. /**
  76905. * Returns the point fill mode
  76906. */
  76907. static readonly MATERIAL_PointFillMode: number;
  76908. /**
  76909. * Returns the point list draw mode
  76910. */
  76911. static readonly MATERIAL_PointListDrawMode: number;
  76912. /**
  76913. * Returns the line list draw mode
  76914. */
  76915. static readonly MATERIAL_LineListDrawMode: number;
  76916. /**
  76917. * Returns the line loop draw mode
  76918. */
  76919. static readonly MATERIAL_LineLoopDrawMode: number;
  76920. /**
  76921. * Returns the line strip draw mode
  76922. */
  76923. static readonly MATERIAL_LineStripDrawMode: number;
  76924. /**
  76925. * Returns the triangle strip draw mode
  76926. */
  76927. static readonly MATERIAL_TriangleStripDrawMode: number;
  76928. /**
  76929. * Returns the triangle fan draw mode
  76930. */
  76931. static readonly MATERIAL_TriangleFanDrawMode: number;
  76932. /**
  76933. * Stores the clock-wise side orientation
  76934. */
  76935. static readonly MATERIAL_ClockWiseSideOrientation: number;
  76936. /**
  76937. * Stores the counter clock-wise side orientation
  76938. */
  76939. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  76940. /**
  76941. * Nothing
  76942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76943. */
  76944. static readonly ACTION_NothingTrigger: number;
  76945. /**
  76946. * On pick
  76947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76948. */
  76949. static readonly ACTION_OnPickTrigger: number;
  76950. /**
  76951. * On left pick
  76952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76953. */
  76954. static readonly ACTION_OnLeftPickTrigger: number;
  76955. /**
  76956. * On right pick
  76957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76958. */
  76959. static readonly ACTION_OnRightPickTrigger: number;
  76960. /**
  76961. * On center pick
  76962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76963. */
  76964. static readonly ACTION_OnCenterPickTrigger: number;
  76965. /**
  76966. * On pick down
  76967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76968. */
  76969. static readonly ACTION_OnPickDownTrigger: number;
  76970. /**
  76971. * On double pick
  76972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76973. */
  76974. static readonly ACTION_OnDoublePickTrigger: number;
  76975. /**
  76976. * On pick up
  76977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76978. */
  76979. static readonly ACTION_OnPickUpTrigger: number;
  76980. /**
  76981. * On pick out.
  76982. * This trigger will only be raised if you also declared a OnPickDown
  76983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76984. */
  76985. static readonly ACTION_OnPickOutTrigger: number;
  76986. /**
  76987. * On long press
  76988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76989. */
  76990. static readonly ACTION_OnLongPressTrigger: number;
  76991. /**
  76992. * On pointer over
  76993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76994. */
  76995. static readonly ACTION_OnPointerOverTrigger: number;
  76996. /**
  76997. * On pointer out
  76998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76999. */
  77000. static readonly ACTION_OnPointerOutTrigger: number;
  77001. /**
  77002. * On every frame
  77003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77004. */
  77005. static readonly ACTION_OnEveryFrameTrigger: number;
  77006. /**
  77007. * On intersection enter
  77008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77009. */
  77010. static readonly ACTION_OnIntersectionEnterTrigger: number;
  77011. /**
  77012. * On intersection exit
  77013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77014. */
  77015. static readonly ACTION_OnIntersectionExitTrigger: number;
  77016. /**
  77017. * On key down
  77018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77019. */
  77020. static readonly ACTION_OnKeyDownTrigger: number;
  77021. /**
  77022. * On key up
  77023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77024. */
  77025. static readonly ACTION_OnKeyUpTrigger: number;
  77026. /**
  77027. * Billboard mode will only apply to Y axis
  77028. */
  77029. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  77030. /**
  77031. * Billboard mode will apply to all axes
  77032. */
  77033. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  77034. /**
  77035. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  77036. */
  77037. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  77038. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  77039. * Test order :
  77040. * Is the bounding sphere outside the frustum ?
  77041. * If not, are the bounding box vertices outside the frustum ?
  77042. * It not, then the cullable object is in the frustum.
  77043. */
  77044. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  77045. /** Culling strategy : Bounding Sphere Only.
  77046. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  77047. * It's also less accurate than the standard because some not visible objects can still be selected.
  77048. * Test : is the bounding sphere outside the frustum ?
  77049. * If not, then the cullable object is in the frustum.
  77050. */
  77051. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  77052. /** Culling strategy : Optimistic Inclusion.
  77053. * This in an inclusion test first, then the standard exclusion test.
  77054. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  77055. * 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.
  77056. * Anyway, it's as accurate as the standard strategy.
  77057. * Test :
  77058. * Is the cullable object bounding sphere center in the frustum ?
  77059. * If not, apply the default culling strategy.
  77060. */
  77061. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  77062. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  77063. * This in an inclusion test first, then the bounding sphere only exclusion test.
  77064. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  77065. * 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.
  77066. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  77067. * Test :
  77068. * Is the cullable object bounding sphere center in the frustum ?
  77069. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  77070. */
  77071. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  77072. /**
  77073. * No logging while loading
  77074. */
  77075. static readonly SCENELOADER_NO_LOGGING: number;
  77076. /**
  77077. * Minimal logging while loading
  77078. */
  77079. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  77080. /**
  77081. * Summary logging while loading
  77082. */
  77083. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  77084. /**
  77085. * Detailled logging while loading
  77086. */
  77087. static readonly SCENELOADER_DETAILED_LOGGING: number;
  77088. }
  77089. }
  77090. declare module BABYLON {
  77091. /**
  77092. * This represents the required contract to create a new type of texture loader.
  77093. */
  77094. export interface IInternalTextureLoader {
  77095. /**
  77096. * Defines wether the loader supports cascade loading the different faces.
  77097. */
  77098. supportCascades: boolean;
  77099. /**
  77100. * This returns if the loader support the current file information.
  77101. * @param extension defines the file extension of the file being loaded
  77102. * @returns true if the loader can load the specified file
  77103. */
  77104. canLoad(extension: string): boolean;
  77105. /**
  77106. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  77107. * @param data contains the texture data
  77108. * @param texture defines the BabylonJS internal texture
  77109. * @param createPolynomials will be true if polynomials have been requested
  77110. * @param onLoad defines the callback to trigger once the texture is ready
  77111. * @param onError defines the callback to trigger in case of error
  77112. */
  77113. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  77114. /**
  77115. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  77116. * @param data contains the texture data
  77117. * @param texture defines the BabylonJS internal texture
  77118. * @param callback defines the method to call once ready to upload
  77119. */
  77120. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  77121. }
  77122. }
  77123. declare module BABYLON {
  77124. /**
  77125. * Class used to store and describe the pipeline context associated with an effect
  77126. */
  77127. export interface IPipelineContext {
  77128. /**
  77129. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  77130. */
  77131. isAsync: boolean;
  77132. /**
  77133. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  77134. */
  77135. isReady: boolean;
  77136. /** @hidden */
  77137. _getVertexShaderCode(): string | null;
  77138. /** @hidden */
  77139. _getFragmentShaderCode(): string | null;
  77140. /** @hidden */
  77141. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  77142. }
  77143. }
  77144. declare module BABYLON {
  77145. /**
  77146. * Class used to store gfx data (like WebGLBuffer)
  77147. */
  77148. export class DataBuffer {
  77149. /**
  77150. * Gets or sets the number of objects referencing this buffer
  77151. */
  77152. references: number;
  77153. /** Gets or sets the size of the underlying buffer */
  77154. capacity: number;
  77155. /**
  77156. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  77157. */
  77158. is32Bits: boolean;
  77159. /**
  77160. * Gets the underlying buffer
  77161. */
  77162. get underlyingResource(): any;
  77163. }
  77164. }
  77165. declare module BABYLON {
  77166. /** @hidden */
  77167. export interface IShaderProcessor {
  77168. attributeProcessor?: (attribute: string) => string;
  77169. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  77170. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  77171. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  77172. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  77173. lineProcessor?: (line: string, isFragment: boolean) => string;
  77174. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77175. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77176. }
  77177. }
  77178. declare module BABYLON {
  77179. /** @hidden */
  77180. export interface ProcessingOptions {
  77181. defines: string[];
  77182. indexParameters: any;
  77183. isFragment: boolean;
  77184. shouldUseHighPrecisionShader: boolean;
  77185. supportsUniformBuffers: boolean;
  77186. shadersRepository: string;
  77187. includesShadersStore: {
  77188. [key: string]: string;
  77189. };
  77190. processor?: IShaderProcessor;
  77191. version: string;
  77192. platformName: string;
  77193. lookForClosingBracketForUniformBuffer?: boolean;
  77194. }
  77195. }
  77196. declare module BABYLON {
  77197. /** @hidden */
  77198. export class ShaderCodeNode {
  77199. line: string;
  77200. children: ShaderCodeNode[];
  77201. additionalDefineKey?: string;
  77202. additionalDefineValue?: string;
  77203. isValid(preprocessors: {
  77204. [key: string]: string;
  77205. }): boolean;
  77206. process(preprocessors: {
  77207. [key: string]: string;
  77208. }, options: ProcessingOptions): string;
  77209. }
  77210. }
  77211. declare module BABYLON {
  77212. /** @hidden */
  77213. export class ShaderCodeCursor {
  77214. private _lines;
  77215. lineIndex: number;
  77216. get currentLine(): string;
  77217. get canRead(): boolean;
  77218. set lines(value: string[]);
  77219. }
  77220. }
  77221. declare module BABYLON {
  77222. /** @hidden */
  77223. export class ShaderCodeConditionNode extends ShaderCodeNode {
  77224. process(preprocessors: {
  77225. [key: string]: string;
  77226. }, options: ProcessingOptions): string;
  77227. }
  77228. }
  77229. declare module BABYLON {
  77230. /** @hidden */
  77231. export class ShaderDefineExpression {
  77232. isTrue(preprocessors: {
  77233. [key: string]: string;
  77234. }): boolean;
  77235. private static _OperatorPriority;
  77236. private static _Stack;
  77237. static postfixToInfix(postfix: string[]): string;
  77238. static infixToPostfix(infix: string): string[];
  77239. }
  77240. }
  77241. declare module BABYLON {
  77242. /** @hidden */
  77243. export class ShaderCodeTestNode extends ShaderCodeNode {
  77244. testExpression: ShaderDefineExpression;
  77245. isValid(preprocessors: {
  77246. [key: string]: string;
  77247. }): boolean;
  77248. }
  77249. }
  77250. declare module BABYLON {
  77251. /** @hidden */
  77252. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  77253. define: string;
  77254. not: boolean;
  77255. constructor(define: string, not?: boolean);
  77256. isTrue(preprocessors: {
  77257. [key: string]: string;
  77258. }): boolean;
  77259. }
  77260. }
  77261. declare module BABYLON {
  77262. /** @hidden */
  77263. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  77264. leftOperand: ShaderDefineExpression;
  77265. rightOperand: ShaderDefineExpression;
  77266. isTrue(preprocessors: {
  77267. [key: string]: string;
  77268. }): boolean;
  77269. }
  77270. }
  77271. declare module BABYLON {
  77272. /** @hidden */
  77273. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  77274. leftOperand: ShaderDefineExpression;
  77275. rightOperand: ShaderDefineExpression;
  77276. isTrue(preprocessors: {
  77277. [key: string]: string;
  77278. }): boolean;
  77279. }
  77280. }
  77281. declare module BABYLON {
  77282. /** @hidden */
  77283. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  77284. define: string;
  77285. operand: string;
  77286. testValue: string;
  77287. constructor(define: string, operand: string, testValue: string);
  77288. isTrue(preprocessors: {
  77289. [key: string]: string;
  77290. }): boolean;
  77291. }
  77292. }
  77293. declare module BABYLON {
  77294. /**
  77295. * Class used to enable access to offline support
  77296. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  77297. */
  77298. export interface IOfflineProvider {
  77299. /**
  77300. * Gets a boolean indicating if scene must be saved in the database
  77301. */
  77302. enableSceneOffline: boolean;
  77303. /**
  77304. * Gets a boolean indicating if textures must be saved in the database
  77305. */
  77306. enableTexturesOffline: boolean;
  77307. /**
  77308. * Open the offline support and make it available
  77309. * @param successCallback defines the callback to call on success
  77310. * @param errorCallback defines the callback to call on error
  77311. */
  77312. open(successCallback: () => void, errorCallback: () => void): void;
  77313. /**
  77314. * Loads an image from the offline support
  77315. * @param url defines the url to load from
  77316. * @param image defines the target DOM image
  77317. */
  77318. loadImage(url: string, image: HTMLImageElement): void;
  77319. /**
  77320. * Loads a file from offline support
  77321. * @param url defines the URL to load from
  77322. * @param sceneLoaded defines a callback to call on success
  77323. * @param progressCallBack defines a callback to call when progress changed
  77324. * @param errorCallback defines a callback to call on error
  77325. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  77326. */
  77327. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  77328. }
  77329. }
  77330. declare module BABYLON {
  77331. /**
  77332. * Class used to help managing file picking and drag'n'drop
  77333. * File Storage
  77334. */
  77335. export class FilesInputStore {
  77336. /**
  77337. * List of files ready to be loaded
  77338. */
  77339. static FilesToLoad: {
  77340. [key: string]: File;
  77341. };
  77342. }
  77343. }
  77344. declare module BABYLON {
  77345. /**
  77346. * Class used to define a retry strategy when error happens while loading assets
  77347. */
  77348. export class RetryStrategy {
  77349. /**
  77350. * Function used to defines an exponential back off strategy
  77351. * @param maxRetries defines the maximum number of retries (3 by default)
  77352. * @param baseInterval defines the interval between retries
  77353. * @returns the strategy function to use
  77354. */
  77355. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  77356. }
  77357. }
  77358. declare module BABYLON {
  77359. /**
  77360. * @ignore
  77361. * Application error to support additional information when loading a file
  77362. */
  77363. export abstract class BaseError extends Error {
  77364. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  77365. }
  77366. }
  77367. declare module BABYLON {
  77368. /** @ignore */
  77369. export class LoadFileError extends BaseError {
  77370. request?: WebRequest;
  77371. file?: File;
  77372. /**
  77373. * Creates a new LoadFileError
  77374. * @param message defines the message of the error
  77375. * @param request defines the optional web request
  77376. * @param file defines the optional file
  77377. */
  77378. constructor(message: string, object?: WebRequest | File);
  77379. }
  77380. /** @ignore */
  77381. export class RequestFileError extends BaseError {
  77382. request: WebRequest;
  77383. /**
  77384. * Creates a new LoadFileError
  77385. * @param message defines the message of the error
  77386. * @param request defines the optional web request
  77387. */
  77388. constructor(message: string, request: WebRequest);
  77389. }
  77390. /** @ignore */
  77391. export class ReadFileError extends BaseError {
  77392. file: File;
  77393. /**
  77394. * Creates a new ReadFileError
  77395. * @param message defines the message of the error
  77396. * @param file defines the optional file
  77397. */
  77398. constructor(message: string, file: File);
  77399. }
  77400. /**
  77401. * @hidden
  77402. */
  77403. export class FileTools {
  77404. /**
  77405. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  77406. */
  77407. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  77408. /**
  77409. * Gets or sets the base URL to use to load assets
  77410. */
  77411. static BaseUrl: string;
  77412. /**
  77413. * Default behaviour for cors in the application.
  77414. * It can be a string if the expected behavior is identical in the entire app.
  77415. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  77416. */
  77417. static CorsBehavior: string | ((url: string | string[]) => string);
  77418. /**
  77419. * Gets or sets a function used to pre-process url before using them to load assets
  77420. */
  77421. static PreprocessUrl: (url: string) => string;
  77422. /**
  77423. * Removes unwanted characters from an url
  77424. * @param url defines the url to clean
  77425. * @returns the cleaned url
  77426. */
  77427. private static _CleanUrl;
  77428. /**
  77429. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  77430. * @param url define the url we are trying
  77431. * @param element define the dom element where to configure the cors policy
  77432. */
  77433. static SetCorsBehavior(url: string | string[], element: {
  77434. crossOrigin: string | null;
  77435. }): void;
  77436. /**
  77437. * Loads an image as an HTMLImageElement.
  77438. * @param input url string, ArrayBuffer, or Blob to load
  77439. * @param onLoad callback called when the image successfully loads
  77440. * @param onError callback called when the image fails to load
  77441. * @param offlineProvider offline provider for caching
  77442. * @param mimeType optional mime type
  77443. * @returns the HTMLImageElement of the loaded image
  77444. */
  77445. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  77446. /**
  77447. * Reads a file from a File object
  77448. * @param file defines the file to load
  77449. * @param onSuccess defines the callback to call when data is loaded
  77450. * @param onProgress defines the callback to call during loading process
  77451. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  77452. * @param onError defines the callback to call when an error occurs
  77453. * @returns a file request object
  77454. */
  77455. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  77456. /**
  77457. * Loads a file from a url
  77458. * @param url url to load
  77459. * @param onSuccess callback called when the file successfully loads
  77460. * @param onProgress callback called while file is loading (if the server supports this mode)
  77461. * @param offlineProvider defines the offline provider for caching
  77462. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77463. * @param onError callback called when the file fails to load
  77464. * @returns a file request object
  77465. */
  77466. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  77467. /**
  77468. * Loads a file
  77469. * @param url url to load
  77470. * @param onSuccess callback called when the file successfully loads
  77471. * @param onProgress callback called while file is loading (if the server supports this mode)
  77472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77473. * @param onError callback called when the file fails to load
  77474. * @param onOpened callback called when the web request is opened
  77475. * @returns a file request object
  77476. */
  77477. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  77478. /**
  77479. * Checks if the loaded document was accessed via `file:`-Protocol.
  77480. * @returns boolean
  77481. */
  77482. static IsFileURL(): boolean;
  77483. }
  77484. }
  77485. declare module BABYLON {
  77486. /** @hidden */
  77487. export class ShaderProcessor {
  77488. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  77489. private static _ProcessPrecision;
  77490. private static _ExtractOperation;
  77491. private static _BuildSubExpression;
  77492. private static _BuildExpression;
  77493. private static _MoveCursorWithinIf;
  77494. private static _MoveCursor;
  77495. private static _EvaluatePreProcessors;
  77496. private static _PreparePreProcessors;
  77497. private static _ProcessShaderConversion;
  77498. private static _ProcessIncludes;
  77499. /**
  77500. * Loads a file from a url
  77501. * @param url url to load
  77502. * @param onSuccess callback called when the file successfully loads
  77503. * @param onProgress callback called while file is loading (if the server supports this mode)
  77504. * @param offlineProvider defines the offline provider for caching
  77505. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77506. * @param onError callback called when the file fails to load
  77507. * @returns a file request object
  77508. * @hidden
  77509. */
  77510. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  77511. }
  77512. }
  77513. declare module BABYLON {
  77514. /**
  77515. * @hidden
  77516. */
  77517. export interface IColor4Like {
  77518. r: float;
  77519. g: float;
  77520. b: float;
  77521. a: float;
  77522. }
  77523. /**
  77524. * @hidden
  77525. */
  77526. export interface IColor3Like {
  77527. r: float;
  77528. g: float;
  77529. b: float;
  77530. }
  77531. /**
  77532. * @hidden
  77533. */
  77534. export interface IVector4Like {
  77535. x: float;
  77536. y: float;
  77537. z: float;
  77538. w: float;
  77539. }
  77540. /**
  77541. * @hidden
  77542. */
  77543. export interface IVector3Like {
  77544. x: float;
  77545. y: float;
  77546. z: float;
  77547. }
  77548. /**
  77549. * @hidden
  77550. */
  77551. export interface IVector2Like {
  77552. x: float;
  77553. y: float;
  77554. }
  77555. /**
  77556. * @hidden
  77557. */
  77558. export interface IMatrixLike {
  77559. toArray(): DeepImmutable<Float32Array>;
  77560. updateFlag: int;
  77561. }
  77562. /**
  77563. * @hidden
  77564. */
  77565. export interface IViewportLike {
  77566. x: float;
  77567. y: float;
  77568. width: float;
  77569. height: float;
  77570. }
  77571. /**
  77572. * @hidden
  77573. */
  77574. export interface IPlaneLike {
  77575. normal: IVector3Like;
  77576. d: float;
  77577. normalize(): void;
  77578. }
  77579. }
  77580. declare module BABYLON {
  77581. /**
  77582. * Interface used to define common properties for effect fallbacks
  77583. */
  77584. export interface IEffectFallbacks {
  77585. /**
  77586. * Removes the defines that should be removed when falling back.
  77587. * @param currentDefines defines the current define statements for the shader.
  77588. * @param effect defines the current effect we try to compile
  77589. * @returns The resulting defines with defines of the current rank removed.
  77590. */
  77591. reduce(currentDefines: string, effect: Effect): string;
  77592. /**
  77593. * Removes the fallback from the bound mesh.
  77594. */
  77595. unBindMesh(): void;
  77596. /**
  77597. * Checks to see if more fallbacks are still availible.
  77598. */
  77599. hasMoreFallbacks: boolean;
  77600. }
  77601. }
  77602. declare module BABYLON {
  77603. /**
  77604. * Class used to evalaute queries containing `and` and `or` operators
  77605. */
  77606. export class AndOrNotEvaluator {
  77607. /**
  77608. * Evaluate a query
  77609. * @param query defines the query to evaluate
  77610. * @param evaluateCallback defines the callback used to filter result
  77611. * @returns true if the query matches
  77612. */
  77613. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  77614. private static _HandleParenthesisContent;
  77615. private static _SimplifyNegation;
  77616. }
  77617. }
  77618. declare module BABYLON {
  77619. /**
  77620. * Class used to store custom tags
  77621. */
  77622. export class Tags {
  77623. /**
  77624. * Adds support for tags on the given object
  77625. * @param obj defines the object to use
  77626. */
  77627. static EnableFor(obj: any): void;
  77628. /**
  77629. * Removes tags support
  77630. * @param obj defines the object to use
  77631. */
  77632. static DisableFor(obj: any): void;
  77633. /**
  77634. * Gets a boolean indicating if the given object has tags
  77635. * @param obj defines the object to use
  77636. * @returns a boolean
  77637. */
  77638. static HasTags(obj: any): boolean;
  77639. /**
  77640. * Gets the tags available on a given object
  77641. * @param obj defines the object to use
  77642. * @param asString defines if the tags must be returned as a string instead of an array of strings
  77643. * @returns the tags
  77644. */
  77645. static GetTags(obj: any, asString?: boolean): any;
  77646. /**
  77647. * Adds tags to an object
  77648. * @param obj defines the object to use
  77649. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  77650. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  77651. */
  77652. static AddTagsTo(obj: any, tagsString: string): void;
  77653. /**
  77654. * @hidden
  77655. */
  77656. static _AddTagTo(obj: any, tag: string): void;
  77657. /**
  77658. * Removes specific tags from a specific object
  77659. * @param obj defines the object to use
  77660. * @param tagsString defines the tags to remove
  77661. */
  77662. static RemoveTagsFrom(obj: any, tagsString: string): void;
  77663. /**
  77664. * @hidden
  77665. */
  77666. static _RemoveTagFrom(obj: any, tag: string): void;
  77667. /**
  77668. * Defines if tags hosted on an object match a given query
  77669. * @param obj defines the object to use
  77670. * @param tagsQuery defines the tag query
  77671. * @returns a boolean
  77672. */
  77673. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  77674. }
  77675. }
  77676. declare module BABYLON {
  77677. /**
  77678. * Scalar computation library
  77679. */
  77680. export class Scalar {
  77681. /**
  77682. * Two pi constants convenient for computation.
  77683. */
  77684. static TwoPi: number;
  77685. /**
  77686. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77687. * @param a number
  77688. * @param b number
  77689. * @param epsilon (default = 1.401298E-45)
  77690. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77691. */
  77692. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  77693. /**
  77694. * Returns a string : the upper case translation of the number i to hexadecimal.
  77695. * @param i number
  77696. * @returns the upper case translation of the number i to hexadecimal.
  77697. */
  77698. static ToHex(i: number): string;
  77699. /**
  77700. * Returns -1 if value is negative and +1 is value is positive.
  77701. * @param value the value
  77702. * @returns the value itself if it's equal to zero.
  77703. */
  77704. static Sign(value: number): number;
  77705. /**
  77706. * Returns the value itself if it's between min and max.
  77707. * Returns min if the value is lower than min.
  77708. * Returns max if the value is greater than max.
  77709. * @param value the value to clmap
  77710. * @param min the min value to clamp to (default: 0)
  77711. * @param max the max value to clamp to (default: 1)
  77712. * @returns the clamped value
  77713. */
  77714. static Clamp(value: number, min?: number, max?: number): number;
  77715. /**
  77716. * the log2 of value.
  77717. * @param value the value to compute log2 of
  77718. * @returns the log2 of value.
  77719. */
  77720. static Log2(value: number): number;
  77721. /**
  77722. * Loops the value, so that it is never larger than length and never smaller than 0.
  77723. *
  77724. * This is similar to the modulo operator but it works with floating point numbers.
  77725. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  77726. * With t = 5 and length = 2.5, the result would be 0.0.
  77727. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  77728. * @param value the value
  77729. * @param length the length
  77730. * @returns the looped value
  77731. */
  77732. static Repeat(value: number, length: number): number;
  77733. /**
  77734. * Normalize the value between 0.0 and 1.0 using min and max values
  77735. * @param value value to normalize
  77736. * @param min max to normalize between
  77737. * @param max min to normalize between
  77738. * @returns the normalized value
  77739. */
  77740. static Normalize(value: number, min: number, max: number): number;
  77741. /**
  77742. * Denormalize the value from 0.0 and 1.0 using min and max values
  77743. * @param normalized value to denormalize
  77744. * @param min max to denormalize between
  77745. * @param max min to denormalize between
  77746. * @returns the denormalized value
  77747. */
  77748. static Denormalize(normalized: number, min: number, max: number): number;
  77749. /**
  77750. * Calculates the shortest difference between two given angles given in degrees.
  77751. * @param current current angle in degrees
  77752. * @param target target angle in degrees
  77753. * @returns the delta
  77754. */
  77755. static DeltaAngle(current: number, target: number): number;
  77756. /**
  77757. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  77758. * @param tx value
  77759. * @param length length
  77760. * @returns The returned value will move back and forth between 0 and length
  77761. */
  77762. static PingPong(tx: number, length: number): number;
  77763. /**
  77764. * Interpolates between min and max with smoothing at the limits.
  77765. *
  77766. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  77767. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  77768. * @param from from
  77769. * @param to to
  77770. * @param tx value
  77771. * @returns the smooth stepped value
  77772. */
  77773. static SmoothStep(from: number, to: number, tx: number): number;
  77774. /**
  77775. * Moves a value current towards target.
  77776. *
  77777. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  77778. * Negative values of maxDelta pushes the value away from target.
  77779. * @param current current value
  77780. * @param target target value
  77781. * @param maxDelta max distance to move
  77782. * @returns resulting value
  77783. */
  77784. static MoveTowards(current: number, target: number, maxDelta: number): number;
  77785. /**
  77786. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77787. *
  77788. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  77789. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  77790. * @param current current value
  77791. * @param target target value
  77792. * @param maxDelta max distance to move
  77793. * @returns resulting angle
  77794. */
  77795. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  77796. /**
  77797. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  77798. * @param start start value
  77799. * @param end target value
  77800. * @param amount amount to lerp between
  77801. * @returns the lerped value
  77802. */
  77803. static Lerp(start: number, end: number, amount: number): number;
  77804. /**
  77805. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77806. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  77807. * @param start start value
  77808. * @param end target value
  77809. * @param amount amount to lerp between
  77810. * @returns the lerped value
  77811. */
  77812. static LerpAngle(start: number, end: number, amount: number): number;
  77813. /**
  77814. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  77815. * @param a start value
  77816. * @param b target value
  77817. * @param value value between a and b
  77818. * @returns the inverseLerp value
  77819. */
  77820. static InverseLerp(a: number, b: number, value: number): number;
  77821. /**
  77822. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  77823. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  77824. * @param value1 spline value
  77825. * @param tangent1 spline value
  77826. * @param value2 spline value
  77827. * @param tangent2 spline value
  77828. * @param amount input value
  77829. * @returns hermite result
  77830. */
  77831. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  77832. /**
  77833. * Returns a random float number between and min and max values
  77834. * @param min min value of random
  77835. * @param max max value of random
  77836. * @returns random value
  77837. */
  77838. static RandomRange(min: number, max: number): number;
  77839. /**
  77840. * This function returns percentage of a number in a given range.
  77841. *
  77842. * RangeToPercent(40,20,60) will return 0.5 (50%)
  77843. * RangeToPercent(34,0,100) will return 0.34 (34%)
  77844. * @param number to convert to percentage
  77845. * @param min min range
  77846. * @param max max range
  77847. * @returns the percentage
  77848. */
  77849. static RangeToPercent(number: number, min: number, max: number): number;
  77850. /**
  77851. * This function returns number that corresponds to the percentage in a given range.
  77852. *
  77853. * PercentToRange(0.34,0,100) will return 34.
  77854. * @param percent to convert to number
  77855. * @param min min range
  77856. * @param max max range
  77857. * @returns the number
  77858. */
  77859. static PercentToRange(percent: number, min: number, max: number): number;
  77860. /**
  77861. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  77862. * @param angle The angle to normalize in radian.
  77863. * @return The converted angle.
  77864. */
  77865. static NormalizeRadians(angle: number): number;
  77866. }
  77867. }
  77868. declare module BABYLON {
  77869. /**
  77870. * Constant used to convert a value to gamma space
  77871. * @ignorenaming
  77872. */
  77873. export const ToGammaSpace: number;
  77874. /**
  77875. * Constant used to convert a value to linear space
  77876. * @ignorenaming
  77877. */
  77878. export const ToLinearSpace = 2.2;
  77879. /**
  77880. * Constant used to define the minimal number value in Babylon.js
  77881. * @ignorenaming
  77882. */
  77883. let Epsilon: number;
  77884. }
  77885. declare module BABYLON {
  77886. /**
  77887. * Class used to represent a viewport on screen
  77888. */
  77889. export class Viewport {
  77890. /** viewport left coordinate */
  77891. x: number;
  77892. /** viewport top coordinate */
  77893. y: number;
  77894. /**viewport width */
  77895. width: number;
  77896. /** viewport height */
  77897. height: number;
  77898. /**
  77899. * Creates a Viewport object located at (x, y) and sized (width, height)
  77900. * @param x defines viewport left coordinate
  77901. * @param y defines viewport top coordinate
  77902. * @param width defines the viewport width
  77903. * @param height defines the viewport height
  77904. */
  77905. constructor(
  77906. /** viewport left coordinate */
  77907. x: number,
  77908. /** viewport top coordinate */
  77909. y: number,
  77910. /**viewport width */
  77911. width: number,
  77912. /** viewport height */
  77913. height: number);
  77914. /**
  77915. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77916. * @param renderWidth defines the rendering width
  77917. * @param renderHeight defines the rendering height
  77918. * @returns a new Viewport
  77919. */
  77920. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  77921. /**
  77922. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77923. * @param renderWidth defines the rendering width
  77924. * @param renderHeight defines the rendering height
  77925. * @param ref defines the target viewport
  77926. * @returns the current viewport
  77927. */
  77928. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  77929. /**
  77930. * Returns a new Viewport copied from the current one
  77931. * @returns a new Viewport
  77932. */
  77933. clone(): Viewport;
  77934. }
  77935. }
  77936. declare module BABYLON {
  77937. /**
  77938. * Class containing a set of static utilities functions for arrays.
  77939. */
  77940. export class ArrayTools {
  77941. /**
  77942. * Returns an array of the given size filled with element built from the given constructor and the paramters
  77943. * @param size the number of element to construct and put in the array
  77944. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  77945. * @returns a new array filled with new objects
  77946. */
  77947. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  77948. }
  77949. }
  77950. declare module BABYLON {
  77951. /**
  77952. * Represens a plane by the equation ax + by + cz + d = 0
  77953. */
  77954. export class Plane {
  77955. private static _TmpMatrix;
  77956. /**
  77957. * Normal of the plane (a,b,c)
  77958. */
  77959. normal: Vector3;
  77960. /**
  77961. * d component of the plane
  77962. */
  77963. d: number;
  77964. /**
  77965. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77966. * @param a a component of the plane
  77967. * @param b b component of the plane
  77968. * @param c c component of the plane
  77969. * @param d d component of the plane
  77970. */
  77971. constructor(a: number, b: number, c: number, d: number);
  77972. /**
  77973. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77974. */
  77975. asArray(): number[];
  77976. /**
  77977. * @returns a new plane copied from the current Plane.
  77978. */
  77979. clone(): Plane;
  77980. /**
  77981. * @returns the string "Plane".
  77982. */
  77983. getClassName(): string;
  77984. /**
  77985. * @returns the Plane hash code.
  77986. */
  77987. getHashCode(): number;
  77988. /**
  77989. * Normalize the current Plane in place.
  77990. * @returns the updated Plane.
  77991. */
  77992. normalize(): Plane;
  77993. /**
  77994. * Applies a transformation the plane and returns the result
  77995. * @param transformation the transformation matrix to be applied to the plane
  77996. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77997. */
  77998. transform(transformation: DeepImmutable<Matrix>): Plane;
  77999. /**
  78000. * Compute the dot product between the point and the plane normal
  78001. * @param point point to calculate the dot product with
  78002. * @returns the dot product (float) of the point coordinates and the plane normal.
  78003. */
  78004. dotCoordinate(point: DeepImmutable<Vector3>): number;
  78005. /**
  78006. * Updates the current Plane from the plane defined by the three given points.
  78007. * @param point1 one of the points used to contruct the plane
  78008. * @param point2 one of the points used to contruct the plane
  78009. * @param point3 one of the points used to contruct the plane
  78010. * @returns the updated Plane.
  78011. */
  78012. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78013. /**
  78014. * Checks if the plane is facing a given direction
  78015. * @param direction the direction to check if the plane is facing
  78016. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  78017. * @returns True is the vector "direction" is the same side than the plane normal.
  78018. */
  78019. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  78020. /**
  78021. * Calculates the distance to a point
  78022. * @param point point to calculate distance to
  78023. * @returns the signed distance (float) from the given point to the Plane.
  78024. */
  78025. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  78026. /**
  78027. * Creates a plane from an array
  78028. * @param array the array to create a plane from
  78029. * @returns a new Plane from the given array.
  78030. */
  78031. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  78032. /**
  78033. * Creates a plane from three points
  78034. * @param point1 point used to create the plane
  78035. * @param point2 point used to create the plane
  78036. * @param point3 point used to create the plane
  78037. * @returns a new Plane defined by the three given points.
  78038. */
  78039. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78040. /**
  78041. * Creates a plane from an origin point and a normal
  78042. * @param origin origin of the plane to be constructed
  78043. * @param normal normal of the plane to be constructed
  78044. * @returns a new Plane the normal vector to this plane at the given origin point.
  78045. * Note : the vector "normal" is updated because normalized.
  78046. */
  78047. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  78048. /**
  78049. * Calculates the distance from a plane and a point
  78050. * @param origin origin of the plane to be constructed
  78051. * @param normal normal of the plane to be constructed
  78052. * @param point point to calculate distance to
  78053. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  78054. */
  78055. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  78056. }
  78057. }
  78058. declare module BABYLON {
  78059. /**
  78060. * Class representing a vector containing 2 coordinates
  78061. */
  78062. export class Vector2 {
  78063. /** defines the first coordinate */
  78064. x: number;
  78065. /** defines the second coordinate */
  78066. y: number;
  78067. /**
  78068. * Creates a new Vector2 from the given x and y coordinates
  78069. * @param x defines the first coordinate
  78070. * @param y defines the second coordinate
  78071. */
  78072. constructor(
  78073. /** defines the first coordinate */
  78074. x?: number,
  78075. /** defines the second coordinate */
  78076. y?: number);
  78077. /**
  78078. * Gets a string with the Vector2 coordinates
  78079. * @returns a string with the Vector2 coordinates
  78080. */
  78081. toString(): string;
  78082. /**
  78083. * Gets class name
  78084. * @returns the string "Vector2"
  78085. */
  78086. getClassName(): string;
  78087. /**
  78088. * Gets current vector hash code
  78089. * @returns the Vector2 hash code as a number
  78090. */
  78091. getHashCode(): number;
  78092. /**
  78093. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  78094. * @param array defines the source array
  78095. * @param index defines the offset in source array
  78096. * @returns the current Vector2
  78097. */
  78098. toArray(array: FloatArray, index?: number): Vector2;
  78099. /**
  78100. * Copy the current vector to an array
  78101. * @returns a new array with 2 elements: the Vector2 coordinates.
  78102. */
  78103. asArray(): number[];
  78104. /**
  78105. * Sets the Vector2 coordinates with the given Vector2 coordinates
  78106. * @param source defines the source Vector2
  78107. * @returns the current updated Vector2
  78108. */
  78109. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  78110. /**
  78111. * Sets the Vector2 coordinates with the given floats
  78112. * @param x defines the first coordinate
  78113. * @param y defines the second coordinate
  78114. * @returns the current updated Vector2
  78115. */
  78116. copyFromFloats(x: number, y: number): Vector2;
  78117. /**
  78118. * Sets the Vector2 coordinates with the given floats
  78119. * @param x defines the first coordinate
  78120. * @param y defines the second coordinate
  78121. * @returns the current updated Vector2
  78122. */
  78123. set(x: number, y: number): Vector2;
  78124. /**
  78125. * Add another vector with the current one
  78126. * @param otherVector defines the other vector
  78127. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  78128. */
  78129. add(otherVector: DeepImmutable<Vector2>): Vector2;
  78130. /**
  78131. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  78132. * @param otherVector defines the other vector
  78133. * @param result defines the target vector
  78134. * @returns the unmodified current Vector2
  78135. */
  78136. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78137. /**
  78138. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  78139. * @param otherVector defines the other vector
  78140. * @returns the current updated Vector2
  78141. */
  78142. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78143. /**
  78144. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  78145. * @param otherVector defines the other vector
  78146. * @returns a new Vector2
  78147. */
  78148. addVector3(otherVector: Vector3): Vector2;
  78149. /**
  78150. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  78151. * @param otherVector defines the other vector
  78152. * @returns a new Vector2
  78153. */
  78154. subtract(otherVector: Vector2): Vector2;
  78155. /**
  78156. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  78157. * @param otherVector defines the other vector
  78158. * @param result defines the target vector
  78159. * @returns the unmodified current Vector2
  78160. */
  78161. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78162. /**
  78163. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  78164. * @param otherVector defines the other vector
  78165. * @returns the current updated Vector2
  78166. */
  78167. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78168. /**
  78169. * Multiplies in place the current Vector2 coordinates by the given ones
  78170. * @param otherVector defines the other vector
  78171. * @returns the current updated Vector2
  78172. */
  78173. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78174. /**
  78175. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  78176. * @param otherVector defines the other vector
  78177. * @returns a new Vector2
  78178. */
  78179. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  78180. /**
  78181. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  78182. * @param otherVector defines the other vector
  78183. * @param result defines the target vector
  78184. * @returns the unmodified current Vector2
  78185. */
  78186. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78187. /**
  78188. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  78189. * @param x defines the first coordinate
  78190. * @param y defines the second coordinate
  78191. * @returns a new Vector2
  78192. */
  78193. multiplyByFloats(x: number, y: number): Vector2;
  78194. /**
  78195. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  78196. * @param otherVector defines the other vector
  78197. * @returns a new Vector2
  78198. */
  78199. divide(otherVector: Vector2): Vector2;
  78200. /**
  78201. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  78202. * @param otherVector defines the other vector
  78203. * @param result defines the target vector
  78204. * @returns the unmodified current Vector2
  78205. */
  78206. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78207. /**
  78208. * Divides the current Vector2 coordinates by the given ones
  78209. * @param otherVector defines the other vector
  78210. * @returns the current updated Vector2
  78211. */
  78212. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78213. /**
  78214. * Gets a new Vector2 with current Vector2 negated coordinates
  78215. * @returns a new Vector2
  78216. */
  78217. negate(): Vector2;
  78218. /**
  78219. * Negate this vector in place
  78220. * @returns this
  78221. */
  78222. negateInPlace(): Vector2;
  78223. /**
  78224. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  78225. * @param result defines the Vector3 object where to store the result
  78226. * @returns the current Vector2
  78227. */
  78228. negateToRef(result: Vector2): Vector2;
  78229. /**
  78230. * Multiply the Vector2 coordinates by scale
  78231. * @param scale defines the scaling factor
  78232. * @returns the current updated Vector2
  78233. */
  78234. scaleInPlace(scale: number): Vector2;
  78235. /**
  78236. * Returns a new Vector2 scaled by "scale" from the current Vector2
  78237. * @param scale defines the scaling factor
  78238. * @returns a new Vector2
  78239. */
  78240. scale(scale: number): Vector2;
  78241. /**
  78242. * Scale the current Vector2 values by a factor to a given Vector2
  78243. * @param scale defines the scale factor
  78244. * @param result defines the Vector2 object where to store the result
  78245. * @returns the unmodified current Vector2
  78246. */
  78247. scaleToRef(scale: number, result: Vector2): Vector2;
  78248. /**
  78249. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  78250. * @param scale defines the scale factor
  78251. * @param result defines the Vector2 object where to store the result
  78252. * @returns the unmodified current Vector2
  78253. */
  78254. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  78255. /**
  78256. * Gets a boolean if two vectors are equals
  78257. * @param otherVector defines the other vector
  78258. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  78259. */
  78260. equals(otherVector: DeepImmutable<Vector2>): boolean;
  78261. /**
  78262. * Gets a boolean if two vectors are equals (using an epsilon value)
  78263. * @param otherVector defines the other vector
  78264. * @param epsilon defines the minimal distance to consider equality
  78265. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  78266. */
  78267. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  78268. /**
  78269. * Gets a new Vector2 from current Vector2 floored values
  78270. * @returns a new Vector2
  78271. */
  78272. floor(): Vector2;
  78273. /**
  78274. * Gets a new Vector2 from current Vector2 floored values
  78275. * @returns a new Vector2
  78276. */
  78277. fract(): Vector2;
  78278. /**
  78279. * Gets the length of the vector
  78280. * @returns the vector length (float)
  78281. */
  78282. length(): number;
  78283. /**
  78284. * Gets the vector squared length
  78285. * @returns the vector squared length (float)
  78286. */
  78287. lengthSquared(): number;
  78288. /**
  78289. * Normalize the vector
  78290. * @returns the current updated Vector2
  78291. */
  78292. normalize(): Vector2;
  78293. /**
  78294. * Gets a new Vector2 copied from the Vector2
  78295. * @returns a new Vector2
  78296. */
  78297. clone(): Vector2;
  78298. /**
  78299. * Gets a new Vector2(0, 0)
  78300. * @returns a new Vector2
  78301. */
  78302. static Zero(): Vector2;
  78303. /**
  78304. * Gets a new Vector2(1, 1)
  78305. * @returns a new Vector2
  78306. */
  78307. static One(): Vector2;
  78308. /**
  78309. * Gets a new Vector2 set from the given index element of the given array
  78310. * @param array defines the data source
  78311. * @param offset defines the offset in the data source
  78312. * @returns a new Vector2
  78313. */
  78314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  78315. /**
  78316. * Sets "result" from the given index element of the given array
  78317. * @param array defines the data source
  78318. * @param offset defines the offset in the data source
  78319. * @param result defines the target vector
  78320. */
  78321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  78322. /**
  78323. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  78324. * @param value1 defines 1st point of control
  78325. * @param value2 defines 2nd point of control
  78326. * @param value3 defines 3rd point of control
  78327. * @param value4 defines 4th point of control
  78328. * @param amount defines the interpolation factor
  78329. * @returns a new Vector2
  78330. */
  78331. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  78332. /**
  78333. * 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".
  78334. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  78335. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  78336. * @param value defines the value to clamp
  78337. * @param min defines the lower limit
  78338. * @param max defines the upper limit
  78339. * @returns a new Vector2
  78340. */
  78341. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  78342. /**
  78343. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  78344. * @param value1 defines the 1st control point
  78345. * @param tangent1 defines the outgoing tangent
  78346. * @param value2 defines the 2nd control point
  78347. * @param tangent2 defines the incoming tangent
  78348. * @param amount defines the interpolation factor
  78349. * @returns a new Vector2
  78350. */
  78351. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  78352. /**
  78353. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  78354. * @param start defines the start vector
  78355. * @param end defines the end vector
  78356. * @param amount defines the interpolation factor
  78357. * @returns a new Vector2
  78358. */
  78359. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  78360. /**
  78361. * Gets the dot product of the vector "left" and the vector "right"
  78362. * @param left defines first vector
  78363. * @param right defines second vector
  78364. * @returns the dot product (float)
  78365. */
  78366. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  78367. /**
  78368. * Returns a new Vector2 equal to the normalized given vector
  78369. * @param vector defines the vector to normalize
  78370. * @returns a new Vector2
  78371. */
  78372. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  78373. /**
  78374. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  78375. * @param left defines 1st vector
  78376. * @param right defines 2nd vector
  78377. * @returns a new Vector2
  78378. */
  78379. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78380. /**
  78381. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  78382. * @param left defines 1st vector
  78383. * @param right defines 2nd vector
  78384. * @returns a new Vector2
  78385. */
  78386. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78387. /**
  78388. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  78389. * @param vector defines the vector to transform
  78390. * @param transformation defines the matrix to apply
  78391. * @returns a new Vector2
  78392. */
  78393. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  78394. /**
  78395. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  78396. * @param vector defines the vector to transform
  78397. * @param transformation defines the matrix to apply
  78398. * @param result defines the target vector
  78399. */
  78400. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  78401. /**
  78402. * Determines if a given vector is included in a triangle
  78403. * @param p defines the vector to test
  78404. * @param p0 defines 1st triangle point
  78405. * @param p1 defines 2nd triangle point
  78406. * @param p2 defines 3rd triangle point
  78407. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  78408. */
  78409. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  78410. /**
  78411. * Gets the distance between the vectors "value1" and "value2"
  78412. * @param value1 defines first vector
  78413. * @param value2 defines second vector
  78414. * @returns the distance between vectors
  78415. */
  78416. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78417. /**
  78418. * Returns the squared distance between the vectors "value1" and "value2"
  78419. * @param value1 defines first vector
  78420. * @param value2 defines second vector
  78421. * @returns the squared distance between vectors
  78422. */
  78423. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78424. /**
  78425. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  78426. * @param value1 defines first vector
  78427. * @param value2 defines second vector
  78428. * @returns a new Vector2
  78429. */
  78430. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  78431. /**
  78432. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  78433. * @param p defines the middle point
  78434. * @param segA defines one point of the segment
  78435. * @param segB defines the other point of the segment
  78436. * @returns the shortest distance
  78437. */
  78438. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  78439. }
  78440. /**
  78441. * Class used to store (x,y,z) vector representation
  78442. * A Vector3 is the main object used in 3D geometry
  78443. * It can represent etiher the coordinates of a point the space, either a direction
  78444. * Reminder: js uses a left handed forward facing system
  78445. */
  78446. export class Vector3 {
  78447. /**
  78448. * Defines the first coordinates (on X axis)
  78449. */
  78450. x: number;
  78451. /**
  78452. * Defines the second coordinates (on Y axis)
  78453. */
  78454. y: number;
  78455. /**
  78456. * Defines the third coordinates (on Z axis)
  78457. */
  78458. z: number;
  78459. private static _UpReadOnly;
  78460. private static _ZeroReadOnly;
  78461. /**
  78462. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  78463. * @param x defines the first coordinates (on X axis)
  78464. * @param y defines the second coordinates (on Y axis)
  78465. * @param z defines the third coordinates (on Z axis)
  78466. */
  78467. constructor(
  78468. /**
  78469. * Defines the first coordinates (on X axis)
  78470. */
  78471. x?: number,
  78472. /**
  78473. * Defines the second coordinates (on Y axis)
  78474. */
  78475. y?: number,
  78476. /**
  78477. * Defines the third coordinates (on Z axis)
  78478. */
  78479. z?: number);
  78480. /**
  78481. * Creates a string representation of the Vector3
  78482. * @returns a string with the Vector3 coordinates.
  78483. */
  78484. toString(): string;
  78485. /**
  78486. * Gets the class name
  78487. * @returns the string "Vector3"
  78488. */
  78489. getClassName(): string;
  78490. /**
  78491. * Creates the Vector3 hash code
  78492. * @returns a number which tends to be unique between Vector3 instances
  78493. */
  78494. getHashCode(): number;
  78495. /**
  78496. * Creates an array containing three elements : the coordinates of the Vector3
  78497. * @returns a new array of numbers
  78498. */
  78499. asArray(): number[];
  78500. /**
  78501. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  78502. * @param array defines the destination array
  78503. * @param index defines the offset in the destination array
  78504. * @returns the current Vector3
  78505. */
  78506. toArray(array: FloatArray, index?: number): Vector3;
  78507. /**
  78508. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  78509. * @returns a new Quaternion object, computed from the Vector3 coordinates
  78510. */
  78511. toQuaternion(): Quaternion;
  78512. /**
  78513. * Adds the given vector to the current Vector3
  78514. * @param otherVector defines the second operand
  78515. * @returns the current updated Vector3
  78516. */
  78517. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78518. /**
  78519. * Adds the given coordinates to the current Vector3
  78520. * @param x defines the x coordinate of the operand
  78521. * @param y defines the y coordinate of the operand
  78522. * @param z defines the z coordinate of the operand
  78523. * @returns the current updated Vector3
  78524. */
  78525. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78526. /**
  78527. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  78528. * @param otherVector defines the second operand
  78529. * @returns the resulting Vector3
  78530. */
  78531. add(otherVector: DeepImmutable<Vector3>): Vector3;
  78532. /**
  78533. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  78534. * @param otherVector defines the second operand
  78535. * @param result defines the Vector3 object where to store the result
  78536. * @returns the current Vector3
  78537. */
  78538. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78539. /**
  78540. * Subtract the given vector from the current Vector3
  78541. * @param otherVector defines the second operand
  78542. * @returns the current updated Vector3
  78543. */
  78544. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78545. /**
  78546. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  78547. * @param otherVector defines the second operand
  78548. * @returns the resulting Vector3
  78549. */
  78550. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  78551. /**
  78552. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  78553. * @param otherVector defines the second operand
  78554. * @param result defines the Vector3 object where to store the result
  78555. * @returns the current Vector3
  78556. */
  78557. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78558. /**
  78559. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  78560. * @param x defines the x coordinate of the operand
  78561. * @param y defines the y coordinate of the operand
  78562. * @param z defines the z coordinate of the operand
  78563. * @returns the resulting Vector3
  78564. */
  78565. subtractFromFloats(x: number, y: number, z: number): Vector3;
  78566. /**
  78567. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  78568. * @param x defines the x coordinate of the operand
  78569. * @param y defines the y coordinate of the operand
  78570. * @param z defines the z coordinate of the operand
  78571. * @param result defines the Vector3 object where to store the result
  78572. * @returns the current Vector3
  78573. */
  78574. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  78575. /**
  78576. * Gets a new Vector3 set with the current Vector3 negated coordinates
  78577. * @returns a new Vector3
  78578. */
  78579. negate(): Vector3;
  78580. /**
  78581. * Negate this vector in place
  78582. * @returns this
  78583. */
  78584. negateInPlace(): Vector3;
  78585. /**
  78586. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  78587. * @param result defines the Vector3 object where to store the result
  78588. * @returns the current Vector3
  78589. */
  78590. negateToRef(result: Vector3): Vector3;
  78591. /**
  78592. * Multiplies the Vector3 coordinates by the float "scale"
  78593. * @param scale defines the multiplier factor
  78594. * @returns the current updated Vector3
  78595. */
  78596. scaleInPlace(scale: number): Vector3;
  78597. /**
  78598. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  78599. * @param scale defines the multiplier factor
  78600. * @returns a new Vector3
  78601. */
  78602. scale(scale: number): Vector3;
  78603. /**
  78604. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  78605. * @param scale defines the multiplier factor
  78606. * @param result defines the Vector3 object where to store the result
  78607. * @returns the current Vector3
  78608. */
  78609. scaleToRef(scale: number, result: Vector3): Vector3;
  78610. /**
  78611. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  78612. * @param scale defines the scale factor
  78613. * @param result defines the Vector3 object where to store the result
  78614. * @returns the unmodified current Vector3
  78615. */
  78616. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  78617. /**
  78618. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78619. * @param origin defines the origin of the projection ray
  78620. * @param plane defines the plane to project to
  78621. * @returns the projected vector3
  78622. */
  78623. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  78624. /**
  78625. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78626. * @param origin defines the origin of the projection ray
  78627. * @param plane defines the plane to project to
  78628. * @param result defines the Vector3 where to store the result
  78629. */
  78630. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  78631. /**
  78632. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  78633. * @param otherVector defines the second operand
  78634. * @returns true if both vectors are equals
  78635. */
  78636. equals(otherVector: DeepImmutable<Vector3>): boolean;
  78637. /**
  78638. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  78639. * @param otherVector defines the second operand
  78640. * @param epsilon defines the minimal distance to define values as equals
  78641. * @returns true if both vectors are distant less than epsilon
  78642. */
  78643. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  78644. /**
  78645. * Returns true if the current Vector3 coordinates equals the given floats
  78646. * @param x defines the x coordinate of the operand
  78647. * @param y defines the y coordinate of the operand
  78648. * @param z defines the z coordinate of the operand
  78649. * @returns true if both vectors are equals
  78650. */
  78651. equalsToFloats(x: number, y: number, z: number): boolean;
  78652. /**
  78653. * Multiplies the current Vector3 coordinates by the given ones
  78654. * @param otherVector defines the second operand
  78655. * @returns the current updated Vector3
  78656. */
  78657. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78658. /**
  78659. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  78660. * @param otherVector defines the second operand
  78661. * @returns the new Vector3
  78662. */
  78663. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  78664. /**
  78665. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  78666. * @param otherVector defines the second operand
  78667. * @param result defines the Vector3 object where to store the result
  78668. * @returns the current Vector3
  78669. */
  78670. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78671. /**
  78672. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  78673. * @param x defines the x coordinate of the operand
  78674. * @param y defines the y coordinate of the operand
  78675. * @param z defines the z coordinate of the operand
  78676. * @returns the new Vector3
  78677. */
  78678. multiplyByFloats(x: number, y: number, z: number): Vector3;
  78679. /**
  78680. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  78681. * @param otherVector defines the second operand
  78682. * @returns the new Vector3
  78683. */
  78684. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  78685. /**
  78686. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  78687. * @param otherVector defines the second operand
  78688. * @param result defines the Vector3 object where to store the result
  78689. * @returns the current Vector3
  78690. */
  78691. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78692. /**
  78693. * Divides the current Vector3 coordinates by the given ones.
  78694. * @param otherVector defines the second operand
  78695. * @returns the current updated Vector3
  78696. */
  78697. divideInPlace(otherVector: Vector3): Vector3;
  78698. /**
  78699. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  78700. * @param other defines the second operand
  78701. * @returns the current updated Vector3
  78702. */
  78703. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78704. /**
  78705. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  78706. * @param other defines the second operand
  78707. * @returns the current updated Vector3
  78708. */
  78709. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78710. /**
  78711. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  78712. * @param x defines the x coordinate of the operand
  78713. * @param y defines the y coordinate of the operand
  78714. * @param z defines the z coordinate of the operand
  78715. * @returns the current updated Vector3
  78716. */
  78717. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78718. /**
  78719. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  78720. * @param x defines the x coordinate of the operand
  78721. * @param y defines the y coordinate of the operand
  78722. * @param z defines the z coordinate of the operand
  78723. * @returns the current updated Vector3
  78724. */
  78725. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78726. /**
  78727. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  78728. * Check if is non uniform within a certain amount of decimal places to account for this
  78729. * @param epsilon the amount the values can differ
  78730. * @returns if the the vector is non uniform to a certain number of decimal places
  78731. */
  78732. isNonUniformWithinEpsilon(epsilon: number): boolean;
  78733. /**
  78734. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  78735. */
  78736. get isNonUniform(): boolean;
  78737. /**
  78738. * Gets a new Vector3 from current Vector3 floored values
  78739. * @returns a new Vector3
  78740. */
  78741. floor(): Vector3;
  78742. /**
  78743. * Gets a new Vector3 from current Vector3 floored values
  78744. * @returns a new Vector3
  78745. */
  78746. fract(): Vector3;
  78747. /**
  78748. * Gets the length of the Vector3
  78749. * @returns the length of the Vector3
  78750. */
  78751. length(): number;
  78752. /**
  78753. * Gets the squared length of the Vector3
  78754. * @returns squared length of the Vector3
  78755. */
  78756. lengthSquared(): number;
  78757. /**
  78758. * Normalize the current Vector3.
  78759. * Please note that this is an in place operation.
  78760. * @returns the current updated Vector3
  78761. */
  78762. normalize(): Vector3;
  78763. /**
  78764. * Reorders the x y z properties of the vector in place
  78765. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  78766. * @returns the current updated vector
  78767. */
  78768. reorderInPlace(order: string): this;
  78769. /**
  78770. * Rotates the vector around 0,0,0 by a quaternion
  78771. * @param quaternion the rotation quaternion
  78772. * @param result vector to store the result
  78773. * @returns the resulting vector
  78774. */
  78775. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  78776. /**
  78777. * Rotates a vector around a given point
  78778. * @param quaternion the rotation quaternion
  78779. * @param point the point to rotate around
  78780. * @param result vector to store the result
  78781. * @returns the resulting vector
  78782. */
  78783. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  78784. /**
  78785. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  78786. * The cross product is then orthogonal to both current and "other"
  78787. * @param other defines the right operand
  78788. * @returns the cross product
  78789. */
  78790. cross(other: Vector3): Vector3;
  78791. /**
  78792. * Normalize the current Vector3 with the given input length.
  78793. * Please note that this is an in place operation.
  78794. * @param len the length of the vector
  78795. * @returns the current updated Vector3
  78796. */
  78797. normalizeFromLength(len: number): Vector3;
  78798. /**
  78799. * Normalize the current Vector3 to a new vector
  78800. * @returns the new Vector3
  78801. */
  78802. normalizeToNew(): Vector3;
  78803. /**
  78804. * Normalize the current Vector3 to the reference
  78805. * @param reference define the Vector3 to update
  78806. * @returns the updated Vector3
  78807. */
  78808. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  78809. /**
  78810. * Creates a new Vector3 copied from the current Vector3
  78811. * @returns the new Vector3
  78812. */
  78813. clone(): Vector3;
  78814. /**
  78815. * Copies the given vector coordinates to the current Vector3 ones
  78816. * @param source defines the source Vector3
  78817. * @returns the current updated Vector3
  78818. */
  78819. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  78820. /**
  78821. * Copies the given floats to the current Vector3 coordinates
  78822. * @param x defines the x coordinate of the operand
  78823. * @param y defines the y coordinate of the operand
  78824. * @param z defines the z coordinate of the operand
  78825. * @returns the current updated Vector3
  78826. */
  78827. copyFromFloats(x: number, y: number, z: number): Vector3;
  78828. /**
  78829. * Copies the given floats to the current Vector3 coordinates
  78830. * @param x defines the x coordinate of the operand
  78831. * @param y defines the y coordinate of the operand
  78832. * @param z defines the z coordinate of the operand
  78833. * @returns the current updated Vector3
  78834. */
  78835. set(x: number, y: number, z: number): Vector3;
  78836. /**
  78837. * Copies the given float to the current Vector3 coordinates
  78838. * @param v defines the x, y and z coordinates of the operand
  78839. * @returns the current updated Vector3
  78840. */
  78841. setAll(v: number): Vector3;
  78842. /**
  78843. * Get the clip factor between two vectors
  78844. * @param vector0 defines the first operand
  78845. * @param vector1 defines the second operand
  78846. * @param axis defines the axis to use
  78847. * @param size defines the size along the axis
  78848. * @returns the clip factor
  78849. */
  78850. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  78851. /**
  78852. * Get angle between two vectors
  78853. * @param vector0 angle between vector0 and vector1
  78854. * @param vector1 angle between vector0 and vector1
  78855. * @param normal direction of the normal
  78856. * @return the angle between vector0 and vector1
  78857. */
  78858. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  78859. /**
  78860. * Returns a new Vector3 set from the index "offset" of the given array
  78861. * @param array defines the source array
  78862. * @param offset defines the offset in the source array
  78863. * @returns the new Vector3
  78864. */
  78865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  78866. /**
  78867. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  78868. * @param array defines the source array
  78869. * @param offset defines the offset in the source array
  78870. * @returns the new Vector3
  78871. * @deprecated Please use FromArray instead.
  78872. */
  78873. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  78874. /**
  78875. * Sets the given vector "result" with the element values from the index "offset" of the given array
  78876. * @param array defines the source array
  78877. * @param offset defines the offset in the source array
  78878. * @param result defines the Vector3 where to store the result
  78879. */
  78880. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  78881. /**
  78882. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  78883. * @param array defines the source array
  78884. * @param offset defines the offset in the source array
  78885. * @param result defines the Vector3 where to store the result
  78886. * @deprecated Please use FromArrayToRef instead.
  78887. */
  78888. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  78889. /**
  78890. * Sets the given vector "result" with the given floats.
  78891. * @param x defines the x coordinate of the source
  78892. * @param y defines the y coordinate of the source
  78893. * @param z defines the z coordinate of the source
  78894. * @param result defines the Vector3 where to store the result
  78895. */
  78896. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  78897. /**
  78898. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  78899. * @returns a new empty Vector3
  78900. */
  78901. static Zero(): Vector3;
  78902. /**
  78903. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  78904. * @returns a new unit Vector3
  78905. */
  78906. static One(): Vector3;
  78907. /**
  78908. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  78909. * @returns a new up Vector3
  78910. */
  78911. static Up(): Vector3;
  78912. /**
  78913. * Gets a up Vector3 that must not be updated
  78914. */
  78915. static get UpReadOnly(): DeepImmutable<Vector3>;
  78916. /**
  78917. * Gets a zero Vector3 that must not be updated
  78918. */
  78919. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  78920. /**
  78921. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  78922. * @returns a new down Vector3
  78923. */
  78924. static Down(): Vector3;
  78925. /**
  78926. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  78927. * @param rightHandedSystem is the scene right-handed (negative z)
  78928. * @returns a new forward Vector3
  78929. */
  78930. static Forward(rightHandedSystem?: boolean): Vector3;
  78931. /**
  78932. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  78933. * @param rightHandedSystem is the scene right-handed (negative-z)
  78934. * @returns a new forward Vector3
  78935. */
  78936. static Backward(rightHandedSystem?: boolean): Vector3;
  78937. /**
  78938. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  78939. * @returns a new right Vector3
  78940. */
  78941. static Right(): Vector3;
  78942. /**
  78943. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  78944. * @returns a new left Vector3
  78945. */
  78946. static Left(): Vector3;
  78947. /**
  78948. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  78949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78950. * @param vector defines the Vector3 to transform
  78951. * @param transformation defines the transformation matrix
  78952. * @returns the transformed Vector3
  78953. */
  78954. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78955. /**
  78956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  78957. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78958. * @param vector defines the Vector3 to transform
  78959. * @param transformation defines the transformation matrix
  78960. * @param result defines the Vector3 where to store the result
  78961. */
  78962. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78963. /**
  78964. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  78965. * This method computes tranformed coordinates only, not transformed direction vectors
  78966. * @param x define the x coordinate of the source vector
  78967. * @param y define the y coordinate of the source vector
  78968. * @param z define the z coordinate of the source vector
  78969. * @param transformation defines the transformation matrix
  78970. * @param result defines the Vector3 where to store the result
  78971. */
  78972. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78973. /**
  78974. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  78975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78976. * @param vector defines the Vector3 to transform
  78977. * @param transformation defines the transformation matrix
  78978. * @returns the new Vector3
  78979. */
  78980. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78981. /**
  78982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  78983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78984. * @param vector defines the Vector3 to transform
  78985. * @param transformation defines the transformation matrix
  78986. * @param result defines the Vector3 where to store the result
  78987. */
  78988. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78989. /**
  78990. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  78991. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78992. * @param x define the x coordinate of the source vector
  78993. * @param y define the y coordinate of the source vector
  78994. * @param z define the z coordinate of the source vector
  78995. * @param transformation defines the transformation matrix
  78996. * @param result defines the Vector3 where to store the result
  78997. */
  78998. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78999. /**
  79000. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  79001. * @param value1 defines the first control point
  79002. * @param value2 defines the second control point
  79003. * @param value3 defines the third control point
  79004. * @param value4 defines the fourth control point
  79005. * @param amount defines the amount on the spline to use
  79006. * @returns the new Vector3
  79007. */
  79008. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  79009. /**
  79010. * 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"
  79011. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  79012. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  79013. * @param value defines the current value
  79014. * @param min defines the lower range value
  79015. * @param max defines the upper range value
  79016. * @returns the new Vector3
  79017. */
  79018. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  79019. /**
  79020. * 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"
  79021. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  79022. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  79023. * @param value defines the current value
  79024. * @param min defines the lower range value
  79025. * @param max defines the upper range value
  79026. * @param result defines the Vector3 where to store the result
  79027. */
  79028. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  79029. /**
  79030. * Checks if a given vector is inside a specific range
  79031. * @param v defines the vector to test
  79032. * @param min defines the minimum range
  79033. * @param max defines the maximum range
  79034. */
  79035. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  79036. /**
  79037. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  79038. * @param value1 defines the first control point
  79039. * @param tangent1 defines the first tangent vector
  79040. * @param value2 defines the second control point
  79041. * @param tangent2 defines the second tangent vector
  79042. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  79043. * @returns the new Vector3
  79044. */
  79045. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  79046. /**
  79047. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  79048. * @param start defines the start value
  79049. * @param end defines the end value
  79050. * @param amount max defines amount between both (between 0 and 1)
  79051. * @returns the new Vector3
  79052. */
  79053. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  79054. /**
  79055. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  79056. * @param start defines the start value
  79057. * @param end defines the end value
  79058. * @param amount max defines amount between both (between 0 and 1)
  79059. * @param result defines the Vector3 where to store the result
  79060. */
  79061. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  79062. /**
  79063. * Returns the dot product (float) between the vectors "left" and "right"
  79064. * @param left defines the left operand
  79065. * @param right defines the right operand
  79066. * @returns the dot product
  79067. */
  79068. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  79069. /**
  79070. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  79071. * The cross product is then orthogonal to both "left" and "right"
  79072. * @param left defines the left operand
  79073. * @param right defines the right operand
  79074. * @returns the cross product
  79075. */
  79076. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79077. /**
  79078. * Sets the given vector "result" with the cross product of "left" and "right"
  79079. * The cross product is then orthogonal to both "left" and "right"
  79080. * @param left defines the left operand
  79081. * @param right defines the right operand
  79082. * @param result defines the Vector3 where to store the result
  79083. */
  79084. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  79085. /**
  79086. * Returns a new Vector3 as the normalization of the given vector
  79087. * @param vector defines the Vector3 to normalize
  79088. * @returns the new Vector3
  79089. */
  79090. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  79091. /**
  79092. * Sets the given vector "result" with the normalization of the given first vector
  79093. * @param vector defines the Vector3 to normalize
  79094. * @param result defines the Vector3 where to store the result
  79095. */
  79096. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  79097. /**
  79098. * Project a Vector3 onto screen space
  79099. * @param vector defines the Vector3 to project
  79100. * @param world defines the world matrix to use
  79101. * @param transform defines the transform (view x projection) matrix to use
  79102. * @param viewport defines the screen viewport to use
  79103. * @returns the new Vector3
  79104. */
  79105. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  79106. /** @hidden */
  79107. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  79108. /**
  79109. * Unproject from screen space to object space
  79110. * @param source defines the screen space Vector3 to use
  79111. * @param viewportWidth defines the current width of the viewport
  79112. * @param viewportHeight defines the current height of the viewport
  79113. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79114. * @param transform defines the transform (view x projection) matrix to use
  79115. * @returns the new Vector3
  79116. */
  79117. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  79118. /**
  79119. * Unproject from screen space to object space
  79120. * @param source defines the screen space Vector3 to use
  79121. * @param viewportWidth defines the current width of the viewport
  79122. * @param viewportHeight defines the current height of the viewport
  79123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79124. * @param view defines the view matrix to use
  79125. * @param projection defines the projection matrix to use
  79126. * @returns the new Vector3
  79127. */
  79128. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  79129. /**
  79130. * Unproject from screen space to object space
  79131. * @param source defines the screen space Vector3 to use
  79132. * @param viewportWidth defines the current width of the viewport
  79133. * @param viewportHeight defines the current height of the viewport
  79134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79135. * @param view defines the view matrix to use
  79136. * @param projection defines the projection matrix to use
  79137. * @param result defines the Vector3 where to store the result
  79138. */
  79139. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79140. /**
  79141. * Unproject from screen space to object space
  79142. * @param sourceX defines the screen space x coordinate to use
  79143. * @param sourceY defines the screen space y coordinate to use
  79144. * @param sourceZ defines the screen space z coordinate to use
  79145. * @param viewportWidth defines the current width of the viewport
  79146. * @param viewportHeight defines the current height of the viewport
  79147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79148. * @param view defines the view matrix to use
  79149. * @param projection defines the projection matrix to use
  79150. * @param result defines the Vector3 where to store the result
  79151. */
  79152. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79153. /**
  79154. * Gets the minimal coordinate values between two Vector3
  79155. * @param left defines the first operand
  79156. * @param right defines the second operand
  79157. * @returns the new Vector3
  79158. */
  79159. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79160. /**
  79161. * Gets the maximal coordinate values between two Vector3
  79162. * @param left defines the first operand
  79163. * @param right defines the second operand
  79164. * @returns the new Vector3
  79165. */
  79166. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79167. /**
  79168. * Returns the distance between the vectors "value1" and "value2"
  79169. * @param value1 defines the first operand
  79170. * @param value2 defines the second operand
  79171. * @returns the distance
  79172. */
  79173. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79174. /**
  79175. * Returns the squared distance between the vectors "value1" and "value2"
  79176. * @param value1 defines the first operand
  79177. * @param value2 defines the second operand
  79178. * @returns the squared distance
  79179. */
  79180. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79181. /**
  79182. * Returns a new Vector3 located at the center between "value1" and "value2"
  79183. * @param value1 defines the first operand
  79184. * @param value2 defines the second operand
  79185. * @returns the new Vector3
  79186. */
  79187. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  79188. /**
  79189. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  79190. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  79191. * to something in order to rotate it from its local system to the given target system
  79192. * Note: axis1, axis2 and axis3 are normalized during this operation
  79193. * @param axis1 defines the first axis
  79194. * @param axis2 defines the second axis
  79195. * @param axis3 defines the third axis
  79196. * @returns a new Vector3
  79197. */
  79198. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  79199. /**
  79200. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  79201. * @param axis1 defines the first axis
  79202. * @param axis2 defines the second axis
  79203. * @param axis3 defines the third axis
  79204. * @param ref defines the Vector3 where to store the result
  79205. */
  79206. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  79207. }
  79208. /**
  79209. * Vector4 class created for EulerAngle class conversion to Quaternion
  79210. */
  79211. export class Vector4 {
  79212. /** x value of the vector */
  79213. x: number;
  79214. /** y value of the vector */
  79215. y: number;
  79216. /** z value of the vector */
  79217. z: number;
  79218. /** w value of the vector */
  79219. w: number;
  79220. /**
  79221. * Creates a Vector4 object from the given floats.
  79222. * @param x x value of the vector
  79223. * @param y y value of the vector
  79224. * @param z z value of the vector
  79225. * @param w w value of the vector
  79226. */
  79227. constructor(
  79228. /** x value of the vector */
  79229. x: number,
  79230. /** y value of the vector */
  79231. y: number,
  79232. /** z value of the vector */
  79233. z: number,
  79234. /** w value of the vector */
  79235. w: number);
  79236. /**
  79237. * Returns the string with the Vector4 coordinates.
  79238. * @returns a string containing all the vector values
  79239. */
  79240. toString(): string;
  79241. /**
  79242. * Returns the string "Vector4".
  79243. * @returns "Vector4"
  79244. */
  79245. getClassName(): string;
  79246. /**
  79247. * Returns the Vector4 hash code.
  79248. * @returns a unique hash code
  79249. */
  79250. getHashCode(): number;
  79251. /**
  79252. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  79253. * @returns the resulting array
  79254. */
  79255. asArray(): number[];
  79256. /**
  79257. * Populates the given array from the given index with the Vector4 coordinates.
  79258. * @param array array to populate
  79259. * @param index index of the array to start at (default: 0)
  79260. * @returns the Vector4.
  79261. */
  79262. toArray(array: FloatArray, index?: number): Vector4;
  79263. /**
  79264. * Adds the given vector to the current Vector4.
  79265. * @param otherVector the vector to add
  79266. * @returns the updated Vector4.
  79267. */
  79268. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79269. /**
  79270. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  79271. * @param otherVector the vector to add
  79272. * @returns the resulting vector
  79273. */
  79274. add(otherVector: DeepImmutable<Vector4>): Vector4;
  79275. /**
  79276. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  79277. * @param otherVector the vector to add
  79278. * @param result the vector to store the result
  79279. * @returns the current Vector4.
  79280. */
  79281. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79282. /**
  79283. * Subtract in place the given vector from the current Vector4.
  79284. * @param otherVector the vector to subtract
  79285. * @returns the updated Vector4.
  79286. */
  79287. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79288. /**
  79289. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  79290. * @param otherVector the vector to add
  79291. * @returns the new vector with the result
  79292. */
  79293. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  79294. /**
  79295. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  79296. * @param otherVector the vector to subtract
  79297. * @param result the vector to store the result
  79298. * @returns the current Vector4.
  79299. */
  79300. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79301. /**
  79302. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79303. */
  79304. /**
  79305. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79306. * @param x value to subtract
  79307. * @param y value to subtract
  79308. * @param z value to subtract
  79309. * @param w value to subtract
  79310. * @returns new vector containing the result
  79311. */
  79312. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79313. /**
  79314. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79315. * @param x value to subtract
  79316. * @param y value to subtract
  79317. * @param z value to subtract
  79318. * @param w value to subtract
  79319. * @param result the vector to store the result in
  79320. * @returns the current Vector4.
  79321. */
  79322. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  79323. /**
  79324. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  79325. * @returns a new vector with the negated values
  79326. */
  79327. negate(): Vector4;
  79328. /**
  79329. * Negate this vector in place
  79330. * @returns this
  79331. */
  79332. negateInPlace(): Vector4;
  79333. /**
  79334. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  79335. * @param result defines the Vector3 object where to store the result
  79336. * @returns the current Vector4
  79337. */
  79338. negateToRef(result: Vector4): Vector4;
  79339. /**
  79340. * Multiplies the current Vector4 coordinates by scale (float).
  79341. * @param scale the number to scale with
  79342. * @returns the updated Vector4.
  79343. */
  79344. scaleInPlace(scale: number): Vector4;
  79345. /**
  79346. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  79347. * @param scale the number to scale with
  79348. * @returns a new vector with the result
  79349. */
  79350. scale(scale: number): Vector4;
  79351. /**
  79352. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  79353. * @param scale the number to scale with
  79354. * @param result a vector to store the result in
  79355. * @returns the current Vector4.
  79356. */
  79357. scaleToRef(scale: number, result: Vector4): Vector4;
  79358. /**
  79359. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  79360. * @param scale defines the scale factor
  79361. * @param result defines the Vector4 object where to store the result
  79362. * @returns the unmodified current Vector4
  79363. */
  79364. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  79365. /**
  79366. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  79367. * @param otherVector the vector to compare against
  79368. * @returns true if they are equal
  79369. */
  79370. equals(otherVector: DeepImmutable<Vector4>): boolean;
  79371. /**
  79372. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  79373. * @param otherVector vector to compare against
  79374. * @param epsilon (Default: very small number)
  79375. * @returns true if they are equal
  79376. */
  79377. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  79378. /**
  79379. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  79380. * @param x x value to compare against
  79381. * @param y y value to compare against
  79382. * @param z z value to compare against
  79383. * @param w w value to compare against
  79384. * @returns true if equal
  79385. */
  79386. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  79387. /**
  79388. * Multiplies in place the current Vector4 by the given one.
  79389. * @param otherVector vector to multiple with
  79390. * @returns the updated Vector4.
  79391. */
  79392. multiplyInPlace(otherVector: Vector4): Vector4;
  79393. /**
  79394. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  79395. * @param otherVector vector to multiple with
  79396. * @returns resulting new vector
  79397. */
  79398. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  79399. /**
  79400. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  79401. * @param otherVector vector to multiple with
  79402. * @param result vector to store the result
  79403. * @returns the current Vector4.
  79404. */
  79405. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79406. /**
  79407. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  79408. * @param x x value multiply with
  79409. * @param y y value multiply with
  79410. * @param z z value multiply with
  79411. * @param w w value multiply with
  79412. * @returns resulting new vector
  79413. */
  79414. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  79415. /**
  79416. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  79417. * @param otherVector vector to devide with
  79418. * @returns resulting new vector
  79419. */
  79420. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  79421. /**
  79422. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  79423. * @param otherVector vector to devide with
  79424. * @param result vector to store the result
  79425. * @returns the current Vector4.
  79426. */
  79427. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79428. /**
  79429. * Divides the current Vector3 coordinates by the given ones.
  79430. * @param otherVector vector to devide with
  79431. * @returns the updated Vector3.
  79432. */
  79433. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79434. /**
  79435. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  79436. * @param other defines the second operand
  79437. * @returns the current updated Vector4
  79438. */
  79439. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79440. /**
  79441. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  79442. * @param other defines the second operand
  79443. * @returns the current updated Vector4
  79444. */
  79445. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79446. /**
  79447. * Gets a new Vector4 from current Vector4 floored values
  79448. * @returns a new Vector4
  79449. */
  79450. floor(): Vector4;
  79451. /**
  79452. * Gets a new Vector4 from current Vector3 floored values
  79453. * @returns a new Vector4
  79454. */
  79455. fract(): Vector4;
  79456. /**
  79457. * Returns the Vector4 length (float).
  79458. * @returns the length
  79459. */
  79460. length(): number;
  79461. /**
  79462. * Returns the Vector4 squared length (float).
  79463. * @returns the length squared
  79464. */
  79465. lengthSquared(): number;
  79466. /**
  79467. * Normalizes in place the Vector4.
  79468. * @returns the updated Vector4.
  79469. */
  79470. normalize(): Vector4;
  79471. /**
  79472. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  79473. * @returns this converted to a new vector3
  79474. */
  79475. toVector3(): Vector3;
  79476. /**
  79477. * Returns a new Vector4 copied from the current one.
  79478. * @returns the new cloned vector
  79479. */
  79480. clone(): Vector4;
  79481. /**
  79482. * Updates the current Vector4 with the given one coordinates.
  79483. * @param source the source vector to copy from
  79484. * @returns the updated Vector4.
  79485. */
  79486. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  79487. /**
  79488. * Updates the current Vector4 coordinates with the given floats.
  79489. * @param x float to copy from
  79490. * @param y float to copy from
  79491. * @param z float to copy from
  79492. * @param w float to copy from
  79493. * @returns the updated Vector4.
  79494. */
  79495. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79496. /**
  79497. * Updates the current Vector4 coordinates with the given floats.
  79498. * @param x float to set from
  79499. * @param y float to set from
  79500. * @param z float to set from
  79501. * @param w float to set from
  79502. * @returns the updated Vector4.
  79503. */
  79504. set(x: number, y: number, z: number, w: number): Vector4;
  79505. /**
  79506. * Copies the given float to the current Vector3 coordinates
  79507. * @param v defines the x, y, z and w coordinates of the operand
  79508. * @returns the current updated Vector3
  79509. */
  79510. setAll(v: number): Vector4;
  79511. /**
  79512. * Returns a new Vector4 set from the starting index of the given array.
  79513. * @param array the array to pull values from
  79514. * @param offset the offset into the array to start at
  79515. * @returns the new vector
  79516. */
  79517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  79518. /**
  79519. * Updates the given vector "result" from the starting index of the given array.
  79520. * @param array the array to pull values from
  79521. * @param offset the offset into the array to start at
  79522. * @param result the vector to store the result in
  79523. */
  79524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  79525. /**
  79526. * Updates the given vector "result" from the starting index of the given Float32Array.
  79527. * @param array the array to pull values from
  79528. * @param offset the offset into the array to start at
  79529. * @param result the vector to store the result in
  79530. */
  79531. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  79532. /**
  79533. * Updates the given vector "result" coordinates from the given floats.
  79534. * @param x float to set from
  79535. * @param y float to set from
  79536. * @param z float to set from
  79537. * @param w float to set from
  79538. * @param result the vector to the floats in
  79539. */
  79540. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  79541. /**
  79542. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  79543. * @returns the new vector
  79544. */
  79545. static Zero(): Vector4;
  79546. /**
  79547. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  79548. * @returns the new vector
  79549. */
  79550. static One(): Vector4;
  79551. /**
  79552. * Returns a new normalized Vector4 from the given one.
  79553. * @param vector the vector to normalize
  79554. * @returns the vector
  79555. */
  79556. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  79557. /**
  79558. * Updates the given vector "result" from the normalization of the given one.
  79559. * @param vector the vector to normalize
  79560. * @param result the vector to store the result in
  79561. */
  79562. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  79563. /**
  79564. * Returns a vector with the minimum values from the left and right vectors
  79565. * @param left left vector to minimize
  79566. * @param right right vector to minimize
  79567. * @returns a new vector with the minimum of the left and right vector values
  79568. */
  79569. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79570. /**
  79571. * Returns a vector with the maximum values from the left and right vectors
  79572. * @param left left vector to maximize
  79573. * @param right right vector to maximize
  79574. * @returns a new vector with the maximum of the left and right vector values
  79575. */
  79576. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79577. /**
  79578. * Returns the distance (float) between the vectors "value1" and "value2".
  79579. * @param value1 value to calulate the distance between
  79580. * @param value2 value to calulate the distance between
  79581. * @return the distance between the two vectors
  79582. */
  79583. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79584. /**
  79585. * Returns the squared distance (float) between the vectors "value1" and "value2".
  79586. * @param value1 value to calulate the distance between
  79587. * @param value2 value to calulate the distance between
  79588. * @return the distance between the two vectors squared
  79589. */
  79590. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79591. /**
  79592. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  79593. * @param value1 value to calulate the center between
  79594. * @param value2 value to calulate the center between
  79595. * @return the center between the two vectors
  79596. */
  79597. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  79598. /**
  79599. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  79600. * This methods computes transformed normalized direction vectors only.
  79601. * @param vector the vector to transform
  79602. * @param transformation the transformation matrix to apply
  79603. * @returns the new vector
  79604. */
  79605. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  79606. /**
  79607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  79608. * This methods computes transformed normalized direction vectors only.
  79609. * @param vector the vector to transform
  79610. * @param transformation the transformation matrix to apply
  79611. * @param result the vector to store the result in
  79612. */
  79613. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79614. /**
  79615. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  79616. * This methods computes transformed normalized direction vectors only.
  79617. * @param x value to transform
  79618. * @param y value to transform
  79619. * @param z value to transform
  79620. * @param w value to transform
  79621. * @param transformation the transformation matrix to apply
  79622. * @param result the vector to store the results in
  79623. */
  79624. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79625. /**
  79626. * Creates a new Vector4 from a Vector3
  79627. * @param source defines the source data
  79628. * @param w defines the 4th component (default is 0)
  79629. * @returns a new Vector4
  79630. */
  79631. static FromVector3(source: Vector3, w?: number): Vector4;
  79632. }
  79633. /**
  79634. * Class used to store quaternion data
  79635. * @see https://en.wikipedia.org/wiki/Quaternion
  79636. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  79637. */
  79638. export class Quaternion {
  79639. /** defines the first component (0 by default) */
  79640. x: number;
  79641. /** defines the second component (0 by default) */
  79642. y: number;
  79643. /** defines the third component (0 by default) */
  79644. z: number;
  79645. /** defines the fourth component (1.0 by default) */
  79646. w: number;
  79647. /**
  79648. * Creates a new Quaternion from the given floats
  79649. * @param x defines the first component (0 by default)
  79650. * @param y defines the second component (0 by default)
  79651. * @param z defines the third component (0 by default)
  79652. * @param w defines the fourth component (1.0 by default)
  79653. */
  79654. constructor(
  79655. /** defines the first component (0 by default) */
  79656. x?: number,
  79657. /** defines the second component (0 by default) */
  79658. y?: number,
  79659. /** defines the third component (0 by default) */
  79660. z?: number,
  79661. /** defines the fourth component (1.0 by default) */
  79662. w?: number);
  79663. /**
  79664. * Gets a string representation for the current quaternion
  79665. * @returns a string with the Quaternion coordinates
  79666. */
  79667. toString(): string;
  79668. /**
  79669. * Gets the class name of the quaternion
  79670. * @returns the string "Quaternion"
  79671. */
  79672. getClassName(): string;
  79673. /**
  79674. * Gets a hash code for this quaternion
  79675. * @returns the quaternion hash code
  79676. */
  79677. getHashCode(): number;
  79678. /**
  79679. * Copy the quaternion to an array
  79680. * @returns a new array populated with 4 elements from the quaternion coordinates
  79681. */
  79682. asArray(): number[];
  79683. /**
  79684. * Check if two quaternions are equals
  79685. * @param otherQuaternion defines the second operand
  79686. * @return true if the current quaternion and the given one coordinates are strictly equals
  79687. */
  79688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  79689. /**
  79690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  79691. * @param otherQuaternion defines the other quaternion
  79692. * @param epsilon defines the minimal distance to consider equality
  79693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  79694. */
  79695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  79696. /**
  79697. * Clone the current quaternion
  79698. * @returns a new quaternion copied from the current one
  79699. */
  79700. clone(): Quaternion;
  79701. /**
  79702. * Copy a quaternion to the current one
  79703. * @param other defines the other quaternion
  79704. * @returns the updated current quaternion
  79705. */
  79706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  79707. /**
  79708. * Updates the current quaternion with the given float coordinates
  79709. * @param x defines the x coordinate
  79710. * @param y defines the y coordinate
  79711. * @param z defines the z coordinate
  79712. * @param w defines the w coordinate
  79713. * @returns the updated current quaternion
  79714. */
  79715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  79716. /**
  79717. * Updates the current quaternion from the given float coordinates
  79718. * @param x defines the x coordinate
  79719. * @param y defines the y coordinate
  79720. * @param z defines the z coordinate
  79721. * @param w defines the w coordinate
  79722. * @returns the updated current quaternion
  79723. */
  79724. set(x: number, y: number, z: number, w: number): Quaternion;
  79725. /**
  79726. * Adds two quaternions
  79727. * @param other defines the second operand
  79728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  79729. */
  79730. add(other: DeepImmutable<Quaternion>): Quaternion;
  79731. /**
  79732. * Add a quaternion to the current one
  79733. * @param other defines the quaternion to add
  79734. * @returns the current quaternion
  79735. */
  79736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  79737. /**
  79738. * Subtract two quaternions
  79739. * @param other defines the second operand
  79740. * @returns a new quaternion as the subtraction result of the given one from the current one
  79741. */
  79742. subtract(other: Quaternion): Quaternion;
  79743. /**
  79744. * Multiplies the current quaternion by a scale factor
  79745. * @param value defines the scale factor
  79746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  79747. */
  79748. scale(value: number): Quaternion;
  79749. /**
  79750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  79751. * @param scale defines the scale factor
  79752. * @param result defines the Quaternion object where to store the result
  79753. * @returns the unmodified current quaternion
  79754. */
  79755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  79756. /**
  79757. * Multiplies in place the current quaternion by a scale factor
  79758. * @param value defines the scale factor
  79759. * @returns the current modified quaternion
  79760. */
  79761. scaleInPlace(value: number): Quaternion;
  79762. /**
  79763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  79764. * @param scale defines the scale factor
  79765. * @param result defines the Quaternion object where to store the result
  79766. * @returns the unmodified current quaternion
  79767. */
  79768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  79769. /**
  79770. * Multiplies two quaternions
  79771. * @param q1 defines the second operand
  79772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  79773. */
  79774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  79775. /**
  79776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  79777. * @param q1 defines the second operand
  79778. * @param result defines the target quaternion
  79779. * @returns the current quaternion
  79780. */
  79781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  79782. /**
  79783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  79784. * @param q1 defines the second operand
  79785. * @returns the currentupdated quaternion
  79786. */
  79787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  79788. /**
  79789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  79790. * @param ref defines the target quaternion
  79791. * @returns the current quaternion
  79792. */
  79793. conjugateToRef(ref: Quaternion): Quaternion;
  79794. /**
  79795. * Conjugates in place (1-q) the current quaternion
  79796. * @returns the current updated quaternion
  79797. */
  79798. conjugateInPlace(): Quaternion;
  79799. /**
  79800. * Conjugates in place (1-q) the current quaternion
  79801. * @returns a new quaternion
  79802. */
  79803. conjugate(): Quaternion;
  79804. /**
  79805. * Gets length of current quaternion
  79806. * @returns the quaternion length (float)
  79807. */
  79808. length(): number;
  79809. /**
  79810. * Normalize in place the current quaternion
  79811. * @returns the current updated quaternion
  79812. */
  79813. normalize(): Quaternion;
  79814. /**
  79815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  79816. * @param order is a reserved parameter and is ignore for now
  79817. * @returns a new Vector3 containing the Euler angles
  79818. */
  79819. toEulerAngles(order?: string): Vector3;
  79820. /**
  79821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  79822. * @param result defines the vector which will be filled with the Euler angles
  79823. * @param order is a reserved parameter and is ignore for now
  79824. * @returns the current unchanged quaternion
  79825. */
  79826. toEulerAnglesToRef(result: Vector3): Quaternion;
  79827. /**
  79828. * Updates the given rotation matrix with the current quaternion values
  79829. * @param result defines the target matrix
  79830. * @returns the current unchanged quaternion
  79831. */
  79832. toRotationMatrix(result: Matrix): Quaternion;
  79833. /**
  79834. * Updates the current quaternion from the given rotation matrix values
  79835. * @param matrix defines the source matrix
  79836. * @returns the current updated quaternion
  79837. */
  79838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79839. /**
  79840. * Creates a new quaternion from a rotation matrix
  79841. * @param matrix defines the source matrix
  79842. * @returns a new quaternion created from the given rotation matrix values
  79843. */
  79844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79845. /**
  79846. * Updates the given quaternion with the given rotation matrix values
  79847. * @param matrix defines the source matrix
  79848. * @param result defines the target quaternion
  79849. */
  79850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  79851. /**
  79852. * Returns the dot product (float) between the quaternions "left" and "right"
  79853. * @param left defines the left operand
  79854. * @param right defines the right operand
  79855. * @returns the dot product
  79856. */
  79857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  79858. /**
  79859. * Checks if the two quaternions are close to each other
  79860. * @param quat0 defines the first quaternion to check
  79861. * @param quat1 defines the second quaternion to check
  79862. * @returns true if the two quaternions are close to each other
  79863. */
  79864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  79865. /**
  79866. * Creates an empty quaternion
  79867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  79868. */
  79869. static Zero(): Quaternion;
  79870. /**
  79871. * Inverse a given quaternion
  79872. * @param q defines the source quaternion
  79873. * @returns a new quaternion as the inverted current quaternion
  79874. */
  79875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  79876. /**
  79877. * Inverse a given quaternion
  79878. * @param q defines the source quaternion
  79879. * @param result the quaternion the result will be stored in
  79880. * @returns the result quaternion
  79881. */
  79882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  79883. /**
  79884. * Creates an identity quaternion
  79885. * @returns the identity quaternion
  79886. */
  79887. static Identity(): Quaternion;
  79888. /**
  79889. * Gets a boolean indicating if the given quaternion is identity
  79890. * @param quaternion defines the quaternion to check
  79891. * @returns true if the quaternion is identity
  79892. */
  79893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  79894. /**
  79895. * Creates a quaternion from a rotation around an axis
  79896. * @param axis defines the axis to use
  79897. * @param angle defines the angle to use
  79898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  79899. */
  79900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  79901. /**
  79902. * Creates a rotation around an axis and stores it into the given quaternion
  79903. * @param axis defines the axis to use
  79904. * @param angle defines the angle to use
  79905. * @param result defines the target quaternion
  79906. * @returns the target quaternion
  79907. */
  79908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  79909. /**
  79910. * Creates a new quaternion from data stored into an array
  79911. * @param array defines the data source
  79912. * @param offset defines the offset in the source array where the data starts
  79913. * @returns a new quaternion
  79914. */
  79915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  79916. /**
  79917. * Updates the given quaternion "result" from the starting index of the given array.
  79918. * @param array the array to pull values from
  79919. * @param offset the offset into the array to start at
  79920. * @param result the quaternion to store the result in
  79921. */
  79922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  79923. /**
  79924. * Create a quaternion from Euler rotation angles
  79925. * @param x Pitch
  79926. * @param y Yaw
  79927. * @param z Roll
  79928. * @returns the new Quaternion
  79929. */
  79930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  79931. /**
  79932. * Updates a quaternion from Euler rotation angles
  79933. * @param x Pitch
  79934. * @param y Yaw
  79935. * @param z Roll
  79936. * @param result the quaternion to store the result
  79937. * @returns the updated quaternion
  79938. */
  79939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  79940. /**
  79941. * Create a quaternion from Euler rotation vector
  79942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79943. * @returns the new Quaternion
  79944. */
  79945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  79946. /**
  79947. * Updates a quaternion from Euler rotation vector
  79948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79949. * @param result the quaternion to store the result
  79950. * @returns the updated quaternion
  79951. */
  79952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  79953. /**
  79954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  79955. * @param yaw defines the rotation around Y axis
  79956. * @param pitch defines the rotation around X axis
  79957. * @param roll defines the rotation around Z axis
  79958. * @returns the new quaternion
  79959. */
  79960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  79961. /**
  79962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  79963. * @param yaw defines the rotation around Y axis
  79964. * @param pitch defines the rotation around X axis
  79965. * @param roll defines the rotation around Z axis
  79966. * @param result defines the target quaternion
  79967. */
  79968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  79969. /**
  79970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  79971. * @param alpha defines the rotation around first axis
  79972. * @param beta defines the rotation around second axis
  79973. * @param gamma defines the rotation around third axis
  79974. * @returns the new quaternion
  79975. */
  79976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  79977. /**
  79978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  79979. * @param alpha defines the rotation around first axis
  79980. * @param beta defines the rotation around second axis
  79981. * @param gamma defines the rotation around third axis
  79982. * @param result defines the target quaternion
  79983. */
  79984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  79985. /**
  79986. * 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)
  79987. * @param axis1 defines the first axis
  79988. * @param axis2 defines the second axis
  79989. * @param axis3 defines the third axis
  79990. * @returns the new quaternion
  79991. */
  79992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  79993. /**
  79994. * 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
  79995. * @param axis1 defines the first axis
  79996. * @param axis2 defines the second axis
  79997. * @param axis3 defines the third axis
  79998. * @param ref defines the target quaternion
  79999. */
  80000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  80001. /**
  80002. * Interpolates between two quaternions
  80003. * @param left defines first quaternion
  80004. * @param right defines second quaternion
  80005. * @param amount defines the gradient to use
  80006. * @returns the new interpolated quaternion
  80007. */
  80008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  80009. /**
  80010. * Interpolates between two quaternions and stores it into a target quaternion
  80011. * @param left defines first quaternion
  80012. * @param right defines second quaternion
  80013. * @param amount defines the gradient to use
  80014. * @param result defines the target quaternion
  80015. */
  80016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  80017. /**
  80018. * Interpolate between two quaternions using Hermite interpolation
  80019. * @param value1 defines first quaternion
  80020. * @param tangent1 defines the incoming tangent
  80021. * @param value2 defines second quaternion
  80022. * @param tangent2 defines the outgoing tangent
  80023. * @param amount defines the target quaternion
  80024. * @returns the new interpolated quaternion
  80025. */
  80026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  80027. }
  80028. /**
  80029. * Class used to store matrix data (4x4)
  80030. */
  80031. export class Matrix {
  80032. private static _updateFlagSeed;
  80033. private static _identityReadOnly;
  80034. private _isIdentity;
  80035. private _isIdentityDirty;
  80036. private _isIdentity3x2;
  80037. private _isIdentity3x2Dirty;
  80038. /**
  80039. * Gets the update flag of the matrix which is an unique number for the matrix.
  80040. * It will be incremented every time the matrix data change.
  80041. * You can use it to speed the comparison between two versions of the same matrix.
  80042. */
  80043. updateFlag: number;
  80044. private readonly _m;
  80045. /**
  80046. * Gets the internal data of the matrix
  80047. */
  80048. get m(): DeepImmutable<Float32Array>;
  80049. /** @hidden */
  80050. _markAsUpdated(): void;
  80051. /** @hidden */
  80052. private _updateIdentityStatus;
  80053. /**
  80054. * Creates an empty matrix (filled with zeros)
  80055. */
  80056. constructor();
  80057. /**
  80058. * Check if the current matrix is identity
  80059. * @returns true is the matrix is the identity matrix
  80060. */
  80061. isIdentity(): boolean;
  80062. /**
  80063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  80064. * @returns true is the matrix is the identity matrix
  80065. */
  80066. isIdentityAs3x2(): boolean;
  80067. /**
  80068. * Gets the determinant of the matrix
  80069. * @returns the matrix determinant
  80070. */
  80071. determinant(): number;
  80072. /**
  80073. * Returns the matrix as a Float32Array
  80074. * @returns the matrix underlying array
  80075. */
  80076. toArray(): DeepImmutable<Float32Array>;
  80077. /**
  80078. * Returns the matrix as a Float32Array
  80079. * @returns the matrix underlying array.
  80080. */
  80081. asArray(): DeepImmutable<Float32Array>;
  80082. /**
  80083. * Inverts the current matrix in place
  80084. * @returns the current inverted matrix
  80085. */
  80086. invert(): Matrix;
  80087. /**
  80088. * Sets all the matrix elements to zero
  80089. * @returns the current matrix
  80090. */
  80091. reset(): Matrix;
  80092. /**
  80093. * Adds the current matrix with a second one
  80094. * @param other defines the matrix to add
  80095. * @returns a new matrix as the addition of the current matrix and the given one
  80096. */
  80097. add(other: DeepImmutable<Matrix>): Matrix;
  80098. /**
  80099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  80100. * @param other defines the matrix to add
  80101. * @param result defines the target matrix
  80102. * @returns the current matrix
  80103. */
  80104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80105. /**
  80106. * Adds in place the given matrix to the current matrix
  80107. * @param other defines the second operand
  80108. * @returns the current updated matrix
  80109. */
  80110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  80111. /**
  80112. * Sets the given matrix to the current inverted Matrix
  80113. * @param other defines the target matrix
  80114. * @returns the unmodified current matrix
  80115. */
  80116. invertToRef(other: Matrix): Matrix;
  80117. /**
  80118. * add a value at the specified position in the current Matrix
  80119. * @param index the index of the value within the matrix. between 0 and 15.
  80120. * @param value the value to be added
  80121. * @returns the current updated matrix
  80122. */
  80123. addAtIndex(index: number, value: number): Matrix;
  80124. /**
  80125. * mutiply the specified position in the current Matrix by a value
  80126. * @param index the index of the value within the matrix. between 0 and 15.
  80127. * @param value the value to be added
  80128. * @returns the current updated matrix
  80129. */
  80130. multiplyAtIndex(index: number, value: number): Matrix;
  80131. /**
  80132. * Inserts the translation vector (using 3 floats) in the current matrix
  80133. * @param x defines the 1st component of the translation
  80134. * @param y defines the 2nd component of the translation
  80135. * @param z defines the 3rd component of the translation
  80136. * @returns the current updated matrix
  80137. */
  80138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80139. /**
  80140. * Adds the translation vector (using 3 floats) in the current matrix
  80141. * @param x defines the 1st component of the translation
  80142. * @param y defines the 2nd component of the translation
  80143. * @param z defines the 3rd component of the translation
  80144. * @returns the current updated matrix
  80145. */
  80146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80147. /**
  80148. * Inserts the translation vector in the current matrix
  80149. * @param vector3 defines the translation to insert
  80150. * @returns the current updated matrix
  80151. */
  80152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  80153. /**
  80154. * Gets the translation value of the current matrix
  80155. * @returns a new Vector3 as the extracted translation from the matrix
  80156. */
  80157. getTranslation(): Vector3;
  80158. /**
  80159. * Fill a Vector3 with the extracted translation from the matrix
  80160. * @param result defines the Vector3 where to store the translation
  80161. * @returns the current matrix
  80162. */
  80163. getTranslationToRef(result: Vector3): Matrix;
  80164. /**
  80165. * Remove rotation and scaling part from the matrix
  80166. * @returns the updated matrix
  80167. */
  80168. removeRotationAndScaling(): Matrix;
  80169. /**
  80170. * Multiply two matrices
  80171. * @param other defines the second operand
  80172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  80173. */
  80174. multiply(other: DeepImmutable<Matrix>): Matrix;
  80175. /**
  80176. * Copy the current matrix from the given one
  80177. * @param other defines the source matrix
  80178. * @returns the current updated matrix
  80179. */
  80180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  80181. /**
  80182. * Populates the given array from the starting index with the current matrix values
  80183. * @param array defines the target array
  80184. * @param offset defines the offset in the target array where to start storing values
  80185. * @returns the current matrix
  80186. */
  80187. copyToArray(array: Float32Array, offset?: number): Matrix;
  80188. /**
  80189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  80190. * @param other defines the second operand
  80191. * @param result defines the matrix where to store the multiplication
  80192. * @returns the current matrix
  80193. */
  80194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80195. /**
  80196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  80197. * @param other defines the second operand
  80198. * @param result defines the array where to store the multiplication
  80199. * @param offset defines the offset in the target array where to start storing values
  80200. * @returns the current matrix
  80201. */
  80202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  80203. /**
  80204. * Check equality between this matrix and a second one
  80205. * @param value defines the second matrix to compare
  80206. * @returns true is the current matrix and the given one values are strictly equal
  80207. */
  80208. equals(value: DeepImmutable<Matrix>): boolean;
  80209. /**
  80210. * Clone the current matrix
  80211. * @returns a new matrix from the current matrix
  80212. */
  80213. clone(): Matrix;
  80214. /**
  80215. * Returns the name of the current matrix class
  80216. * @returns the string "Matrix"
  80217. */
  80218. getClassName(): string;
  80219. /**
  80220. * Gets the hash code of the current matrix
  80221. * @returns the hash code
  80222. */
  80223. getHashCode(): number;
  80224. /**
  80225. * Decomposes the current Matrix into a translation, rotation and scaling components
  80226. * @param scale defines the scale vector3 given as a reference to update
  80227. * @param rotation defines the rotation quaternion given as a reference to update
  80228. * @param translation defines the translation vector3 given as a reference to update
  80229. * @returns true if operation was successful
  80230. */
  80231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  80232. /**
  80233. * Gets specific row of the matrix
  80234. * @param index defines the number of the row to get
  80235. * @returns the index-th row of the current matrix as a new Vector4
  80236. */
  80237. getRow(index: number): Nullable<Vector4>;
  80238. /**
  80239. * Sets the index-th row of the current matrix to the vector4 values
  80240. * @param index defines the number of the row to set
  80241. * @param row defines the target vector4
  80242. * @returns the updated current matrix
  80243. */
  80244. setRow(index: number, row: Vector4): Matrix;
  80245. /**
  80246. * Compute the transpose of the matrix
  80247. * @returns the new transposed matrix
  80248. */
  80249. transpose(): Matrix;
  80250. /**
  80251. * Compute the transpose of the matrix and store it in a given matrix
  80252. * @param result defines the target matrix
  80253. * @returns the current matrix
  80254. */
  80255. transposeToRef(result: Matrix): Matrix;
  80256. /**
  80257. * Sets the index-th row of the current matrix with the given 4 x float values
  80258. * @param index defines the row index
  80259. * @param x defines the x component to set
  80260. * @param y defines the y component to set
  80261. * @param z defines the z component to set
  80262. * @param w defines the w component to set
  80263. * @returns the updated current matrix
  80264. */
  80265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  80266. /**
  80267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  80268. * @param scale defines the scale factor
  80269. * @returns a new matrix
  80270. */
  80271. scale(scale: number): Matrix;
  80272. /**
  80273. * Scale the current matrix values by a factor to a given result matrix
  80274. * @param scale defines the scale factor
  80275. * @param result defines the matrix to store the result
  80276. * @returns the current matrix
  80277. */
  80278. scaleToRef(scale: number, result: Matrix): Matrix;
  80279. /**
  80280. * Scale the current matrix values by a factor and add the result to a given matrix
  80281. * @param scale defines the scale factor
  80282. * @param result defines the Matrix to store the result
  80283. * @returns the current matrix
  80284. */
  80285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  80286. /**
  80287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  80288. * @param ref matrix to store the result
  80289. */
  80290. toNormalMatrix(ref: Matrix): void;
  80291. /**
  80292. * Gets only rotation part of the current matrix
  80293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  80294. */
  80295. getRotationMatrix(): Matrix;
  80296. /**
  80297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  80298. * @param result defines the target matrix to store data to
  80299. * @returns the current matrix
  80300. */
  80301. getRotationMatrixToRef(result: Matrix): Matrix;
  80302. /**
  80303. * Toggles model matrix from being right handed to left handed in place and vice versa
  80304. */
  80305. toggleModelMatrixHandInPlace(): void;
  80306. /**
  80307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  80308. */
  80309. toggleProjectionMatrixHandInPlace(): void;
  80310. /**
  80311. * Creates a matrix from an array
  80312. * @param array defines the source array
  80313. * @param offset defines an offset in the source array
  80314. * @returns a new Matrix set from the starting index of the given array
  80315. */
  80316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  80317. /**
  80318. * Copy the content of an array into a given matrix
  80319. * @param array defines the source array
  80320. * @param offset defines an offset in the source array
  80321. * @param result defines the target matrix
  80322. */
  80323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  80324. /**
  80325. * Stores an array into a matrix after having multiplied each component by a given factor
  80326. * @param array defines the source array
  80327. * @param offset defines the offset in the source array
  80328. * @param scale defines the scaling factor
  80329. * @param result defines the target matrix
  80330. */
  80331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  80332. /**
  80333. * Gets an identity matrix that must not be updated
  80334. */
  80335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  80336. /**
  80337. * Stores a list of values (16) inside a given matrix
  80338. * @param initialM11 defines 1st value of 1st row
  80339. * @param initialM12 defines 2nd value of 1st row
  80340. * @param initialM13 defines 3rd value of 1st row
  80341. * @param initialM14 defines 4th value of 1st row
  80342. * @param initialM21 defines 1st value of 2nd row
  80343. * @param initialM22 defines 2nd value of 2nd row
  80344. * @param initialM23 defines 3rd value of 2nd row
  80345. * @param initialM24 defines 4th value of 2nd row
  80346. * @param initialM31 defines 1st value of 3rd row
  80347. * @param initialM32 defines 2nd value of 3rd row
  80348. * @param initialM33 defines 3rd value of 3rd row
  80349. * @param initialM34 defines 4th value of 3rd row
  80350. * @param initialM41 defines 1st value of 4th row
  80351. * @param initialM42 defines 2nd value of 4th row
  80352. * @param initialM43 defines 3rd value of 4th row
  80353. * @param initialM44 defines 4th value of 4th row
  80354. * @param result defines the target matrix
  80355. */
  80356. 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;
  80357. /**
  80358. * Creates new matrix from a list of values (16)
  80359. * @param initialM11 defines 1st value of 1st row
  80360. * @param initialM12 defines 2nd value of 1st row
  80361. * @param initialM13 defines 3rd value of 1st row
  80362. * @param initialM14 defines 4th value of 1st row
  80363. * @param initialM21 defines 1st value of 2nd row
  80364. * @param initialM22 defines 2nd value of 2nd row
  80365. * @param initialM23 defines 3rd value of 2nd row
  80366. * @param initialM24 defines 4th value of 2nd row
  80367. * @param initialM31 defines 1st value of 3rd row
  80368. * @param initialM32 defines 2nd value of 3rd row
  80369. * @param initialM33 defines 3rd value of 3rd row
  80370. * @param initialM34 defines 4th value of 3rd row
  80371. * @param initialM41 defines 1st value of 4th row
  80372. * @param initialM42 defines 2nd value of 4th row
  80373. * @param initialM43 defines 3rd value of 4th row
  80374. * @param initialM44 defines 4th value of 4th row
  80375. * @returns the new matrix
  80376. */
  80377. 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;
  80378. /**
  80379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80380. * @param scale defines the scale vector3
  80381. * @param rotation defines the rotation quaternion
  80382. * @param translation defines the translation vector3
  80383. * @returns a new matrix
  80384. */
  80385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  80386. /**
  80387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80388. * @param scale defines the scale vector3
  80389. * @param rotation defines the rotation quaternion
  80390. * @param translation defines the translation vector3
  80391. * @param result defines the target matrix
  80392. */
  80393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  80394. /**
  80395. * Creates a new identity matrix
  80396. * @returns a new identity matrix
  80397. */
  80398. static Identity(): Matrix;
  80399. /**
  80400. * Creates a new identity matrix and stores the result in a given matrix
  80401. * @param result defines the target matrix
  80402. */
  80403. static IdentityToRef(result: Matrix): void;
  80404. /**
  80405. * Creates a new zero matrix
  80406. * @returns a new zero matrix
  80407. */
  80408. static Zero(): Matrix;
  80409. /**
  80410. * Creates a new rotation matrix for "angle" radians around the X axis
  80411. * @param angle defines the angle (in radians) to use
  80412. * @return the new matrix
  80413. */
  80414. static RotationX(angle: number): Matrix;
  80415. /**
  80416. * Creates a new matrix as the invert of a given matrix
  80417. * @param source defines the source matrix
  80418. * @returns the new matrix
  80419. */
  80420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  80421. /**
  80422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  80423. * @param angle defines the angle (in radians) to use
  80424. * @param result defines the target matrix
  80425. */
  80426. static RotationXToRef(angle: number, result: Matrix): void;
  80427. /**
  80428. * Creates a new rotation matrix for "angle" radians around the Y axis
  80429. * @param angle defines the angle (in radians) to use
  80430. * @return the new matrix
  80431. */
  80432. static RotationY(angle: number): Matrix;
  80433. /**
  80434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  80435. * @param angle defines the angle (in radians) to use
  80436. * @param result defines the target matrix
  80437. */
  80438. static RotationYToRef(angle: number, result: Matrix): void;
  80439. /**
  80440. * Creates a new rotation matrix for "angle" radians around the Z axis
  80441. * @param angle defines the angle (in radians) to use
  80442. * @return the new matrix
  80443. */
  80444. static RotationZ(angle: number): Matrix;
  80445. /**
  80446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  80447. * @param angle defines the angle (in radians) to use
  80448. * @param result defines the target matrix
  80449. */
  80450. static RotationZToRef(angle: number, result: Matrix): void;
  80451. /**
  80452. * Creates a new rotation matrix for "angle" radians around the given axis
  80453. * @param axis defines the axis to use
  80454. * @param angle defines the angle (in radians) to use
  80455. * @return the new matrix
  80456. */
  80457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  80458. /**
  80459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  80460. * @param axis defines the axis to use
  80461. * @param angle defines the angle (in radians) to use
  80462. * @param result defines the target matrix
  80463. */
  80464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  80465. /**
  80466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  80467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  80468. * @param from defines the vector to align
  80469. * @param to defines the vector to align to
  80470. * @param result defines the target matrix
  80471. */
  80472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  80473. /**
  80474. * Creates a rotation matrix
  80475. * @param yaw defines the yaw angle in radians (Y axis)
  80476. * @param pitch defines the pitch angle in radians (X axis)
  80477. * @param roll defines the roll angle in radians (X axis)
  80478. * @returns the new rotation matrix
  80479. */
  80480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  80481. /**
  80482. * Creates a rotation matrix and stores it in a given matrix
  80483. * @param yaw defines the yaw angle in radians (Y axis)
  80484. * @param pitch defines the pitch angle in radians (X axis)
  80485. * @param roll defines the roll angle in radians (X axis)
  80486. * @param result defines the target matrix
  80487. */
  80488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  80489. /**
  80490. * Creates a scaling matrix
  80491. * @param x defines the scale factor on X axis
  80492. * @param y defines the scale factor on Y axis
  80493. * @param z defines the scale factor on Z axis
  80494. * @returns the new matrix
  80495. */
  80496. static Scaling(x: number, y: number, z: number): Matrix;
  80497. /**
  80498. * Creates a scaling matrix and stores it in a given matrix
  80499. * @param x defines the scale factor on X axis
  80500. * @param y defines the scale factor on Y axis
  80501. * @param z defines the scale factor on Z axis
  80502. * @param result defines the target matrix
  80503. */
  80504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  80505. /**
  80506. * Creates a translation matrix
  80507. * @param x defines the translation on X axis
  80508. * @param y defines the translation on Y axis
  80509. * @param z defines the translationon Z axis
  80510. * @returns the new matrix
  80511. */
  80512. static Translation(x: number, y: number, z: number): Matrix;
  80513. /**
  80514. * Creates a translation matrix and stores it in a given matrix
  80515. * @param x defines the translation on X axis
  80516. * @param y defines the translation on Y axis
  80517. * @param z defines the translationon Z axis
  80518. * @param result defines the target matrix
  80519. */
  80520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  80521. /**
  80522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80523. * @param startValue defines the start value
  80524. * @param endValue defines the end value
  80525. * @param gradient defines the gradient factor
  80526. * @returns the new matrix
  80527. */
  80528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80529. /**
  80530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80531. * @param startValue defines the start value
  80532. * @param endValue defines the end value
  80533. * @param gradient defines the gradient factor
  80534. * @param result defines the Matrix object where to store data
  80535. */
  80536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80537. /**
  80538. * Builds a new matrix whose values are computed by:
  80539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80542. * @param startValue defines the first matrix
  80543. * @param endValue defines the second matrix
  80544. * @param gradient defines the gradient between the two matrices
  80545. * @returns the new matrix
  80546. */
  80547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80548. /**
  80549. * Update a matrix to values which are computed by:
  80550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80553. * @param startValue defines the first matrix
  80554. * @param endValue defines the second matrix
  80555. * @param gradient defines the gradient between the two matrices
  80556. * @param result defines the target matrix
  80557. */
  80558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80559. /**
  80560. * 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"
  80561. * This function works in left handed mode
  80562. * @param eye defines the final position of the entity
  80563. * @param target defines where the entity should look at
  80564. * @param up defines the up vector for the entity
  80565. * @returns the new matrix
  80566. */
  80567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80568. /**
  80569. * 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".
  80570. * This function works in left handed mode
  80571. * @param eye defines the final position of the entity
  80572. * @param target defines where the entity should look at
  80573. * @param up defines the up vector for the entity
  80574. * @param result defines the target matrix
  80575. */
  80576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80577. /**
  80578. * 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"
  80579. * This function works in right handed mode
  80580. * @param eye defines the final position of the entity
  80581. * @param target defines where the entity should look at
  80582. * @param up defines the up vector for the entity
  80583. * @returns the new matrix
  80584. */
  80585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80586. /**
  80587. * 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".
  80588. * This function works in right handed mode
  80589. * @param eye defines the final position of the entity
  80590. * @param target defines where the entity should look at
  80591. * @param up defines the up vector for the entity
  80592. * @param result defines the target matrix
  80593. */
  80594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80595. /**
  80596. * Create a left-handed orthographic projection matrix
  80597. * @param width defines the viewport width
  80598. * @param height defines the viewport height
  80599. * @param znear defines the near clip plane
  80600. * @param zfar defines the far clip plane
  80601. * @returns a new matrix as a left-handed orthographic projection matrix
  80602. */
  80603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80604. /**
  80605. * Store a left-handed orthographic projection to a given matrix
  80606. * @param width defines the viewport width
  80607. * @param height defines the viewport height
  80608. * @param znear defines the near clip plane
  80609. * @param zfar defines the far clip plane
  80610. * @param result defines the target matrix
  80611. */
  80612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  80613. /**
  80614. * Create a left-handed orthographic projection matrix
  80615. * @param left defines the viewport left coordinate
  80616. * @param right defines the viewport right coordinate
  80617. * @param bottom defines the viewport bottom coordinate
  80618. * @param top defines the viewport top coordinate
  80619. * @param znear defines the near clip plane
  80620. * @param zfar defines the far clip plane
  80621. * @returns a new matrix as a left-handed orthographic projection matrix
  80622. */
  80623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80624. /**
  80625. * Stores a left-handed orthographic projection into a given matrix
  80626. * @param left defines the viewport left coordinate
  80627. * @param right defines the viewport right coordinate
  80628. * @param bottom defines the viewport bottom coordinate
  80629. * @param top defines the viewport top coordinate
  80630. * @param znear defines the near clip plane
  80631. * @param zfar defines the far clip plane
  80632. * @param result defines the target matrix
  80633. */
  80634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80635. /**
  80636. * Creates a right-handed orthographic projection matrix
  80637. * @param left defines the viewport left coordinate
  80638. * @param right defines the viewport right coordinate
  80639. * @param bottom defines the viewport bottom coordinate
  80640. * @param top defines the viewport top coordinate
  80641. * @param znear defines the near clip plane
  80642. * @param zfar defines the far clip plane
  80643. * @returns a new matrix as a right-handed orthographic projection matrix
  80644. */
  80645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80646. /**
  80647. * Stores a right-handed orthographic projection into a given matrix
  80648. * @param left defines the viewport left coordinate
  80649. * @param right defines the viewport right coordinate
  80650. * @param bottom defines the viewport bottom coordinate
  80651. * @param top defines the viewport top coordinate
  80652. * @param znear defines the near clip plane
  80653. * @param zfar defines the far clip plane
  80654. * @param result defines the target matrix
  80655. */
  80656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80657. /**
  80658. * Creates a left-handed perspective projection matrix
  80659. * @param width defines the viewport width
  80660. * @param height defines the viewport height
  80661. * @param znear defines the near clip plane
  80662. * @param zfar defines the far clip plane
  80663. * @returns a new matrix as a left-handed perspective projection matrix
  80664. */
  80665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80666. /**
  80667. * Creates a left-handed perspective projection matrix
  80668. * @param fov defines the horizontal field of view
  80669. * @param aspect defines the aspect ratio
  80670. * @param znear defines the near clip plane
  80671. * @param zfar defines the far clip plane
  80672. * @returns a new matrix as a left-handed perspective projection matrix
  80673. */
  80674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80675. /**
  80676. * Stores a left-handed perspective projection into a given matrix
  80677. * @param fov defines the horizontal field of view
  80678. * @param aspect defines the aspect ratio
  80679. * @param znear defines the near clip plane
  80680. * @param zfar defines the far clip plane
  80681. * @param result defines the target matrix
  80682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80683. */
  80684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80685. /**
  80686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  80687. * @param fov defines the horizontal field of view
  80688. * @param aspect defines the aspect ratio
  80689. * @param znear defines the near clip plane
  80690. * @param zfar not used as infinity is used as far clip
  80691. * @param result defines the target matrix
  80692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80693. */
  80694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80695. /**
  80696. * Creates a right-handed perspective projection matrix
  80697. * @param fov defines the horizontal field of view
  80698. * @param aspect defines the aspect ratio
  80699. * @param znear defines the near clip plane
  80700. * @param zfar defines the far clip plane
  80701. * @returns a new matrix as a right-handed perspective projection matrix
  80702. */
  80703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80704. /**
  80705. * Stores a right-handed perspective projection into a given matrix
  80706. * @param fov defines the horizontal field of view
  80707. * @param aspect defines the aspect ratio
  80708. * @param znear defines the near clip plane
  80709. * @param zfar defines the far clip plane
  80710. * @param result defines the target matrix
  80711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80712. */
  80713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80714. /**
  80715. * Stores a right-handed perspective projection into a given matrix
  80716. * @param fov defines the horizontal field of view
  80717. * @param aspect defines the aspect ratio
  80718. * @param znear defines the near clip plane
  80719. * @param zfar not used as infinity is used as far clip
  80720. * @param result defines the target matrix
  80721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80722. */
  80723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80724. /**
  80725. * Stores a perspective projection for WebVR info a given matrix
  80726. * @param fov defines the field of view
  80727. * @param znear defines the near clip plane
  80728. * @param zfar defines the far clip plane
  80729. * @param result defines the target matrix
  80730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  80731. */
  80732. static PerspectiveFovWebVRToRef(fov: {
  80733. upDegrees: number;
  80734. downDegrees: number;
  80735. leftDegrees: number;
  80736. rightDegrees: number;
  80737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  80738. /**
  80739. * Computes a complete transformation matrix
  80740. * @param viewport defines the viewport to use
  80741. * @param world defines the world matrix
  80742. * @param view defines the view matrix
  80743. * @param projection defines the projection matrix
  80744. * @param zmin defines the near clip plane
  80745. * @param zmax defines the far clip plane
  80746. * @returns the transformation matrix
  80747. */
  80748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  80749. /**
  80750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  80751. * @param matrix defines the matrix to use
  80752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  80753. */
  80754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  80755. /**
  80756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  80757. * @param matrix defines the matrix to use
  80758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  80759. */
  80760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  80761. /**
  80762. * Compute the transpose of a given matrix
  80763. * @param matrix defines the matrix to transpose
  80764. * @returns the new matrix
  80765. */
  80766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  80767. /**
  80768. * Compute the transpose of a matrix and store it in a target matrix
  80769. * @param matrix defines the matrix to transpose
  80770. * @param result defines the target matrix
  80771. */
  80772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  80773. /**
  80774. * Computes a reflection matrix from a plane
  80775. * @param plane defines the reflection plane
  80776. * @returns a new matrix
  80777. */
  80778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  80779. /**
  80780. * Computes a reflection matrix from a plane
  80781. * @param plane defines the reflection plane
  80782. * @param result defines the target matrix
  80783. */
  80784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  80785. /**
  80786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  80787. * @param xaxis defines the value of the 1st axis
  80788. * @param yaxis defines the value of the 2nd axis
  80789. * @param zaxis defines the value of the 3rd axis
  80790. * @param result defines the target matrix
  80791. */
  80792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  80793. /**
  80794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  80795. * @param quat defines the quaternion to use
  80796. * @param result defines the target matrix
  80797. */
  80798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  80799. }
  80800. /**
  80801. * @hidden
  80802. */
  80803. export class TmpVectors {
  80804. static Vector2: Vector2[];
  80805. static Vector3: Vector3[];
  80806. static Vector4: Vector4[];
  80807. static Quaternion: Quaternion[];
  80808. static Matrix: Matrix[];
  80809. }
  80810. }
  80811. declare module BABYLON {
  80812. /**
  80813. * Defines potential orientation for back face culling
  80814. */
  80815. export enum Orientation {
  80816. /**
  80817. * Clockwise
  80818. */
  80819. CW = 0,
  80820. /** Counter clockwise */
  80821. CCW = 1
  80822. }
  80823. /** Class used to represent a Bezier curve */
  80824. export class BezierCurve {
  80825. /**
  80826. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  80827. * @param t defines the time
  80828. * @param x1 defines the left coordinate on X axis
  80829. * @param y1 defines the left coordinate on Y axis
  80830. * @param x2 defines the right coordinate on X axis
  80831. * @param y2 defines the right coordinate on Y axis
  80832. * @returns the interpolated value
  80833. */
  80834. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  80835. }
  80836. /**
  80837. * Defines angle representation
  80838. */
  80839. export class Angle {
  80840. private _radians;
  80841. /**
  80842. * Creates an Angle object of "radians" radians (float).
  80843. * @param radians the angle in radians
  80844. */
  80845. constructor(radians: number);
  80846. /**
  80847. * Get value in degrees
  80848. * @returns the Angle value in degrees (float)
  80849. */
  80850. degrees(): number;
  80851. /**
  80852. * Get value in radians
  80853. * @returns the Angle value in radians (float)
  80854. */
  80855. radians(): number;
  80856. /**
  80857. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  80858. * @param a defines first vector
  80859. * @param b defines second vector
  80860. * @returns a new Angle
  80861. */
  80862. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  80863. /**
  80864. * Gets a new Angle object from the given float in radians
  80865. * @param radians defines the angle value in radians
  80866. * @returns a new Angle
  80867. */
  80868. static FromRadians(radians: number): Angle;
  80869. /**
  80870. * Gets a new Angle object from the given float in degrees
  80871. * @param degrees defines the angle value in degrees
  80872. * @returns a new Angle
  80873. */
  80874. static FromDegrees(degrees: number): Angle;
  80875. }
  80876. /**
  80877. * This represents an arc in a 2d space.
  80878. */
  80879. export class Arc2 {
  80880. /** Defines the start point of the arc */
  80881. startPoint: Vector2;
  80882. /** Defines the mid point of the arc */
  80883. midPoint: Vector2;
  80884. /** Defines the end point of the arc */
  80885. endPoint: Vector2;
  80886. /**
  80887. * Defines the center point of the arc.
  80888. */
  80889. centerPoint: Vector2;
  80890. /**
  80891. * Defines the radius of the arc.
  80892. */
  80893. radius: number;
  80894. /**
  80895. * Defines the angle of the arc (from mid point to end point).
  80896. */
  80897. angle: Angle;
  80898. /**
  80899. * Defines the start angle of the arc (from start point to middle point).
  80900. */
  80901. startAngle: Angle;
  80902. /**
  80903. * Defines the orientation of the arc (clock wise/counter clock wise).
  80904. */
  80905. orientation: Orientation;
  80906. /**
  80907. * Creates an Arc object from the three given points : start, middle and end.
  80908. * @param startPoint Defines the start point of the arc
  80909. * @param midPoint Defines the midlle point of the arc
  80910. * @param endPoint Defines the end point of the arc
  80911. */
  80912. constructor(
  80913. /** Defines the start point of the arc */
  80914. startPoint: Vector2,
  80915. /** Defines the mid point of the arc */
  80916. midPoint: Vector2,
  80917. /** Defines the end point of the arc */
  80918. endPoint: Vector2);
  80919. }
  80920. /**
  80921. * Represents a 2D path made up of multiple 2D points
  80922. */
  80923. export class Path2 {
  80924. private _points;
  80925. private _length;
  80926. /**
  80927. * If the path start and end point are the same
  80928. */
  80929. closed: boolean;
  80930. /**
  80931. * Creates a Path2 object from the starting 2D coordinates x and y.
  80932. * @param x the starting points x value
  80933. * @param y the starting points y value
  80934. */
  80935. constructor(x: number, y: number);
  80936. /**
  80937. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  80938. * @param x the added points x value
  80939. * @param y the added points y value
  80940. * @returns the updated Path2.
  80941. */
  80942. addLineTo(x: number, y: number): Path2;
  80943. /**
  80944. * 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.
  80945. * @param midX middle point x value
  80946. * @param midY middle point y value
  80947. * @param endX end point x value
  80948. * @param endY end point y value
  80949. * @param numberOfSegments (default: 36)
  80950. * @returns the updated Path2.
  80951. */
  80952. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  80953. /**
  80954. * Closes the Path2.
  80955. * @returns the Path2.
  80956. */
  80957. close(): Path2;
  80958. /**
  80959. * Gets the sum of the distance between each sequential point in the path
  80960. * @returns the Path2 total length (float).
  80961. */
  80962. length(): number;
  80963. /**
  80964. * Gets the points which construct the path
  80965. * @returns the Path2 internal array of points.
  80966. */
  80967. getPoints(): Vector2[];
  80968. /**
  80969. * Retreives the point at the distance aways from the starting point
  80970. * @param normalizedLengthPosition the length along the path to retreive the point from
  80971. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  80972. */
  80973. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  80974. /**
  80975. * Creates a new path starting from an x and y position
  80976. * @param x starting x value
  80977. * @param y starting y value
  80978. * @returns a new Path2 starting at the coordinates (x, y).
  80979. */
  80980. static StartingAt(x: number, y: number): Path2;
  80981. }
  80982. /**
  80983. * Represents a 3D path made up of multiple 3D points
  80984. */
  80985. export class Path3D {
  80986. /**
  80987. * an array of Vector3, the curve axis of the Path3D
  80988. */
  80989. path: Vector3[];
  80990. private _curve;
  80991. private _distances;
  80992. private _tangents;
  80993. private _normals;
  80994. private _binormals;
  80995. private _raw;
  80996. private _alignTangentsWithPath;
  80997. private readonly _pointAtData;
  80998. /**
  80999. * new Path3D(path, normal, raw)
  81000. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  81001. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  81002. * @param path an array of Vector3, the curve axis of the Path3D
  81003. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  81004. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  81005. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  81006. */
  81007. constructor(
  81008. /**
  81009. * an array of Vector3, the curve axis of the Path3D
  81010. */
  81011. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  81012. /**
  81013. * Returns the Path3D array of successive Vector3 designing its curve.
  81014. * @returns the Path3D array of successive Vector3 designing its curve.
  81015. */
  81016. getCurve(): Vector3[];
  81017. /**
  81018. * Returns the Path3D array of successive Vector3 designing its curve.
  81019. * @returns the Path3D array of successive Vector3 designing its curve.
  81020. */
  81021. getPoints(): Vector3[];
  81022. /**
  81023. * @returns the computed length (float) of the path.
  81024. */
  81025. length(): number;
  81026. /**
  81027. * Returns an array populated with tangent vectors on each Path3D curve point.
  81028. * @returns an array populated with tangent vectors on each Path3D curve point.
  81029. */
  81030. getTangents(): Vector3[];
  81031. /**
  81032. * Returns an array populated with normal vectors on each Path3D curve point.
  81033. * @returns an array populated with normal vectors on each Path3D curve point.
  81034. */
  81035. getNormals(): Vector3[];
  81036. /**
  81037. * Returns an array populated with binormal vectors on each Path3D curve point.
  81038. * @returns an array populated with binormal vectors on each Path3D curve point.
  81039. */
  81040. getBinormals(): Vector3[];
  81041. /**
  81042. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  81043. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  81044. */
  81045. getDistances(): number[];
  81046. /**
  81047. * Returns an interpolated point along this path
  81048. * @param position the position of the point along this path, from 0.0 to 1.0
  81049. * @returns a new Vector3 as the point
  81050. */
  81051. getPointAt(position: number): Vector3;
  81052. /**
  81053. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  81054. * @param position the position of the point along this path, from 0.0 to 1.0
  81055. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  81056. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  81057. */
  81058. getTangentAt(position: number, interpolated?: boolean): Vector3;
  81059. /**
  81060. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  81061. * @param position the position of the point along this path, from 0.0 to 1.0
  81062. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  81063. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  81064. */
  81065. getNormalAt(position: number, interpolated?: boolean): Vector3;
  81066. /**
  81067. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  81068. * @param position the position of the point along this path, from 0.0 to 1.0
  81069. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  81070. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  81071. */
  81072. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  81073. /**
  81074. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  81075. * @param position the position of the point along this path, from 0.0 to 1.0
  81076. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  81077. */
  81078. getDistanceAt(position: number): number;
  81079. /**
  81080. * Returns the array index of the previous point of an interpolated point along this path
  81081. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81082. * @returns the array index
  81083. */
  81084. getPreviousPointIndexAt(position: number): number;
  81085. /**
  81086. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  81087. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81088. * @returns the sub position
  81089. */
  81090. getSubPositionAt(position: number): number;
  81091. /**
  81092. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  81093. * @param target the vector of which to get the closest position to
  81094. * @returns the position of the closest virtual point on this path to the target vector
  81095. */
  81096. getClosestPositionTo(target: Vector3): number;
  81097. /**
  81098. * Returns a sub path (slice) of this path
  81099. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  81100. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  81101. * @returns a sub path (slice) of this path
  81102. */
  81103. slice(start?: number, end?: number): Path3D;
  81104. /**
  81105. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  81106. * @param path path which all values are copied into the curves points
  81107. * @param firstNormal which should be projected onto the curve
  81108. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  81109. * @returns the same object updated.
  81110. */
  81111. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  81112. private _compute;
  81113. private _getFirstNonNullVector;
  81114. private _getLastNonNullVector;
  81115. private _normalVector;
  81116. /**
  81117. * Updates the point at data for an interpolated point along this curve
  81118. * @param position the position of the point along this curve, from 0.0 to 1.0
  81119. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  81120. * @returns the (updated) point at data
  81121. */
  81122. private _updatePointAtData;
  81123. /**
  81124. * Updates the point at data from the specified parameters
  81125. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  81126. * @param point the interpolated point
  81127. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  81128. */
  81129. private _setPointAtData;
  81130. /**
  81131. * Updates the point at interpolation matrix for the tangents, normals and binormals
  81132. */
  81133. private _updateInterpolationMatrix;
  81134. }
  81135. /**
  81136. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81137. * A Curve3 is designed from a series of successive Vector3.
  81138. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  81139. */
  81140. export class Curve3 {
  81141. private _points;
  81142. private _length;
  81143. /**
  81144. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  81145. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  81146. * @param v1 (Vector3) the control point
  81147. * @param v2 (Vector3) the end point of the Quadratic Bezier
  81148. * @param nbPoints (integer) the wanted number of points in the curve
  81149. * @returns the created Curve3
  81150. */
  81151. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81152. /**
  81153. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  81154. * @param v0 (Vector3) the origin point of the Cubic Bezier
  81155. * @param v1 (Vector3) the first control point
  81156. * @param v2 (Vector3) the second control point
  81157. * @param v3 (Vector3) the end point of the Cubic Bezier
  81158. * @param nbPoints (integer) the wanted number of points in the curve
  81159. * @returns the created Curve3
  81160. */
  81161. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81162. /**
  81163. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  81164. * @param p1 (Vector3) the origin point of the Hermite Spline
  81165. * @param t1 (Vector3) the tangent vector at the origin point
  81166. * @param p2 (Vector3) the end point of the Hermite Spline
  81167. * @param t2 (Vector3) the tangent vector at the end point
  81168. * @param nbPoints (integer) the wanted number of points in the curve
  81169. * @returns the created Curve3
  81170. */
  81171. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81172. /**
  81173. * Returns a Curve3 object along a CatmullRom Spline curve :
  81174. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  81175. * @param nbPoints (integer) the wanted number of points between each curve control points
  81176. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  81177. * @returns the created Curve3
  81178. */
  81179. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  81180. /**
  81181. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81182. * A Curve3 is designed from a series of successive Vector3.
  81183. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  81184. * @param points points which make up the curve
  81185. */
  81186. constructor(points: Vector3[]);
  81187. /**
  81188. * @returns the Curve3 stored array of successive Vector3
  81189. */
  81190. getPoints(): Vector3[];
  81191. /**
  81192. * @returns the computed length (float) of the curve.
  81193. */
  81194. length(): number;
  81195. /**
  81196. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  81197. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  81198. * curveA and curveB keep unchanged.
  81199. * @param curve the curve to continue from this curve
  81200. * @returns the newly constructed curve
  81201. */
  81202. continue(curve: DeepImmutable<Curve3>): Curve3;
  81203. private _computeLength;
  81204. }
  81205. }
  81206. declare module BABYLON {
  81207. /**
  81208. * This represents the main contract an easing function should follow.
  81209. * Easing functions are used throughout the animation system.
  81210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81211. */
  81212. export interface IEasingFunction {
  81213. /**
  81214. * Given an input gradient between 0 and 1, this returns the corrseponding value
  81215. * of the easing function.
  81216. * The link below provides some of the most common examples of easing functions.
  81217. * @see https://easings.net/
  81218. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81219. * @returns the corresponding value on the curve defined by the easing function
  81220. */
  81221. ease(gradient: number): number;
  81222. }
  81223. /**
  81224. * Base class used for every default easing function.
  81225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81226. */
  81227. export class EasingFunction implements IEasingFunction {
  81228. /**
  81229. * Interpolation follows the mathematical formula associated with the easing function.
  81230. */
  81231. static readonly EASINGMODE_EASEIN: number;
  81232. /**
  81233. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  81234. */
  81235. static readonly EASINGMODE_EASEOUT: number;
  81236. /**
  81237. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  81238. */
  81239. static readonly EASINGMODE_EASEINOUT: number;
  81240. private _easingMode;
  81241. /**
  81242. * Sets the easing mode of the current function.
  81243. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  81244. */
  81245. setEasingMode(easingMode: number): void;
  81246. /**
  81247. * Gets the current easing mode.
  81248. * @returns the easing mode
  81249. */
  81250. getEasingMode(): number;
  81251. /**
  81252. * @hidden
  81253. */
  81254. easeInCore(gradient: number): number;
  81255. /**
  81256. * Given an input gradient between 0 and 1, this returns the corresponding value
  81257. * of the easing function.
  81258. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81259. * @returns the corresponding value on the curve defined by the easing function
  81260. */
  81261. ease(gradient: number): number;
  81262. }
  81263. /**
  81264. * Easing function with a circle shape (see link below).
  81265. * @see https://easings.net/#easeInCirc
  81266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81267. */
  81268. export class CircleEase extends EasingFunction implements IEasingFunction {
  81269. /** @hidden */
  81270. easeInCore(gradient: number): number;
  81271. }
  81272. /**
  81273. * Easing function with a ease back shape (see link below).
  81274. * @see https://easings.net/#easeInBack
  81275. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81276. */
  81277. export class BackEase extends EasingFunction implements IEasingFunction {
  81278. /** Defines the amplitude of the function */
  81279. amplitude: number;
  81280. /**
  81281. * Instantiates a back ease easing
  81282. * @see https://easings.net/#easeInBack
  81283. * @param amplitude Defines the amplitude of the function
  81284. */
  81285. constructor(
  81286. /** Defines the amplitude of the function */
  81287. amplitude?: number);
  81288. /** @hidden */
  81289. easeInCore(gradient: number): number;
  81290. }
  81291. /**
  81292. * Easing function with a bouncing shape (see link below).
  81293. * @see https://easings.net/#easeInBounce
  81294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81295. */
  81296. export class BounceEase extends EasingFunction implements IEasingFunction {
  81297. /** Defines the number of bounces */
  81298. bounces: number;
  81299. /** Defines the amplitude of the bounce */
  81300. bounciness: number;
  81301. /**
  81302. * Instantiates a bounce easing
  81303. * @see https://easings.net/#easeInBounce
  81304. * @param bounces Defines the number of bounces
  81305. * @param bounciness Defines the amplitude of the bounce
  81306. */
  81307. constructor(
  81308. /** Defines the number of bounces */
  81309. bounces?: number,
  81310. /** Defines the amplitude of the bounce */
  81311. bounciness?: number);
  81312. /** @hidden */
  81313. easeInCore(gradient: number): number;
  81314. }
  81315. /**
  81316. * Easing function with a power of 3 shape (see link below).
  81317. * @see https://easings.net/#easeInCubic
  81318. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81319. */
  81320. export class CubicEase extends EasingFunction implements IEasingFunction {
  81321. /** @hidden */
  81322. easeInCore(gradient: number): number;
  81323. }
  81324. /**
  81325. * Easing function with an elastic shape (see link below).
  81326. * @see https://easings.net/#easeInElastic
  81327. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81328. */
  81329. export class ElasticEase extends EasingFunction implements IEasingFunction {
  81330. /** Defines the number of oscillations*/
  81331. oscillations: number;
  81332. /** Defines the amplitude of the oscillations*/
  81333. springiness: number;
  81334. /**
  81335. * Instantiates an elastic easing function
  81336. * @see https://easings.net/#easeInElastic
  81337. * @param oscillations Defines the number of oscillations
  81338. * @param springiness Defines the amplitude of the oscillations
  81339. */
  81340. constructor(
  81341. /** Defines the number of oscillations*/
  81342. oscillations?: number,
  81343. /** Defines the amplitude of the oscillations*/
  81344. springiness?: number);
  81345. /** @hidden */
  81346. easeInCore(gradient: number): number;
  81347. }
  81348. /**
  81349. * Easing function with an exponential shape (see link below).
  81350. * @see https://easings.net/#easeInExpo
  81351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81352. */
  81353. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  81354. /** Defines the exponent of the function */
  81355. exponent: number;
  81356. /**
  81357. * Instantiates an exponential easing function
  81358. * @see https://easings.net/#easeInExpo
  81359. * @param exponent Defines the exponent of the function
  81360. */
  81361. constructor(
  81362. /** Defines the exponent of the function */
  81363. exponent?: number);
  81364. /** @hidden */
  81365. easeInCore(gradient: number): number;
  81366. }
  81367. /**
  81368. * Easing function with a power shape (see link below).
  81369. * @see https://easings.net/#easeInQuad
  81370. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81371. */
  81372. export class PowerEase extends EasingFunction implements IEasingFunction {
  81373. /** Defines the power of the function */
  81374. power: number;
  81375. /**
  81376. * Instantiates an power base easing function
  81377. * @see https://easings.net/#easeInQuad
  81378. * @param power Defines the power of the function
  81379. */
  81380. constructor(
  81381. /** Defines the power of the function */
  81382. power?: number);
  81383. /** @hidden */
  81384. easeInCore(gradient: number): number;
  81385. }
  81386. /**
  81387. * Easing function with a power of 2 shape (see link below).
  81388. * @see https://easings.net/#easeInQuad
  81389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81390. */
  81391. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  81392. /** @hidden */
  81393. easeInCore(gradient: number): number;
  81394. }
  81395. /**
  81396. * Easing function with a power of 4 shape (see link below).
  81397. * @see https://easings.net/#easeInQuart
  81398. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81399. */
  81400. export class QuarticEase extends EasingFunction implements IEasingFunction {
  81401. /** @hidden */
  81402. easeInCore(gradient: number): number;
  81403. }
  81404. /**
  81405. * Easing function with a power of 5 shape (see link below).
  81406. * @see https://easings.net/#easeInQuint
  81407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81408. */
  81409. export class QuinticEase extends EasingFunction implements IEasingFunction {
  81410. /** @hidden */
  81411. easeInCore(gradient: number): number;
  81412. }
  81413. /**
  81414. * Easing function with a sin shape (see link below).
  81415. * @see https://easings.net/#easeInSine
  81416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81417. */
  81418. export class SineEase extends EasingFunction implements IEasingFunction {
  81419. /** @hidden */
  81420. easeInCore(gradient: number): number;
  81421. }
  81422. /**
  81423. * Easing function with a bezier shape (see link below).
  81424. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81425. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81426. */
  81427. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  81428. /** Defines the x component of the start tangent in the bezier curve */
  81429. x1: number;
  81430. /** Defines the y component of the start tangent in the bezier curve */
  81431. y1: number;
  81432. /** Defines the x component of the end tangent in the bezier curve */
  81433. x2: number;
  81434. /** Defines the y component of the end tangent in the bezier curve */
  81435. y2: number;
  81436. /**
  81437. * Instantiates a bezier function
  81438. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81439. * @param x1 Defines the x component of the start tangent in the bezier curve
  81440. * @param y1 Defines the y component of the start tangent in the bezier curve
  81441. * @param x2 Defines the x component of the end tangent in the bezier curve
  81442. * @param y2 Defines the y component of the end tangent in the bezier curve
  81443. */
  81444. constructor(
  81445. /** Defines the x component of the start tangent in the bezier curve */
  81446. x1?: number,
  81447. /** Defines the y component of the start tangent in the bezier curve */
  81448. y1?: number,
  81449. /** Defines the x component of the end tangent in the bezier curve */
  81450. x2?: number,
  81451. /** Defines the y component of the end tangent in the bezier curve */
  81452. y2?: number);
  81453. /** @hidden */
  81454. easeInCore(gradient: number): number;
  81455. }
  81456. }
  81457. declare module BABYLON {
  81458. /**
  81459. * Class used to hold a RBG color
  81460. */
  81461. export class Color3 {
  81462. /**
  81463. * Defines the red component (between 0 and 1, default is 0)
  81464. */
  81465. r: number;
  81466. /**
  81467. * Defines the green component (between 0 and 1, default is 0)
  81468. */
  81469. g: number;
  81470. /**
  81471. * Defines the blue component (between 0 and 1, default is 0)
  81472. */
  81473. b: number;
  81474. /**
  81475. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  81476. * @param r defines the red component (between 0 and 1, default is 0)
  81477. * @param g defines the green component (between 0 and 1, default is 0)
  81478. * @param b defines the blue component (between 0 and 1, default is 0)
  81479. */
  81480. constructor(
  81481. /**
  81482. * Defines the red component (between 0 and 1, default is 0)
  81483. */
  81484. r?: number,
  81485. /**
  81486. * Defines the green component (between 0 and 1, default is 0)
  81487. */
  81488. g?: number,
  81489. /**
  81490. * Defines the blue component (between 0 and 1, default is 0)
  81491. */
  81492. b?: number);
  81493. /**
  81494. * Creates a string with the Color3 current values
  81495. * @returns the string representation of the Color3 object
  81496. */
  81497. toString(): string;
  81498. /**
  81499. * Returns the string "Color3"
  81500. * @returns "Color3"
  81501. */
  81502. getClassName(): string;
  81503. /**
  81504. * Compute the Color3 hash code
  81505. * @returns an unique number that can be used to hash Color3 objects
  81506. */
  81507. getHashCode(): number;
  81508. /**
  81509. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  81510. * @param array defines the array where to store the r,g,b components
  81511. * @param index defines an optional index in the target array to define where to start storing values
  81512. * @returns the current Color3 object
  81513. */
  81514. toArray(array: FloatArray, index?: number): Color3;
  81515. /**
  81516. * Returns a new Color4 object from the current Color3 and the given alpha
  81517. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  81518. * @returns a new Color4 object
  81519. */
  81520. toColor4(alpha?: number): Color4;
  81521. /**
  81522. * Returns a new array populated with 3 numeric elements : red, green and blue values
  81523. * @returns the new array
  81524. */
  81525. asArray(): number[];
  81526. /**
  81527. * Returns the luminance value
  81528. * @returns a float value
  81529. */
  81530. toLuminance(): number;
  81531. /**
  81532. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  81533. * @param otherColor defines the second operand
  81534. * @returns the new Color3 object
  81535. */
  81536. multiply(otherColor: DeepImmutable<Color3>): Color3;
  81537. /**
  81538. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  81539. * @param otherColor defines the second operand
  81540. * @param result defines the Color3 object where to store the result
  81541. * @returns the current Color3
  81542. */
  81543. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81544. /**
  81545. * Determines equality between Color3 objects
  81546. * @param otherColor defines the second operand
  81547. * @returns true if the rgb values are equal to the given ones
  81548. */
  81549. equals(otherColor: DeepImmutable<Color3>): boolean;
  81550. /**
  81551. * Determines equality between the current Color3 object and a set of r,b,g values
  81552. * @param r defines the red component to check
  81553. * @param g defines the green component to check
  81554. * @param b defines the blue component to check
  81555. * @returns true if the rgb values are equal to the given ones
  81556. */
  81557. equalsFloats(r: number, g: number, b: number): boolean;
  81558. /**
  81559. * Multiplies in place each rgb value by scale
  81560. * @param scale defines the scaling factor
  81561. * @returns the updated Color3
  81562. */
  81563. scale(scale: number): Color3;
  81564. /**
  81565. * Multiplies the rgb values by scale and stores the result into "result"
  81566. * @param scale defines the scaling factor
  81567. * @param result defines the Color3 object where to store the result
  81568. * @returns the unmodified current Color3
  81569. */
  81570. scaleToRef(scale: number, result: Color3): Color3;
  81571. /**
  81572. * Scale the current Color3 values by a factor and add the result to a given Color3
  81573. * @param scale defines the scale factor
  81574. * @param result defines color to store the result into
  81575. * @returns the unmodified current Color3
  81576. */
  81577. scaleAndAddToRef(scale: number, result: Color3): Color3;
  81578. /**
  81579. * Clamps the rgb values by the min and max values and stores the result into "result"
  81580. * @param min defines minimum clamping value (default is 0)
  81581. * @param max defines maximum clamping value (default is 1)
  81582. * @param result defines color to store the result into
  81583. * @returns the original Color3
  81584. */
  81585. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  81586. /**
  81587. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  81588. * @param otherColor defines the second operand
  81589. * @returns the new Color3
  81590. */
  81591. add(otherColor: DeepImmutable<Color3>): Color3;
  81592. /**
  81593. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  81594. * @param otherColor defines the second operand
  81595. * @param result defines Color3 object to store the result into
  81596. * @returns the unmodified current Color3
  81597. */
  81598. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81599. /**
  81600. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  81601. * @param otherColor defines the second operand
  81602. * @returns the new Color3
  81603. */
  81604. subtract(otherColor: DeepImmutable<Color3>): Color3;
  81605. /**
  81606. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  81607. * @param otherColor defines the second operand
  81608. * @param result defines Color3 object to store the result into
  81609. * @returns the unmodified current Color3
  81610. */
  81611. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81612. /**
  81613. * Copy the current object
  81614. * @returns a new Color3 copied the current one
  81615. */
  81616. clone(): Color3;
  81617. /**
  81618. * Copies the rgb values from the source in the current Color3
  81619. * @param source defines the source Color3 object
  81620. * @returns the updated Color3 object
  81621. */
  81622. copyFrom(source: DeepImmutable<Color3>): Color3;
  81623. /**
  81624. * Updates the Color3 rgb values from the given floats
  81625. * @param r defines the red component to read from
  81626. * @param g defines the green component to read from
  81627. * @param b defines the blue component to read from
  81628. * @returns the current Color3 object
  81629. */
  81630. copyFromFloats(r: number, g: number, b: number): Color3;
  81631. /**
  81632. * Updates the Color3 rgb values from the given floats
  81633. * @param r defines the red component to read from
  81634. * @param g defines the green component to read from
  81635. * @param b defines the blue component to read from
  81636. * @returns the current Color3 object
  81637. */
  81638. set(r: number, g: number, b: number): Color3;
  81639. /**
  81640. * Compute the Color3 hexadecimal code as a string
  81641. * @returns a string containing the hexadecimal representation of the Color3 object
  81642. */
  81643. toHexString(): string;
  81644. /**
  81645. * Computes a new Color3 converted from the current one to linear space
  81646. * @returns a new Color3 object
  81647. */
  81648. toLinearSpace(): Color3;
  81649. /**
  81650. * Converts current color in rgb space to HSV values
  81651. * @returns a new color3 representing the HSV values
  81652. */
  81653. toHSV(): Color3;
  81654. /**
  81655. * Converts current color in rgb space to HSV values
  81656. * @param result defines the Color3 where to store the HSV values
  81657. */
  81658. toHSVToRef(result: Color3): void;
  81659. /**
  81660. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  81661. * @param convertedColor defines the Color3 object where to store the linear space version
  81662. * @returns the unmodified Color3
  81663. */
  81664. toLinearSpaceToRef(convertedColor: Color3): Color3;
  81665. /**
  81666. * Computes a new Color3 converted from the current one to gamma space
  81667. * @returns a new Color3 object
  81668. */
  81669. toGammaSpace(): Color3;
  81670. /**
  81671. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  81672. * @param convertedColor defines the Color3 object where to store the gamma space version
  81673. * @returns the unmodified Color3
  81674. */
  81675. toGammaSpaceToRef(convertedColor: Color3): Color3;
  81676. private static _BlackReadOnly;
  81677. /**
  81678. * Convert Hue, saturation and value to a Color3 (RGB)
  81679. * @param hue defines the hue
  81680. * @param saturation defines the saturation
  81681. * @param value defines the value
  81682. * @param result defines the Color3 where to store the RGB values
  81683. */
  81684. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  81685. /**
  81686. * Creates a new Color3 from the string containing valid hexadecimal values
  81687. * @param hex defines a string containing valid hexadecimal values
  81688. * @returns a new Color3 object
  81689. */
  81690. static FromHexString(hex: string): Color3;
  81691. /**
  81692. * Creates a new Color3 from the starting index of the given array
  81693. * @param array defines the source array
  81694. * @param offset defines an offset in the source array
  81695. * @returns a new Color3 object
  81696. */
  81697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  81698. /**
  81699. * Creates a new Color3 from integer values (< 256)
  81700. * @param r defines the red component to read from (value between 0 and 255)
  81701. * @param g defines the green component to read from (value between 0 and 255)
  81702. * @param b defines the blue component to read from (value between 0 and 255)
  81703. * @returns a new Color3 object
  81704. */
  81705. static FromInts(r: number, g: number, b: number): Color3;
  81706. /**
  81707. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81708. * @param start defines the start Color3 value
  81709. * @param end defines the end Color3 value
  81710. * @param amount defines the gradient value between start and end
  81711. * @returns a new Color3 object
  81712. */
  81713. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  81714. /**
  81715. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81716. * @param left defines the start value
  81717. * @param right defines the end value
  81718. * @param amount defines the gradient factor
  81719. * @param result defines the Color3 object where to store the result
  81720. */
  81721. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  81722. /**
  81723. * Returns a Color3 value containing a red color
  81724. * @returns a new Color3 object
  81725. */
  81726. static Red(): Color3;
  81727. /**
  81728. * Returns a Color3 value containing a green color
  81729. * @returns a new Color3 object
  81730. */
  81731. static Green(): Color3;
  81732. /**
  81733. * Returns a Color3 value containing a blue color
  81734. * @returns a new Color3 object
  81735. */
  81736. static Blue(): Color3;
  81737. /**
  81738. * Returns a Color3 value containing a black color
  81739. * @returns a new Color3 object
  81740. */
  81741. static Black(): Color3;
  81742. /**
  81743. * Gets a Color3 value containing a black color that must not be updated
  81744. */
  81745. static get BlackReadOnly(): DeepImmutable<Color3>;
  81746. /**
  81747. * Returns a Color3 value containing a white color
  81748. * @returns a new Color3 object
  81749. */
  81750. static White(): Color3;
  81751. /**
  81752. * Returns a Color3 value containing a purple color
  81753. * @returns a new Color3 object
  81754. */
  81755. static Purple(): Color3;
  81756. /**
  81757. * Returns a Color3 value containing a magenta color
  81758. * @returns a new Color3 object
  81759. */
  81760. static Magenta(): Color3;
  81761. /**
  81762. * Returns a Color3 value containing a yellow color
  81763. * @returns a new Color3 object
  81764. */
  81765. static Yellow(): Color3;
  81766. /**
  81767. * Returns a Color3 value containing a gray color
  81768. * @returns a new Color3 object
  81769. */
  81770. static Gray(): Color3;
  81771. /**
  81772. * Returns a Color3 value containing a teal color
  81773. * @returns a new Color3 object
  81774. */
  81775. static Teal(): Color3;
  81776. /**
  81777. * Returns a Color3 value containing a random color
  81778. * @returns a new Color3 object
  81779. */
  81780. static Random(): Color3;
  81781. }
  81782. /**
  81783. * Class used to hold a RBGA color
  81784. */
  81785. export class Color4 {
  81786. /**
  81787. * Defines the red component (between 0 and 1, default is 0)
  81788. */
  81789. r: number;
  81790. /**
  81791. * Defines the green component (between 0 and 1, default is 0)
  81792. */
  81793. g: number;
  81794. /**
  81795. * Defines the blue component (between 0 and 1, default is 0)
  81796. */
  81797. b: number;
  81798. /**
  81799. * Defines the alpha component (between 0 and 1, default is 1)
  81800. */
  81801. a: number;
  81802. /**
  81803. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  81804. * @param r defines the red component (between 0 and 1, default is 0)
  81805. * @param g defines the green component (between 0 and 1, default is 0)
  81806. * @param b defines the blue component (between 0 and 1, default is 0)
  81807. * @param a defines the alpha component (between 0 and 1, default is 1)
  81808. */
  81809. constructor(
  81810. /**
  81811. * Defines the red component (between 0 and 1, default is 0)
  81812. */
  81813. r?: number,
  81814. /**
  81815. * Defines the green component (between 0 and 1, default is 0)
  81816. */
  81817. g?: number,
  81818. /**
  81819. * Defines the blue component (between 0 and 1, default is 0)
  81820. */
  81821. b?: number,
  81822. /**
  81823. * Defines the alpha component (between 0 and 1, default is 1)
  81824. */
  81825. a?: number);
  81826. /**
  81827. * Adds in place the given Color4 values to the current Color4 object
  81828. * @param right defines the second operand
  81829. * @returns the current updated Color4 object
  81830. */
  81831. addInPlace(right: DeepImmutable<Color4>): Color4;
  81832. /**
  81833. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  81834. * @returns the new array
  81835. */
  81836. asArray(): number[];
  81837. /**
  81838. * Stores from the starting index in the given array the Color4 successive values
  81839. * @param array defines the array where to store the r,g,b components
  81840. * @param index defines an optional index in the target array to define where to start storing values
  81841. * @returns the current Color4 object
  81842. */
  81843. toArray(array: number[], index?: number): Color4;
  81844. /**
  81845. * Determines equality between Color4 objects
  81846. * @param otherColor defines the second operand
  81847. * @returns true if the rgba values are equal to the given ones
  81848. */
  81849. equals(otherColor: DeepImmutable<Color4>): boolean;
  81850. /**
  81851. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  81852. * @param right defines the second operand
  81853. * @returns a new Color4 object
  81854. */
  81855. add(right: DeepImmutable<Color4>): Color4;
  81856. /**
  81857. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  81858. * @param right defines the second operand
  81859. * @returns a new Color4 object
  81860. */
  81861. subtract(right: DeepImmutable<Color4>): Color4;
  81862. /**
  81863. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  81864. * @param right defines the second operand
  81865. * @param result defines the Color4 object where to store the result
  81866. * @returns the current Color4 object
  81867. */
  81868. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  81869. /**
  81870. * Creates a new Color4 with the current Color4 values multiplied by scale
  81871. * @param scale defines the scaling factor to apply
  81872. * @returns a new Color4 object
  81873. */
  81874. scale(scale: number): Color4;
  81875. /**
  81876. * Multiplies the current Color4 values by scale and stores the result in "result"
  81877. * @param scale defines the scaling factor to apply
  81878. * @param result defines the Color4 object where to store the result
  81879. * @returns the current unmodified Color4
  81880. */
  81881. scaleToRef(scale: number, result: Color4): Color4;
  81882. /**
  81883. * Scale the current Color4 values by a factor and add the result to a given Color4
  81884. * @param scale defines the scale factor
  81885. * @param result defines the Color4 object where to store the result
  81886. * @returns the unmodified current Color4
  81887. */
  81888. scaleAndAddToRef(scale: number, result: Color4): Color4;
  81889. /**
  81890. * Clamps the rgb values by the min and max values and stores the result into "result"
  81891. * @param min defines minimum clamping value (default is 0)
  81892. * @param max defines maximum clamping value (default is 1)
  81893. * @param result defines color to store the result into.
  81894. * @returns the cuurent Color4
  81895. */
  81896. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  81897. /**
  81898. * Multipy an Color4 value by another and return a new Color4 object
  81899. * @param color defines the Color4 value to multiply by
  81900. * @returns a new Color4 object
  81901. */
  81902. multiply(color: Color4): Color4;
  81903. /**
  81904. * Multipy a Color4 value by another and push the result in a reference value
  81905. * @param color defines the Color4 value to multiply by
  81906. * @param result defines the Color4 to fill the result in
  81907. * @returns the result Color4
  81908. */
  81909. multiplyToRef(color: Color4, result: Color4): Color4;
  81910. /**
  81911. * Creates a string with the Color4 current values
  81912. * @returns the string representation of the Color4 object
  81913. */
  81914. toString(): string;
  81915. /**
  81916. * Returns the string "Color4"
  81917. * @returns "Color4"
  81918. */
  81919. getClassName(): string;
  81920. /**
  81921. * Compute the Color4 hash code
  81922. * @returns an unique number that can be used to hash Color4 objects
  81923. */
  81924. getHashCode(): number;
  81925. /**
  81926. * Creates a new Color4 copied from the current one
  81927. * @returns a new Color4 object
  81928. */
  81929. clone(): Color4;
  81930. /**
  81931. * Copies the given Color4 values into the current one
  81932. * @param source defines the source Color4 object
  81933. * @returns the current updated Color4 object
  81934. */
  81935. copyFrom(source: Color4): Color4;
  81936. /**
  81937. * Copies the given float values into the current one
  81938. * @param r defines the red component to read from
  81939. * @param g defines the green component to read from
  81940. * @param b defines the blue component to read from
  81941. * @param a defines the alpha component to read from
  81942. * @returns the current updated Color4 object
  81943. */
  81944. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  81945. /**
  81946. * Copies the given float values into the current one
  81947. * @param r defines the red component to read from
  81948. * @param g defines the green component to read from
  81949. * @param b defines the blue component to read from
  81950. * @param a defines the alpha component to read from
  81951. * @returns the current updated Color4 object
  81952. */
  81953. set(r: number, g: number, b: number, a: number): Color4;
  81954. /**
  81955. * Compute the Color4 hexadecimal code as a string
  81956. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  81957. * @returns a string containing the hexadecimal representation of the Color4 object
  81958. */
  81959. toHexString(returnAsColor3?: boolean): string;
  81960. /**
  81961. * Computes a new Color4 converted from the current one to linear space
  81962. * @returns a new Color4 object
  81963. */
  81964. toLinearSpace(): Color4;
  81965. /**
  81966. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81967. * @param convertedColor defines the Color4 object where to store the linear space version
  81968. * @returns the unmodified Color4
  81969. */
  81970. toLinearSpaceToRef(convertedColor: Color4): Color4;
  81971. /**
  81972. * Computes a new Color4 converted from the current one to gamma space
  81973. * @returns a new Color4 object
  81974. */
  81975. toGammaSpace(): Color4;
  81976. /**
  81977. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81978. * @param convertedColor defines the Color4 object where to store the gamma space version
  81979. * @returns the unmodified Color4
  81980. */
  81981. toGammaSpaceToRef(convertedColor: Color4): Color4;
  81982. /**
  81983. * Creates a new Color4 from the string containing valid hexadecimal values
  81984. * @param hex defines a string containing valid hexadecimal values
  81985. * @returns a new Color4 object
  81986. */
  81987. static FromHexString(hex: string): Color4;
  81988. /**
  81989. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81990. * @param left defines the start value
  81991. * @param right defines the end value
  81992. * @param amount defines the gradient factor
  81993. * @returns a new Color4 object
  81994. */
  81995. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  81996. /**
  81997. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81998. * @param left defines the start value
  81999. * @param right defines the end value
  82000. * @param amount defines the gradient factor
  82001. * @param result defines the Color4 object where to store data
  82002. */
  82003. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  82004. /**
  82005. * Creates a new Color4 from a Color3 and an alpha value
  82006. * @param color3 defines the source Color3 to read from
  82007. * @param alpha defines the alpha component (1.0 by default)
  82008. * @returns a new Color4 object
  82009. */
  82010. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  82011. /**
  82012. * Creates a new Color4 from the starting index element of the given array
  82013. * @param array defines the source array to read from
  82014. * @param offset defines the offset in the source array
  82015. * @returns a new Color4 object
  82016. */
  82017. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  82018. /**
  82019. * Creates a new Color3 from integer values (< 256)
  82020. * @param r defines the red component to read from (value between 0 and 255)
  82021. * @param g defines the green component to read from (value between 0 and 255)
  82022. * @param b defines the blue component to read from (value between 0 and 255)
  82023. * @param a defines the alpha component to read from (value between 0 and 255)
  82024. * @returns a new Color3 object
  82025. */
  82026. static FromInts(r: number, g: number, b: number, a: number): Color4;
  82027. /**
  82028. * Check the content of a given array and convert it to an array containing RGBA data
  82029. * If the original array was already containing count * 4 values then it is returned directly
  82030. * @param colors defines the array to check
  82031. * @param count defines the number of RGBA data to expect
  82032. * @returns an array containing count * 4 values (RGBA)
  82033. */
  82034. static CheckColors4(colors: number[], count: number): number[];
  82035. }
  82036. /**
  82037. * @hidden
  82038. */
  82039. export class TmpColors {
  82040. static Color3: Color3[];
  82041. static Color4: Color4[];
  82042. }
  82043. }
  82044. declare module BABYLON {
  82045. /**
  82046. * Defines an interface which represents an animation key frame
  82047. */
  82048. export interface IAnimationKey {
  82049. /**
  82050. * Frame of the key frame
  82051. */
  82052. frame: number;
  82053. /**
  82054. * Value at the specifies key frame
  82055. */
  82056. value: any;
  82057. /**
  82058. * The input tangent for the cubic hermite spline
  82059. */
  82060. inTangent?: any;
  82061. /**
  82062. * The output tangent for the cubic hermite spline
  82063. */
  82064. outTangent?: any;
  82065. /**
  82066. * The animation interpolation type
  82067. */
  82068. interpolation?: AnimationKeyInterpolation;
  82069. }
  82070. /**
  82071. * Enum for the animation key frame interpolation type
  82072. */
  82073. export enum AnimationKeyInterpolation {
  82074. /**
  82075. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  82076. */
  82077. STEP = 1
  82078. }
  82079. }
  82080. declare module BABYLON {
  82081. /**
  82082. * Represents the range of an animation
  82083. */
  82084. export class AnimationRange {
  82085. /**The name of the animation range**/
  82086. name: string;
  82087. /**The starting frame of the animation */
  82088. from: number;
  82089. /**The ending frame of the animation*/
  82090. to: number;
  82091. /**
  82092. * Initializes the range of an animation
  82093. * @param name The name of the animation range
  82094. * @param from The starting frame of the animation
  82095. * @param to The ending frame of the animation
  82096. */
  82097. constructor(
  82098. /**The name of the animation range**/
  82099. name: string,
  82100. /**The starting frame of the animation */
  82101. from: number,
  82102. /**The ending frame of the animation*/
  82103. to: number);
  82104. /**
  82105. * Makes a copy of the animation range
  82106. * @returns A copy of the animation range
  82107. */
  82108. clone(): AnimationRange;
  82109. }
  82110. }
  82111. declare module BABYLON {
  82112. /**
  82113. * Composed of a frame, and an action function
  82114. */
  82115. export class AnimationEvent {
  82116. /** The frame for which the event is triggered **/
  82117. frame: number;
  82118. /** The event to perform when triggered **/
  82119. action: (currentFrame: number) => void;
  82120. /** Specifies if the event should be triggered only once**/
  82121. onlyOnce?: boolean | undefined;
  82122. /**
  82123. * Specifies if the animation event is done
  82124. */
  82125. isDone: boolean;
  82126. /**
  82127. * Initializes the animation event
  82128. * @param frame The frame for which the event is triggered
  82129. * @param action The event to perform when triggered
  82130. * @param onlyOnce Specifies if the event should be triggered only once
  82131. */
  82132. constructor(
  82133. /** The frame for which the event is triggered **/
  82134. frame: number,
  82135. /** The event to perform when triggered **/
  82136. action: (currentFrame: number) => void,
  82137. /** Specifies if the event should be triggered only once**/
  82138. onlyOnce?: boolean | undefined);
  82139. /** @hidden */
  82140. _clone(): AnimationEvent;
  82141. }
  82142. }
  82143. declare module BABYLON {
  82144. /**
  82145. * Interface used to define a behavior
  82146. */
  82147. export interface Behavior<T> {
  82148. /** gets or sets behavior's name */
  82149. name: string;
  82150. /**
  82151. * Function called when the behavior needs to be initialized (after attaching it to a target)
  82152. */
  82153. init(): void;
  82154. /**
  82155. * Called when the behavior is attached to a target
  82156. * @param target defines the target where the behavior is attached to
  82157. */
  82158. attach(target: T): void;
  82159. /**
  82160. * Called when the behavior is detached from its target
  82161. */
  82162. detach(): void;
  82163. }
  82164. /**
  82165. * Interface implemented by classes supporting behaviors
  82166. */
  82167. export interface IBehaviorAware<T> {
  82168. /**
  82169. * Attach a behavior
  82170. * @param behavior defines the behavior to attach
  82171. * @returns the current host
  82172. */
  82173. addBehavior(behavior: Behavior<T>): T;
  82174. /**
  82175. * Remove a behavior from the current object
  82176. * @param behavior defines the behavior to detach
  82177. * @returns the current host
  82178. */
  82179. removeBehavior(behavior: Behavior<T>): T;
  82180. /**
  82181. * Gets a behavior using its name to search
  82182. * @param name defines the name to search
  82183. * @returns the behavior or null if not found
  82184. */
  82185. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  82186. }
  82187. }
  82188. declare module BABYLON {
  82189. /**
  82190. * Defines an array and its length.
  82191. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  82192. */
  82193. export interface ISmartArrayLike<T> {
  82194. /**
  82195. * The data of the array.
  82196. */
  82197. data: Array<T>;
  82198. /**
  82199. * The active length of the array.
  82200. */
  82201. length: number;
  82202. }
  82203. /**
  82204. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82205. */
  82206. export class SmartArray<T> implements ISmartArrayLike<T> {
  82207. /**
  82208. * The full set of data from the array.
  82209. */
  82210. data: Array<T>;
  82211. /**
  82212. * The active length of the array.
  82213. */
  82214. length: number;
  82215. protected _id: number;
  82216. /**
  82217. * Instantiates a Smart Array.
  82218. * @param capacity defines the default capacity of the array.
  82219. */
  82220. constructor(capacity: number);
  82221. /**
  82222. * Pushes a value at the end of the active data.
  82223. * @param value defines the object to push in the array.
  82224. */
  82225. push(value: T): void;
  82226. /**
  82227. * Iterates over the active data and apply the lambda to them.
  82228. * @param func defines the action to apply on each value.
  82229. */
  82230. forEach(func: (content: T) => void): void;
  82231. /**
  82232. * Sorts the full sets of data.
  82233. * @param compareFn defines the comparison function to apply.
  82234. */
  82235. sort(compareFn: (a: T, b: T) => number): void;
  82236. /**
  82237. * Resets the active data to an empty array.
  82238. */
  82239. reset(): void;
  82240. /**
  82241. * Releases all the data from the array as well as the array.
  82242. */
  82243. dispose(): void;
  82244. /**
  82245. * Concats the active data with a given array.
  82246. * @param array defines the data to concatenate with.
  82247. */
  82248. concat(array: any): void;
  82249. /**
  82250. * Returns the position of a value in the active data.
  82251. * @param value defines the value to find the index for
  82252. * @returns the index if found in the active data otherwise -1
  82253. */
  82254. indexOf(value: T): number;
  82255. /**
  82256. * Returns whether an element is part of the active data.
  82257. * @param value defines the value to look for
  82258. * @returns true if found in the active data otherwise false
  82259. */
  82260. contains(value: T): boolean;
  82261. private static _GlobalId;
  82262. }
  82263. /**
  82264. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82265. * The data in this array can only be present once
  82266. */
  82267. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  82268. private _duplicateId;
  82269. /**
  82270. * Pushes a value at the end of the active data.
  82271. * THIS DOES NOT PREVENT DUPPLICATE DATA
  82272. * @param value defines the object to push in the array.
  82273. */
  82274. push(value: T): void;
  82275. /**
  82276. * Pushes a value at the end of the active data.
  82277. * If the data is already present, it won t be added again
  82278. * @param value defines the object to push in the array.
  82279. * @returns true if added false if it was already present
  82280. */
  82281. pushNoDuplicate(value: T): boolean;
  82282. /**
  82283. * Resets the active data to an empty array.
  82284. */
  82285. reset(): void;
  82286. /**
  82287. * Concats the active data with a given array.
  82288. * This ensures no dupplicate will be present in the result.
  82289. * @param array defines the data to concatenate with.
  82290. */
  82291. concatWithNoDuplicate(array: any): void;
  82292. }
  82293. }
  82294. declare module BABYLON {
  82295. /**
  82296. * @ignore
  82297. * This is a list of all the different input types that are available in the application.
  82298. * Fo instance: ArcRotateCameraGamepadInput...
  82299. */
  82300. export var CameraInputTypes: {};
  82301. /**
  82302. * This is the contract to implement in order to create a new input class.
  82303. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  82304. */
  82305. export interface ICameraInput<TCamera extends Camera> {
  82306. /**
  82307. * Defines the camera the input is attached to.
  82308. */
  82309. camera: Nullable<TCamera>;
  82310. /**
  82311. * Gets the class name of the current intput.
  82312. * @returns the class name
  82313. */
  82314. getClassName(): string;
  82315. /**
  82316. * Get the friendly name associated with the input class.
  82317. * @returns the input friendly name
  82318. */
  82319. getSimpleName(): string;
  82320. /**
  82321. * Attach the input controls to a specific dom element to get the input from.
  82322. * @param element Defines the element the controls should be listened from
  82323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82324. */
  82325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82326. /**
  82327. * Detach the current controls from the specified dom element.
  82328. * @param element Defines the element to stop listening the inputs from
  82329. */
  82330. detachControl(element: Nullable<HTMLElement>): void;
  82331. /**
  82332. * Update the current camera state depending on the inputs that have been used this frame.
  82333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82334. */
  82335. checkInputs?: () => void;
  82336. }
  82337. /**
  82338. * Represents a map of input types to input instance or input index to input instance.
  82339. */
  82340. export interface CameraInputsMap<TCamera extends Camera> {
  82341. /**
  82342. * Accessor to the input by input type.
  82343. */
  82344. [name: string]: ICameraInput<TCamera>;
  82345. /**
  82346. * Accessor to the input by input index.
  82347. */
  82348. [idx: number]: ICameraInput<TCamera>;
  82349. }
  82350. /**
  82351. * This represents the input manager used within a camera.
  82352. * It helps dealing with all the different kind of input attached to a camera.
  82353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82354. */
  82355. export class CameraInputsManager<TCamera extends Camera> {
  82356. /**
  82357. * Defines the list of inputs attahed to the camera.
  82358. */
  82359. attached: CameraInputsMap<TCamera>;
  82360. /**
  82361. * Defines the dom element the camera is collecting inputs from.
  82362. * This is null if the controls have not been attached.
  82363. */
  82364. attachedElement: Nullable<HTMLElement>;
  82365. /**
  82366. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82367. */
  82368. noPreventDefault: boolean;
  82369. /**
  82370. * Defined the camera the input manager belongs to.
  82371. */
  82372. camera: TCamera;
  82373. /**
  82374. * Update the current camera state depending on the inputs that have been used this frame.
  82375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82376. */
  82377. checkInputs: () => void;
  82378. /**
  82379. * Instantiate a new Camera Input Manager.
  82380. * @param camera Defines the camera the input manager blongs to
  82381. */
  82382. constructor(camera: TCamera);
  82383. /**
  82384. * Add an input method to a camera
  82385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82386. * @param input camera input method
  82387. */
  82388. add(input: ICameraInput<TCamera>): void;
  82389. /**
  82390. * Remove a specific input method from a camera
  82391. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  82392. * @param inputToRemove camera input method
  82393. */
  82394. remove(inputToRemove: ICameraInput<TCamera>): void;
  82395. /**
  82396. * Remove a specific input type from a camera
  82397. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  82398. * @param inputType the type of the input to remove
  82399. */
  82400. removeByType(inputType: string): void;
  82401. private _addCheckInputs;
  82402. /**
  82403. * Attach the input controls to the currently attached dom element to listen the events from.
  82404. * @param input Defines the input to attach
  82405. */
  82406. attachInput(input: ICameraInput<TCamera>): void;
  82407. /**
  82408. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  82409. * @param element Defines the dom element to collect the events from
  82410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82411. */
  82412. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  82413. /**
  82414. * Detach the current manager inputs controls from a specific dom element.
  82415. * @param element Defines the dom element to collect the events from
  82416. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  82417. */
  82418. detachElement(element: HTMLElement, disconnect?: boolean): void;
  82419. /**
  82420. * Rebuild the dynamic inputCheck function from the current list of
  82421. * defined inputs in the manager.
  82422. */
  82423. rebuildInputCheck(): void;
  82424. /**
  82425. * Remove all attached input methods from a camera
  82426. */
  82427. clear(): void;
  82428. /**
  82429. * Serialize the current input manager attached to a camera.
  82430. * This ensures than once parsed,
  82431. * the input associated to the camera will be identical to the current ones
  82432. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  82433. */
  82434. serialize(serializedCamera: any): void;
  82435. /**
  82436. * Parses an input manager serialized JSON to restore the previous list of inputs
  82437. * and states associated to a camera.
  82438. * @param parsedCamera Defines the JSON to parse
  82439. */
  82440. parse(parsedCamera: any): void;
  82441. }
  82442. }
  82443. declare module BABYLON {
  82444. /**
  82445. * Class used to store data that will be store in GPU memory
  82446. */
  82447. export class Buffer {
  82448. private _engine;
  82449. private _buffer;
  82450. /** @hidden */
  82451. _data: Nullable<DataArray>;
  82452. private _updatable;
  82453. private _instanced;
  82454. private _divisor;
  82455. /**
  82456. * Gets the byte stride.
  82457. */
  82458. readonly byteStride: number;
  82459. /**
  82460. * Constructor
  82461. * @param engine the engine
  82462. * @param data the data to use for this buffer
  82463. * @param updatable whether the data is updatable
  82464. * @param stride the stride (optional)
  82465. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82466. * @param instanced whether the buffer is instanced (optional)
  82467. * @param useBytes set to true if the stride in in bytes (optional)
  82468. * @param divisor sets an optional divisor for instances (1 by default)
  82469. */
  82470. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  82471. /**
  82472. * Create a new VertexBuffer based on the current buffer
  82473. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82474. * @param offset defines offset in the buffer (0 by default)
  82475. * @param size defines the size in floats of attributes (position is 3 for instance)
  82476. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82477. * @param instanced defines if the vertex buffer contains indexed data
  82478. * @param useBytes defines if the offset and stride are in bytes *
  82479. * @param divisor sets an optional divisor for instances (1 by default)
  82480. * @returns the new vertex buffer
  82481. */
  82482. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  82483. /**
  82484. * Gets a boolean indicating if the Buffer is updatable?
  82485. * @returns true if the buffer is updatable
  82486. */
  82487. isUpdatable(): boolean;
  82488. /**
  82489. * Gets current buffer's data
  82490. * @returns a DataArray or null
  82491. */
  82492. getData(): Nullable<DataArray>;
  82493. /**
  82494. * Gets underlying native buffer
  82495. * @returns underlying native buffer
  82496. */
  82497. getBuffer(): Nullable<DataBuffer>;
  82498. /**
  82499. * Gets the stride in float32 units (i.e. byte stride / 4).
  82500. * May not be an integer if the byte stride is not divisible by 4.
  82501. * @returns the stride in float32 units
  82502. * @deprecated Please use byteStride instead.
  82503. */
  82504. getStrideSize(): number;
  82505. /**
  82506. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82507. * @param data defines the data to store
  82508. */
  82509. create(data?: Nullable<DataArray>): void;
  82510. /** @hidden */
  82511. _rebuild(): void;
  82512. /**
  82513. * Update current buffer data
  82514. * @param data defines the data to store
  82515. */
  82516. update(data: DataArray): void;
  82517. /**
  82518. * Updates the data directly.
  82519. * @param data the new data
  82520. * @param offset the new offset
  82521. * @param vertexCount the vertex count (optional)
  82522. * @param useBytes set to true if the offset is in bytes
  82523. */
  82524. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  82525. /**
  82526. * Release all resources
  82527. */
  82528. dispose(): void;
  82529. }
  82530. /**
  82531. * Specialized buffer used to store vertex data
  82532. */
  82533. export class VertexBuffer {
  82534. /** @hidden */
  82535. _buffer: Buffer;
  82536. private _kind;
  82537. private _size;
  82538. private _ownsBuffer;
  82539. private _instanced;
  82540. private _instanceDivisor;
  82541. /**
  82542. * The byte type.
  82543. */
  82544. static readonly BYTE: number;
  82545. /**
  82546. * The unsigned byte type.
  82547. */
  82548. static readonly UNSIGNED_BYTE: number;
  82549. /**
  82550. * The short type.
  82551. */
  82552. static readonly SHORT: number;
  82553. /**
  82554. * The unsigned short type.
  82555. */
  82556. static readonly UNSIGNED_SHORT: number;
  82557. /**
  82558. * The integer type.
  82559. */
  82560. static readonly INT: number;
  82561. /**
  82562. * The unsigned integer type.
  82563. */
  82564. static readonly UNSIGNED_INT: number;
  82565. /**
  82566. * The float type.
  82567. */
  82568. static readonly FLOAT: number;
  82569. /**
  82570. * Gets or sets the instance divisor when in instanced mode
  82571. */
  82572. get instanceDivisor(): number;
  82573. set instanceDivisor(value: number);
  82574. /**
  82575. * Gets the byte stride.
  82576. */
  82577. readonly byteStride: number;
  82578. /**
  82579. * Gets the byte offset.
  82580. */
  82581. readonly byteOffset: number;
  82582. /**
  82583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  82584. */
  82585. readonly normalized: boolean;
  82586. /**
  82587. * Gets the data type of each component in the array.
  82588. */
  82589. readonly type: number;
  82590. /**
  82591. * Constructor
  82592. * @param engine the engine
  82593. * @param data the data to use for this vertex buffer
  82594. * @param kind the vertex buffer kind
  82595. * @param updatable whether the data is updatable
  82596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82597. * @param stride the stride (optional)
  82598. * @param instanced whether the buffer is instanced (optional)
  82599. * @param offset the offset of the data (optional)
  82600. * @param size the number of components (optional)
  82601. * @param type the type of the component (optional)
  82602. * @param normalized whether the data contains normalized data (optional)
  82603. * @param useBytes set to true if stride and offset are in bytes (optional)
  82604. * @param divisor defines the instance divisor to use (1 by default)
  82605. */
  82606. 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, divisor?: number);
  82607. /** @hidden */
  82608. _rebuild(): void;
  82609. /**
  82610. * Returns the kind of the VertexBuffer (string)
  82611. * @returns a string
  82612. */
  82613. getKind(): string;
  82614. /**
  82615. * Gets a boolean indicating if the VertexBuffer is updatable?
  82616. * @returns true if the buffer is updatable
  82617. */
  82618. isUpdatable(): boolean;
  82619. /**
  82620. * Gets current buffer's data
  82621. * @returns a DataArray or null
  82622. */
  82623. getData(): Nullable<DataArray>;
  82624. /**
  82625. * Gets underlying native buffer
  82626. * @returns underlying native buffer
  82627. */
  82628. getBuffer(): Nullable<DataBuffer>;
  82629. /**
  82630. * Gets the stride in float32 units (i.e. byte stride / 4).
  82631. * May not be an integer if the byte stride is not divisible by 4.
  82632. * @returns the stride in float32 units
  82633. * @deprecated Please use byteStride instead.
  82634. */
  82635. getStrideSize(): number;
  82636. /**
  82637. * Returns the offset as a multiple of the type byte length.
  82638. * @returns the offset in bytes
  82639. * @deprecated Please use byteOffset instead.
  82640. */
  82641. getOffset(): number;
  82642. /**
  82643. * Returns the number of components per vertex attribute (integer)
  82644. * @returns the size in float
  82645. */
  82646. getSize(): number;
  82647. /**
  82648. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82649. * @returns true if this buffer is instanced
  82650. */
  82651. getIsInstanced(): boolean;
  82652. /**
  82653. * Returns the instancing divisor, zero for non-instanced (integer).
  82654. * @returns a number
  82655. */
  82656. getInstanceDivisor(): number;
  82657. /**
  82658. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82659. * @param data defines the data to store
  82660. */
  82661. create(data?: DataArray): void;
  82662. /**
  82663. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82664. * This function will create a new buffer if the current one is not updatable
  82665. * @param data defines the data to store
  82666. */
  82667. update(data: DataArray): void;
  82668. /**
  82669. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82670. * Returns the directly updated WebGLBuffer.
  82671. * @param data the new data
  82672. * @param offset the new offset
  82673. * @param useBytes set to true if the offset is in bytes
  82674. */
  82675. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  82676. /**
  82677. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82678. */
  82679. dispose(): void;
  82680. /**
  82681. * Enumerates each value of this vertex buffer as numbers.
  82682. * @param count the number of values to enumerate
  82683. * @param callback the callback function called for each value
  82684. */
  82685. forEach(count: number, callback: (value: number, index: number) => void): void;
  82686. /**
  82687. * Positions
  82688. */
  82689. static readonly PositionKind: string;
  82690. /**
  82691. * Normals
  82692. */
  82693. static readonly NormalKind: string;
  82694. /**
  82695. * Tangents
  82696. */
  82697. static readonly TangentKind: string;
  82698. /**
  82699. * Texture coordinates
  82700. */
  82701. static readonly UVKind: string;
  82702. /**
  82703. * Texture coordinates 2
  82704. */
  82705. static readonly UV2Kind: string;
  82706. /**
  82707. * Texture coordinates 3
  82708. */
  82709. static readonly UV3Kind: string;
  82710. /**
  82711. * Texture coordinates 4
  82712. */
  82713. static readonly UV4Kind: string;
  82714. /**
  82715. * Texture coordinates 5
  82716. */
  82717. static readonly UV5Kind: string;
  82718. /**
  82719. * Texture coordinates 6
  82720. */
  82721. static readonly UV6Kind: string;
  82722. /**
  82723. * Colors
  82724. */
  82725. static readonly ColorKind: string;
  82726. /**
  82727. * Matrix indices (for bones)
  82728. */
  82729. static readonly MatricesIndicesKind: string;
  82730. /**
  82731. * Matrix weights (for bones)
  82732. */
  82733. static readonly MatricesWeightsKind: string;
  82734. /**
  82735. * Additional matrix indices (for bones)
  82736. */
  82737. static readonly MatricesIndicesExtraKind: string;
  82738. /**
  82739. * Additional matrix weights (for bones)
  82740. */
  82741. static readonly MatricesWeightsExtraKind: string;
  82742. /**
  82743. * Deduces the stride given a kind.
  82744. * @param kind The kind string to deduce
  82745. * @returns The deduced stride
  82746. */
  82747. static DeduceStride(kind: string): number;
  82748. /**
  82749. * Gets the byte length of the given type.
  82750. * @param type the type
  82751. * @returns the number of bytes
  82752. */
  82753. static GetTypeByteLength(type: number): number;
  82754. /**
  82755. * Enumerates each value of the given parameters as numbers.
  82756. * @param data the data to enumerate
  82757. * @param byteOffset the byte offset of the data
  82758. * @param byteStride the byte stride of the data
  82759. * @param componentCount the number of components per element
  82760. * @param componentType the type of the component
  82761. * @param count the number of values to enumerate
  82762. * @param normalized whether the data is normalized
  82763. * @param callback the callback function called for each value
  82764. */
  82765. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  82766. private static _GetFloatValue;
  82767. }
  82768. }
  82769. declare module BABYLON {
  82770. /**
  82771. * @hidden
  82772. */
  82773. export class IntersectionInfo {
  82774. bu: Nullable<number>;
  82775. bv: Nullable<number>;
  82776. distance: number;
  82777. faceId: number;
  82778. subMeshId: number;
  82779. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  82780. }
  82781. }
  82782. declare module BABYLON {
  82783. /**
  82784. * Class used to store bounding sphere information
  82785. */
  82786. export class BoundingSphere {
  82787. /**
  82788. * Gets the center of the bounding sphere in local space
  82789. */
  82790. readonly center: Vector3;
  82791. /**
  82792. * Radius of the bounding sphere in local space
  82793. */
  82794. radius: number;
  82795. /**
  82796. * Gets the center of the bounding sphere in world space
  82797. */
  82798. readonly centerWorld: Vector3;
  82799. /**
  82800. * Radius of the bounding sphere in world space
  82801. */
  82802. radiusWorld: number;
  82803. /**
  82804. * Gets the minimum vector in local space
  82805. */
  82806. readonly minimum: Vector3;
  82807. /**
  82808. * Gets the maximum vector in local space
  82809. */
  82810. readonly maximum: Vector3;
  82811. private _worldMatrix;
  82812. private static readonly TmpVector3;
  82813. /**
  82814. * Creates a new bounding sphere
  82815. * @param min defines the minimum vector (in local space)
  82816. * @param max defines the maximum vector (in local space)
  82817. * @param worldMatrix defines the new world matrix
  82818. */
  82819. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82820. /**
  82821. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  82822. * @param min defines the new minimum vector (in local space)
  82823. * @param max defines the new maximum vector (in local space)
  82824. * @param worldMatrix defines the new world matrix
  82825. */
  82826. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82827. /**
  82828. * Scale the current bounding sphere by applying a scale factor
  82829. * @param factor defines the scale factor to apply
  82830. * @returns the current bounding box
  82831. */
  82832. scale(factor: number): BoundingSphere;
  82833. /**
  82834. * Gets the world matrix of the bounding box
  82835. * @returns a matrix
  82836. */
  82837. getWorldMatrix(): DeepImmutable<Matrix>;
  82838. /** @hidden */
  82839. _update(worldMatrix: DeepImmutable<Matrix>): void;
  82840. /**
  82841. * Tests if the bounding sphere is intersecting the frustum planes
  82842. * @param frustumPlanes defines the frustum planes to test
  82843. * @returns true if there is an intersection
  82844. */
  82845. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82846. /**
  82847. * Tests if the bounding sphere center is in between the frustum planes.
  82848. * Used for optimistic fast inclusion.
  82849. * @param frustumPlanes defines the frustum planes to test
  82850. * @returns true if the sphere center is in between the frustum planes
  82851. */
  82852. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82853. /**
  82854. * Tests if a point is inside the bounding sphere
  82855. * @param point defines the point to test
  82856. * @returns true if the point is inside the bounding sphere
  82857. */
  82858. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82859. /**
  82860. * Checks if two sphere intersct
  82861. * @param sphere0 sphere 0
  82862. * @param sphere1 sphere 1
  82863. * @returns true if the speres intersect
  82864. */
  82865. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  82866. }
  82867. }
  82868. declare module BABYLON {
  82869. /**
  82870. * Class used to store bounding box information
  82871. */
  82872. export class BoundingBox implements ICullable {
  82873. /**
  82874. * Gets the 8 vectors representing the bounding box in local space
  82875. */
  82876. readonly vectors: Vector3[];
  82877. /**
  82878. * Gets the center of the bounding box in local space
  82879. */
  82880. readonly center: Vector3;
  82881. /**
  82882. * Gets the center of the bounding box in world space
  82883. */
  82884. readonly centerWorld: Vector3;
  82885. /**
  82886. * Gets the extend size in local space
  82887. */
  82888. readonly extendSize: Vector3;
  82889. /**
  82890. * Gets the extend size in world space
  82891. */
  82892. readonly extendSizeWorld: Vector3;
  82893. /**
  82894. * Gets the OBB (object bounding box) directions
  82895. */
  82896. readonly directions: Vector3[];
  82897. /**
  82898. * Gets the 8 vectors representing the bounding box in world space
  82899. */
  82900. readonly vectorsWorld: Vector3[];
  82901. /**
  82902. * Gets the minimum vector in world space
  82903. */
  82904. readonly minimumWorld: Vector3;
  82905. /**
  82906. * Gets the maximum vector in world space
  82907. */
  82908. readonly maximumWorld: Vector3;
  82909. /**
  82910. * Gets the minimum vector in local space
  82911. */
  82912. readonly minimum: Vector3;
  82913. /**
  82914. * Gets the maximum vector in local space
  82915. */
  82916. readonly maximum: Vector3;
  82917. private _worldMatrix;
  82918. private static readonly TmpVector3;
  82919. /**
  82920. * @hidden
  82921. */
  82922. _tag: number;
  82923. /**
  82924. * Creates a new bounding box
  82925. * @param min defines the minimum vector (in local space)
  82926. * @param max defines the maximum vector (in local space)
  82927. * @param worldMatrix defines the new world matrix
  82928. */
  82929. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82930. /**
  82931. * Recreates the entire bounding box from scratch as if we call the constructor in place
  82932. * @param min defines the new minimum vector (in local space)
  82933. * @param max defines the new maximum vector (in local space)
  82934. * @param worldMatrix defines the new world matrix
  82935. */
  82936. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82937. /**
  82938. * Scale the current bounding box by applying a scale factor
  82939. * @param factor defines the scale factor to apply
  82940. * @returns the current bounding box
  82941. */
  82942. scale(factor: number): BoundingBox;
  82943. /**
  82944. * Gets the world matrix of the bounding box
  82945. * @returns a matrix
  82946. */
  82947. getWorldMatrix(): DeepImmutable<Matrix>;
  82948. /** @hidden */
  82949. _update(world: DeepImmutable<Matrix>): void;
  82950. /**
  82951. * Tests if the bounding box is intersecting the frustum planes
  82952. * @param frustumPlanes defines the frustum planes to test
  82953. * @returns true if there is an intersection
  82954. */
  82955. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82956. /**
  82957. * Tests if the bounding box is entirely inside the frustum planes
  82958. * @param frustumPlanes defines the frustum planes to test
  82959. * @returns true if there is an inclusion
  82960. */
  82961. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82962. /**
  82963. * Tests if a point is inside the bounding box
  82964. * @param point defines the point to test
  82965. * @returns true if the point is inside the bounding box
  82966. */
  82967. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82968. /**
  82969. * Tests if the bounding box intersects with a bounding sphere
  82970. * @param sphere defines the sphere to test
  82971. * @returns true if there is an intersection
  82972. */
  82973. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  82974. /**
  82975. * Tests if the bounding box intersects with a box defined by a min and max vectors
  82976. * @param min defines the min vector to use
  82977. * @param max defines the max vector to use
  82978. * @returns true if there is an intersection
  82979. */
  82980. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  82981. /**
  82982. * Tests if two bounding boxes are intersections
  82983. * @param box0 defines the first box to test
  82984. * @param box1 defines the second box to test
  82985. * @returns true if there is an intersection
  82986. */
  82987. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  82988. /**
  82989. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  82990. * @param minPoint defines the minimum vector of the bounding box
  82991. * @param maxPoint defines the maximum vector of the bounding box
  82992. * @param sphereCenter defines the sphere center
  82993. * @param sphereRadius defines the sphere radius
  82994. * @returns true if there is an intersection
  82995. */
  82996. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  82997. /**
  82998. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  82999. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  83000. * @param frustumPlanes defines the frustum planes to test
  83001. * @return true if there is an inclusion
  83002. */
  83003. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83004. /**
  83005. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  83006. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  83007. * @param frustumPlanes defines the frustum planes to test
  83008. * @return true if there is an intersection
  83009. */
  83010. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83011. }
  83012. }
  83013. declare module BABYLON {
  83014. /** @hidden */
  83015. export class Collider {
  83016. /** Define if a collision was found */
  83017. collisionFound: boolean;
  83018. /**
  83019. * Define last intersection point in local space
  83020. */
  83021. intersectionPoint: Vector3;
  83022. /**
  83023. * Define last collided mesh
  83024. */
  83025. collidedMesh: Nullable<AbstractMesh>;
  83026. private _collisionPoint;
  83027. private _planeIntersectionPoint;
  83028. private _tempVector;
  83029. private _tempVector2;
  83030. private _tempVector3;
  83031. private _tempVector4;
  83032. private _edge;
  83033. private _baseToVertex;
  83034. private _destinationPoint;
  83035. private _slidePlaneNormal;
  83036. private _displacementVector;
  83037. /** @hidden */
  83038. _radius: Vector3;
  83039. /** @hidden */
  83040. _retry: number;
  83041. private _velocity;
  83042. private _basePoint;
  83043. private _epsilon;
  83044. /** @hidden */
  83045. _velocityWorldLength: number;
  83046. /** @hidden */
  83047. _basePointWorld: Vector3;
  83048. private _velocityWorld;
  83049. private _normalizedVelocity;
  83050. /** @hidden */
  83051. _initialVelocity: Vector3;
  83052. /** @hidden */
  83053. _initialPosition: Vector3;
  83054. private _nearestDistance;
  83055. private _collisionMask;
  83056. get collisionMask(): number;
  83057. set collisionMask(mask: number);
  83058. /**
  83059. * Gets the plane normal used to compute the sliding response (in local space)
  83060. */
  83061. get slidePlaneNormal(): Vector3;
  83062. /** @hidden */
  83063. _initialize(source: Vector3, dir: Vector3, e: number): void;
  83064. /** @hidden */
  83065. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  83066. /** @hidden */
  83067. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  83068. /** @hidden */
  83069. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83070. /** @hidden */
  83071. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83072. /** @hidden */
  83073. _getResponse(pos: Vector3, vel: Vector3): void;
  83074. }
  83075. }
  83076. declare module BABYLON {
  83077. /**
  83078. * Interface for cullable objects
  83079. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  83080. */
  83081. export interface ICullable {
  83082. /**
  83083. * Checks if the object or part of the object is in the frustum
  83084. * @param frustumPlanes Camera near/planes
  83085. * @returns true if the object is in frustum otherwise false
  83086. */
  83087. isInFrustum(frustumPlanes: Plane[]): boolean;
  83088. /**
  83089. * Checks if a cullable object (mesh...) is in the camera frustum
  83090. * Unlike isInFrustum this cheks the full bounding box
  83091. * @param frustumPlanes Camera near/planes
  83092. * @returns true if the object is in frustum otherwise false
  83093. */
  83094. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83095. }
  83096. /**
  83097. * Info for a bounding data of a mesh
  83098. */
  83099. export class BoundingInfo implements ICullable {
  83100. /**
  83101. * Bounding box for the mesh
  83102. */
  83103. readonly boundingBox: BoundingBox;
  83104. /**
  83105. * Bounding sphere for the mesh
  83106. */
  83107. readonly boundingSphere: BoundingSphere;
  83108. private _isLocked;
  83109. private static readonly TmpVector3;
  83110. /**
  83111. * Constructs bounding info
  83112. * @param minimum min vector of the bounding box/sphere
  83113. * @param maximum max vector of the bounding box/sphere
  83114. * @param worldMatrix defines the new world matrix
  83115. */
  83116. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83117. /**
  83118. * Recreates the entire bounding info from scratch as if we call the constructor in place
  83119. * @param min defines the new minimum vector (in local space)
  83120. * @param max defines the new maximum vector (in local space)
  83121. * @param worldMatrix defines the new world matrix
  83122. */
  83123. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83124. /**
  83125. * min vector of the bounding box/sphere
  83126. */
  83127. get minimum(): Vector3;
  83128. /**
  83129. * max vector of the bounding box/sphere
  83130. */
  83131. get maximum(): Vector3;
  83132. /**
  83133. * If the info is locked and won't be updated to avoid perf overhead
  83134. */
  83135. get isLocked(): boolean;
  83136. set isLocked(value: boolean);
  83137. /**
  83138. * Updates the bounding sphere and box
  83139. * @param world world matrix to be used to update
  83140. */
  83141. update(world: DeepImmutable<Matrix>): void;
  83142. /**
  83143. * Recreate the bounding info to be centered around a specific point given a specific extend.
  83144. * @param center New center of the bounding info
  83145. * @param extend New extend of the bounding info
  83146. * @returns the current bounding info
  83147. */
  83148. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  83149. /**
  83150. * Scale the current bounding info by applying a scale factor
  83151. * @param factor defines the scale factor to apply
  83152. * @returns the current bounding info
  83153. */
  83154. scale(factor: number): BoundingInfo;
  83155. /**
  83156. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  83157. * @param frustumPlanes defines the frustum to test
  83158. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  83159. * @returns true if the bounding info is in the frustum planes
  83160. */
  83161. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  83162. /**
  83163. * Gets the world distance between the min and max points of the bounding box
  83164. */
  83165. get diagonalLength(): number;
  83166. /**
  83167. * Checks if a cullable object (mesh...) is in the camera frustum
  83168. * Unlike isInFrustum this cheks the full bounding box
  83169. * @param frustumPlanes Camera near/planes
  83170. * @returns true if the object is in frustum otherwise false
  83171. */
  83172. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83173. /** @hidden */
  83174. _checkCollision(collider: Collider): boolean;
  83175. /**
  83176. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  83177. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83178. * @param point the point to check intersection with
  83179. * @returns if the point intersects
  83180. */
  83181. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83182. /**
  83183. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  83184. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83185. * @param boundingInfo the bounding info to check intersection with
  83186. * @param precise if the intersection should be done using OBB
  83187. * @returns if the bounding info intersects
  83188. */
  83189. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  83190. }
  83191. }
  83192. declare module BABYLON {
  83193. /**
  83194. * Extracts minimum and maximum values from a list of indexed positions
  83195. * @param positions defines the positions to use
  83196. * @param indices defines the indices to the positions
  83197. * @param indexStart defines the start index
  83198. * @param indexCount defines the end index
  83199. * @param bias defines bias value to add to the result
  83200. * @return minimum and maximum values
  83201. */
  83202. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  83203. minimum: Vector3;
  83204. maximum: Vector3;
  83205. };
  83206. /**
  83207. * Extracts minimum and maximum values from a list of positions
  83208. * @param positions defines the positions to use
  83209. * @param start defines the start index in the positions array
  83210. * @param count defines the number of positions to handle
  83211. * @param bias defines bias value to add to the result
  83212. * @param stride defines the stride size to use (distance between two positions in the positions array)
  83213. * @return minimum and maximum values
  83214. */
  83215. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  83216. minimum: Vector3;
  83217. maximum: Vector3;
  83218. };
  83219. }
  83220. declare module BABYLON {
  83221. /** @hidden */
  83222. export class WebGLDataBuffer extends DataBuffer {
  83223. private _buffer;
  83224. constructor(resource: WebGLBuffer);
  83225. get underlyingResource(): any;
  83226. }
  83227. }
  83228. declare module BABYLON {
  83229. /** @hidden */
  83230. export class WebGLPipelineContext implements IPipelineContext {
  83231. engine: ThinEngine;
  83232. program: Nullable<WebGLProgram>;
  83233. context?: WebGLRenderingContext;
  83234. vertexShader?: WebGLShader;
  83235. fragmentShader?: WebGLShader;
  83236. isParallelCompiled: boolean;
  83237. onCompiled?: () => void;
  83238. transformFeedback?: WebGLTransformFeedback | null;
  83239. vertexCompilationError: Nullable<string>;
  83240. fragmentCompilationError: Nullable<string>;
  83241. programLinkError: Nullable<string>;
  83242. programValidationError: Nullable<string>;
  83243. get isAsync(): boolean;
  83244. get isReady(): boolean;
  83245. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  83246. _getVertexShaderCode(): string | null;
  83247. _getFragmentShaderCode(): string | null;
  83248. }
  83249. }
  83250. declare module BABYLON {
  83251. interface ThinEngine {
  83252. /**
  83253. * Create an uniform buffer
  83254. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83255. * @param elements defines the content of the uniform buffer
  83256. * @returns the webGL uniform buffer
  83257. */
  83258. createUniformBuffer(elements: FloatArray): DataBuffer;
  83259. /**
  83260. * Create a dynamic uniform buffer
  83261. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83262. * @param elements defines the content of the uniform buffer
  83263. * @returns the webGL uniform buffer
  83264. */
  83265. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  83266. /**
  83267. * Update an existing uniform buffer
  83268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83269. * @param uniformBuffer defines the target uniform buffer
  83270. * @param elements defines the content to update
  83271. * @param offset defines the offset in the uniform buffer where update should start
  83272. * @param count defines the size of the data to update
  83273. */
  83274. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83275. /**
  83276. * Bind an uniform buffer to the current webGL context
  83277. * @param buffer defines the buffer to bind
  83278. */
  83279. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  83280. /**
  83281. * Bind a buffer to the current webGL context at a given location
  83282. * @param buffer defines the buffer to bind
  83283. * @param location defines the index where to bind the buffer
  83284. */
  83285. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  83286. /**
  83287. * Bind a specific block at a given index in a specific shader program
  83288. * @param pipelineContext defines the pipeline context to use
  83289. * @param blockName defines the block name
  83290. * @param index defines the index where to bind the block
  83291. */
  83292. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  83293. }
  83294. }
  83295. declare module BABYLON {
  83296. /**
  83297. * Uniform buffer objects.
  83298. *
  83299. * Handles blocks of uniform on the GPU.
  83300. *
  83301. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83302. *
  83303. * For more information, please refer to :
  83304. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83305. */
  83306. export class UniformBuffer {
  83307. private _engine;
  83308. private _buffer;
  83309. private _data;
  83310. private _bufferData;
  83311. private _dynamic?;
  83312. private _uniformLocations;
  83313. private _uniformSizes;
  83314. private _uniformLocationPointer;
  83315. private _needSync;
  83316. private _noUBO;
  83317. private _currentEffect;
  83318. /** @hidden */
  83319. _alreadyBound: boolean;
  83320. private static _MAX_UNIFORM_SIZE;
  83321. private static _tempBuffer;
  83322. /**
  83323. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83324. * This is dynamic to allow compat with webgl 1 and 2.
  83325. * You will need to pass the name of the uniform as well as the value.
  83326. */
  83327. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83328. /**
  83329. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83330. * This is dynamic to allow compat with webgl 1 and 2.
  83331. * You will need to pass the name of the uniform as well as the value.
  83332. */
  83333. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83334. /**
  83335. * Lambda to Update a single float in a uniform buffer.
  83336. * This is dynamic to allow compat with webgl 1 and 2.
  83337. * You will need to pass the name of the uniform as well as the value.
  83338. */
  83339. updateFloat: (name: string, x: number) => void;
  83340. /**
  83341. * Lambda to Update a vec2 of float in a uniform buffer.
  83342. * This is dynamic to allow compat with webgl 1 and 2.
  83343. * You will need to pass the name of the uniform as well as the value.
  83344. */
  83345. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83346. /**
  83347. * Lambda to Update a vec3 of float in a uniform buffer.
  83348. * This is dynamic to allow compat with webgl 1 and 2.
  83349. * You will need to pass the name of the uniform as well as the value.
  83350. */
  83351. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83352. /**
  83353. * Lambda to Update a vec4 of float in a uniform buffer.
  83354. * This is dynamic to allow compat with webgl 1 and 2.
  83355. * You will need to pass the name of the uniform as well as the value.
  83356. */
  83357. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83358. /**
  83359. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83360. * This is dynamic to allow compat with webgl 1 and 2.
  83361. * You will need to pass the name of the uniform as well as the value.
  83362. */
  83363. updateMatrix: (name: string, mat: Matrix) => void;
  83364. /**
  83365. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83366. * This is dynamic to allow compat with webgl 1 and 2.
  83367. * You will need to pass the name of the uniform as well as the value.
  83368. */
  83369. updateVector3: (name: string, vector: Vector3) => void;
  83370. /**
  83371. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83372. * This is dynamic to allow compat with webgl 1 and 2.
  83373. * You will need to pass the name of the uniform as well as the value.
  83374. */
  83375. updateVector4: (name: string, vector: Vector4) => void;
  83376. /**
  83377. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83378. * This is dynamic to allow compat with webgl 1 and 2.
  83379. * You will need to pass the name of the uniform as well as the value.
  83380. */
  83381. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83382. /**
  83383. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83384. * This is dynamic to allow compat with webgl 1 and 2.
  83385. * You will need to pass the name of the uniform as well as the value.
  83386. */
  83387. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83388. /**
  83389. * Instantiates a new Uniform buffer objects.
  83390. *
  83391. * Handles blocks of uniform on the GPU.
  83392. *
  83393. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83394. *
  83395. * For more information, please refer to :
  83396. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83397. * @param engine Define the engine the buffer is associated with
  83398. * @param data Define the data contained in the buffer
  83399. * @param dynamic Define if the buffer is updatable
  83400. */
  83401. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83402. /**
  83403. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83404. * or just falling back on setUniformXXX calls.
  83405. */
  83406. get useUbo(): boolean;
  83407. /**
  83408. * Indicates if the WebGL underlying uniform buffer is in sync
  83409. * with the javascript cache data.
  83410. */
  83411. get isSync(): boolean;
  83412. /**
  83413. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83414. * Also, a dynamic UniformBuffer will disable cache verification and always
  83415. * update the underlying WebGL uniform buffer to the GPU.
  83416. * @returns if Dynamic, otherwise false
  83417. */
  83418. isDynamic(): boolean;
  83419. /**
  83420. * The data cache on JS side.
  83421. * @returns the underlying data as a float array
  83422. */
  83423. getData(): Float32Array;
  83424. /**
  83425. * The underlying WebGL Uniform buffer.
  83426. * @returns the webgl buffer
  83427. */
  83428. getBuffer(): Nullable<DataBuffer>;
  83429. /**
  83430. * std140 layout specifies how to align data within an UBO structure.
  83431. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83432. * for specs.
  83433. */
  83434. private _fillAlignment;
  83435. /**
  83436. * Adds an uniform in the buffer.
  83437. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83438. * for the layout to be correct !
  83439. * @param name Name of the uniform, as used in the uniform block in the shader.
  83440. * @param size Data size, or data directly.
  83441. */
  83442. addUniform(name: string, size: number | number[]): void;
  83443. /**
  83444. * Adds a Matrix 4x4 to the uniform buffer.
  83445. * @param name Name of the uniform, as used in the uniform block in the shader.
  83446. * @param mat A 4x4 matrix.
  83447. */
  83448. addMatrix(name: string, mat: Matrix): void;
  83449. /**
  83450. * Adds a vec2 to the uniform buffer.
  83451. * @param name Name of the uniform, as used in the uniform block in the shader.
  83452. * @param x Define the x component value of the vec2
  83453. * @param y Define the y component value of the vec2
  83454. */
  83455. addFloat2(name: string, x: number, y: number): void;
  83456. /**
  83457. * Adds a vec3 to the uniform buffer.
  83458. * @param name Name of the uniform, as used in the uniform block in the shader.
  83459. * @param x Define the x component value of the vec3
  83460. * @param y Define the y component value of the vec3
  83461. * @param z Define the z component value of the vec3
  83462. */
  83463. addFloat3(name: string, x: number, y: number, z: number): void;
  83464. /**
  83465. * Adds a vec3 to the uniform buffer.
  83466. * @param name Name of the uniform, as used in the uniform block in the shader.
  83467. * @param color Define the vec3 from a Color
  83468. */
  83469. addColor3(name: string, color: Color3): void;
  83470. /**
  83471. * Adds a vec4 to the uniform buffer.
  83472. * @param name Name of the uniform, as used in the uniform block in the shader.
  83473. * @param color Define the rgb components from a Color
  83474. * @param alpha Define the a component of the vec4
  83475. */
  83476. addColor4(name: string, color: Color3, alpha: number): void;
  83477. /**
  83478. * Adds a vec3 to the uniform buffer.
  83479. * @param name Name of the uniform, as used in the uniform block in the shader.
  83480. * @param vector Define the vec3 components from a Vector
  83481. */
  83482. addVector3(name: string, vector: Vector3): void;
  83483. /**
  83484. * Adds a Matrix 3x3 to the uniform buffer.
  83485. * @param name Name of the uniform, as used in the uniform block in the shader.
  83486. */
  83487. addMatrix3x3(name: string): void;
  83488. /**
  83489. * Adds a Matrix 2x2 to the uniform buffer.
  83490. * @param name Name of the uniform, as used in the uniform block in the shader.
  83491. */
  83492. addMatrix2x2(name: string): void;
  83493. /**
  83494. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83495. */
  83496. create(): void;
  83497. /** @hidden */
  83498. _rebuild(): void;
  83499. /**
  83500. * Updates the WebGL Uniform Buffer on the GPU.
  83501. * If the `dynamic` flag is set to true, no cache comparison is done.
  83502. * Otherwise, the buffer will be updated only if the cache differs.
  83503. */
  83504. update(): void;
  83505. /**
  83506. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83507. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83508. * @param data Define the flattened data
  83509. * @param size Define the size of the data.
  83510. */
  83511. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83512. private _valueCache;
  83513. private _cacheMatrix;
  83514. private _updateMatrix3x3ForUniform;
  83515. private _updateMatrix3x3ForEffect;
  83516. private _updateMatrix2x2ForEffect;
  83517. private _updateMatrix2x2ForUniform;
  83518. private _updateFloatForEffect;
  83519. private _updateFloatForUniform;
  83520. private _updateFloat2ForEffect;
  83521. private _updateFloat2ForUniform;
  83522. private _updateFloat3ForEffect;
  83523. private _updateFloat3ForUniform;
  83524. private _updateFloat4ForEffect;
  83525. private _updateFloat4ForUniform;
  83526. private _updateMatrixForEffect;
  83527. private _updateMatrixForUniform;
  83528. private _updateVector3ForEffect;
  83529. private _updateVector3ForUniform;
  83530. private _updateVector4ForEffect;
  83531. private _updateVector4ForUniform;
  83532. private _updateColor3ForEffect;
  83533. private _updateColor3ForUniform;
  83534. private _updateColor4ForEffect;
  83535. private _updateColor4ForUniform;
  83536. /**
  83537. * Sets a sampler uniform on the effect.
  83538. * @param name Define the name of the sampler.
  83539. * @param texture Define the texture to set in the sampler
  83540. */
  83541. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83542. /**
  83543. * Directly updates the value of the uniform in the cache AND on the GPU.
  83544. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83545. * @param data Define the flattened data
  83546. */
  83547. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83548. /**
  83549. * Binds this uniform buffer to an effect.
  83550. * @param effect Define the effect to bind the buffer to
  83551. * @param name Name of the uniform block in the shader.
  83552. */
  83553. bindToEffect(effect: Effect, name: string): void;
  83554. /**
  83555. * Disposes the uniform buffer.
  83556. */
  83557. dispose(): void;
  83558. }
  83559. }
  83560. declare module BABYLON {
  83561. /**
  83562. * Enum that determines the text-wrapping mode to use.
  83563. */
  83564. export enum InspectableType {
  83565. /**
  83566. * Checkbox for booleans
  83567. */
  83568. Checkbox = 0,
  83569. /**
  83570. * Sliders for numbers
  83571. */
  83572. Slider = 1,
  83573. /**
  83574. * Vector3
  83575. */
  83576. Vector3 = 2,
  83577. /**
  83578. * Quaternions
  83579. */
  83580. Quaternion = 3,
  83581. /**
  83582. * Color3
  83583. */
  83584. Color3 = 4,
  83585. /**
  83586. * String
  83587. */
  83588. String = 5
  83589. }
  83590. /**
  83591. * Interface used to define custom inspectable properties.
  83592. * This interface is used by the inspector to display custom property grids
  83593. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83594. */
  83595. export interface IInspectable {
  83596. /**
  83597. * Gets the label to display
  83598. */
  83599. label: string;
  83600. /**
  83601. * Gets the name of the property to edit
  83602. */
  83603. propertyName: string;
  83604. /**
  83605. * Gets the type of the editor to use
  83606. */
  83607. type: InspectableType;
  83608. /**
  83609. * Gets the minimum value of the property when using in "slider" mode
  83610. */
  83611. min?: number;
  83612. /**
  83613. * Gets the maximum value of the property when using in "slider" mode
  83614. */
  83615. max?: number;
  83616. /**
  83617. * Gets the setp to use when using in "slider" mode
  83618. */
  83619. step?: number;
  83620. }
  83621. }
  83622. declare module BABYLON {
  83623. /**
  83624. * Class used to provide helper for timing
  83625. */
  83626. export class TimingTools {
  83627. /**
  83628. * Polyfill for setImmediate
  83629. * @param action defines the action to execute after the current execution block
  83630. */
  83631. static SetImmediate(action: () => void): void;
  83632. }
  83633. }
  83634. declare module BABYLON {
  83635. /**
  83636. * Class used to enable instatition of objects by class name
  83637. */
  83638. export class InstantiationTools {
  83639. /**
  83640. * Use this object to register external classes like custom textures or material
  83641. * to allow the laoders to instantiate them
  83642. */
  83643. static RegisteredExternalClasses: {
  83644. [key: string]: Object;
  83645. };
  83646. /**
  83647. * Tries to instantiate a new object from a given class name
  83648. * @param className defines the class name to instantiate
  83649. * @returns the new object or null if the system was not able to do the instantiation
  83650. */
  83651. static Instantiate(className: string): any;
  83652. }
  83653. }
  83654. declare module BABYLON {
  83655. /**
  83656. * Define options used to create a depth texture
  83657. */
  83658. export class DepthTextureCreationOptions {
  83659. /** Specifies whether or not a stencil should be allocated in the texture */
  83660. generateStencil?: boolean;
  83661. /** Specifies whether or not bilinear filtering is enable on the texture */
  83662. bilinearFiltering?: boolean;
  83663. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83664. comparisonFunction?: number;
  83665. /** Specifies if the created texture is a cube texture */
  83666. isCube?: boolean;
  83667. }
  83668. }
  83669. declare module BABYLON {
  83670. interface ThinEngine {
  83671. /**
  83672. * Creates a depth stencil cube texture.
  83673. * This is only available in WebGL 2.
  83674. * @param size The size of face edge in the cube texture.
  83675. * @param options The options defining the cube texture.
  83676. * @returns The cube texture
  83677. */
  83678. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  83679. /**
  83680. * Creates a cube texture
  83681. * @param rootUrl defines the url where the files to load is located
  83682. * @param scene defines the current scene
  83683. * @param files defines the list of files to load (1 per face)
  83684. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83685. * @param onLoad defines an optional callback raised when the texture is loaded
  83686. * @param onError defines an optional callback raised if there is an issue to load the texture
  83687. * @param format defines the format of the data
  83688. * @param forcedExtension defines the extension to use to pick the right loader
  83689. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83690. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83691. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83692. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  83693. * @returns the cube texture as an InternalTexture
  83694. */
  83695. 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>): InternalTexture;
  83696. /**
  83697. * Creates a cube texture
  83698. * @param rootUrl defines the url where the files to load is located
  83699. * @param scene defines the current scene
  83700. * @param files defines the list of files to load (1 per face)
  83701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83702. * @param onLoad defines an optional callback raised when the texture is loaded
  83703. * @param onError defines an optional callback raised if there is an issue to load the texture
  83704. * @param format defines the format of the data
  83705. * @param forcedExtension defines the extension to use to pick the right loader
  83706. * @returns the cube texture as an InternalTexture
  83707. */
  83708. 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;
  83709. /**
  83710. * Creates a cube texture
  83711. * @param rootUrl defines the url where the files to load is located
  83712. * @param scene defines the current scene
  83713. * @param files defines the list of files to load (1 per face)
  83714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83715. * @param onLoad defines an optional callback raised when the texture is loaded
  83716. * @param onError defines an optional callback raised if there is an issue to load the texture
  83717. * @param format defines the format of the data
  83718. * @param forcedExtension defines the extension to use to pick the right loader
  83719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83722. * @returns the cube texture as an InternalTexture
  83723. */
  83724. 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;
  83725. /** @hidden */
  83726. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  83727. /** @hidden */
  83728. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  83729. /** @hidden */
  83730. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83731. /** @hidden */
  83732. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83733. /**
  83734. * @hidden
  83735. */
  83736. _setCubeMapTextureParams(loadMipmap: boolean): void;
  83737. }
  83738. }
  83739. declare module BABYLON {
  83740. /**
  83741. * Class for creating a cube texture
  83742. */
  83743. export class CubeTexture extends BaseTexture {
  83744. private _delayedOnLoad;
  83745. /**
  83746. * Observable triggered once the texture has been loaded.
  83747. */
  83748. onLoadObservable: Observable<CubeTexture>;
  83749. /**
  83750. * The url of the texture
  83751. */
  83752. url: string;
  83753. /**
  83754. * Gets or sets the center of the bounding box associated with the cube texture.
  83755. * It must define where the camera used to render the texture was set
  83756. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83757. */
  83758. boundingBoxPosition: Vector3;
  83759. private _boundingBoxSize;
  83760. /**
  83761. * Gets or sets the size of the bounding box associated with the cube texture
  83762. * When defined, the cubemap will switch to local mode
  83763. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83764. * @example https://www.babylonjs-playground.com/#RNASML
  83765. */
  83766. set boundingBoxSize(value: Vector3);
  83767. /**
  83768. * Returns the bounding box size
  83769. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83770. */
  83771. get boundingBoxSize(): Vector3;
  83772. protected _rotationY: number;
  83773. /**
  83774. * Sets texture matrix rotation angle around Y axis in radians.
  83775. */
  83776. set rotationY(value: number);
  83777. /**
  83778. * Gets texture matrix rotation angle around Y axis radians.
  83779. */
  83780. get rotationY(): number;
  83781. /**
  83782. * Are mip maps generated for this texture or not.
  83783. */
  83784. get noMipmap(): boolean;
  83785. private _noMipmap;
  83786. private _files;
  83787. protected _forcedExtension: Nullable<string>;
  83788. private _extensions;
  83789. private _textureMatrix;
  83790. private _format;
  83791. private _createPolynomials;
  83792. /** @hidden */
  83793. _prefiltered: boolean;
  83794. /**
  83795. * Creates a cube texture from an array of image urls
  83796. * @param files defines an array of image urls
  83797. * @param scene defines the hosting scene
  83798. * @param noMipmap specifies if mip maps are not used
  83799. * @returns a cube texture
  83800. */
  83801. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  83802. /**
  83803. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  83804. * @param url defines the url of the prefiltered texture
  83805. * @param scene defines the scene the texture is attached to
  83806. * @param forcedExtension defines the extension of the file if different from the url
  83807. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83808. * @return the prefiltered texture
  83809. */
  83810. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  83811. /**
  83812. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  83813. * as prefiltered data.
  83814. * @param rootUrl defines the url of the texture or the root name of the six images
  83815. * @param null defines the scene or engine the texture is attached to
  83816. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  83817. * @param noMipmap defines if mipmaps should be created or not
  83818. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  83819. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  83820. * @param onError defines a callback triggered in case of error during load
  83821. * @param format defines the internal format to use for the texture once loaded
  83822. * @param prefiltered defines whether or not the texture is created from prefiltered data
  83823. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  83824. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83827. * @return the cube texture
  83828. */
  83829. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  83830. /**
  83831. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  83832. */
  83833. get isPrefiltered(): boolean;
  83834. /**
  83835. * Get the current class name of the texture useful for serialization or dynamic coding.
  83836. * @returns "CubeTexture"
  83837. */
  83838. getClassName(): string;
  83839. /**
  83840. * Update the url (and optional buffer) of this texture if url was null during construction.
  83841. * @param url the url of the texture
  83842. * @param forcedExtension defines the extension to use
  83843. * @param onLoad callback called when the texture is loaded (defaults to null)
  83844. * @param prefiltered Defines whether the updated texture is prefiltered or not
  83845. */
  83846. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  83847. /**
  83848. * Delays loading of the cube texture
  83849. * @param forcedExtension defines the extension to use
  83850. */
  83851. delayLoad(forcedExtension?: string): void;
  83852. /**
  83853. * Returns the reflection texture matrix
  83854. * @returns the reflection texture matrix
  83855. */
  83856. getReflectionTextureMatrix(): Matrix;
  83857. /**
  83858. * Sets the reflection texture matrix
  83859. * @param value Reflection texture matrix
  83860. */
  83861. setReflectionTextureMatrix(value: Matrix): void;
  83862. /**
  83863. * Parses text to create a cube texture
  83864. * @param parsedTexture define the serialized text to read from
  83865. * @param scene defines the hosting scene
  83866. * @param rootUrl defines the root url of the cube texture
  83867. * @returns a cube texture
  83868. */
  83869. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  83870. /**
  83871. * Makes a clone, or deep copy, of the cube texture
  83872. * @returns a new cube texture
  83873. */
  83874. clone(): CubeTexture;
  83875. }
  83876. }
  83877. declare module BABYLON {
  83878. /**
  83879. * Manages the defines for the Material
  83880. */
  83881. export class MaterialDefines {
  83882. /** @hidden */
  83883. protected _keys: string[];
  83884. private _isDirty;
  83885. /** @hidden */
  83886. _renderId: number;
  83887. /** @hidden */
  83888. _areLightsDirty: boolean;
  83889. /** @hidden */
  83890. _areLightsDisposed: boolean;
  83891. /** @hidden */
  83892. _areAttributesDirty: boolean;
  83893. /** @hidden */
  83894. _areTexturesDirty: boolean;
  83895. /** @hidden */
  83896. _areFresnelDirty: boolean;
  83897. /** @hidden */
  83898. _areMiscDirty: boolean;
  83899. /** @hidden */
  83900. _areImageProcessingDirty: boolean;
  83901. /** @hidden */
  83902. _normals: boolean;
  83903. /** @hidden */
  83904. _uvs: boolean;
  83905. /** @hidden */
  83906. _needNormals: boolean;
  83907. /** @hidden */
  83908. _needUVs: boolean;
  83909. [id: string]: any;
  83910. /**
  83911. * Specifies if the material needs to be re-calculated
  83912. */
  83913. get isDirty(): boolean;
  83914. /**
  83915. * Marks the material to indicate that it has been re-calculated
  83916. */
  83917. markAsProcessed(): void;
  83918. /**
  83919. * Marks the material to indicate that it needs to be re-calculated
  83920. */
  83921. markAsUnprocessed(): void;
  83922. /**
  83923. * Marks the material to indicate all of its defines need to be re-calculated
  83924. */
  83925. markAllAsDirty(): void;
  83926. /**
  83927. * Marks the material to indicate that image processing needs to be re-calculated
  83928. */
  83929. markAsImageProcessingDirty(): void;
  83930. /**
  83931. * Marks the material to indicate the lights need to be re-calculated
  83932. * @param disposed Defines whether the light is dirty due to dispose or not
  83933. */
  83934. markAsLightDirty(disposed?: boolean): void;
  83935. /**
  83936. * Marks the attribute state as changed
  83937. */
  83938. markAsAttributesDirty(): void;
  83939. /**
  83940. * Marks the texture state as changed
  83941. */
  83942. markAsTexturesDirty(): void;
  83943. /**
  83944. * Marks the fresnel state as changed
  83945. */
  83946. markAsFresnelDirty(): void;
  83947. /**
  83948. * Marks the misc state as changed
  83949. */
  83950. markAsMiscDirty(): void;
  83951. /**
  83952. * Rebuilds the material defines
  83953. */
  83954. rebuild(): void;
  83955. /**
  83956. * Specifies if two material defines are equal
  83957. * @param other - A material define instance to compare to
  83958. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  83959. */
  83960. isEqual(other: MaterialDefines): boolean;
  83961. /**
  83962. * Clones this instance's defines to another instance
  83963. * @param other - material defines to clone values to
  83964. */
  83965. cloneTo(other: MaterialDefines): void;
  83966. /**
  83967. * Resets the material define values
  83968. */
  83969. reset(): void;
  83970. /**
  83971. * Converts the material define values to a string
  83972. * @returns - String of material define information
  83973. */
  83974. toString(): string;
  83975. }
  83976. }
  83977. declare module BABYLON {
  83978. /**
  83979. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  83980. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  83981. * 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;
  83982. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  83983. */
  83984. export class ColorCurves {
  83985. private _dirty;
  83986. private _tempColor;
  83987. private _globalCurve;
  83988. private _highlightsCurve;
  83989. private _midtonesCurve;
  83990. private _shadowsCurve;
  83991. private _positiveCurve;
  83992. private _negativeCurve;
  83993. private _globalHue;
  83994. private _globalDensity;
  83995. private _globalSaturation;
  83996. private _globalExposure;
  83997. /**
  83998. * Gets the global Hue value.
  83999. * 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).
  84000. */
  84001. get globalHue(): number;
  84002. /**
  84003. * Sets the global Hue value.
  84004. * 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).
  84005. */
  84006. set globalHue(value: number);
  84007. /**
  84008. * Gets the global Density value.
  84009. * 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.
  84010. * Values less than zero provide a filter of opposite hue.
  84011. */
  84012. get globalDensity(): number;
  84013. /**
  84014. * Sets the global Density value.
  84015. * 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.
  84016. * Values less than zero provide a filter of opposite hue.
  84017. */
  84018. set globalDensity(value: number);
  84019. /**
  84020. * Gets the global Saturation value.
  84021. * 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.
  84022. */
  84023. get globalSaturation(): number;
  84024. /**
  84025. * Sets the global Saturation value.
  84026. * 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.
  84027. */
  84028. set globalSaturation(value: number);
  84029. /**
  84030. * Gets the global Exposure value.
  84031. * 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.
  84032. */
  84033. get globalExposure(): number;
  84034. /**
  84035. * Sets the global Exposure value.
  84036. * 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.
  84037. */
  84038. set globalExposure(value: number);
  84039. private _highlightsHue;
  84040. private _highlightsDensity;
  84041. private _highlightsSaturation;
  84042. private _highlightsExposure;
  84043. /**
  84044. * Gets the highlights Hue value.
  84045. * 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).
  84046. */
  84047. get highlightsHue(): number;
  84048. /**
  84049. * Sets the highlights Hue value.
  84050. * 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).
  84051. */
  84052. set highlightsHue(value: number);
  84053. /**
  84054. * Gets the highlights Density value.
  84055. * 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.
  84056. * Values less than zero provide a filter of opposite hue.
  84057. */
  84058. get highlightsDensity(): number;
  84059. /**
  84060. * Sets the highlights Density value.
  84061. * 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.
  84062. * Values less than zero provide a filter of opposite hue.
  84063. */
  84064. set highlightsDensity(value: number);
  84065. /**
  84066. * Gets the highlights Saturation value.
  84067. * 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.
  84068. */
  84069. get highlightsSaturation(): number;
  84070. /**
  84071. * Sets the highlights Saturation value.
  84072. * 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.
  84073. */
  84074. set highlightsSaturation(value: number);
  84075. /**
  84076. * Gets the highlights Exposure value.
  84077. * 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.
  84078. */
  84079. get highlightsExposure(): number;
  84080. /**
  84081. * Sets the highlights Exposure value.
  84082. * 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.
  84083. */
  84084. set highlightsExposure(value: number);
  84085. private _midtonesHue;
  84086. private _midtonesDensity;
  84087. private _midtonesSaturation;
  84088. private _midtonesExposure;
  84089. /**
  84090. * Gets the midtones Hue value.
  84091. * 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).
  84092. */
  84093. get midtonesHue(): number;
  84094. /**
  84095. * Sets the midtones Hue value.
  84096. * 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).
  84097. */
  84098. set midtonesHue(value: number);
  84099. /**
  84100. * Gets the midtones Density value.
  84101. * 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.
  84102. * Values less than zero provide a filter of opposite hue.
  84103. */
  84104. get midtonesDensity(): number;
  84105. /**
  84106. * Sets the midtones Density value.
  84107. * 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.
  84108. * Values less than zero provide a filter of opposite hue.
  84109. */
  84110. set midtonesDensity(value: number);
  84111. /**
  84112. * Gets the midtones Saturation value.
  84113. * 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.
  84114. */
  84115. get midtonesSaturation(): number;
  84116. /**
  84117. * Sets the midtones Saturation value.
  84118. * 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.
  84119. */
  84120. set midtonesSaturation(value: number);
  84121. /**
  84122. * Gets the midtones Exposure value.
  84123. * 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.
  84124. */
  84125. get midtonesExposure(): number;
  84126. /**
  84127. * Sets the midtones Exposure value.
  84128. * 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.
  84129. */
  84130. set midtonesExposure(value: number);
  84131. private _shadowsHue;
  84132. private _shadowsDensity;
  84133. private _shadowsSaturation;
  84134. private _shadowsExposure;
  84135. /**
  84136. * Gets the shadows Hue value.
  84137. * 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).
  84138. */
  84139. get shadowsHue(): number;
  84140. /**
  84141. * Sets the shadows Hue value.
  84142. * 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).
  84143. */
  84144. set shadowsHue(value: number);
  84145. /**
  84146. * Gets the shadows Density value.
  84147. * 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.
  84148. * Values less than zero provide a filter of opposite hue.
  84149. */
  84150. get shadowsDensity(): number;
  84151. /**
  84152. * Sets the shadows Density value.
  84153. * 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.
  84154. * Values less than zero provide a filter of opposite hue.
  84155. */
  84156. set shadowsDensity(value: number);
  84157. /**
  84158. * Gets the shadows Saturation value.
  84159. * 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.
  84160. */
  84161. get shadowsSaturation(): number;
  84162. /**
  84163. * Sets the shadows Saturation value.
  84164. * 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.
  84165. */
  84166. set shadowsSaturation(value: number);
  84167. /**
  84168. * Gets the shadows Exposure value.
  84169. * 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.
  84170. */
  84171. get shadowsExposure(): number;
  84172. /**
  84173. * Sets the shadows Exposure value.
  84174. * 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.
  84175. */
  84176. set shadowsExposure(value: number);
  84177. /**
  84178. * Returns the class name
  84179. * @returns The class name
  84180. */
  84181. getClassName(): string;
  84182. /**
  84183. * Binds the color curves to the shader.
  84184. * @param colorCurves The color curve to bind
  84185. * @param effect The effect to bind to
  84186. * @param positiveUniform The positive uniform shader parameter
  84187. * @param neutralUniform The neutral uniform shader parameter
  84188. * @param negativeUniform The negative uniform shader parameter
  84189. */
  84190. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  84191. /**
  84192. * Prepare the list of uniforms associated with the ColorCurves effects.
  84193. * @param uniformsList The list of uniforms used in the effect
  84194. */
  84195. static PrepareUniforms(uniformsList: string[]): void;
  84196. /**
  84197. * Returns color grading data based on a hue, density, saturation and exposure value.
  84198. * @param filterHue The hue of the color filter.
  84199. * @param filterDensity The density of the color filter.
  84200. * @param saturation The saturation.
  84201. * @param exposure The exposure.
  84202. * @param result The result data container.
  84203. */
  84204. private getColorGradingDataToRef;
  84205. /**
  84206. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  84207. * @param value The input slider value in range [-100,100].
  84208. * @returns Adjusted value.
  84209. */
  84210. private static applyColorGradingSliderNonlinear;
  84211. /**
  84212. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  84213. * @param hue The hue (H) input.
  84214. * @param saturation The saturation (S) input.
  84215. * @param brightness The brightness (B) input.
  84216. * @result An RGBA color represented as Vector4.
  84217. */
  84218. private static fromHSBToRef;
  84219. /**
  84220. * Returns a value clamped between min and max
  84221. * @param value The value to clamp
  84222. * @param min The minimum of value
  84223. * @param max The maximum of value
  84224. * @returns The clamped value.
  84225. */
  84226. private static clamp;
  84227. /**
  84228. * Clones the current color curve instance.
  84229. * @return The cloned curves
  84230. */
  84231. clone(): ColorCurves;
  84232. /**
  84233. * Serializes the current color curve instance to a json representation.
  84234. * @return a JSON representation
  84235. */
  84236. serialize(): any;
  84237. /**
  84238. * Parses the color curve from a json representation.
  84239. * @param source the JSON source to parse
  84240. * @return The parsed curves
  84241. */
  84242. static Parse(source: any): ColorCurves;
  84243. }
  84244. }
  84245. declare module BABYLON {
  84246. /**
  84247. * Interface to follow in your material defines to integrate easily the
  84248. * Image proccessing functions.
  84249. * @hidden
  84250. */
  84251. export interface IImageProcessingConfigurationDefines {
  84252. IMAGEPROCESSING: boolean;
  84253. VIGNETTE: boolean;
  84254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84255. VIGNETTEBLENDMODEOPAQUE: boolean;
  84256. TONEMAPPING: boolean;
  84257. TONEMAPPING_ACES: boolean;
  84258. CONTRAST: boolean;
  84259. EXPOSURE: boolean;
  84260. COLORCURVES: boolean;
  84261. COLORGRADING: boolean;
  84262. COLORGRADING3D: boolean;
  84263. SAMPLER3DGREENDEPTH: boolean;
  84264. SAMPLER3DBGRMAP: boolean;
  84265. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84266. }
  84267. /**
  84268. * @hidden
  84269. */
  84270. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  84271. IMAGEPROCESSING: boolean;
  84272. VIGNETTE: boolean;
  84273. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84274. VIGNETTEBLENDMODEOPAQUE: boolean;
  84275. TONEMAPPING: boolean;
  84276. TONEMAPPING_ACES: boolean;
  84277. CONTRAST: boolean;
  84278. COLORCURVES: boolean;
  84279. COLORGRADING: boolean;
  84280. COLORGRADING3D: boolean;
  84281. SAMPLER3DGREENDEPTH: boolean;
  84282. SAMPLER3DBGRMAP: boolean;
  84283. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84284. EXPOSURE: boolean;
  84285. constructor();
  84286. }
  84287. /**
  84288. * This groups together the common properties used for image processing either in direct forward pass
  84289. * or through post processing effect depending on the use of the image processing pipeline in your scene
  84290. * or not.
  84291. */
  84292. export class ImageProcessingConfiguration {
  84293. /**
  84294. * Default tone mapping applied in BabylonJS.
  84295. */
  84296. static readonly TONEMAPPING_STANDARD: number;
  84297. /**
  84298. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  84299. * to other engines rendering to increase portability.
  84300. */
  84301. static readonly TONEMAPPING_ACES: number;
  84302. /**
  84303. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  84304. */
  84305. colorCurves: Nullable<ColorCurves>;
  84306. private _colorCurvesEnabled;
  84307. /**
  84308. * Gets wether the color curves effect is enabled.
  84309. */
  84310. get colorCurvesEnabled(): boolean;
  84311. /**
  84312. * Sets wether the color curves effect is enabled.
  84313. */
  84314. set colorCurvesEnabled(value: boolean);
  84315. private _colorGradingTexture;
  84316. /**
  84317. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84318. */
  84319. get colorGradingTexture(): Nullable<BaseTexture>;
  84320. /**
  84321. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84322. */
  84323. set colorGradingTexture(value: Nullable<BaseTexture>);
  84324. private _colorGradingEnabled;
  84325. /**
  84326. * Gets wether the color grading effect is enabled.
  84327. */
  84328. get colorGradingEnabled(): boolean;
  84329. /**
  84330. * Sets wether the color grading effect is enabled.
  84331. */
  84332. set colorGradingEnabled(value: boolean);
  84333. private _colorGradingWithGreenDepth;
  84334. /**
  84335. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  84336. */
  84337. get colorGradingWithGreenDepth(): boolean;
  84338. /**
  84339. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  84340. */
  84341. set colorGradingWithGreenDepth(value: boolean);
  84342. private _colorGradingBGR;
  84343. /**
  84344. * Gets wether the color grading texture contains BGR values.
  84345. */
  84346. get colorGradingBGR(): boolean;
  84347. /**
  84348. * Sets wether the color grading texture contains BGR values.
  84349. */
  84350. set colorGradingBGR(value: boolean);
  84351. /** @hidden */
  84352. _exposure: number;
  84353. /**
  84354. * Gets the Exposure used in the effect.
  84355. */
  84356. get exposure(): number;
  84357. /**
  84358. * Sets the Exposure used in the effect.
  84359. */
  84360. set exposure(value: number);
  84361. private _toneMappingEnabled;
  84362. /**
  84363. * Gets wether the tone mapping effect is enabled.
  84364. */
  84365. get toneMappingEnabled(): boolean;
  84366. /**
  84367. * Sets wether the tone mapping effect is enabled.
  84368. */
  84369. set toneMappingEnabled(value: boolean);
  84370. private _toneMappingType;
  84371. /**
  84372. * Gets the type of tone mapping effect.
  84373. */
  84374. get toneMappingType(): number;
  84375. /**
  84376. * Sets the type of tone mapping effect used in BabylonJS.
  84377. */
  84378. set toneMappingType(value: number);
  84379. protected _contrast: number;
  84380. /**
  84381. * Gets the contrast used in the effect.
  84382. */
  84383. get contrast(): number;
  84384. /**
  84385. * Sets the contrast used in the effect.
  84386. */
  84387. set contrast(value: number);
  84388. /**
  84389. * Vignette stretch size.
  84390. */
  84391. vignetteStretch: number;
  84392. /**
  84393. * Vignette centre X Offset.
  84394. */
  84395. vignetteCentreX: number;
  84396. /**
  84397. * Vignette centre Y Offset.
  84398. */
  84399. vignetteCentreY: number;
  84400. /**
  84401. * Vignette weight or intensity of the vignette effect.
  84402. */
  84403. vignetteWeight: number;
  84404. /**
  84405. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  84406. * if vignetteEnabled is set to true.
  84407. */
  84408. vignetteColor: Color4;
  84409. /**
  84410. * Camera field of view used by the Vignette effect.
  84411. */
  84412. vignetteCameraFov: number;
  84413. private _vignetteBlendMode;
  84414. /**
  84415. * Gets the vignette blend mode allowing different kind of effect.
  84416. */
  84417. get vignetteBlendMode(): number;
  84418. /**
  84419. * Sets the vignette blend mode allowing different kind of effect.
  84420. */
  84421. set vignetteBlendMode(value: number);
  84422. private _vignetteEnabled;
  84423. /**
  84424. * Gets wether the vignette effect is enabled.
  84425. */
  84426. get vignetteEnabled(): boolean;
  84427. /**
  84428. * Sets wether the vignette effect is enabled.
  84429. */
  84430. set vignetteEnabled(value: boolean);
  84431. private _applyByPostProcess;
  84432. /**
  84433. * Gets wether the image processing is applied through a post process or not.
  84434. */
  84435. get applyByPostProcess(): boolean;
  84436. /**
  84437. * Sets wether the image processing is applied through a post process or not.
  84438. */
  84439. set applyByPostProcess(value: boolean);
  84440. private _isEnabled;
  84441. /**
  84442. * Gets wether the image processing is enabled or not.
  84443. */
  84444. get isEnabled(): boolean;
  84445. /**
  84446. * Sets wether the image processing is enabled or not.
  84447. */
  84448. set isEnabled(value: boolean);
  84449. /**
  84450. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  84451. */
  84452. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  84453. /**
  84454. * Method called each time the image processing information changes requires to recompile the effect.
  84455. */
  84456. protected _updateParameters(): void;
  84457. /**
  84458. * Gets the current class name.
  84459. * @return "ImageProcessingConfiguration"
  84460. */
  84461. getClassName(): string;
  84462. /**
  84463. * Prepare the list of uniforms associated with the Image Processing effects.
  84464. * @param uniforms The list of uniforms used in the effect
  84465. * @param defines the list of defines currently in use
  84466. */
  84467. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  84468. /**
  84469. * Prepare the list of samplers associated with the Image Processing effects.
  84470. * @param samplersList The list of uniforms used in the effect
  84471. * @param defines the list of defines currently in use
  84472. */
  84473. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  84474. /**
  84475. * Prepare the list of defines associated to the shader.
  84476. * @param defines the list of defines to complete
  84477. * @param forPostProcess Define if we are currently in post process mode or not
  84478. */
  84479. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  84480. /**
  84481. * Returns true if all the image processing information are ready.
  84482. * @returns True if ready, otherwise, false
  84483. */
  84484. isReady(): boolean;
  84485. /**
  84486. * Binds the image processing to the shader.
  84487. * @param effect The effect to bind to
  84488. * @param overrideAspectRatio Override the aspect ratio of the effect
  84489. */
  84490. bind(effect: Effect, overrideAspectRatio?: number): void;
  84491. /**
  84492. * Clones the current image processing instance.
  84493. * @return The cloned image processing
  84494. */
  84495. clone(): ImageProcessingConfiguration;
  84496. /**
  84497. * Serializes the current image processing instance to a json representation.
  84498. * @return a JSON representation
  84499. */
  84500. serialize(): any;
  84501. /**
  84502. * Parses the image processing from a json representation.
  84503. * @param source the JSON source to parse
  84504. * @return The parsed image processing
  84505. */
  84506. static Parse(source: any): ImageProcessingConfiguration;
  84507. private static _VIGNETTEMODE_MULTIPLY;
  84508. private static _VIGNETTEMODE_OPAQUE;
  84509. /**
  84510. * Used to apply the vignette as a mix with the pixel color.
  84511. */
  84512. static get VIGNETTEMODE_MULTIPLY(): number;
  84513. /**
  84514. * Used to apply the vignette as a replacement of the pixel color.
  84515. */
  84516. static get VIGNETTEMODE_OPAQUE(): number;
  84517. }
  84518. }
  84519. declare module BABYLON {
  84520. /** @hidden */
  84521. export var postprocessVertexShader: {
  84522. name: string;
  84523. shader: string;
  84524. };
  84525. }
  84526. declare module BABYLON {
  84527. interface ThinEngine {
  84528. /**
  84529. * Creates a new render target texture
  84530. * @param size defines the size of the texture
  84531. * @param options defines the options used to create the texture
  84532. * @returns a new render target texture stored in an InternalTexture
  84533. */
  84534. createRenderTargetTexture(size: number | {
  84535. width: number;
  84536. height: number;
  84537. layers?: number;
  84538. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84539. /**
  84540. * Creates a depth stencil texture.
  84541. * This is only available in WebGL 2 or with the depth texture extension available.
  84542. * @param size The size of face edge in the texture.
  84543. * @param options The options defining the texture.
  84544. * @returns The texture
  84545. */
  84546. createDepthStencilTexture(size: number | {
  84547. width: number;
  84548. height: number;
  84549. layers?: number;
  84550. }, options: DepthTextureCreationOptions): InternalTexture;
  84551. /** @hidden */
  84552. _createDepthStencilTexture(size: number | {
  84553. width: number;
  84554. height: number;
  84555. layers?: number;
  84556. }, options: DepthTextureCreationOptions): InternalTexture;
  84557. }
  84558. }
  84559. declare module BABYLON {
  84560. /** Defines supported spaces */
  84561. export enum Space {
  84562. /** Local (object) space */
  84563. LOCAL = 0,
  84564. /** World space */
  84565. WORLD = 1,
  84566. /** Bone space */
  84567. BONE = 2
  84568. }
  84569. /** Defines the 3 main axes */
  84570. export class Axis {
  84571. /** X axis */
  84572. static X: Vector3;
  84573. /** Y axis */
  84574. static Y: Vector3;
  84575. /** Z axis */
  84576. static Z: Vector3;
  84577. }
  84578. }
  84579. declare module BABYLON {
  84580. /**
  84581. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  84582. * This is the base of the follow, arc rotate cameras and Free camera
  84583. * @see http://doc.babylonjs.com/features/cameras
  84584. */
  84585. export class TargetCamera extends Camera {
  84586. private static _RigCamTransformMatrix;
  84587. private static _TargetTransformMatrix;
  84588. private static _TargetFocalPoint;
  84589. /**
  84590. * Define the current direction the camera is moving to
  84591. */
  84592. cameraDirection: Vector3;
  84593. /**
  84594. * Define the current rotation the camera is rotating to
  84595. */
  84596. cameraRotation: Vector2;
  84597. /**
  84598. * When set, the up vector of the camera will be updated by the rotation of the camera
  84599. */
  84600. updateUpVectorFromRotation: boolean;
  84601. private _tmpQuaternion;
  84602. /**
  84603. * Define the current rotation of the camera
  84604. */
  84605. rotation: Vector3;
  84606. /**
  84607. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  84608. */
  84609. rotationQuaternion: Quaternion;
  84610. /**
  84611. * Define the current speed of the camera
  84612. */
  84613. speed: number;
  84614. /**
  84615. * Add constraint to the camera to prevent it to move freely in all directions and
  84616. * around all axis.
  84617. */
  84618. noRotationConstraint: boolean;
  84619. /**
  84620. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  84621. * panning
  84622. */
  84623. invertRotation: boolean;
  84624. /**
  84625. * Speed multiplier for inverse camera panning
  84626. */
  84627. inverseRotationSpeed: number;
  84628. /**
  84629. * Define the current target of the camera as an object or a position.
  84630. */
  84631. lockedTarget: any;
  84632. /** @hidden */
  84633. _currentTarget: Vector3;
  84634. /** @hidden */
  84635. _initialFocalDistance: number;
  84636. /** @hidden */
  84637. _viewMatrix: Matrix;
  84638. /** @hidden */
  84639. _camMatrix: Matrix;
  84640. /** @hidden */
  84641. _cameraTransformMatrix: Matrix;
  84642. /** @hidden */
  84643. _cameraRotationMatrix: Matrix;
  84644. /** @hidden */
  84645. _referencePoint: Vector3;
  84646. /** @hidden */
  84647. _transformedReferencePoint: Vector3;
  84648. protected _globalCurrentTarget: Vector3;
  84649. protected _globalCurrentUpVector: Vector3;
  84650. /** @hidden */
  84651. _reset: () => void;
  84652. private _defaultUp;
  84653. /**
  84654. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  84655. * This is the base of the follow, arc rotate cameras and Free camera
  84656. * @see http://doc.babylonjs.com/features/cameras
  84657. * @param name Defines the name of the camera in the scene
  84658. * @param position Defines the start position of the camera in the scene
  84659. * @param scene Defines the scene the camera belongs to
  84660. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84661. */
  84662. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84663. /**
  84664. * Gets the position in front of the camera at a given distance.
  84665. * @param distance The distance from the camera we want the position to be
  84666. * @returns the position
  84667. */
  84668. getFrontPosition(distance: number): Vector3;
  84669. /** @hidden */
  84670. _getLockedTargetPosition(): Nullable<Vector3>;
  84671. private _storedPosition;
  84672. private _storedRotation;
  84673. private _storedRotationQuaternion;
  84674. /**
  84675. * Store current camera state of the camera (fov, position, rotation, etc..)
  84676. * @returns the camera
  84677. */
  84678. storeState(): Camera;
  84679. /**
  84680. * Restored camera state. You must call storeState() first
  84681. * @returns whether it was successful or not
  84682. * @hidden
  84683. */
  84684. _restoreStateValues(): boolean;
  84685. /** @hidden */
  84686. _initCache(): void;
  84687. /** @hidden */
  84688. _updateCache(ignoreParentClass?: boolean): void;
  84689. /** @hidden */
  84690. _isSynchronizedViewMatrix(): boolean;
  84691. /** @hidden */
  84692. _computeLocalCameraSpeed(): number;
  84693. /**
  84694. * Defines the target the camera should look at.
  84695. * @param target Defines the new target as a Vector or a mesh
  84696. */
  84697. setTarget(target: Vector3): void;
  84698. /**
  84699. * Return the current target position of the camera. This value is expressed in local space.
  84700. * @returns the target position
  84701. */
  84702. getTarget(): Vector3;
  84703. /** @hidden */
  84704. _decideIfNeedsToMove(): boolean;
  84705. /** @hidden */
  84706. _updatePosition(): void;
  84707. /** @hidden */
  84708. _checkInputs(): void;
  84709. protected _updateCameraRotationMatrix(): void;
  84710. /**
  84711. * 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)
  84712. * @returns the current camera
  84713. */
  84714. private _rotateUpVectorWithCameraRotationMatrix;
  84715. private _cachedRotationZ;
  84716. private _cachedQuaternionRotationZ;
  84717. /** @hidden */
  84718. _getViewMatrix(): Matrix;
  84719. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  84720. /**
  84721. * @hidden
  84722. */
  84723. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  84724. /**
  84725. * @hidden
  84726. */
  84727. _updateRigCameras(): void;
  84728. private _getRigCamPositionAndTarget;
  84729. /**
  84730. * Gets the current object class name.
  84731. * @return the class name
  84732. */
  84733. getClassName(): string;
  84734. }
  84735. }
  84736. declare module BABYLON {
  84737. /**
  84738. * Gather the list of keyboard event types as constants.
  84739. */
  84740. export class KeyboardEventTypes {
  84741. /**
  84742. * The keydown event is fired when a key becomes active (pressed).
  84743. */
  84744. static readonly KEYDOWN: number;
  84745. /**
  84746. * The keyup event is fired when a key has been released.
  84747. */
  84748. static readonly KEYUP: number;
  84749. }
  84750. /**
  84751. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84752. */
  84753. export class KeyboardInfo {
  84754. /**
  84755. * Defines the type of event (KeyboardEventTypes)
  84756. */
  84757. type: number;
  84758. /**
  84759. * Defines the related dom event
  84760. */
  84761. event: KeyboardEvent;
  84762. /**
  84763. * Instantiates a new keyboard info.
  84764. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84765. * @param type Defines the type of event (KeyboardEventTypes)
  84766. * @param event Defines the related dom event
  84767. */
  84768. constructor(
  84769. /**
  84770. * Defines the type of event (KeyboardEventTypes)
  84771. */
  84772. type: number,
  84773. /**
  84774. * Defines the related dom event
  84775. */
  84776. event: KeyboardEvent);
  84777. }
  84778. /**
  84779. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84780. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  84781. */
  84782. export class KeyboardInfoPre extends KeyboardInfo {
  84783. /**
  84784. * Defines the type of event (KeyboardEventTypes)
  84785. */
  84786. type: number;
  84787. /**
  84788. * Defines the related dom event
  84789. */
  84790. event: KeyboardEvent;
  84791. /**
  84792. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  84793. */
  84794. skipOnPointerObservable: boolean;
  84795. /**
  84796. * Instantiates a new keyboard pre info.
  84797. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84798. * @param type Defines the type of event (KeyboardEventTypes)
  84799. * @param event Defines the related dom event
  84800. */
  84801. constructor(
  84802. /**
  84803. * Defines the type of event (KeyboardEventTypes)
  84804. */
  84805. type: number,
  84806. /**
  84807. * Defines the related dom event
  84808. */
  84809. event: KeyboardEvent);
  84810. }
  84811. }
  84812. declare module BABYLON {
  84813. /**
  84814. * Manage the keyboard inputs to control the movement of a free camera.
  84815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84816. */
  84817. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  84818. /**
  84819. * Defines the camera the input is attached to.
  84820. */
  84821. camera: FreeCamera;
  84822. /**
  84823. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84824. */
  84825. keysUp: number[];
  84826. /**
  84827. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  84828. */
  84829. keysUpward: number[];
  84830. /**
  84831. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84832. */
  84833. keysDown: number[];
  84834. /**
  84835. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  84836. */
  84837. keysDownward: number[];
  84838. /**
  84839. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84840. */
  84841. keysLeft: number[];
  84842. /**
  84843. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84844. */
  84845. keysRight: number[];
  84846. private _keys;
  84847. private _onCanvasBlurObserver;
  84848. private _onKeyboardObserver;
  84849. private _engine;
  84850. private _scene;
  84851. /**
  84852. * Attach the input controls to a specific dom element to get the input from.
  84853. * @param element Defines the element the controls should be listened from
  84854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84855. */
  84856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84857. /**
  84858. * Detach the current controls from the specified dom element.
  84859. * @param element Defines the element to stop listening the inputs from
  84860. */
  84861. detachControl(element: Nullable<HTMLElement>): void;
  84862. /**
  84863. * Update the current camera state depending on the inputs that have been used this frame.
  84864. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84865. */
  84866. checkInputs(): void;
  84867. /**
  84868. * Gets the class name of the current intput.
  84869. * @returns the class name
  84870. */
  84871. getClassName(): string;
  84872. /** @hidden */
  84873. _onLostFocus(): void;
  84874. /**
  84875. * Get the friendly name associated with the input class.
  84876. * @returns the input friendly name
  84877. */
  84878. getSimpleName(): string;
  84879. }
  84880. }
  84881. declare module BABYLON {
  84882. /**
  84883. * Interface describing all the common properties and methods a shadow light needs to implement.
  84884. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  84885. * as well as binding the different shadow properties to the effects.
  84886. */
  84887. export interface IShadowLight extends Light {
  84888. /**
  84889. * The light id in the scene (used in scene.findLighById for instance)
  84890. */
  84891. id: string;
  84892. /**
  84893. * The position the shdow will be casted from.
  84894. */
  84895. position: Vector3;
  84896. /**
  84897. * In 2d mode (needCube being false), the direction used to cast the shadow.
  84898. */
  84899. direction: Vector3;
  84900. /**
  84901. * The transformed position. Position of the light in world space taking parenting in account.
  84902. */
  84903. transformedPosition: Vector3;
  84904. /**
  84905. * The transformed direction. Direction of the light in world space taking parenting in account.
  84906. */
  84907. transformedDirection: Vector3;
  84908. /**
  84909. * The friendly name of the light in the scene.
  84910. */
  84911. name: string;
  84912. /**
  84913. * Defines the shadow projection clipping minimum z value.
  84914. */
  84915. shadowMinZ: number;
  84916. /**
  84917. * Defines the shadow projection clipping maximum z value.
  84918. */
  84919. shadowMaxZ: number;
  84920. /**
  84921. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84922. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84923. */
  84924. computeTransformedInformation(): boolean;
  84925. /**
  84926. * Gets the scene the light belongs to.
  84927. * @returns The scene
  84928. */
  84929. getScene(): Scene;
  84930. /**
  84931. * Callback defining a custom Projection Matrix Builder.
  84932. * This can be used to override the default projection matrix computation.
  84933. */
  84934. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84935. /**
  84936. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84937. * @param matrix The materix to updated with the projection information
  84938. * @param viewMatrix The transform matrix of the light
  84939. * @param renderList The list of mesh to render in the map
  84940. * @returns The current light
  84941. */
  84942. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84943. /**
  84944. * Gets the current depth scale used in ESM.
  84945. * @returns The scale
  84946. */
  84947. getDepthScale(): number;
  84948. /**
  84949. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84950. * @returns true if a cube texture needs to be use
  84951. */
  84952. needCube(): boolean;
  84953. /**
  84954. * Detects if the projection matrix requires to be recomputed this frame.
  84955. * @returns true if it requires to be recomputed otherwise, false.
  84956. */
  84957. needProjectionMatrixCompute(): boolean;
  84958. /**
  84959. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84960. */
  84961. forceProjectionMatrixCompute(): void;
  84962. /**
  84963. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84964. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84965. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84966. */
  84967. getShadowDirection(faceIndex?: number): Vector3;
  84968. /**
  84969. * Gets the minZ used for shadow according to both the scene and the light.
  84970. * @param activeCamera The camera we are returning the min for
  84971. * @returns the depth min z
  84972. */
  84973. getDepthMinZ(activeCamera: Camera): number;
  84974. /**
  84975. * Gets the maxZ used for shadow according to both the scene and the light.
  84976. * @param activeCamera The camera we are returning the max for
  84977. * @returns the depth max z
  84978. */
  84979. getDepthMaxZ(activeCamera: Camera): number;
  84980. }
  84981. /**
  84982. * Base implementation IShadowLight
  84983. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  84984. */
  84985. export abstract class ShadowLight extends Light implements IShadowLight {
  84986. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  84987. protected _position: Vector3;
  84988. protected _setPosition(value: Vector3): void;
  84989. /**
  84990. * Sets the position the shadow will be casted from. Also use as the light position for both
  84991. * point and spot lights.
  84992. */
  84993. get position(): Vector3;
  84994. /**
  84995. * Sets the position the shadow will be casted from. Also use as the light position for both
  84996. * point and spot lights.
  84997. */
  84998. set position(value: Vector3);
  84999. protected _direction: Vector3;
  85000. protected _setDirection(value: Vector3): void;
  85001. /**
  85002. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  85003. * Also use as the light direction on spot and directional lights.
  85004. */
  85005. get direction(): Vector3;
  85006. /**
  85007. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  85008. * Also use as the light direction on spot and directional lights.
  85009. */
  85010. set direction(value: Vector3);
  85011. protected _shadowMinZ: number;
  85012. /**
  85013. * Gets the shadow projection clipping minimum z value.
  85014. */
  85015. get shadowMinZ(): number;
  85016. /**
  85017. * Sets the shadow projection clipping minimum z value.
  85018. */
  85019. set shadowMinZ(value: number);
  85020. protected _shadowMaxZ: number;
  85021. /**
  85022. * Sets the shadow projection clipping maximum z value.
  85023. */
  85024. get shadowMaxZ(): number;
  85025. /**
  85026. * Gets the shadow projection clipping maximum z value.
  85027. */
  85028. set shadowMaxZ(value: number);
  85029. /**
  85030. * Callback defining a custom Projection Matrix Builder.
  85031. * This can be used to override the default projection matrix computation.
  85032. */
  85033. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  85034. /**
  85035. * The transformed position. Position of the light in world space taking parenting in account.
  85036. */
  85037. transformedPosition: Vector3;
  85038. /**
  85039. * The transformed direction. Direction of the light in world space taking parenting in account.
  85040. */
  85041. transformedDirection: Vector3;
  85042. private _needProjectionMatrixCompute;
  85043. /**
  85044. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  85045. * @returns true if the information has been computed, false if it does not need to (no parenting)
  85046. */
  85047. computeTransformedInformation(): boolean;
  85048. /**
  85049. * Return the depth scale used for the shadow map.
  85050. * @returns the depth scale.
  85051. */
  85052. getDepthScale(): number;
  85053. /**
  85054. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  85055. * @param faceIndex The index of the face we are computed the direction to generate shadow
  85056. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  85057. */
  85058. getShadowDirection(faceIndex?: number): Vector3;
  85059. /**
  85060. * Returns the ShadowLight absolute position in the World.
  85061. * @returns the position vector in world space
  85062. */
  85063. getAbsolutePosition(): Vector3;
  85064. /**
  85065. * Sets the ShadowLight direction toward the passed target.
  85066. * @param target The point to target in local space
  85067. * @returns the updated ShadowLight direction
  85068. */
  85069. setDirectionToTarget(target: Vector3): Vector3;
  85070. /**
  85071. * Returns the light rotation in euler definition.
  85072. * @returns the x y z rotation in local space.
  85073. */
  85074. getRotation(): Vector3;
  85075. /**
  85076. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  85077. * @returns true if a cube texture needs to be use
  85078. */
  85079. needCube(): boolean;
  85080. /**
  85081. * Detects if the projection matrix requires to be recomputed this frame.
  85082. * @returns true if it requires to be recomputed otherwise, false.
  85083. */
  85084. needProjectionMatrixCompute(): boolean;
  85085. /**
  85086. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  85087. */
  85088. forceProjectionMatrixCompute(): void;
  85089. /** @hidden */
  85090. _initCache(): void;
  85091. /** @hidden */
  85092. _isSynchronized(): boolean;
  85093. /**
  85094. * Computes the world matrix of the node
  85095. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85096. * @returns the world matrix
  85097. */
  85098. computeWorldMatrix(force?: boolean): Matrix;
  85099. /**
  85100. * Gets the minZ used for shadow according to both the scene and the light.
  85101. * @param activeCamera The camera we are returning the min for
  85102. * @returns the depth min z
  85103. */
  85104. getDepthMinZ(activeCamera: Camera): number;
  85105. /**
  85106. * Gets the maxZ used for shadow according to both the scene and the light.
  85107. * @param activeCamera The camera we are returning the max for
  85108. * @returns the depth max z
  85109. */
  85110. getDepthMaxZ(activeCamera: Camera): number;
  85111. /**
  85112. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  85113. * @param matrix The materix to updated with the projection information
  85114. * @param viewMatrix The transform matrix of the light
  85115. * @param renderList The list of mesh to render in the map
  85116. * @returns The current light
  85117. */
  85118. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  85119. }
  85120. }
  85121. declare module BABYLON {
  85122. /**
  85123. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85124. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85125. */
  85126. export class EffectFallbacks implements IEffectFallbacks {
  85127. private _defines;
  85128. private _currentRank;
  85129. private _maxRank;
  85130. private _mesh;
  85131. /**
  85132. * Removes the fallback from the bound mesh.
  85133. */
  85134. unBindMesh(): void;
  85135. /**
  85136. * Adds a fallback on the specified property.
  85137. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85138. * @param define The name of the define in the shader
  85139. */
  85140. addFallback(rank: number, define: string): void;
  85141. /**
  85142. * Sets the mesh to use CPU skinning when needing to fallback.
  85143. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85144. * @param mesh The mesh to use the fallbacks.
  85145. */
  85146. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85147. /**
  85148. * Checks to see if more fallbacks are still availible.
  85149. */
  85150. get hasMoreFallbacks(): boolean;
  85151. /**
  85152. * Removes the defines that should be removed when falling back.
  85153. * @param currentDefines defines the current define statements for the shader.
  85154. * @param effect defines the current effect we try to compile
  85155. * @returns The resulting defines with defines of the current rank removed.
  85156. */
  85157. reduce(currentDefines: string, effect: Effect): string;
  85158. }
  85159. }
  85160. declare module BABYLON {
  85161. /**
  85162. * "Static Class" containing the most commonly used helper while dealing with material for
  85163. * rendering purpose.
  85164. *
  85165. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  85166. *
  85167. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  85168. */
  85169. export class MaterialHelper {
  85170. /**
  85171. * Bind the current view position to an effect.
  85172. * @param effect The effect to be bound
  85173. * @param scene The scene the eyes position is used from
  85174. * @param variableName name of the shader variable that will hold the eye position
  85175. */
  85176. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  85177. /**
  85178. * Helps preparing the defines values about the UVs in used in the effect.
  85179. * UVs are shared as much as we can accross channels in the shaders.
  85180. * @param texture The texture we are preparing the UVs for
  85181. * @param defines The defines to update
  85182. * @param key The channel key "diffuse", "specular"... used in the shader
  85183. */
  85184. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  85185. /**
  85186. * Binds a texture matrix value to its corrsponding uniform
  85187. * @param texture The texture to bind the matrix for
  85188. * @param uniformBuffer The uniform buffer receivin the data
  85189. * @param key The channel key "diffuse", "specular"... used in the shader
  85190. */
  85191. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  85192. /**
  85193. * Gets the current status of the fog (should it be enabled?)
  85194. * @param mesh defines the mesh to evaluate for fog support
  85195. * @param scene defines the hosting scene
  85196. * @returns true if fog must be enabled
  85197. */
  85198. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  85199. /**
  85200. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  85201. * @param mesh defines the current mesh
  85202. * @param scene defines the current scene
  85203. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  85204. * @param pointsCloud defines if point cloud rendering has to be turned on
  85205. * @param fogEnabled defines if fog has to be turned on
  85206. * @param alphaTest defines if alpha testing has to be turned on
  85207. * @param defines defines the current list of defines
  85208. */
  85209. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  85210. /**
  85211. * Helper used to prepare the list of defines associated with frame values for shader compilation
  85212. * @param scene defines the current scene
  85213. * @param engine defines the current engine
  85214. * @param defines specifies the list of active defines
  85215. * @param useInstances defines if instances have to be turned on
  85216. * @param useClipPlane defines if clip plane have to be turned on
  85217. */
  85218. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  85219. /**
  85220. * Prepares the defines for bones
  85221. * @param mesh The mesh containing the geometry data we will draw
  85222. * @param defines The defines to update
  85223. */
  85224. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  85225. /**
  85226. * Prepares the defines for morph targets
  85227. * @param mesh The mesh containing the geometry data we will draw
  85228. * @param defines The defines to update
  85229. */
  85230. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  85231. /**
  85232. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  85233. * @param mesh The mesh containing the geometry data we will draw
  85234. * @param defines The defines to update
  85235. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  85236. * @param useBones Precise whether bones should be used or not (override mesh info)
  85237. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  85238. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  85239. * @returns false if defines are considered not dirty and have not been checked
  85240. */
  85241. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  85242. /**
  85243. * Prepares the defines related to multiview
  85244. * @param scene The scene we are intending to draw
  85245. * @param defines The defines to update
  85246. */
  85247. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  85248. /**
  85249. * Prepares the defines related to the light information passed in parameter
  85250. * @param scene The scene we are intending to draw
  85251. * @param mesh The mesh the effect is compiling for
  85252. * @param light The light the effect is compiling for
  85253. * @param lightIndex The index of the light
  85254. * @param defines The defines to update
  85255. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85256. * @param state Defines the current state regarding what is needed (normals, etc...)
  85257. */
  85258. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  85259. needNormals: boolean;
  85260. needRebuild: boolean;
  85261. shadowEnabled: boolean;
  85262. specularEnabled: boolean;
  85263. lightmapMode: boolean;
  85264. }): void;
  85265. /**
  85266. * Prepares the defines related to the light information passed in parameter
  85267. * @param scene The scene we are intending to draw
  85268. * @param mesh The mesh the effect is compiling for
  85269. * @param defines The defines to update
  85270. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85271. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  85272. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  85273. * @returns true if normals will be required for the rest of the effect
  85274. */
  85275. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  85276. /**
  85277. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  85278. * @param lightIndex defines the light index
  85279. * @param uniformsList The uniform list
  85280. * @param samplersList The sampler list
  85281. * @param projectedLightTexture defines if projected texture must be used
  85282. * @param uniformBuffersList defines an optional list of uniform buffers
  85283. */
  85284. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  85285. /**
  85286. * Prepares the uniforms and samplers list to be used in the effect
  85287. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  85288. * @param samplersList The sampler list
  85289. * @param defines The defines helping in the list generation
  85290. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  85291. */
  85292. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  85293. /**
  85294. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  85295. * @param defines The defines to update while falling back
  85296. * @param fallbacks The authorized effect fallbacks
  85297. * @param maxSimultaneousLights The maximum number of lights allowed
  85298. * @param rank the current rank of the Effect
  85299. * @returns The newly affected rank
  85300. */
  85301. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  85302. private static _TmpMorphInfluencers;
  85303. /**
  85304. * Prepares the list of attributes required for morph targets according to the effect defines.
  85305. * @param attribs The current list of supported attribs
  85306. * @param mesh The mesh to prepare the morph targets attributes for
  85307. * @param influencers The number of influencers
  85308. */
  85309. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  85310. /**
  85311. * Prepares the list of attributes required for morph targets according to the effect defines.
  85312. * @param attribs The current list of supported attribs
  85313. * @param mesh The mesh to prepare the morph targets attributes for
  85314. * @param defines The current Defines of the effect
  85315. */
  85316. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  85317. /**
  85318. * Prepares the list of attributes required for bones according to the effect defines.
  85319. * @param attribs The current list of supported attribs
  85320. * @param mesh The mesh to prepare the bones attributes for
  85321. * @param defines The current Defines of the effect
  85322. * @param fallbacks The current efffect fallback strategy
  85323. */
  85324. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  85325. /**
  85326. * Check and prepare the list of attributes required for instances according to the effect defines.
  85327. * @param attribs The current list of supported attribs
  85328. * @param defines The current MaterialDefines of the effect
  85329. */
  85330. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  85331. /**
  85332. * Add the list of attributes required for instances to the attribs array.
  85333. * @param attribs The current list of supported attribs
  85334. */
  85335. static PushAttributesForInstances(attribs: string[]): void;
  85336. /**
  85337. * Binds the light information to the effect.
  85338. * @param light The light containing the generator
  85339. * @param effect The effect we are binding the data to
  85340. * @param lightIndex The light index in the effect used to render
  85341. */
  85342. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  85343. /**
  85344. * Binds the lights information from the scene to the effect for the given mesh.
  85345. * @param light Light to bind
  85346. * @param lightIndex Light index
  85347. * @param scene The scene where the light belongs to
  85348. * @param effect The effect we are binding the data to
  85349. * @param useSpecular Defines if specular is supported
  85350. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85351. */
  85352. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  85353. /**
  85354. * Binds the lights information from the scene to the effect for the given mesh.
  85355. * @param scene The scene the lights belongs to
  85356. * @param mesh The mesh we are binding the information to render
  85357. * @param effect The effect we are binding the data to
  85358. * @param defines The generated defines for the effect
  85359. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  85360. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85361. */
  85362. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  85363. private static _tempFogColor;
  85364. /**
  85365. * Binds the fog information from the scene to the effect for the given mesh.
  85366. * @param scene The scene the lights belongs to
  85367. * @param mesh The mesh we are binding the information to render
  85368. * @param effect The effect we are binding the data to
  85369. * @param linearSpace Defines if the fog effect is applied in linear space
  85370. */
  85371. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  85372. /**
  85373. * Binds the bones information from the mesh to the effect.
  85374. * @param mesh The mesh we are binding the information to render
  85375. * @param effect The effect we are binding the data to
  85376. */
  85377. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  85378. /**
  85379. * Binds the morph targets information from the mesh to the effect.
  85380. * @param abstractMesh The mesh we are binding the information to render
  85381. * @param effect The effect we are binding the data to
  85382. */
  85383. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  85384. /**
  85385. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  85386. * @param defines The generated defines used in the effect
  85387. * @param effect The effect we are binding the data to
  85388. * @param scene The scene we are willing to render with logarithmic scale for
  85389. */
  85390. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  85391. /**
  85392. * Binds the clip plane information from the scene to the effect.
  85393. * @param scene The scene the clip plane information are extracted from
  85394. * @param effect The effect we are binding the data to
  85395. */
  85396. static BindClipPlane(effect: Effect, scene: Scene): void;
  85397. }
  85398. }
  85399. declare module BABYLON {
  85400. /** @hidden */
  85401. export var packingFunctions: {
  85402. name: string;
  85403. shader: string;
  85404. };
  85405. }
  85406. declare module BABYLON {
  85407. /** @hidden */
  85408. export var bayerDitherFunctions: {
  85409. name: string;
  85410. shader: string;
  85411. };
  85412. }
  85413. declare module BABYLON {
  85414. /** @hidden */
  85415. export var shadowMapFragmentDeclaration: {
  85416. name: string;
  85417. shader: string;
  85418. };
  85419. }
  85420. declare module BABYLON {
  85421. /** @hidden */
  85422. export var clipPlaneFragmentDeclaration: {
  85423. name: string;
  85424. shader: string;
  85425. };
  85426. }
  85427. declare module BABYLON {
  85428. /** @hidden */
  85429. export var clipPlaneFragment: {
  85430. name: string;
  85431. shader: string;
  85432. };
  85433. }
  85434. declare module BABYLON {
  85435. /** @hidden */
  85436. export var shadowMapFragment: {
  85437. name: string;
  85438. shader: string;
  85439. };
  85440. }
  85441. declare module BABYLON {
  85442. /** @hidden */
  85443. export var shadowMapPixelShader: {
  85444. name: string;
  85445. shader: string;
  85446. };
  85447. }
  85448. declare module BABYLON {
  85449. /** @hidden */
  85450. export var bonesDeclaration: {
  85451. name: string;
  85452. shader: string;
  85453. };
  85454. }
  85455. declare module BABYLON {
  85456. /** @hidden */
  85457. export var morphTargetsVertexGlobalDeclaration: {
  85458. name: string;
  85459. shader: string;
  85460. };
  85461. }
  85462. declare module BABYLON {
  85463. /** @hidden */
  85464. export var morphTargetsVertexDeclaration: {
  85465. name: string;
  85466. shader: string;
  85467. };
  85468. }
  85469. declare module BABYLON {
  85470. /** @hidden */
  85471. export var instancesDeclaration: {
  85472. name: string;
  85473. shader: string;
  85474. };
  85475. }
  85476. declare module BABYLON {
  85477. /** @hidden */
  85478. export var helperFunctions: {
  85479. name: string;
  85480. shader: string;
  85481. };
  85482. }
  85483. declare module BABYLON {
  85484. /** @hidden */
  85485. export var shadowMapVertexDeclaration: {
  85486. name: string;
  85487. shader: string;
  85488. };
  85489. }
  85490. declare module BABYLON {
  85491. /** @hidden */
  85492. export var clipPlaneVertexDeclaration: {
  85493. name: string;
  85494. shader: string;
  85495. };
  85496. }
  85497. declare module BABYLON {
  85498. /** @hidden */
  85499. export var morphTargetsVertex: {
  85500. name: string;
  85501. shader: string;
  85502. };
  85503. }
  85504. declare module BABYLON {
  85505. /** @hidden */
  85506. export var instancesVertex: {
  85507. name: string;
  85508. shader: string;
  85509. };
  85510. }
  85511. declare module BABYLON {
  85512. /** @hidden */
  85513. export var bonesVertex: {
  85514. name: string;
  85515. shader: string;
  85516. };
  85517. }
  85518. declare module BABYLON {
  85519. /** @hidden */
  85520. export var shadowMapVertexNormalBias: {
  85521. name: string;
  85522. shader: string;
  85523. };
  85524. }
  85525. declare module BABYLON {
  85526. /** @hidden */
  85527. export var shadowMapVertexMetric: {
  85528. name: string;
  85529. shader: string;
  85530. };
  85531. }
  85532. declare module BABYLON {
  85533. /** @hidden */
  85534. export var clipPlaneVertex: {
  85535. name: string;
  85536. shader: string;
  85537. };
  85538. }
  85539. declare module BABYLON {
  85540. /** @hidden */
  85541. export var shadowMapVertexShader: {
  85542. name: string;
  85543. shader: string;
  85544. };
  85545. }
  85546. declare module BABYLON {
  85547. /** @hidden */
  85548. export var depthBoxBlurPixelShader: {
  85549. name: string;
  85550. shader: string;
  85551. };
  85552. }
  85553. declare module BABYLON {
  85554. /** @hidden */
  85555. export var shadowMapFragmentSoftTransparentShadow: {
  85556. name: string;
  85557. shader: string;
  85558. };
  85559. }
  85560. declare module BABYLON {
  85561. /**
  85562. * Class representing a ray with position and direction
  85563. */
  85564. export class Ray {
  85565. /** origin point */
  85566. origin: Vector3;
  85567. /** direction */
  85568. direction: Vector3;
  85569. /** length of the ray */
  85570. length: number;
  85571. private static readonly TmpVector3;
  85572. private _tmpRay;
  85573. /**
  85574. * Creates a new ray
  85575. * @param origin origin point
  85576. * @param direction direction
  85577. * @param length length of the ray
  85578. */
  85579. constructor(
  85580. /** origin point */
  85581. origin: Vector3,
  85582. /** direction */
  85583. direction: Vector3,
  85584. /** length of the ray */
  85585. length?: number);
  85586. /**
  85587. * Checks if the ray intersects a box
  85588. * This does not account for the ray lenght by design to improve perfs.
  85589. * @param minimum bound of the box
  85590. * @param maximum bound of the box
  85591. * @param intersectionTreshold extra extend to be added to the box in all direction
  85592. * @returns if the box was hit
  85593. */
  85594. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  85595. /**
  85596. * Checks if the ray intersects a box
  85597. * This does not account for the ray lenght by design to improve perfs.
  85598. * @param box the bounding box to check
  85599. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  85600. * @returns if the box was hit
  85601. */
  85602. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  85603. /**
  85604. * If the ray hits a sphere
  85605. * @param sphere the bounding sphere to check
  85606. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  85607. * @returns true if it hits the sphere
  85608. */
  85609. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  85610. /**
  85611. * If the ray hits a triange
  85612. * @param vertex0 triangle vertex
  85613. * @param vertex1 triangle vertex
  85614. * @param vertex2 triangle vertex
  85615. * @returns intersection information if hit
  85616. */
  85617. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  85618. /**
  85619. * Checks if ray intersects a plane
  85620. * @param plane the plane to check
  85621. * @returns the distance away it was hit
  85622. */
  85623. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  85624. /**
  85625. * Calculate the intercept of a ray on a given axis
  85626. * @param axis to check 'x' | 'y' | 'z'
  85627. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  85628. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  85629. */
  85630. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  85631. /**
  85632. * Checks if ray intersects a mesh
  85633. * @param mesh the mesh to check
  85634. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85635. * @returns picking info of the intersecton
  85636. */
  85637. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  85638. /**
  85639. * Checks if ray intersects a mesh
  85640. * @param meshes the meshes to check
  85641. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85642. * @param results array to store result in
  85643. * @returns Array of picking infos
  85644. */
  85645. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  85646. private _comparePickingInfo;
  85647. private static smallnum;
  85648. private static rayl;
  85649. /**
  85650. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  85651. * @param sega the first point of the segment to test the intersection against
  85652. * @param segb the second point of the segment to test the intersection against
  85653. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  85654. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  85655. */
  85656. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  85657. /**
  85658. * Update the ray from viewport position
  85659. * @param x position
  85660. * @param y y position
  85661. * @param viewportWidth viewport width
  85662. * @param viewportHeight viewport height
  85663. * @param world world matrix
  85664. * @param view view matrix
  85665. * @param projection projection matrix
  85666. * @returns this ray updated
  85667. */
  85668. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85669. /**
  85670. * Creates a ray with origin and direction of 0,0,0
  85671. * @returns the new ray
  85672. */
  85673. static Zero(): Ray;
  85674. /**
  85675. * Creates a new ray from screen space and viewport
  85676. * @param x position
  85677. * @param y y position
  85678. * @param viewportWidth viewport width
  85679. * @param viewportHeight viewport height
  85680. * @param world world matrix
  85681. * @param view view matrix
  85682. * @param projection projection matrix
  85683. * @returns new ray
  85684. */
  85685. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85686. /**
  85687. * 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
  85688. * transformed to the given world matrix.
  85689. * @param origin The origin point
  85690. * @param end The end point
  85691. * @param world a matrix to transform the ray to. Default is the identity matrix.
  85692. * @returns the new ray
  85693. */
  85694. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  85695. /**
  85696. * Transforms a ray by a matrix
  85697. * @param ray ray to transform
  85698. * @param matrix matrix to apply
  85699. * @returns the resulting new ray
  85700. */
  85701. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  85702. /**
  85703. * Transforms a ray by a matrix
  85704. * @param ray ray to transform
  85705. * @param matrix matrix to apply
  85706. * @param result ray to store result in
  85707. */
  85708. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  85709. /**
  85710. * Unproject a ray from screen space to object space
  85711. * @param sourceX defines the screen space x coordinate to use
  85712. * @param sourceY defines the screen space y coordinate to use
  85713. * @param viewportWidth defines the current width of the viewport
  85714. * @param viewportHeight defines the current height of the viewport
  85715. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85716. * @param view defines the view matrix to use
  85717. * @param projection defines the projection matrix to use
  85718. */
  85719. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  85720. }
  85721. /**
  85722. * Type used to define predicate used to select faces when a mesh intersection is detected
  85723. */
  85724. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  85725. interface Scene {
  85726. /** @hidden */
  85727. _tempPickingRay: Nullable<Ray>;
  85728. /** @hidden */
  85729. _cachedRayForTransform: Ray;
  85730. /** @hidden */
  85731. _pickWithRayInverseMatrix: Matrix;
  85732. /** @hidden */
  85733. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  85734. /** @hidden */
  85735. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  85736. }
  85737. }
  85738. declare module BABYLON {
  85739. /**
  85740. * Groups all the scene component constants in one place to ease maintenance.
  85741. * @hidden
  85742. */
  85743. export class SceneComponentConstants {
  85744. static readonly NAME_EFFECTLAYER: string;
  85745. static readonly NAME_LAYER: string;
  85746. static readonly NAME_LENSFLARESYSTEM: string;
  85747. static readonly NAME_BOUNDINGBOXRENDERER: string;
  85748. static readonly NAME_PARTICLESYSTEM: string;
  85749. static readonly NAME_GAMEPAD: string;
  85750. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  85751. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  85752. static readonly NAME_DEPTHRENDERER: string;
  85753. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  85754. static readonly NAME_SPRITE: string;
  85755. static readonly NAME_OUTLINERENDERER: string;
  85756. static readonly NAME_PROCEDURALTEXTURE: string;
  85757. static readonly NAME_SHADOWGENERATOR: string;
  85758. static readonly NAME_OCTREE: string;
  85759. static readonly NAME_PHYSICSENGINE: string;
  85760. static readonly NAME_AUDIO: string;
  85761. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  85762. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85763. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  85764. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85765. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  85766. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  85767. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  85768. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  85769. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  85770. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  85771. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  85772. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  85773. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  85774. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  85775. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  85776. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  85777. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  85778. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  85779. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  85780. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  85781. static readonly STEP_AFTERRENDER_AUDIO: number;
  85782. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  85783. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  85784. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  85785. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  85786. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  85787. static readonly STEP_POINTERMOVE_SPRITE: number;
  85788. static readonly STEP_POINTERDOWN_SPRITE: number;
  85789. static readonly STEP_POINTERUP_SPRITE: number;
  85790. }
  85791. /**
  85792. * This represents a scene component.
  85793. *
  85794. * This is used to decouple the dependency the scene is having on the different workloads like
  85795. * layers, post processes...
  85796. */
  85797. export interface ISceneComponent {
  85798. /**
  85799. * The name of the component. Each component must have a unique name.
  85800. */
  85801. name: string;
  85802. /**
  85803. * The scene the component belongs to.
  85804. */
  85805. scene: Scene;
  85806. /**
  85807. * Register the component to one instance of a scene.
  85808. */
  85809. register(): void;
  85810. /**
  85811. * Rebuilds the elements related to this component in case of
  85812. * context lost for instance.
  85813. */
  85814. rebuild(): void;
  85815. /**
  85816. * Disposes the component and the associated ressources.
  85817. */
  85818. dispose(): void;
  85819. }
  85820. /**
  85821. * This represents a SERIALIZABLE scene component.
  85822. *
  85823. * This extends Scene Component to add Serialization methods on top.
  85824. */
  85825. export interface ISceneSerializableComponent extends ISceneComponent {
  85826. /**
  85827. * Adds all the elements from the container to the scene
  85828. * @param container the container holding the elements
  85829. */
  85830. addFromContainer(container: AbstractScene): void;
  85831. /**
  85832. * Removes all the elements in the container from the scene
  85833. * @param container contains the elements to remove
  85834. * @param dispose if the removed element should be disposed (default: false)
  85835. */
  85836. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  85837. /**
  85838. * Serializes the component data to the specified json object
  85839. * @param serializationObject The object to serialize to
  85840. */
  85841. serialize(serializationObject: any): void;
  85842. }
  85843. /**
  85844. * Strong typing of a Mesh related stage step action
  85845. */
  85846. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  85847. /**
  85848. * Strong typing of a Evaluate Sub Mesh related stage step action
  85849. */
  85850. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  85851. /**
  85852. * Strong typing of a Active Mesh related stage step action
  85853. */
  85854. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  85855. /**
  85856. * Strong typing of a Camera related stage step action
  85857. */
  85858. export type CameraStageAction = (camera: Camera) => void;
  85859. /**
  85860. * Strong typing of a Camera Frame buffer related stage step action
  85861. */
  85862. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  85863. /**
  85864. * Strong typing of a Render Target related stage step action
  85865. */
  85866. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  85867. /**
  85868. * Strong typing of a RenderingGroup related stage step action
  85869. */
  85870. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  85871. /**
  85872. * Strong typing of a Mesh Render related stage step action
  85873. */
  85874. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  85875. /**
  85876. * Strong typing of a simple stage step action
  85877. */
  85878. export type SimpleStageAction = () => void;
  85879. /**
  85880. * Strong typing of a render target action.
  85881. */
  85882. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  85883. /**
  85884. * Strong typing of a pointer move action.
  85885. */
  85886. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  85887. /**
  85888. * Strong typing of a pointer up/down action.
  85889. */
  85890. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  85891. /**
  85892. * Representation of a stage in the scene (Basically a list of ordered steps)
  85893. * @hidden
  85894. */
  85895. export class Stage<T extends Function> extends Array<{
  85896. index: number;
  85897. component: ISceneComponent;
  85898. action: T;
  85899. }> {
  85900. /**
  85901. * Hide ctor from the rest of the world.
  85902. * @param items The items to add.
  85903. */
  85904. private constructor();
  85905. /**
  85906. * Creates a new Stage.
  85907. * @returns A new instance of a Stage
  85908. */
  85909. static Create<T extends Function>(): Stage<T>;
  85910. /**
  85911. * Registers a step in an ordered way in the targeted stage.
  85912. * @param index Defines the position to register the step in
  85913. * @param component Defines the component attached to the step
  85914. * @param action Defines the action to launch during the step
  85915. */
  85916. registerStep(index: number, component: ISceneComponent, action: T): void;
  85917. /**
  85918. * Clears all the steps from the stage.
  85919. */
  85920. clear(): void;
  85921. }
  85922. }
  85923. declare module BABYLON {
  85924. interface Scene {
  85925. /** @hidden */
  85926. _pointerOverSprite: Nullable<Sprite>;
  85927. /** @hidden */
  85928. _pickedDownSprite: Nullable<Sprite>;
  85929. /** @hidden */
  85930. _tempSpritePickingRay: Nullable<Ray>;
  85931. /**
  85932. * All of the sprite managers added to this scene
  85933. * @see http://doc.babylonjs.com/babylon101/sprites
  85934. */
  85935. spriteManagers: Array<ISpriteManager>;
  85936. /**
  85937. * An event triggered when sprites rendering is about to start
  85938. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85939. */
  85940. onBeforeSpritesRenderingObservable: Observable<Scene>;
  85941. /**
  85942. * An event triggered when sprites rendering is done
  85943. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85944. */
  85945. onAfterSpritesRenderingObservable: Observable<Scene>;
  85946. /** @hidden */
  85947. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85948. /** Launch a ray to try to pick a sprite in the scene
  85949. * @param x position on screen
  85950. * @param y position on screen
  85951. * @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
  85952. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85953. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85954. * @returns a PickingInfo
  85955. */
  85956. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85957. /** Use the given ray to pick a sprite in the scene
  85958. * @param ray The ray (in world space) to use to pick meshes
  85959. * @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
  85960. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85962. * @returns a PickingInfo
  85963. */
  85964. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85965. /** @hidden */
  85966. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85967. /** Launch a ray to try to pick sprites in the scene
  85968. * @param x position on screen
  85969. * @param y position on screen
  85970. * @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
  85971. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85972. * @returns a PickingInfo array
  85973. */
  85974. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85975. /** Use the given ray to pick sprites in the scene
  85976. * @param ray The ray (in world space) to use to pick meshes
  85977. * @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
  85978. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85979. * @returns a PickingInfo array
  85980. */
  85981. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85982. /**
  85983. * Force the sprite under the pointer
  85984. * @param sprite defines the sprite to use
  85985. */
  85986. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  85987. /**
  85988. * Gets the sprite under the pointer
  85989. * @returns a Sprite or null if no sprite is under the pointer
  85990. */
  85991. getPointerOverSprite(): Nullable<Sprite>;
  85992. }
  85993. /**
  85994. * Defines the sprite scene component responsible to manage sprites
  85995. * in a given scene.
  85996. */
  85997. export class SpriteSceneComponent implements ISceneComponent {
  85998. /**
  85999. * The component name helpfull to identify the component in the list of scene components.
  86000. */
  86001. readonly name: string;
  86002. /**
  86003. * The scene the component belongs to.
  86004. */
  86005. scene: Scene;
  86006. /** @hidden */
  86007. private _spritePredicate;
  86008. /**
  86009. * Creates a new instance of the component for the given scene
  86010. * @param scene Defines the scene to register the component in
  86011. */
  86012. constructor(scene: Scene);
  86013. /**
  86014. * Registers the component in a given scene
  86015. */
  86016. register(): void;
  86017. /**
  86018. * Rebuilds the elements related to this component in case of
  86019. * context lost for instance.
  86020. */
  86021. rebuild(): void;
  86022. /**
  86023. * Disposes the component and the associated ressources.
  86024. */
  86025. dispose(): void;
  86026. private _pickSpriteButKeepRay;
  86027. private _pointerMove;
  86028. private _pointerDown;
  86029. private _pointerUp;
  86030. }
  86031. }
  86032. declare module BABYLON {
  86033. /** @hidden */
  86034. export var fogFragmentDeclaration: {
  86035. name: string;
  86036. shader: string;
  86037. };
  86038. }
  86039. declare module BABYLON {
  86040. /** @hidden */
  86041. export var fogFragment: {
  86042. name: string;
  86043. shader: string;
  86044. };
  86045. }
  86046. declare module BABYLON {
  86047. /** @hidden */
  86048. export var spritesPixelShader: {
  86049. name: string;
  86050. shader: string;
  86051. };
  86052. }
  86053. declare module BABYLON {
  86054. /** @hidden */
  86055. export var fogVertexDeclaration: {
  86056. name: string;
  86057. shader: string;
  86058. };
  86059. }
  86060. declare module BABYLON {
  86061. /** @hidden */
  86062. export var spritesVertexShader: {
  86063. name: string;
  86064. shader: string;
  86065. };
  86066. }
  86067. declare module BABYLON {
  86068. /**
  86069. * Defines the minimum interface to fullfil in order to be a sprite manager.
  86070. */
  86071. export interface ISpriteManager extends IDisposable {
  86072. /**
  86073. * Gets manager's name
  86074. */
  86075. name: string;
  86076. /**
  86077. * Restricts the camera to viewing objects with the same layerMask.
  86078. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  86079. */
  86080. layerMask: number;
  86081. /**
  86082. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86083. */
  86084. isPickable: boolean;
  86085. /**
  86086. * Gets the hosting scene
  86087. */
  86088. scene: Scene;
  86089. /**
  86090. * Specifies the rendering group id for this mesh (0 by default)
  86091. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86092. */
  86093. renderingGroupId: number;
  86094. /**
  86095. * Defines the list of sprites managed by the manager.
  86096. */
  86097. sprites: Array<Sprite>;
  86098. /**
  86099. * Gets or sets the spritesheet texture
  86100. */
  86101. texture: Texture;
  86102. /** Defines the default width of a cell in the spritesheet */
  86103. cellWidth: number;
  86104. /** Defines the default height of a cell in the spritesheet */
  86105. cellHeight: number;
  86106. /**
  86107. * Tests the intersection of a sprite with a specific ray.
  86108. * @param ray The ray we are sending to test the collision
  86109. * @param camera The camera space we are sending rays in
  86110. * @param predicate A predicate allowing excluding sprites from the list of object to test
  86111. * @param fastCheck defines if the first intersection will be used (and not the closest)
  86112. * @returns picking info or null.
  86113. */
  86114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86115. /**
  86116. * Intersects the sprites with a ray
  86117. * @param ray defines the ray to intersect with
  86118. * @param camera defines the current active camera
  86119. * @param predicate defines a predicate used to select candidate sprites
  86120. * @returns null if no hit or a PickingInfo array
  86121. */
  86122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86123. /**
  86124. * Renders the list of sprites on screen.
  86125. */
  86126. render(): void;
  86127. }
  86128. /**
  86129. * Class used to manage multiple sprites on the same spritesheet
  86130. * @see http://doc.babylonjs.com/babylon101/sprites
  86131. */
  86132. export class SpriteManager implements ISpriteManager {
  86133. /** defines the manager's name */
  86134. name: string;
  86135. /** Gets the list of sprites */
  86136. sprites: Sprite[];
  86137. /** Gets or sets the rendering group id (0 by default) */
  86138. renderingGroupId: number;
  86139. /** Gets or sets camera layer mask */
  86140. layerMask: number;
  86141. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  86142. fogEnabled: boolean;
  86143. /** Gets or sets a boolean indicating if the sprites are pickable */
  86144. isPickable: boolean;
  86145. /** Defines the default width of a cell in the spritesheet */
  86146. cellWidth: number;
  86147. /** Defines the default height of a cell in the spritesheet */
  86148. cellHeight: number;
  86149. /** Associative array from JSON sprite data file */
  86150. private _cellData;
  86151. /** Array of sprite names from JSON sprite data file */
  86152. private _spriteMap;
  86153. /** True when packed cell data from JSON file is ready*/
  86154. private _packedAndReady;
  86155. private _textureContent;
  86156. /**
  86157. * An event triggered when the manager is disposed.
  86158. */
  86159. onDisposeObservable: Observable<SpriteManager>;
  86160. private _onDisposeObserver;
  86161. /**
  86162. * Callback called when the manager is disposed
  86163. */
  86164. set onDispose(callback: () => void);
  86165. private _capacity;
  86166. private _fromPacked;
  86167. private _spriteTexture;
  86168. private _epsilon;
  86169. private _scene;
  86170. private _vertexData;
  86171. private _buffer;
  86172. private _vertexBuffers;
  86173. private _indexBuffer;
  86174. private _effectBase;
  86175. private _effectFog;
  86176. /**
  86177. * Gets or sets the unique id of the sprite
  86178. */
  86179. uniqueId: number;
  86180. /**
  86181. * Gets the array of sprites
  86182. */
  86183. get children(): Sprite[];
  86184. /**
  86185. * Gets the hosting scene
  86186. */
  86187. get scene(): Scene;
  86188. /**
  86189. * Gets or sets the capacity of the manager
  86190. */
  86191. get capacity(): number;
  86192. set capacity(value: number);
  86193. /**
  86194. * Gets or sets the spritesheet texture
  86195. */
  86196. get texture(): Texture;
  86197. set texture(value: Texture);
  86198. private _blendMode;
  86199. /**
  86200. * Blend mode use to render the particle, it can be any of
  86201. * the static Constants.ALPHA_x properties provided in this class.
  86202. * Default value is Constants.ALPHA_COMBINE
  86203. */
  86204. get blendMode(): number;
  86205. set blendMode(blendMode: number);
  86206. /** Disables writing to the depth buffer when rendering the sprites.
  86207. * It can be handy to disable depth writing when using textures without alpha channel
  86208. * and setting some specific blend modes.
  86209. */
  86210. disableDepthWrite: boolean;
  86211. /**
  86212. * Creates a new sprite manager
  86213. * @param name defines the manager's name
  86214. * @param imgUrl defines the sprite sheet url
  86215. * @param capacity defines the maximum allowed number of sprites
  86216. * @param cellSize defines the size of a sprite cell
  86217. * @param scene defines the hosting scene
  86218. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  86219. * @param samplingMode defines the smapling mode to use with spritesheet
  86220. * @param fromPacked set to false; do not alter
  86221. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  86222. */
  86223. constructor(
  86224. /** defines the manager's name */
  86225. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  86226. /**
  86227. * Returns the string "SpriteManager"
  86228. * @returns "SpriteManager"
  86229. */
  86230. getClassName(): string;
  86231. private _makePacked;
  86232. private _appendSpriteVertex;
  86233. private _checkTextureAlpha;
  86234. /**
  86235. * Intersects the sprites with a ray
  86236. * @param ray defines the ray to intersect with
  86237. * @param camera defines the current active camera
  86238. * @param predicate defines a predicate used to select candidate sprites
  86239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  86240. * @returns null if no hit or a PickingInfo
  86241. */
  86242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86243. /**
  86244. * Intersects the sprites with a ray
  86245. * @param ray defines the ray to intersect with
  86246. * @param camera defines the current active camera
  86247. * @param predicate defines a predicate used to select candidate sprites
  86248. * @returns null if no hit or a PickingInfo array
  86249. */
  86250. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86251. /**
  86252. * Render all child sprites
  86253. */
  86254. render(): void;
  86255. /**
  86256. * Release associated resources
  86257. */
  86258. dispose(): void;
  86259. }
  86260. }
  86261. declare module BABYLON {
  86262. /** Interface used by value gradients (color, factor, ...) */
  86263. export interface IValueGradient {
  86264. /**
  86265. * Gets or sets the gradient value (between 0 and 1)
  86266. */
  86267. gradient: number;
  86268. }
  86269. /** Class used to store color4 gradient */
  86270. export class ColorGradient implements IValueGradient {
  86271. /**
  86272. * Gets or sets the gradient value (between 0 and 1)
  86273. */
  86274. gradient: number;
  86275. /**
  86276. * Gets or sets first associated color
  86277. */
  86278. color1: Color4;
  86279. /**
  86280. * Gets or sets second associated color
  86281. */
  86282. color2?: Color4 | undefined;
  86283. /**
  86284. * Creates a new color4 gradient
  86285. * @param gradient gets or sets the gradient value (between 0 and 1)
  86286. * @param color1 gets or sets first associated color
  86287. * @param color2 gets or sets first second color
  86288. */
  86289. constructor(
  86290. /**
  86291. * Gets or sets the gradient value (between 0 and 1)
  86292. */
  86293. gradient: number,
  86294. /**
  86295. * Gets or sets first associated color
  86296. */
  86297. color1: Color4,
  86298. /**
  86299. * Gets or sets second associated color
  86300. */
  86301. color2?: Color4 | undefined);
  86302. /**
  86303. * Will get a color picked randomly between color1 and color2.
  86304. * If color2 is undefined then color1 will be used
  86305. * @param result defines the target Color4 to store the result in
  86306. */
  86307. getColorToRef(result: Color4): void;
  86308. }
  86309. /** Class used to store color 3 gradient */
  86310. export class Color3Gradient implements IValueGradient {
  86311. /**
  86312. * Gets or sets the gradient value (between 0 and 1)
  86313. */
  86314. gradient: number;
  86315. /**
  86316. * Gets or sets the associated color
  86317. */
  86318. color: Color3;
  86319. /**
  86320. * Creates a new color3 gradient
  86321. * @param gradient gets or sets the gradient value (between 0 and 1)
  86322. * @param color gets or sets associated color
  86323. */
  86324. constructor(
  86325. /**
  86326. * Gets or sets the gradient value (between 0 and 1)
  86327. */
  86328. gradient: number,
  86329. /**
  86330. * Gets or sets the associated color
  86331. */
  86332. color: Color3);
  86333. }
  86334. /** Class used to store factor gradient */
  86335. export class FactorGradient implements IValueGradient {
  86336. /**
  86337. * Gets or sets the gradient value (between 0 and 1)
  86338. */
  86339. gradient: number;
  86340. /**
  86341. * Gets or sets first associated factor
  86342. */
  86343. factor1: number;
  86344. /**
  86345. * Gets or sets second associated factor
  86346. */
  86347. factor2?: number | undefined;
  86348. /**
  86349. * Creates a new factor gradient
  86350. * @param gradient gets or sets the gradient value (between 0 and 1)
  86351. * @param factor1 gets or sets first associated factor
  86352. * @param factor2 gets or sets second associated factor
  86353. */
  86354. constructor(
  86355. /**
  86356. * Gets or sets the gradient value (between 0 and 1)
  86357. */
  86358. gradient: number,
  86359. /**
  86360. * Gets or sets first associated factor
  86361. */
  86362. factor1: number,
  86363. /**
  86364. * Gets or sets second associated factor
  86365. */
  86366. factor2?: number | undefined);
  86367. /**
  86368. * Will get a number picked randomly between factor1 and factor2.
  86369. * If factor2 is undefined then factor1 will be used
  86370. * @returns the picked number
  86371. */
  86372. getFactor(): number;
  86373. }
  86374. /**
  86375. * Helper used to simplify some generic gradient tasks
  86376. */
  86377. export class GradientHelper {
  86378. /**
  86379. * Gets the current gradient from an array of IValueGradient
  86380. * @param ratio defines the current ratio to get
  86381. * @param gradients defines the array of IValueGradient
  86382. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86383. */
  86384. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86385. }
  86386. }
  86387. declare module BABYLON {
  86388. /**
  86389. * Interface for the size containing width and height
  86390. */
  86391. export interface ISize {
  86392. /**
  86393. * Width
  86394. */
  86395. width: number;
  86396. /**
  86397. * Heighht
  86398. */
  86399. height: number;
  86400. }
  86401. /**
  86402. * Size containing widht and height
  86403. */
  86404. export class Size implements ISize {
  86405. /**
  86406. * Width
  86407. */
  86408. width: number;
  86409. /**
  86410. * Height
  86411. */
  86412. height: number;
  86413. /**
  86414. * Creates a Size object from the given width and height (floats).
  86415. * @param width width of the new size
  86416. * @param height height of the new size
  86417. */
  86418. constructor(width: number, height: number);
  86419. /**
  86420. * Returns a string with the Size width and height
  86421. * @returns a string with the Size width and height
  86422. */
  86423. toString(): string;
  86424. /**
  86425. * "Size"
  86426. * @returns the string "Size"
  86427. */
  86428. getClassName(): string;
  86429. /**
  86430. * Returns the Size hash code.
  86431. * @returns a hash code for a unique width and height
  86432. */
  86433. getHashCode(): number;
  86434. /**
  86435. * Updates the current size from the given one.
  86436. * @param src the given size
  86437. */
  86438. copyFrom(src: Size): void;
  86439. /**
  86440. * Updates in place the current Size from the given floats.
  86441. * @param width width of the new size
  86442. * @param height height of the new size
  86443. * @returns the updated Size.
  86444. */
  86445. copyFromFloats(width: number, height: number): Size;
  86446. /**
  86447. * Updates in place the current Size from the given floats.
  86448. * @param width width to set
  86449. * @param height height to set
  86450. * @returns the updated Size.
  86451. */
  86452. set(width: number, height: number): Size;
  86453. /**
  86454. * Multiplies the width and height by numbers
  86455. * @param w factor to multiple the width by
  86456. * @param h factor to multiple the height by
  86457. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86458. */
  86459. multiplyByFloats(w: number, h: number): Size;
  86460. /**
  86461. * Clones the size
  86462. * @returns a new Size copied from the given one.
  86463. */
  86464. clone(): Size;
  86465. /**
  86466. * True if the current Size and the given one width and height are strictly equal.
  86467. * @param other the other size to compare against
  86468. * @returns True if the current Size and the given one width and height are strictly equal.
  86469. */
  86470. equals(other: Size): boolean;
  86471. /**
  86472. * The surface of the Size : width * height (float).
  86473. */
  86474. get surface(): number;
  86475. /**
  86476. * Create a new size of zero
  86477. * @returns a new Size set to (0.0, 0.0)
  86478. */
  86479. static Zero(): Size;
  86480. /**
  86481. * Sums the width and height of two sizes
  86482. * @param otherSize size to add to this size
  86483. * @returns a new Size set as the addition result of the current Size and the given one.
  86484. */
  86485. add(otherSize: Size): Size;
  86486. /**
  86487. * Subtracts the width and height of two
  86488. * @param otherSize size to subtract to this size
  86489. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86490. */
  86491. subtract(otherSize: Size): Size;
  86492. /**
  86493. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86494. * @param start starting size to lerp between
  86495. * @param end end size to lerp between
  86496. * @param amount amount to lerp between the start and end values
  86497. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86498. */
  86499. static Lerp(start: Size, end: Size, amount: number): Size;
  86500. }
  86501. }
  86502. declare module BABYLON {
  86503. interface ThinEngine {
  86504. /**
  86505. * Creates a dynamic texture
  86506. * @param width defines the width of the texture
  86507. * @param height defines the height of the texture
  86508. * @param generateMipMaps defines if the engine should generate the mip levels
  86509. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86510. * @returns the dynamic texture inside an InternalTexture
  86511. */
  86512. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86513. /**
  86514. * Update the content of a dynamic texture
  86515. * @param texture defines the texture to update
  86516. * @param canvas defines the canvas containing the source
  86517. * @param invertY defines if data must be stored with Y axis inverted
  86518. * @param premulAlpha defines if alpha is stored as premultiplied
  86519. * @param format defines the format of the data
  86520. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86521. */
  86522. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86523. }
  86524. }
  86525. declare module BABYLON {
  86526. /**
  86527. * Helper class used to generate a canvas to manipulate images
  86528. */
  86529. export class CanvasGenerator {
  86530. /**
  86531. * Create a new canvas (or offscreen canvas depending on the context)
  86532. * @param width defines the expected width
  86533. * @param height defines the expected height
  86534. * @return a new canvas or offscreen canvas
  86535. */
  86536. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86537. }
  86538. }
  86539. declare module BABYLON {
  86540. /**
  86541. * A class extending Texture allowing drawing on a texture
  86542. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86543. */
  86544. export class DynamicTexture extends Texture {
  86545. private _generateMipMaps;
  86546. private _canvas;
  86547. private _context;
  86548. /**
  86549. * Creates a DynamicTexture
  86550. * @param name defines the name of the texture
  86551. * @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
  86552. * @param scene defines the scene where you want the texture
  86553. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86554. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86555. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86556. */
  86557. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86558. /**
  86559. * Get the current class name of the texture useful for serialization or dynamic coding.
  86560. * @returns "DynamicTexture"
  86561. */
  86562. getClassName(): string;
  86563. /**
  86564. * Gets the current state of canRescale
  86565. */
  86566. get canRescale(): boolean;
  86567. private _recreate;
  86568. /**
  86569. * Scales the texture
  86570. * @param ratio the scale factor to apply to both width and height
  86571. */
  86572. scale(ratio: number): void;
  86573. /**
  86574. * Resizes the texture
  86575. * @param width the new width
  86576. * @param height the new height
  86577. */
  86578. scaleTo(width: number, height: number): void;
  86579. /**
  86580. * Gets the context of the canvas used by the texture
  86581. * @returns the canvas context of the dynamic texture
  86582. */
  86583. getContext(): CanvasRenderingContext2D;
  86584. /**
  86585. * Clears the texture
  86586. */
  86587. clear(): void;
  86588. /**
  86589. * Updates the texture
  86590. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86591. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  86592. */
  86593. update(invertY?: boolean, premulAlpha?: boolean): void;
  86594. /**
  86595. * Draws text onto the texture
  86596. * @param text defines the text to be drawn
  86597. * @param x defines the placement of the text from the left
  86598. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  86599. * @param font defines the font to be used with font-style, font-size, font-name
  86600. * @param color defines the color used for the text
  86601. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  86602. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86603. * @param update defines whether texture is immediately update (default is true)
  86604. */
  86605. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  86606. /**
  86607. * Clones the texture
  86608. * @returns the clone of the texture.
  86609. */
  86610. clone(): DynamicTexture;
  86611. /**
  86612. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  86613. * @returns a serialized dynamic texture object
  86614. */
  86615. serialize(): any;
  86616. /** @hidden */
  86617. _rebuild(): void;
  86618. }
  86619. }
  86620. declare module BABYLON {
  86621. interface ThinEngine {
  86622. /**
  86623. * Creates a raw texture
  86624. * @param data defines the data to store in the texture
  86625. * @param width defines the width of the texture
  86626. * @param height defines the height of the texture
  86627. * @param format defines the format of the data
  86628. * @param generateMipMaps defines if the engine should generate the mip levels
  86629. * @param invertY defines if data must be stored with Y axis inverted
  86630. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86631. * @param compression defines the compression used (null by default)
  86632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86633. * @returns the raw texture inside an InternalTexture
  86634. */
  86635. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  86636. /**
  86637. * Update a raw texture
  86638. * @param texture defines the texture to update
  86639. * @param data defines the data to store in the texture
  86640. * @param format defines the format of the data
  86641. * @param invertY defines if data must be stored with Y axis inverted
  86642. */
  86643. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86644. /**
  86645. * Update a raw texture
  86646. * @param texture defines the texture to update
  86647. * @param data defines the data to store in the texture
  86648. * @param format defines the format of the data
  86649. * @param invertY defines if data must be stored with Y axis inverted
  86650. * @param compression defines the compression used (null by default)
  86651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86652. */
  86653. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  86654. /**
  86655. * Creates a new raw cube texture
  86656. * @param data defines the array of data to use to create each face
  86657. * @param size defines the size of the textures
  86658. * @param format defines the format of the data
  86659. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86660. * @param generateMipMaps defines if the engine should generate the mip levels
  86661. * @param invertY defines if data must be stored with Y axis inverted
  86662. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86663. * @param compression defines the compression used (null by default)
  86664. * @returns the cube texture as an InternalTexture
  86665. */
  86666. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  86667. /**
  86668. * Update a raw cube texture
  86669. * @param texture defines the texture to udpdate
  86670. * @param data defines the data to store
  86671. * @param format defines the data format
  86672. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86673. * @param invertY defines if data must be stored with Y axis inverted
  86674. */
  86675. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  86676. /**
  86677. * Update a raw cube texture
  86678. * @param texture defines the texture to udpdate
  86679. * @param data defines the data to store
  86680. * @param format defines the data format
  86681. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86682. * @param invertY defines if data must be stored with Y axis inverted
  86683. * @param compression defines the compression used (null by default)
  86684. */
  86685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  86686. /**
  86687. * Update a raw cube texture
  86688. * @param texture defines the texture to udpdate
  86689. * @param data defines the data to store
  86690. * @param format defines the data format
  86691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86692. * @param invertY defines if data must be stored with Y axis inverted
  86693. * @param compression defines the compression used (null by default)
  86694. * @param level defines which level of the texture to update
  86695. */
  86696. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  86697. /**
  86698. * Creates a new raw cube texture from a specified url
  86699. * @param url defines the url where the data is located
  86700. * @param scene defines the current scene
  86701. * @param size defines the size of the textures
  86702. * @param format defines the format of the data
  86703. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86704. * @param noMipmap defines if the engine should avoid generating the mip levels
  86705. * @param callback defines a callback used to extract texture data from loaded data
  86706. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86707. * @param onLoad defines a callback called when texture is loaded
  86708. * @param onError defines a callback called if there is an error
  86709. * @returns the cube texture as an InternalTexture
  86710. */
  86711. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  86712. /**
  86713. * Creates a new raw cube texture from a specified url
  86714. * @param url defines the url where the data is located
  86715. * @param scene defines the current scene
  86716. * @param size defines the size of the textures
  86717. * @param format defines the format of the data
  86718. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86719. * @param noMipmap defines if the engine should avoid generating the mip levels
  86720. * @param callback defines a callback used to extract texture data from loaded data
  86721. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86722. * @param onLoad defines a callback called when texture is loaded
  86723. * @param onError defines a callback called if there is an error
  86724. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86725. * @param invertY defines if data must be stored with Y axis inverted
  86726. * @returns the cube texture as an InternalTexture
  86727. */
  86728. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  86729. /**
  86730. * Creates a new raw 3D texture
  86731. * @param data defines the data used to create the texture
  86732. * @param width defines the width of the texture
  86733. * @param height defines the height of the texture
  86734. * @param depth defines the depth of the texture
  86735. * @param format defines the format of the texture
  86736. * @param generateMipMaps defines if the engine must generate mip levels
  86737. * @param invertY defines if data must be stored with Y axis inverted
  86738. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86739. * @param compression defines the compressed used (can be null)
  86740. * @param textureType defines the compressed used (can be null)
  86741. * @returns a new raw 3D texture (stored in an InternalTexture)
  86742. */
  86743. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86744. /**
  86745. * Update a raw 3D texture
  86746. * @param texture defines the texture to update
  86747. * @param data defines the data to store
  86748. * @param format defines the data format
  86749. * @param invertY defines if data must be stored with Y axis inverted
  86750. */
  86751. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86752. /**
  86753. * Update a raw 3D texture
  86754. * @param texture defines the texture to update
  86755. * @param data defines the data to store
  86756. * @param format defines the data format
  86757. * @param invertY defines if data must be stored with Y axis inverted
  86758. * @param compression defines the used compression (can be null)
  86759. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86760. */
  86761. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86762. /**
  86763. * Creates a new raw 2D array texture
  86764. * @param data defines the data used to create the texture
  86765. * @param width defines the width of the texture
  86766. * @param height defines the height of the texture
  86767. * @param depth defines the number of layers of the texture
  86768. * @param format defines the format of the texture
  86769. * @param generateMipMaps defines if the engine must generate mip levels
  86770. * @param invertY defines if data must be stored with Y axis inverted
  86771. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86772. * @param compression defines the compressed used (can be null)
  86773. * @param textureType defines the compressed used (can be null)
  86774. * @returns a new raw 2D array texture (stored in an InternalTexture)
  86775. */
  86776. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86777. /**
  86778. * Update a raw 2D array texture
  86779. * @param texture defines the texture to update
  86780. * @param data defines the data to store
  86781. * @param format defines the data format
  86782. * @param invertY defines if data must be stored with Y axis inverted
  86783. */
  86784. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86785. /**
  86786. * Update a raw 2D array texture
  86787. * @param texture defines the texture to update
  86788. * @param data defines the data to store
  86789. * @param format defines the data format
  86790. * @param invertY defines if data must be stored with Y axis inverted
  86791. * @param compression defines the used compression (can be null)
  86792. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86793. */
  86794. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86795. }
  86796. }
  86797. declare module BABYLON {
  86798. /**
  86799. * Raw texture can help creating a texture directly from an array of data.
  86800. * This can be super useful if you either get the data from an uncompressed source or
  86801. * if you wish to create your texture pixel by pixel.
  86802. */
  86803. export class RawTexture extends Texture {
  86804. /**
  86805. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86806. */
  86807. format: number;
  86808. /**
  86809. * Instantiates a new RawTexture.
  86810. * Raw texture can help creating a texture directly from an array of data.
  86811. * This can be super useful if you either get the data from an uncompressed source or
  86812. * if you wish to create your texture pixel by pixel.
  86813. * @param data define the array of data to use to create the texture
  86814. * @param width define the width of the texture
  86815. * @param height define the height of the texture
  86816. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86817. * @param scene define the scene the texture belongs to
  86818. * @param generateMipMaps define whether mip maps should be generated or not
  86819. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86820. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86821. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86822. */
  86823. constructor(data: ArrayBufferView, width: number, height: number,
  86824. /**
  86825. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86826. */
  86827. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86828. /**
  86829. * Updates the texture underlying data.
  86830. * @param data Define the new data of the texture
  86831. */
  86832. update(data: ArrayBufferView): void;
  86833. /**
  86834. * Creates a luminance texture from some data.
  86835. * @param data Define the texture data
  86836. * @param width Define the width of the texture
  86837. * @param height Define the height of the texture
  86838. * @param scene Define the scene the texture belongs to
  86839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86842. * @returns the luminance texture
  86843. */
  86844. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86845. /**
  86846. * Creates a luminance alpha texture from some data.
  86847. * @param data Define the texture data
  86848. * @param width Define the width of the texture
  86849. * @param height Define the height of the texture
  86850. * @param scene Define the scene the texture belongs to
  86851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86854. * @returns the luminance alpha texture
  86855. */
  86856. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86857. /**
  86858. * Creates an alpha texture from some data.
  86859. * @param data Define the texture data
  86860. * @param width Define the width of the texture
  86861. * @param height Define the height of the texture
  86862. * @param scene Define the scene the texture belongs to
  86863. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86864. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86865. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86866. * @returns the alpha texture
  86867. */
  86868. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86869. /**
  86870. * Creates a RGB texture from some data.
  86871. * @param data Define the texture data
  86872. * @param width Define the width of the texture
  86873. * @param height Define the height of the texture
  86874. * @param scene Define the scene the texture belongs to
  86875. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86878. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86879. * @returns the RGB alpha texture
  86880. */
  86881. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86882. /**
  86883. * Creates a RGBA texture from some data.
  86884. * @param data Define the texture data
  86885. * @param width Define the width of the texture
  86886. * @param height Define the height of the texture
  86887. * @param scene Define the scene the texture belongs to
  86888. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86892. * @returns the RGBA texture
  86893. */
  86894. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86895. /**
  86896. * Creates a R texture from some data.
  86897. * @param data Define the texture data
  86898. * @param width Define the width of the texture
  86899. * @param height Define the height of the texture
  86900. * @param scene Define the scene the texture belongs to
  86901. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86905. * @returns the R texture
  86906. */
  86907. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86908. }
  86909. }
  86910. declare module BABYLON {
  86911. interface AbstractScene {
  86912. /**
  86913. * The list of procedural textures added to the scene
  86914. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86915. */
  86916. proceduralTextures: Array<ProceduralTexture>;
  86917. }
  86918. /**
  86919. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86920. * in a given scene.
  86921. */
  86922. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86923. /**
  86924. * The component name helpfull to identify the component in the list of scene components.
  86925. */
  86926. readonly name: string;
  86927. /**
  86928. * The scene the component belongs to.
  86929. */
  86930. scene: Scene;
  86931. /**
  86932. * Creates a new instance of the component for the given scene
  86933. * @param scene Defines the scene to register the component in
  86934. */
  86935. constructor(scene: Scene);
  86936. /**
  86937. * Registers the component in a given scene
  86938. */
  86939. register(): void;
  86940. /**
  86941. * Rebuilds the elements related to this component in case of
  86942. * context lost for instance.
  86943. */
  86944. rebuild(): void;
  86945. /**
  86946. * Disposes the component and the associated ressources.
  86947. */
  86948. dispose(): void;
  86949. private _beforeClear;
  86950. }
  86951. }
  86952. declare module BABYLON {
  86953. interface ThinEngine {
  86954. /**
  86955. * Creates a new render target cube texture
  86956. * @param size defines the size of the texture
  86957. * @param options defines the options used to create the texture
  86958. * @returns a new render target cube texture stored in an InternalTexture
  86959. */
  86960. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86961. }
  86962. }
  86963. declare module BABYLON {
  86964. /** @hidden */
  86965. export var proceduralVertexShader: {
  86966. name: string;
  86967. shader: string;
  86968. };
  86969. }
  86970. declare module BABYLON {
  86971. /**
  86972. * 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.
  86973. * This is the base class of any Procedural texture and contains most of the shareable code.
  86974. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86975. */
  86976. export class ProceduralTexture extends Texture {
  86977. isCube: boolean;
  86978. /**
  86979. * Define if the texture is enabled or not (disabled texture will not render)
  86980. */
  86981. isEnabled: boolean;
  86982. /**
  86983. * Define if the texture must be cleared before rendering (default is true)
  86984. */
  86985. autoClear: boolean;
  86986. /**
  86987. * Callback called when the texture is generated
  86988. */
  86989. onGenerated: () => void;
  86990. /**
  86991. * Event raised when the texture is generated
  86992. */
  86993. onGeneratedObservable: Observable<ProceduralTexture>;
  86994. /** @hidden */
  86995. _generateMipMaps: boolean;
  86996. /** @hidden **/
  86997. _effect: Effect;
  86998. /** @hidden */
  86999. _textures: {
  87000. [key: string]: Texture;
  87001. };
  87002. /** @hidden */
  87003. protected _fallbackTexture: Nullable<Texture>;
  87004. private _size;
  87005. private _currentRefreshId;
  87006. private _frameId;
  87007. private _refreshRate;
  87008. private _vertexBuffers;
  87009. private _indexBuffer;
  87010. private _uniforms;
  87011. private _samplers;
  87012. private _fragment;
  87013. private _floats;
  87014. private _ints;
  87015. private _floatsArrays;
  87016. private _colors3;
  87017. private _colors4;
  87018. private _vectors2;
  87019. private _vectors3;
  87020. private _matrices;
  87021. private _fallbackTextureUsed;
  87022. private _fullEngine;
  87023. private _cachedDefines;
  87024. private _contentUpdateId;
  87025. private _contentData;
  87026. /**
  87027. * Instantiates a new procedural texture.
  87028. * 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.
  87029. * This is the base class of any Procedural texture and contains most of the shareable code.
  87030. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87031. * @param name Define the name of the texture
  87032. * @param size Define the size of the texture to create
  87033. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87034. * @param scene Define the scene the texture belongs to
  87035. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87036. * @param generateMipMaps Define if the texture should creates mip maps or not
  87037. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87038. */
  87039. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87040. /**
  87041. * The effect that is created when initializing the post process.
  87042. * @returns The created effect corresponding the the postprocess.
  87043. */
  87044. getEffect(): Effect;
  87045. /**
  87046. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87047. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87048. */
  87049. getContent(): Nullable<ArrayBufferView>;
  87050. private _createIndexBuffer;
  87051. /** @hidden */
  87052. _rebuild(): void;
  87053. /**
  87054. * Resets the texture in order to recreate its associated resources.
  87055. * This can be called in case of context loss
  87056. */
  87057. reset(): void;
  87058. protected _getDefines(): string;
  87059. /**
  87060. * Is the texture ready to be used ? (rendered at least once)
  87061. * @returns true if ready, otherwise, false.
  87062. */
  87063. isReady(): boolean;
  87064. /**
  87065. * Resets the refresh counter of the texture and start bak from scratch.
  87066. * Could be useful to regenerate the texture if it is setup to render only once.
  87067. */
  87068. resetRefreshCounter(): void;
  87069. /**
  87070. * Set the fragment shader to use in order to render the texture.
  87071. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87072. */
  87073. setFragment(fragment: any): void;
  87074. /**
  87075. * Define the refresh rate of the texture or the rendering frequency.
  87076. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87077. */
  87078. get refreshRate(): number;
  87079. set refreshRate(value: number);
  87080. /** @hidden */
  87081. _shouldRender(): boolean;
  87082. /**
  87083. * Get the size the texture is rendering at.
  87084. * @returns the size (texture is always squared)
  87085. */
  87086. getRenderSize(): number;
  87087. /**
  87088. * Resize the texture to new value.
  87089. * @param size Define the new size the texture should have
  87090. * @param generateMipMaps Define whether the new texture should create mip maps
  87091. */
  87092. resize(size: number, generateMipMaps: boolean): void;
  87093. private _checkUniform;
  87094. /**
  87095. * Set a texture in the shader program used to render.
  87096. * @param name Define the name of the uniform samplers as defined in the shader
  87097. * @param texture Define the texture to bind to this sampler
  87098. * @return the texture itself allowing "fluent" like uniform updates
  87099. */
  87100. setTexture(name: string, texture: Texture): ProceduralTexture;
  87101. /**
  87102. * Set a float in the shader.
  87103. * @param name Define the name of the uniform as defined in the shader
  87104. * @param value Define the value to give to the uniform
  87105. * @return the texture itself allowing "fluent" like uniform updates
  87106. */
  87107. setFloat(name: string, value: number): ProceduralTexture;
  87108. /**
  87109. * Set a int in the shader.
  87110. * @param name Define the name of the uniform as defined in the shader
  87111. * @param value Define the value to give to the uniform
  87112. * @return the texture itself allowing "fluent" like uniform updates
  87113. */
  87114. setInt(name: string, value: number): ProceduralTexture;
  87115. /**
  87116. * Set an array of floats in the shader.
  87117. * @param name Define the name of the uniform as defined in the shader
  87118. * @param value Define the value to give to the uniform
  87119. * @return the texture itself allowing "fluent" like uniform updates
  87120. */
  87121. setFloats(name: string, value: number[]): ProceduralTexture;
  87122. /**
  87123. * Set a vec3 in the shader from a Color3.
  87124. * @param name Define the name of the uniform as defined in the shader
  87125. * @param value Define the value to give to the uniform
  87126. * @return the texture itself allowing "fluent" like uniform updates
  87127. */
  87128. setColor3(name: string, value: Color3): ProceduralTexture;
  87129. /**
  87130. * Set a vec4 in the shader from a Color4.
  87131. * @param name Define the name of the uniform as defined in the shader
  87132. * @param value Define the value to give to the uniform
  87133. * @return the texture itself allowing "fluent" like uniform updates
  87134. */
  87135. setColor4(name: string, value: Color4): ProceduralTexture;
  87136. /**
  87137. * Set a vec2 in the shader from a Vector2.
  87138. * @param name Define the name of the uniform as defined in the shader
  87139. * @param value Define the value to give to the uniform
  87140. * @return the texture itself allowing "fluent" like uniform updates
  87141. */
  87142. setVector2(name: string, value: Vector2): ProceduralTexture;
  87143. /**
  87144. * Set a vec3 in the shader from a Vector3.
  87145. * @param name Define the name of the uniform as defined in the shader
  87146. * @param value Define the value to give to the uniform
  87147. * @return the texture itself allowing "fluent" like uniform updates
  87148. */
  87149. setVector3(name: string, value: Vector3): ProceduralTexture;
  87150. /**
  87151. * Set a mat4 in the shader from a MAtrix.
  87152. * @param name Define the name of the uniform as defined in the shader
  87153. * @param value Define the value to give to the uniform
  87154. * @return the texture itself allowing "fluent" like uniform updates
  87155. */
  87156. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87157. /**
  87158. * Render the texture to its associated render target.
  87159. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87160. */
  87161. render(useCameraPostProcess?: boolean): void;
  87162. /**
  87163. * Clone the texture.
  87164. * @returns the cloned texture
  87165. */
  87166. clone(): ProceduralTexture;
  87167. /**
  87168. * Dispose the texture and release its asoociated resources.
  87169. */
  87170. dispose(): void;
  87171. }
  87172. }
  87173. declare module BABYLON {
  87174. /**
  87175. * This represents the base class for particle system in Babylon.
  87176. * 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.
  87177. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87178. * @example https://doc.babylonjs.com/babylon101/particles
  87179. */
  87180. export class BaseParticleSystem {
  87181. /**
  87182. * Source color is added to the destination color without alpha affecting the result
  87183. */
  87184. static BLENDMODE_ONEONE: number;
  87185. /**
  87186. * Blend current color and particle color using particle’s alpha
  87187. */
  87188. static BLENDMODE_STANDARD: number;
  87189. /**
  87190. * Add current color and particle color multiplied by particle’s alpha
  87191. */
  87192. static BLENDMODE_ADD: number;
  87193. /**
  87194. * Multiply current color with particle color
  87195. */
  87196. static BLENDMODE_MULTIPLY: number;
  87197. /**
  87198. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87199. */
  87200. static BLENDMODE_MULTIPLYADD: number;
  87201. /**
  87202. * List of animations used by the particle system.
  87203. */
  87204. animations: Animation[];
  87205. /**
  87206. * Gets or sets the unique id of the particle system
  87207. */
  87208. uniqueId: number;
  87209. /**
  87210. * The id of the Particle system.
  87211. */
  87212. id: string;
  87213. /**
  87214. * The friendly name of the Particle system.
  87215. */
  87216. name: string;
  87217. /**
  87218. * Snippet ID if the particle system was created from the snippet server
  87219. */
  87220. snippetId: string;
  87221. /**
  87222. * The rendering group used by the Particle system to chose when to render.
  87223. */
  87224. renderingGroupId: number;
  87225. /**
  87226. * The emitter represents the Mesh or position we are attaching the particle system to.
  87227. */
  87228. emitter: Nullable<AbstractMesh | Vector3>;
  87229. /**
  87230. * The maximum number of particles to emit per frame
  87231. */
  87232. emitRate: number;
  87233. /**
  87234. * If you want to launch only a few particles at once, that can be done, as well.
  87235. */
  87236. manualEmitCount: number;
  87237. /**
  87238. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87239. */
  87240. updateSpeed: number;
  87241. /**
  87242. * The amount of time the particle system is running (depends of the overall update speed).
  87243. */
  87244. targetStopDuration: number;
  87245. /**
  87246. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87247. */
  87248. disposeOnStop: boolean;
  87249. /**
  87250. * Minimum power of emitting particles.
  87251. */
  87252. minEmitPower: number;
  87253. /**
  87254. * Maximum power of emitting particles.
  87255. */
  87256. maxEmitPower: number;
  87257. /**
  87258. * Minimum life time of emitting particles.
  87259. */
  87260. minLifeTime: number;
  87261. /**
  87262. * Maximum life time of emitting particles.
  87263. */
  87264. maxLifeTime: number;
  87265. /**
  87266. * Minimum Size of emitting particles.
  87267. */
  87268. minSize: number;
  87269. /**
  87270. * Maximum Size of emitting particles.
  87271. */
  87272. maxSize: number;
  87273. /**
  87274. * Minimum scale of emitting particles on X axis.
  87275. */
  87276. minScaleX: number;
  87277. /**
  87278. * Maximum scale of emitting particles on X axis.
  87279. */
  87280. maxScaleX: number;
  87281. /**
  87282. * Minimum scale of emitting particles on Y axis.
  87283. */
  87284. minScaleY: number;
  87285. /**
  87286. * Maximum scale of emitting particles on Y axis.
  87287. */
  87288. maxScaleY: number;
  87289. /**
  87290. * Gets or sets the minimal initial rotation in radians.
  87291. */
  87292. minInitialRotation: number;
  87293. /**
  87294. * Gets or sets the maximal initial rotation in radians.
  87295. */
  87296. maxInitialRotation: number;
  87297. /**
  87298. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87299. */
  87300. minAngularSpeed: number;
  87301. /**
  87302. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87303. */
  87304. maxAngularSpeed: number;
  87305. /**
  87306. * The texture used to render each particle. (this can be a spritesheet)
  87307. */
  87308. particleTexture: Nullable<Texture>;
  87309. /**
  87310. * The layer mask we are rendering the particles through.
  87311. */
  87312. layerMask: number;
  87313. /**
  87314. * This can help using your own shader to render the particle system.
  87315. * The according effect will be created
  87316. */
  87317. customShader: any;
  87318. /**
  87319. * By default particle system starts as soon as they are created. This prevents the
  87320. * automatic start to happen and let you decide when to start emitting particles.
  87321. */
  87322. preventAutoStart: boolean;
  87323. private _noiseTexture;
  87324. /**
  87325. * Gets or sets a texture used to add random noise to particle positions
  87326. */
  87327. get noiseTexture(): Nullable<ProceduralTexture>;
  87328. set noiseTexture(value: Nullable<ProceduralTexture>);
  87329. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87330. noiseStrength: Vector3;
  87331. /**
  87332. * Callback triggered when the particle animation is ending.
  87333. */
  87334. onAnimationEnd: Nullable<() => void>;
  87335. /**
  87336. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87337. */
  87338. blendMode: number;
  87339. /**
  87340. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87341. * to override the particles.
  87342. */
  87343. forceDepthWrite: boolean;
  87344. /** 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 */
  87345. preWarmCycles: number;
  87346. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87347. preWarmStepOffset: number;
  87348. /**
  87349. * 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)
  87350. */
  87351. spriteCellChangeSpeed: number;
  87352. /**
  87353. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87354. */
  87355. startSpriteCellID: number;
  87356. /**
  87357. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87358. */
  87359. endSpriteCellID: number;
  87360. /**
  87361. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87362. */
  87363. spriteCellWidth: number;
  87364. /**
  87365. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87366. */
  87367. spriteCellHeight: number;
  87368. /**
  87369. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87370. */
  87371. spriteRandomStartCell: boolean;
  87372. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87373. translationPivot: Vector2;
  87374. /** @hidden */
  87375. protected _isAnimationSheetEnabled: boolean;
  87376. /**
  87377. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87378. */
  87379. beginAnimationOnStart: boolean;
  87380. /**
  87381. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87382. */
  87383. beginAnimationFrom: number;
  87384. /**
  87385. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87386. */
  87387. beginAnimationTo: number;
  87388. /**
  87389. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87390. */
  87391. beginAnimationLoop: boolean;
  87392. /**
  87393. * Gets or sets a world offset applied to all particles
  87394. */
  87395. worldOffset: Vector3;
  87396. /**
  87397. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87398. */
  87399. get isAnimationSheetEnabled(): boolean;
  87400. set isAnimationSheetEnabled(value: boolean);
  87401. /**
  87402. * Get hosting scene
  87403. * @returns the scene
  87404. */
  87405. getScene(): Scene;
  87406. /**
  87407. * You can use gravity if you want to give an orientation to your particles.
  87408. */
  87409. gravity: Vector3;
  87410. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87411. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87412. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87413. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87414. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87415. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87416. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87417. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87418. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87419. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87420. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87421. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87422. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87423. /**
  87424. * Defines the delay in milliseconds before starting the system (0 by default)
  87425. */
  87426. startDelay: number;
  87427. /**
  87428. * Gets the current list of drag gradients.
  87429. * You must use addDragGradient and removeDragGradient to udpate this list
  87430. * @returns the list of drag gradients
  87431. */
  87432. getDragGradients(): Nullable<Array<FactorGradient>>;
  87433. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87434. limitVelocityDamping: number;
  87435. /**
  87436. * Gets the current list of limit velocity gradients.
  87437. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87438. * @returns the list of limit velocity gradients
  87439. */
  87440. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87441. /**
  87442. * Gets the current list of color gradients.
  87443. * You must use addColorGradient and removeColorGradient to udpate this list
  87444. * @returns the list of color gradients
  87445. */
  87446. getColorGradients(): Nullable<Array<ColorGradient>>;
  87447. /**
  87448. * Gets the current list of size gradients.
  87449. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87450. * @returns the list of size gradients
  87451. */
  87452. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87453. /**
  87454. * Gets the current list of color remap gradients.
  87455. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87456. * @returns the list of color remap gradients
  87457. */
  87458. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87459. /**
  87460. * Gets the current list of alpha remap gradients.
  87461. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87462. * @returns the list of alpha remap gradients
  87463. */
  87464. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87465. /**
  87466. * Gets the current list of life time gradients.
  87467. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87468. * @returns the list of life time gradients
  87469. */
  87470. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87471. /**
  87472. * Gets the current list of angular speed gradients.
  87473. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87474. * @returns the list of angular speed gradients
  87475. */
  87476. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87477. /**
  87478. * Gets the current list of velocity gradients.
  87479. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87480. * @returns the list of velocity gradients
  87481. */
  87482. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87483. /**
  87484. * Gets the current list of start size gradients.
  87485. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87486. * @returns the list of start size gradients
  87487. */
  87488. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87489. /**
  87490. * Gets the current list of emit rate gradients.
  87491. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87492. * @returns the list of emit rate gradients
  87493. */
  87494. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87495. /**
  87496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87497. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87498. */
  87499. get direction1(): Vector3;
  87500. set direction1(value: Vector3);
  87501. /**
  87502. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87504. */
  87505. get direction2(): Vector3;
  87506. set direction2(value: Vector3);
  87507. /**
  87508. * 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.
  87509. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87510. */
  87511. get minEmitBox(): Vector3;
  87512. set minEmitBox(value: Vector3);
  87513. /**
  87514. * 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.
  87515. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87516. */
  87517. get maxEmitBox(): Vector3;
  87518. set maxEmitBox(value: Vector3);
  87519. /**
  87520. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87521. */
  87522. color1: Color4;
  87523. /**
  87524. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87525. */
  87526. color2: Color4;
  87527. /**
  87528. * Color the particle will have at the end of its lifetime
  87529. */
  87530. colorDead: Color4;
  87531. /**
  87532. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87533. */
  87534. textureMask: Color4;
  87535. /**
  87536. * The particle emitter type defines the emitter used by the particle system.
  87537. * It can be for example box, sphere, or cone...
  87538. */
  87539. particleEmitterType: IParticleEmitterType;
  87540. /** @hidden */
  87541. _isSubEmitter: boolean;
  87542. /**
  87543. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87544. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87545. */
  87546. billboardMode: number;
  87547. protected _isBillboardBased: boolean;
  87548. /**
  87549. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87550. */
  87551. get isBillboardBased(): boolean;
  87552. set isBillboardBased(value: boolean);
  87553. /**
  87554. * The scene the particle system belongs to.
  87555. */
  87556. protected _scene: Scene;
  87557. /**
  87558. * Local cache of defines for image processing.
  87559. */
  87560. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87561. /**
  87562. * Default configuration related to image processing available in the standard Material.
  87563. */
  87564. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87565. /**
  87566. * Gets the image processing configuration used either in this material.
  87567. */
  87568. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87569. /**
  87570. * Sets the Default image processing configuration used either in the this material.
  87571. *
  87572. * If sets to null, the scene one is in use.
  87573. */
  87574. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87575. /**
  87576. * Attaches a new image processing configuration to the Standard Material.
  87577. * @param configuration
  87578. */
  87579. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87580. /** @hidden */
  87581. protected _reset(): void;
  87582. /** @hidden */
  87583. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87584. /**
  87585. * Instantiates a particle system.
  87586. * 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.
  87587. * @param name The name of the particle system
  87588. */
  87589. constructor(name: string);
  87590. /**
  87591. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87592. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87593. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87594. * @returns the emitter
  87595. */
  87596. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87597. /**
  87598. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87599. * @param radius The radius of the hemisphere to emit from
  87600. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87601. * @returns the emitter
  87602. */
  87603. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87604. /**
  87605. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87606. * @param radius The radius of the sphere to emit from
  87607. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87608. * @returns the emitter
  87609. */
  87610. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87611. /**
  87612. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87613. * @param radius The radius of the sphere to emit from
  87614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87616. * @returns the emitter
  87617. */
  87618. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87619. /**
  87620. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87621. * @param radius The radius of the emission cylinder
  87622. * @param height The height of the emission cylinder
  87623. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87624. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87625. * @returns the emitter
  87626. */
  87627. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87628. /**
  87629. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87630. * @param radius The radius of the cylinder to emit from
  87631. * @param height The height of the emission cylinder
  87632. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87635. * @returns the emitter
  87636. */
  87637. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87638. /**
  87639. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87640. * @param radius The radius of the cone to emit from
  87641. * @param angle The base angle of the cone
  87642. * @returns the emitter
  87643. */
  87644. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87645. /**
  87646. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87647. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87648. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87649. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87650. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87651. * @returns the emitter
  87652. */
  87653. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87654. }
  87655. }
  87656. declare module BABYLON {
  87657. /**
  87658. * Type of sub emitter
  87659. */
  87660. export enum SubEmitterType {
  87661. /**
  87662. * Attached to the particle over it's lifetime
  87663. */
  87664. ATTACHED = 0,
  87665. /**
  87666. * Created when the particle dies
  87667. */
  87668. END = 1
  87669. }
  87670. /**
  87671. * Sub emitter class used to emit particles from an existing particle
  87672. */
  87673. export class SubEmitter {
  87674. /**
  87675. * the particle system to be used by the sub emitter
  87676. */
  87677. particleSystem: ParticleSystem;
  87678. /**
  87679. * Type of the submitter (Default: END)
  87680. */
  87681. type: SubEmitterType;
  87682. /**
  87683. * 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)
  87684. * Note: This only is supported when using an emitter of type Mesh
  87685. */
  87686. inheritDirection: boolean;
  87687. /**
  87688. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87689. */
  87690. inheritedVelocityAmount: number;
  87691. /**
  87692. * Creates a sub emitter
  87693. * @param particleSystem the particle system to be used by the sub emitter
  87694. */
  87695. constructor(
  87696. /**
  87697. * the particle system to be used by the sub emitter
  87698. */
  87699. particleSystem: ParticleSystem);
  87700. /**
  87701. * Clones the sub emitter
  87702. * @returns the cloned sub emitter
  87703. */
  87704. clone(): SubEmitter;
  87705. /**
  87706. * Serialize current object to a JSON object
  87707. * @returns the serialized object
  87708. */
  87709. serialize(): any;
  87710. /** @hidden */
  87711. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87712. /**
  87713. * Creates a new SubEmitter from a serialized JSON version
  87714. * @param serializationObject defines the JSON object to read from
  87715. * @param scene defines the hosting scene
  87716. * @param rootUrl defines the rootUrl for data loading
  87717. * @returns a new SubEmitter
  87718. */
  87719. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87720. /** Release associated resources */
  87721. dispose(): void;
  87722. }
  87723. }
  87724. declare module BABYLON {
  87725. /** @hidden */
  87726. export var imageProcessingDeclaration: {
  87727. name: string;
  87728. shader: string;
  87729. };
  87730. }
  87731. declare module BABYLON {
  87732. /** @hidden */
  87733. export var imageProcessingFunctions: {
  87734. name: string;
  87735. shader: string;
  87736. };
  87737. }
  87738. declare module BABYLON {
  87739. /** @hidden */
  87740. export var particlesPixelShader: {
  87741. name: string;
  87742. shader: string;
  87743. };
  87744. }
  87745. declare module BABYLON {
  87746. /** @hidden */
  87747. export var particlesVertexShader: {
  87748. name: string;
  87749. shader: string;
  87750. };
  87751. }
  87752. declare module BABYLON {
  87753. /**
  87754. * This represents a particle system in Babylon.
  87755. * 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.
  87756. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87757. * @example https://doc.babylonjs.com/babylon101/particles
  87758. */
  87759. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87760. /**
  87761. * Billboard mode will only apply to Y axis
  87762. */
  87763. static readonly BILLBOARDMODE_Y: number;
  87764. /**
  87765. * Billboard mode will apply to all axes
  87766. */
  87767. static readonly BILLBOARDMODE_ALL: number;
  87768. /**
  87769. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87770. */
  87771. static readonly BILLBOARDMODE_STRETCHED: number;
  87772. /**
  87773. * This function can be defined to provide custom update for active particles.
  87774. * This function will be called instead of regular update (age, position, color, etc.).
  87775. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87776. */
  87777. updateFunction: (particles: Particle[]) => void;
  87778. private _emitterWorldMatrix;
  87779. /**
  87780. * This function can be defined to specify initial direction for every new particle.
  87781. * It by default use the emitterType defined function
  87782. */
  87783. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87784. /**
  87785. * This function can be defined to specify initial position for every new particle.
  87786. * It by default use the emitterType defined function
  87787. */
  87788. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87789. /**
  87790. * @hidden
  87791. */
  87792. _inheritedVelocityOffset: Vector3;
  87793. /**
  87794. * An event triggered when the system is disposed
  87795. */
  87796. onDisposeObservable: Observable<ParticleSystem>;
  87797. private _onDisposeObserver;
  87798. /**
  87799. * Sets a callback that will be triggered when the system is disposed
  87800. */
  87801. set onDispose(callback: () => void);
  87802. private _particles;
  87803. private _epsilon;
  87804. private _capacity;
  87805. private _stockParticles;
  87806. private _newPartsExcess;
  87807. private _vertexData;
  87808. private _vertexBuffer;
  87809. private _vertexBuffers;
  87810. private _spriteBuffer;
  87811. private _indexBuffer;
  87812. private _effect;
  87813. private _customEffect;
  87814. private _cachedDefines;
  87815. private _scaledColorStep;
  87816. private _colorDiff;
  87817. private _scaledDirection;
  87818. private _scaledGravity;
  87819. private _currentRenderId;
  87820. private _alive;
  87821. private _useInstancing;
  87822. private _started;
  87823. private _stopped;
  87824. private _actualFrame;
  87825. private _scaledUpdateSpeed;
  87826. private _vertexBufferSize;
  87827. /** @hidden */
  87828. _currentEmitRateGradient: Nullable<FactorGradient>;
  87829. /** @hidden */
  87830. _currentEmitRate1: number;
  87831. /** @hidden */
  87832. _currentEmitRate2: number;
  87833. /** @hidden */
  87834. _currentStartSizeGradient: Nullable<FactorGradient>;
  87835. /** @hidden */
  87836. _currentStartSize1: number;
  87837. /** @hidden */
  87838. _currentStartSize2: number;
  87839. private readonly _rawTextureWidth;
  87840. private _rampGradientsTexture;
  87841. private _useRampGradients;
  87842. /** Gets or sets a boolean indicating that ramp gradients must be used
  87843. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87844. */
  87845. get useRampGradients(): boolean;
  87846. set useRampGradients(value: boolean);
  87847. /**
  87848. * 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.
  87849. * 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: [])
  87850. */
  87851. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87852. private _subEmitters;
  87853. /**
  87854. * @hidden
  87855. * If the particle systems emitter should be disposed when the particle system is disposed
  87856. */
  87857. _disposeEmitterOnDispose: boolean;
  87858. /**
  87859. * The current active Sub-systems, this property is used by the root particle system only.
  87860. */
  87861. activeSubSystems: Array<ParticleSystem>;
  87862. /**
  87863. * Specifies if the particles are updated in emitter local space or world space
  87864. */
  87865. isLocal: boolean;
  87866. private _rootParticleSystem;
  87867. /**
  87868. * Gets the current list of active particles
  87869. */
  87870. get particles(): Particle[];
  87871. /**
  87872. * Gets the number of particles active at the same time.
  87873. * @returns The number of active particles.
  87874. */
  87875. getActiveCount(): number;
  87876. /**
  87877. * Returns the string "ParticleSystem"
  87878. * @returns a string containing the class name
  87879. */
  87880. getClassName(): string;
  87881. /**
  87882. * Gets a boolean indicating that the system is stopping
  87883. * @returns true if the system is currently stopping
  87884. */
  87885. isStopping(): boolean;
  87886. /**
  87887. * Instantiates a particle system.
  87888. * 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.
  87889. * @param name The name of the particle system
  87890. * @param capacity The max number of particles alive at the same time
  87891. * @param scene The scene the particle system belongs to
  87892. * @param customEffect a custom effect used to change the way particles are rendered by default
  87893. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87894. * @param epsilon Offset used to render the particles
  87895. */
  87896. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87897. private _addFactorGradient;
  87898. private _removeFactorGradient;
  87899. /**
  87900. * Adds a new life time gradient
  87901. * @param gradient defines the gradient to use (between 0 and 1)
  87902. * @param factor defines the life time factor to affect to the specified gradient
  87903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87904. * @returns the current particle system
  87905. */
  87906. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87907. /**
  87908. * Remove a specific life time gradient
  87909. * @param gradient defines the gradient to remove
  87910. * @returns the current particle system
  87911. */
  87912. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87913. /**
  87914. * Adds a new size gradient
  87915. * @param gradient defines the gradient to use (between 0 and 1)
  87916. * @param factor defines the size factor to affect to the specified gradient
  87917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87918. * @returns the current particle system
  87919. */
  87920. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87921. /**
  87922. * Remove a specific size gradient
  87923. * @param gradient defines the gradient to remove
  87924. * @returns the current particle system
  87925. */
  87926. removeSizeGradient(gradient: number): IParticleSystem;
  87927. /**
  87928. * Adds a new color remap gradient
  87929. * @param gradient defines the gradient to use (between 0 and 1)
  87930. * @param min defines the color remap minimal range
  87931. * @param max defines the color remap maximal range
  87932. * @returns the current particle system
  87933. */
  87934. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87935. /**
  87936. * Remove a specific color remap gradient
  87937. * @param gradient defines the gradient to remove
  87938. * @returns the current particle system
  87939. */
  87940. removeColorRemapGradient(gradient: number): IParticleSystem;
  87941. /**
  87942. * Adds a new alpha remap gradient
  87943. * @param gradient defines the gradient to use (between 0 and 1)
  87944. * @param min defines the alpha remap minimal range
  87945. * @param max defines the alpha remap maximal range
  87946. * @returns the current particle system
  87947. */
  87948. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87949. /**
  87950. * Remove a specific alpha remap gradient
  87951. * @param gradient defines the gradient to remove
  87952. * @returns the current particle system
  87953. */
  87954. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87955. /**
  87956. * Adds a new angular speed gradient
  87957. * @param gradient defines the gradient to use (between 0 and 1)
  87958. * @param factor defines the angular speed to affect to the specified gradient
  87959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87960. * @returns the current particle system
  87961. */
  87962. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87963. /**
  87964. * Remove a specific angular speed gradient
  87965. * @param gradient defines the gradient to remove
  87966. * @returns the current particle system
  87967. */
  87968. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87969. /**
  87970. * Adds a new velocity gradient
  87971. * @param gradient defines the gradient to use (between 0 and 1)
  87972. * @param factor defines the velocity to affect to the specified gradient
  87973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87974. * @returns the current particle system
  87975. */
  87976. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87977. /**
  87978. * Remove a specific velocity gradient
  87979. * @param gradient defines the gradient to remove
  87980. * @returns the current particle system
  87981. */
  87982. removeVelocityGradient(gradient: number): IParticleSystem;
  87983. /**
  87984. * Adds a new limit velocity gradient
  87985. * @param gradient defines the gradient to use (between 0 and 1)
  87986. * @param factor defines the limit velocity value to affect to the specified gradient
  87987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87988. * @returns the current particle system
  87989. */
  87990. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87991. /**
  87992. * Remove a specific limit velocity gradient
  87993. * @param gradient defines the gradient to remove
  87994. * @returns the current particle system
  87995. */
  87996. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87997. /**
  87998. * Adds a new drag gradient
  87999. * @param gradient defines the gradient to use (between 0 and 1)
  88000. * @param factor defines the drag value to affect to the specified gradient
  88001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88002. * @returns the current particle system
  88003. */
  88004. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88005. /**
  88006. * Remove a specific drag gradient
  88007. * @param gradient defines the gradient to remove
  88008. * @returns the current particle system
  88009. */
  88010. removeDragGradient(gradient: number): IParticleSystem;
  88011. /**
  88012. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88013. * @param gradient defines the gradient to use (between 0 and 1)
  88014. * @param factor defines the emit rate value to affect to the specified gradient
  88015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88016. * @returns the current particle system
  88017. */
  88018. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88019. /**
  88020. * Remove a specific emit rate gradient
  88021. * @param gradient defines the gradient to remove
  88022. * @returns the current particle system
  88023. */
  88024. removeEmitRateGradient(gradient: number): IParticleSystem;
  88025. /**
  88026. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88027. * @param gradient defines the gradient to use (between 0 and 1)
  88028. * @param factor defines the start size value to affect to the specified gradient
  88029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88030. * @returns the current particle system
  88031. */
  88032. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88033. /**
  88034. * Remove a specific start size gradient
  88035. * @param gradient defines the gradient to remove
  88036. * @returns the current particle system
  88037. */
  88038. removeStartSizeGradient(gradient: number): IParticleSystem;
  88039. private _createRampGradientTexture;
  88040. /**
  88041. * Gets the current list of ramp gradients.
  88042. * You must use addRampGradient and removeRampGradient to udpate this list
  88043. * @returns the list of ramp gradients
  88044. */
  88045. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88046. /** Force the system to rebuild all gradients that need to be resync */
  88047. forceRefreshGradients(): void;
  88048. private _syncRampGradientTexture;
  88049. /**
  88050. * Adds a new ramp gradient used to remap particle colors
  88051. * @param gradient defines the gradient to use (between 0 and 1)
  88052. * @param color defines the color to affect to the specified gradient
  88053. * @returns the current particle system
  88054. */
  88055. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88056. /**
  88057. * Remove a specific ramp gradient
  88058. * @param gradient defines the gradient to remove
  88059. * @returns the current particle system
  88060. */
  88061. removeRampGradient(gradient: number): ParticleSystem;
  88062. /**
  88063. * Adds a new color gradient
  88064. * @param gradient defines the gradient to use (between 0 and 1)
  88065. * @param color1 defines the color to affect to the specified gradient
  88066. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88067. * @returns this particle system
  88068. */
  88069. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88070. /**
  88071. * Remove a specific color gradient
  88072. * @param gradient defines the gradient to remove
  88073. * @returns this particle system
  88074. */
  88075. removeColorGradient(gradient: number): IParticleSystem;
  88076. private _fetchR;
  88077. protected _reset(): void;
  88078. private _resetEffect;
  88079. private _createVertexBuffers;
  88080. private _createIndexBuffer;
  88081. /**
  88082. * Gets the maximum number of particles active at the same time.
  88083. * @returns The max number of active particles.
  88084. */
  88085. getCapacity(): number;
  88086. /**
  88087. * Gets whether there are still active particles in the system.
  88088. * @returns True if it is alive, otherwise false.
  88089. */
  88090. isAlive(): boolean;
  88091. /**
  88092. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88093. * @returns True if it has been started, otherwise false.
  88094. */
  88095. isStarted(): boolean;
  88096. private _prepareSubEmitterInternalArray;
  88097. /**
  88098. * Starts the particle system and begins to emit
  88099. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88100. */
  88101. start(delay?: number): void;
  88102. /**
  88103. * Stops the particle system.
  88104. * @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.
  88105. */
  88106. stop(stopSubEmitters?: boolean): void;
  88107. /**
  88108. * Remove all active particles
  88109. */
  88110. reset(): void;
  88111. /**
  88112. * @hidden (for internal use only)
  88113. */
  88114. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88115. /**
  88116. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88117. * Its lifetime will start back at 0.
  88118. */
  88119. recycleParticle: (particle: Particle) => void;
  88120. private _stopSubEmitters;
  88121. private _createParticle;
  88122. private _removeFromRoot;
  88123. private _emitFromParticle;
  88124. private _update;
  88125. /** @hidden */
  88126. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88127. /** @hidden */
  88128. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88129. /** @hidden */
  88130. private _getEffect;
  88131. /**
  88132. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88133. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88134. */
  88135. animate(preWarmOnly?: boolean): void;
  88136. private _appendParticleVertices;
  88137. /**
  88138. * Rebuilds the particle system.
  88139. */
  88140. rebuild(): void;
  88141. /**
  88142. * Is this system ready to be used/rendered
  88143. * @return true if the system is ready
  88144. */
  88145. isReady(): boolean;
  88146. private _render;
  88147. /**
  88148. * Renders the particle system in its current state.
  88149. * @returns the current number of particles
  88150. */
  88151. render(): number;
  88152. /**
  88153. * Disposes the particle system and free the associated resources
  88154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88155. */
  88156. dispose(disposeTexture?: boolean): void;
  88157. /**
  88158. * Clones the particle system.
  88159. * @param name The name of the cloned object
  88160. * @param newEmitter The new emitter to use
  88161. * @returns the cloned particle system
  88162. */
  88163. clone(name: string, newEmitter: any): ParticleSystem;
  88164. /**
  88165. * Serializes the particle system to a JSON object
  88166. * @param serializeTexture defines if the texture must be serialized as well
  88167. * @returns the JSON object
  88168. */
  88169. serialize(serializeTexture?: boolean): any;
  88170. /** @hidden */
  88171. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  88172. /** @hidden */
  88173. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88174. /**
  88175. * Parses a JSON object to create a particle system.
  88176. * @param parsedParticleSystem The JSON object to parse
  88177. * @param scene The scene to create the particle system in
  88178. * @param rootUrl The root url to use to load external dependencies like texture
  88179. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88180. * @returns the Parsed particle system
  88181. */
  88182. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88183. }
  88184. }
  88185. declare module BABYLON {
  88186. /**
  88187. * A particle represents one of the element emitted by a particle system.
  88188. * This is mainly define by its coordinates, direction, velocity and age.
  88189. */
  88190. export class Particle {
  88191. /**
  88192. * The particle system the particle belongs to.
  88193. */
  88194. particleSystem: ParticleSystem;
  88195. private static _Count;
  88196. /**
  88197. * Unique ID of the particle
  88198. */
  88199. id: number;
  88200. /**
  88201. * The world position of the particle in the scene.
  88202. */
  88203. position: Vector3;
  88204. /**
  88205. * The world direction of the particle in the scene.
  88206. */
  88207. direction: Vector3;
  88208. /**
  88209. * The color of the particle.
  88210. */
  88211. color: Color4;
  88212. /**
  88213. * The color change of the particle per step.
  88214. */
  88215. colorStep: Color4;
  88216. /**
  88217. * Defines how long will the life of the particle be.
  88218. */
  88219. lifeTime: number;
  88220. /**
  88221. * The current age of the particle.
  88222. */
  88223. age: number;
  88224. /**
  88225. * The current size of the particle.
  88226. */
  88227. size: number;
  88228. /**
  88229. * The current scale of the particle.
  88230. */
  88231. scale: Vector2;
  88232. /**
  88233. * The current angle of the particle.
  88234. */
  88235. angle: number;
  88236. /**
  88237. * Defines how fast is the angle changing.
  88238. */
  88239. angularSpeed: number;
  88240. /**
  88241. * Defines the cell index used by the particle to be rendered from a sprite.
  88242. */
  88243. cellIndex: number;
  88244. /**
  88245. * The information required to support color remapping
  88246. */
  88247. remapData: Vector4;
  88248. /** @hidden */
  88249. _randomCellOffset?: number;
  88250. /** @hidden */
  88251. _initialDirection: Nullable<Vector3>;
  88252. /** @hidden */
  88253. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88254. /** @hidden */
  88255. _initialStartSpriteCellID: number;
  88256. /** @hidden */
  88257. _initialEndSpriteCellID: number;
  88258. /** @hidden */
  88259. _currentColorGradient: Nullable<ColorGradient>;
  88260. /** @hidden */
  88261. _currentColor1: Color4;
  88262. /** @hidden */
  88263. _currentColor2: Color4;
  88264. /** @hidden */
  88265. _currentSizeGradient: Nullable<FactorGradient>;
  88266. /** @hidden */
  88267. _currentSize1: number;
  88268. /** @hidden */
  88269. _currentSize2: number;
  88270. /** @hidden */
  88271. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88272. /** @hidden */
  88273. _currentAngularSpeed1: number;
  88274. /** @hidden */
  88275. _currentAngularSpeed2: number;
  88276. /** @hidden */
  88277. _currentVelocityGradient: Nullable<FactorGradient>;
  88278. /** @hidden */
  88279. _currentVelocity1: number;
  88280. /** @hidden */
  88281. _currentVelocity2: number;
  88282. /** @hidden */
  88283. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88284. /** @hidden */
  88285. _currentLimitVelocity1: number;
  88286. /** @hidden */
  88287. _currentLimitVelocity2: number;
  88288. /** @hidden */
  88289. _currentDragGradient: Nullable<FactorGradient>;
  88290. /** @hidden */
  88291. _currentDrag1: number;
  88292. /** @hidden */
  88293. _currentDrag2: number;
  88294. /** @hidden */
  88295. _randomNoiseCoordinates1: Vector3;
  88296. /** @hidden */
  88297. _randomNoiseCoordinates2: Vector3;
  88298. /** @hidden */
  88299. _localPosition?: Vector3;
  88300. /**
  88301. * Creates a new instance Particle
  88302. * @param particleSystem the particle system the particle belongs to
  88303. */
  88304. constructor(
  88305. /**
  88306. * The particle system the particle belongs to.
  88307. */
  88308. particleSystem: ParticleSystem);
  88309. private updateCellInfoFromSystem;
  88310. /**
  88311. * Defines how the sprite cell index is updated for the particle
  88312. */
  88313. updateCellIndex(): void;
  88314. /** @hidden */
  88315. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88316. /** @hidden */
  88317. _inheritParticleInfoToSubEmitters(): void;
  88318. /** @hidden */
  88319. _reset(): void;
  88320. /**
  88321. * Copy the properties of particle to another one.
  88322. * @param other the particle to copy the information to.
  88323. */
  88324. copyTo(other: Particle): void;
  88325. }
  88326. }
  88327. declare module BABYLON {
  88328. /**
  88329. * Particle emitter represents a volume emitting particles.
  88330. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88331. */
  88332. export interface IParticleEmitterType {
  88333. /**
  88334. * Called by the particle System when the direction is computed for the created particle.
  88335. * @param worldMatrix is the world matrix of the particle system
  88336. * @param directionToUpdate is the direction vector to update with the result
  88337. * @param particle is the particle we are computed the direction for
  88338. * @param isLocal defines if the direction should be set in local space
  88339. */
  88340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88341. /**
  88342. * Called by the particle System when the position is computed for the created particle.
  88343. * @param worldMatrix is the world matrix of the particle system
  88344. * @param positionToUpdate is the position vector to update with the result
  88345. * @param particle is the particle we are computed the position for
  88346. * @param isLocal defines if the position should be set in local space
  88347. */
  88348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88349. /**
  88350. * Clones the current emitter and returns a copy of it
  88351. * @returns the new emitter
  88352. */
  88353. clone(): IParticleEmitterType;
  88354. /**
  88355. * Called by the GPUParticleSystem to setup the update shader
  88356. * @param effect defines the update shader
  88357. */
  88358. applyToShader(effect: Effect): void;
  88359. /**
  88360. * Returns a string to use to update the GPU particles update shader
  88361. * @returns the effect defines string
  88362. */
  88363. getEffectDefines(): string;
  88364. /**
  88365. * Returns a string representing the class name
  88366. * @returns a string containing the class name
  88367. */
  88368. getClassName(): string;
  88369. /**
  88370. * Serializes the particle system to a JSON object.
  88371. * @returns the JSON object
  88372. */
  88373. serialize(): any;
  88374. /**
  88375. * Parse properties from a JSON object
  88376. * @param serializationObject defines the JSON object
  88377. * @param scene defines the hosting scene
  88378. */
  88379. parse(serializationObject: any, scene: Scene): void;
  88380. }
  88381. }
  88382. declare module BABYLON {
  88383. /**
  88384. * Particle emitter emitting particles from the inside of a box.
  88385. * It emits the particles randomly between 2 given directions.
  88386. */
  88387. export class BoxParticleEmitter implements IParticleEmitterType {
  88388. /**
  88389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88390. */
  88391. direction1: Vector3;
  88392. /**
  88393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88394. */
  88395. direction2: Vector3;
  88396. /**
  88397. * 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.
  88398. */
  88399. minEmitBox: Vector3;
  88400. /**
  88401. * 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.
  88402. */
  88403. maxEmitBox: Vector3;
  88404. /**
  88405. * Creates a new instance BoxParticleEmitter
  88406. */
  88407. constructor();
  88408. /**
  88409. * Called by the particle System when the direction is computed for the created particle.
  88410. * @param worldMatrix is the world matrix of the particle system
  88411. * @param directionToUpdate is the direction vector to update with the result
  88412. * @param particle is the particle we are computed the direction for
  88413. * @param isLocal defines if the direction should be set in local space
  88414. */
  88415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88416. /**
  88417. * Called by the particle System when the position is computed for the created particle.
  88418. * @param worldMatrix is the world matrix of the particle system
  88419. * @param positionToUpdate is the position vector to update with the result
  88420. * @param particle is the particle we are computed the position for
  88421. * @param isLocal defines if the position should be set in local space
  88422. */
  88423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88424. /**
  88425. * Clones the current emitter and returns a copy of it
  88426. * @returns the new emitter
  88427. */
  88428. clone(): BoxParticleEmitter;
  88429. /**
  88430. * Called by the GPUParticleSystem to setup the update shader
  88431. * @param effect defines the update shader
  88432. */
  88433. applyToShader(effect: Effect): void;
  88434. /**
  88435. * Returns a string to use to update the GPU particles update shader
  88436. * @returns a string containng the defines string
  88437. */
  88438. getEffectDefines(): string;
  88439. /**
  88440. * Returns the string "BoxParticleEmitter"
  88441. * @returns a string containing the class name
  88442. */
  88443. getClassName(): string;
  88444. /**
  88445. * Serializes the particle system to a JSON object.
  88446. * @returns the JSON object
  88447. */
  88448. serialize(): any;
  88449. /**
  88450. * Parse properties from a JSON object
  88451. * @param serializationObject defines the JSON object
  88452. */
  88453. parse(serializationObject: any): void;
  88454. }
  88455. }
  88456. declare module BABYLON {
  88457. /**
  88458. * Particle emitter emitting particles from the inside of a cone.
  88459. * It emits the particles alongside the cone volume from the base to the particle.
  88460. * The emission direction might be randomized.
  88461. */
  88462. export class ConeParticleEmitter implements IParticleEmitterType {
  88463. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88464. directionRandomizer: number;
  88465. private _radius;
  88466. private _angle;
  88467. private _height;
  88468. /**
  88469. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88470. */
  88471. radiusRange: number;
  88472. /**
  88473. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88474. */
  88475. heightRange: number;
  88476. /**
  88477. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88478. */
  88479. emitFromSpawnPointOnly: boolean;
  88480. /**
  88481. * Gets or sets the radius of the emission cone
  88482. */
  88483. get radius(): number;
  88484. set radius(value: number);
  88485. /**
  88486. * Gets or sets the angle of the emission cone
  88487. */
  88488. get angle(): number;
  88489. set angle(value: number);
  88490. private _buildHeight;
  88491. /**
  88492. * Creates a new instance ConeParticleEmitter
  88493. * @param radius the radius of the emission cone (1 by default)
  88494. * @param angle the cone base angle (PI by default)
  88495. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88496. */
  88497. constructor(radius?: number, angle?: number,
  88498. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88499. directionRandomizer?: number);
  88500. /**
  88501. * Called by the particle System when the direction is computed for the created particle.
  88502. * @param worldMatrix is the world matrix of the particle system
  88503. * @param directionToUpdate is the direction vector to update with the result
  88504. * @param particle is the particle we are computed the direction for
  88505. * @param isLocal defines if the direction should be set in local space
  88506. */
  88507. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88508. /**
  88509. * Called by the particle System when the position is computed for the created particle.
  88510. * @param worldMatrix is the world matrix of the particle system
  88511. * @param positionToUpdate is the position vector to update with the result
  88512. * @param particle is the particle we are computed the position for
  88513. * @param isLocal defines if the position should be set in local space
  88514. */
  88515. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88516. /**
  88517. * Clones the current emitter and returns a copy of it
  88518. * @returns the new emitter
  88519. */
  88520. clone(): ConeParticleEmitter;
  88521. /**
  88522. * Called by the GPUParticleSystem to setup the update shader
  88523. * @param effect defines the update shader
  88524. */
  88525. applyToShader(effect: Effect): void;
  88526. /**
  88527. * Returns a string to use to update the GPU particles update shader
  88528. * @returns a string containng the defines string
  88529. */
  88530. getEffectDefines(): string;
  88531. /**
  88532. * Returns the string "ConeParticleEmitter"
  88533. * @returns a string containing the class name
  88534. */
  88535. getClassName(): string;
  88536. /**
  88537. * Serializes the particle system to a JSON object.
  88538. * @returns the JSON object
  88539. */
  88540. serialize(): any;
  88541. /**
  88542. * Parse properties from a JSON object
  88543. * @param serializationObject defines the JSON object
  88544. */
  88545. parse(serializationObject: any): void;
  88546. }
  88547. }
  88548. declare module BABYLON {
  88549. /**
  88550. * Particle emitter emitting particles from the inside of a cylinder.
  88551. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88552. */
  88553. export class CylinderParticleEmitter implements IParticleEmitterType {
  88554. /**
  88555. * The radius of the emission cylinder.
  88556. */
  88557. radius: number;
  88558. /**
  88559. * The height of the emission cylinder.
  88560. */
  88561. height: number;
  88562. /**
  88563. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88564. */
  88565. radiusRange: number;
  88566. /**
  88567. * How much to randomize the particle direction [0-1].
  88568. */
  88569. directionRandomizer: number;
  88570. /**
  88571. * Creates a new instance CylinderParticleEmitter
  88572. * @param radius the radius of the emission cylinder (1 by default)
  88573. * @param height the height of the emission cylinder (1 by default)
  88574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88575. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88576. */
  88577. constructor(
  88578. /**
  88579. * The radius of the emission cylinder.
  88580. */
  88581. radius?: number,
  88582. /**
  88583. * The height of the emission cylinder.
  88584. */
  88585. height?: number,
  88586. /**
  88587. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88588. */
  88589. radiusRange?: number,
  88590. /**
  88591. * How much to randomize the particle direction [0-1].
  88592. */
  88593. directionRandomizer?: number);
  88594. /**
  88595. * Called by the particle System when the direction is computed for the created particle.
  88596. * @param worldMatrix is the world matrix of the particle system
  88597. * @param directionToUpdate is the direction vector to update with the result
  88598. * @param particle is the particle we are computed the direction for
  88599. * @param isLocal defines if the direction should be set in local space
  88600. */
  88601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88602. /**
  88603. * Called by the particle System when the position is computed for the created particle.
  88604. * @param worldMatrix is the world matrix of the particle system
  88605. * @param positionToUpdate is the position vector to update with the result
  88606. * @param particle is the particle we are computed the position for
  88607. * @param isLocal defines if the position should be set in local space
  88608. */
  88609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88610. /**
  88611. * Clones the current emitter and returns a copy of it
  88612. * @returns the new emitter
  88613. */
  88614. clone(): CylinderParticleEmitter;
  88615. /**
  88616. * Called by the GPUParticleSystem to setup the update shader
  88617. * @param effect defines the update shader
  88618. */
  88619. applyToShader(effect: Effect): void;
  88620. /**
  88621. * Returns a string to use to update the GPU particles update shader
  88622. * @returns a string containng the defines string
  88623. */
  88624. getEffectDefines(): string;
  88625. /**
  88626. * Returns the string "CylinderParticleEmitter"
  88627. * @returns a string containing the class name
  88628. */
  88629. getClassName(): string;
  88630. /**
  88631. * Serializes the particle system to a JSON object.
  88632. * @returns the JSON object
  88633. */
  88634. serialize(): any;
  88635. /**
  88636. * Parse properties from a JSON object
  88637. * @param serializationObject defines the JSON object
  88638. */
  88639. parse(serializationObject: any): void;
  88640. }
  88641. /**
  88642. * Particle emitter emitting particles from the inside of a cylinder.
  88643. * It emits the particles randomly between two vectors.
  88644. */
  88645. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88646. /**
  88647. * The min limit of the emission direction.
  88648. */
  88649. direction1: Vector3;
  88650. /**
  88651. * The max limit of the emission direction.
  88652. */
  88653. direction2: Vector3;
  88654. /**
  88655. * Creates a new instance CylinderDirectedParticleEmitter
  88656. * @param radius the radius of the emission cylinder (1 by default)
  88657. * @param height the height of the emission cylinder (1 by default)
  88658. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88659. * @param direction1 the min limit of the emission direction (up vector by default)
  88660. * @param direction2 the max limit of the emission direction (up vector by default)
  88661. */
  88662. constructor(radius?: number, height?: number, radiusRange?: number,
  88663. /**
  88664. * The min limit of the emission direction.
  88665. */
  88666. direction1?: Vector3,
  88667. /**
  88668. * The max limit of the emission direction.
  88669. */
  88670. direction2?: Vector3);
  88671. /**
  88672. * Called by the particle System when the direction is computed for the created particle.
  88673. * @param worldMatrix is the world matrix of the particle system
  88674. * @param directionToUpdate is the direction vector to update with the result
  88675. * @param particle is the particle we are computed the direction for
  88676. */
  88677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88678. /**
  88679. * Clones the current emitter and returns a copy of it
  88680. * @returns the new emitter
  88681. */
  88682. clone(): CylinderDirectedParticleEmitter;
  88683. /**
  88684. * Called by the GPUParticleSystem to setup the update shader
  88685. * @param effect defines the update shader
  88686. */
  88687. applyToShader(effect: Effect): void;
  88688. /**
  88689. * Returns a string to use to update the GPU particles update shader
  88690. * @returns a string containng the defines string
  88691. */
  88692. getEffectDefines(): string;
  88693. /**
  88694. * Returns the string "CylinderDirectedParticleEmitter"
  88695. * @returns a string containing the class name
  88696. */
  88697. getClassName(): string;
  88698. /**
  88699. * Serializes the particle system to a JSON object.
  88700. * @returns the JSON object
  88701. */
  88702. serialize(): any;
  88703. /**
  88704. * Parse properties from a JSON object
  88705. * @param serializationObject defines the JSON object
  88706. */
  88707. parse(serializationObject: any): void;
  88708. }
  88709. }
  88710. declare module BABYLON {
  88711. /**
  88712. * Particle emitter emitting particles from the inside of a hemisphere.
  88713. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88714. */
  88715. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88716. /**
  88717. * The radius of the emission hemisphere.
  88718. */
  88719. radius: number;
  88720. /**
  88721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88722. */
  88723. radiusRange: number;
  88724. /**
  88725. * How much to randomize the particle direction [0-1].
  88726. */
  88727. directionRandomizer: number;
  88728. /**
  88729. * Creates a new instance HemisphericParticleEmitter
  88730. * @param radius the radius of the emission hemisphere (1 by default)
  88731. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88733. */
  88734. constructor(
  88735. /**
  88736. * The radius of the emission hemisphere.
  88737. */
  88738. radius?: number,
  88739. /**
  88740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88741. */
  88742. radiusRange?: number,
  88743. /**
  88744. * How much to randomize the particle direction [0-1].
  88745. */
  88746. directionRandomizer?: number);
  88747. /**
  88748. * Called by the particle System when the direction is computed for the created particle.
  88749. * @param worldMatrix is the world matrix of the particle system
  88750. * @param directionToUpdate is the direction vector to update with the result
  88751. * @param particle is the particle we are computed the direction for
  88752. * @param isLocal defines if the direction should be set in local space
  88753. */
  88754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88755. /**
  88756. * Called by the particle System when the position is computed for the created particle.
  88757. * @param worldMatrix is the world matrix of the particle system
  88758. * @param positionToUpdate is the position vector to update with the result
  88759. * @param particle is the particle we are computed the position for
  88760. * @param isLocal defines if the position should be set in local space
  88761. */
  88762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88763. /**
  88764. * Clones the current emitter and returns a copy of it
  88765. * @returns the new emitter
  88766. */
  88767. clone(): HemisphericParticleEmitter;
  88768. /**
  88769. * Called by the GPUParticleSystem to setup the update shader
  88770. * @param effect defines the update shader
  88771. */
  88772. applyToShader(effect: Effect): void;
  88773. /**
  88774. * Returns a string to use to update the GPU particles update shader
  88775. * @returns a string containng the defines string
  88776. */
  88777. getEffectDefines(): string;
  88778. /**
  88779. * Returns the string "HemisphericParticleEmitter"
  88780. * @returns a string containing the class name
  88781. */
  88782. getClassName(): string;
  88783. /**
  88784. * Serializes the particle system to a JSON object.
  88785. * @returns the JSON object
  88786. */
  88787. serialize(): any;
  88788. /**
  88789. * Parse properties from a JSON object
  88790. * @param serializationObject defines the JSON object
  88791. */
  88792. parse(serializationObject: any): void;
  88793. }
  88794. }
  88795. declare module BABYLON {
  88796. /**
  88797. * Particle emitter emitting particles from a point.
  88798. * It emits the particles randomly between 2 given directions.
  88799. */
  88800. export class PointParticleEmitter implements IParticleEmitterType {
  88801. /**
  88802. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88803. */
  88804. direction1: Vector3;
  88805. /**
  88806. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88807. */
  88808. direction2: Vector3;
  88809. /**
  88810. * Creates a new instance PointParticleEmitter
  88811. */
  88812. constructor();
  88813. /**
  88814. * Called by the particle System when the direction is computed for the created particle.
  88815. * @param worldMatrix is the world matrix of the particle system
  88816. * @param directionToUpdate is the direction vector to update with the result
  88817. * @param particle is the particle we are computed the direction for
  88818. * @param isLocal defines if the direction should be set in local space
  88819. */
  88820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88821. /**
  88822. * Called by the particle System when the position is computed for the created particle.
  88823. * @param worldMatrix is the world matrix of the particle system
  88824. * @param positionToUpdate is the position vector to update with the result
  88825. * @param particle is the particle we are computed the position for
  88826. * @param isLocal defines if the position should be set in local space
  88827. */
  88828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88829. /**
  88830. * Clones the current emitter and returns a copy of it
  88831. * @returns the new emitter
  88832. */
  88833. clone(): PointParticleEmitter;
  88834. /**
  88835. * Called by the GPUParticleSystem to setup the update shader
  88836. * @param effect defines the update shader
  88837. */
  88838. applyToShader(effect: Effect): void;
  88839. /**
  88840. * Returns a string to use to update the GPU particles update shader
  88841. * @returns a string containng the defines string
  88842. */
  88843. getEffectDefines(): string;
  88844. /**
  88845. * Returns the string "PointParticleEmitter"
  88846. * @returns a string containing the class name
  88847. */
  88848. getClassName(): string;
  88849. /**
  88850. * Serializes the particle system to a JSON object.
  88851. * @returns the JSON object
  88852. */
  88853. serialize(): any;
  88854. /**
  88855. * Parse properties from a JSON object
  88856. * @param serializationObject defines the JSON object
  88857. */
  88858. parse(serializationObject: any): void;
  88859. }
  88860. }
  88861. declare module BABYLON {
  88862. /**
  88863. * Particle emitter emitting particles from the inside of a sphere.
  88864. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88865. */
  88866. export class SphereParticleEmitter implements IParticleEmitterType {
  88867. /**
  88868. * The radius of the emission sphere.
  88869. */
  88870. radius: number;
  88871. /**
  88872. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88873. */
  88874. radiusRange: number;
  88875. /**
  88876. * How much to randomize the particle direction [0-1].
  88877. */
  88878. directionRandomizer: number;
  88879. /**
  88880. * Creates a new instance SphereParticleEmitter
  88881. * @param radius the radius of the emission sphere (1 by default)
  88882. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88883. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88884. */
  88885. constructor(
  88886. /**
  88887. * The radius of the emission sphere.
  88888. */
  88889. radius?: number,
  88890. /**
  88891. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88892. */
  88893. radiusRange?: number,
  88894. /**
  88895. * How much to randomize the particle direction [0-1].
  88896. */
  88897. directionRandomizer?: number);
  88898. /**
  88899. * Called by the particle System when the direction is computed for the created particle.
  88900. * @param worldMatrix is the world matrix of the particle system
  88901. * @param directionToUpdate is the direction vector to update with the result
  88902. * @param particle is the particle we are computed the direction for
  88903. * @param isLocal defines if the direction should be set in local space
  88904. */
  88905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88906. /**
  88907. * Called by the particle System when the position is computed for the created particle.
  88908. * @param worldMatrix is the world matrix of the particle system
  88909. * @param positionToUpdate is the position vector to update with the result
  88910. * @param particle is the particle we are computed the position for
  88911. * @param isLocal defines if the position should be set in local space
  88912. */
  88913. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88914. /**
  88915. * Clones the current emitter and returns a copy of it
  88916. * @returns the new emitter
  88917. */
  88918. clone(): SphereParticleEmitter;
  88919. /**
  88920. * Called by the GPUParticleSystem to setup the update shader
  88921. * @param effect defines the update shader
  88922. */
  88923. applyToShader(effect: Effect): void;
  88924. /**
  88925. * Returns a string to use to update the GPU particles update shader
  88926. * @returns a string containng the defines string
  88927. */
  88928. getEffectDefines(): string;
  88929. /**
  88930. * Returns the string "SphereParticleEmitter"
  88931. * @returns a string containing the class name
  88932. */
  88933. getClassName(): string;
  88934. /**
  88935. * Serializes the particle system to a JSON object.
  88936. * @returns the JSON object
  88937. */
  88938. serialize(): any;
  88939. /**
  88940. * Parse properties from a JSON object
  88941. * @param serializationObject defines the JSON object
  88942. */
  88943. parse(serializationObject: any): void;
  88944. }
  88945. /**
  88946. * Particle emitter emitting particles from the inside of a sphere.
  88947. * It emits the particles randomly between two vectors.
  88948. */
  88949. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88950. /**
  88951. * The min limit of the emission direction.
  88952. */
  88953. direction1: Vector3;
  88954. /**
  88955. * The max limit of the emission direction.
  88956. */
  88957. direction2: Vector3;
  88958. /**
  88959. * Creates a new instance SphereDirectedParticleEmitter
  88960. * @param radius the radius of the emission sphere (1 by default)
  88961. * @param direction1 the min limit of the emission direction (up vector by default)
  88962. * @param direction2 the max limit of the emission direction (up vector by default)
  88963. */
  88964. constructor(radius?: number,
  88965. /**
  88966. * The min limit of the emission direction.
  88967. */
  88968. direction1?: Vector3,
  88969. /**
  88970. * The max limit of the emission direction.
  88971. */
  88972. direction2?: Vector3);
  88973. /**
  88974. * Called by the particle System when the direction is computed for the created particle.
  88975. * @param worldMatrix is the world matrix of the particle system
  88976. * @param directionToUpdate is the direction vector to update with the result
  88977. * @param particle is the particle we are computed the direction for
  88978. */
  88979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88980. /**
  88981. * Clones the current emitter and returns a copy of it
  88982. * @returns the new emitter
  88983. */
  88984. clone(): SphereDirectedParticleEmitter;
  88985. /**
  88986. * Called by the GPUParticleSystem to setup the update shader
  88987. * @param effect defines the update shader
  88988. */
  88989. applyToShader(effect: Effect): void;
  88990. /**
  88991. * Returns a string to use to update the GPU particles update shader
  88992. * @returns a string containng the defines string
  88993. */
  88994. getEffectDefines(): string;
  88995. /**
  88996. * Returns the string "SphereDirectedParticleEmitter"
  88997. * @returns a string containing the class name
  88998. */
  88999. getClassName(): string;
  89000. /**
  89001. * Serializes the particle system to a JSON object.
  89002. * @returns the JSON object
  89003. */
  89004. serialize(): any;
  89005. /**
  89006. * Parse properties from a JSON object
  89007. * @param serializationObject defines the JSON object
  89008. */
  89009. parse(serializationObject: any): void;
  89010. }
  89011. }
  89012. declare module BABYLON {
  89013. /**
  89014. * Particle emitter emitting particles from a custom list of positions.
  89015. */
  89016. export class CustomParticleEmitter implements IParticleEmitterType {
  89017. /**
  89018. * Gets or sets the position generator that will create the inital position of each particle.
  89019. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  89020. */
  89021. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  89022. /**
  89023. * Gets or sets the destination generator that will create the final destination of each particle.
  89024. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  89025. */
  89026. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  89027. /**
  89028. * Creates a new instance CustomParticleEmitter
  89029. */
  89030. constructor();
  89031. /**
  89032. * Called by the particle System when the direction is computed for the created particle.
  89033. * @param worldMatrix is the world matrix of the particle system
  89034. * @param directionToUpdate is the direction vector to update with the result
  89035. * @param particle is the particle we are computed the direction for
  89036. * @param isLocal defines if the direction should be set in local space
  89037. */
  89038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89039. /**
  89040. * Called by the particle System when the position is computed for the created particle.
  89041. * @param worldMatrix is the world matrix of the particle system
  89042. * @param positionToUpdate is the position vector to update with the result
  89043. * @param particle is the particle we are computed the position for
  89044. * @param isLocal defines if the position should be set in local space
  89045. */
  89046. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89047. /**
  89048. * Clones the current emitter and returns a copy of it
  89049. * @returns the new emitter
  89050. */
  89051. clone(): CustomParticleEmitter;
  89052. /**
  89053. * Called by the GPUParticleSystem to setup the update shader
  89054. * @param effect defines the update shader
  89055. */
  89056. applyToShader(effect: Effect): void;
  89057. /**
  89058. * Returns a string to use to update the GPU particles update shader
  89059. * @returns a string containng the defines string
  89060. */
  89061. getEffectDefines(): string;
  89062. /**
  89063. * Returns the string "PointParticleEmitter"
  89064. * @returns a string containing the class name
  89065. */
  89066. getClassName(): string;
  89067. /**
  89068. * Serializes the particle system to a JSON object.
  89069. * @returns the JSON object
  89070. */
  89071. serialize(): any;
  89072. /**
  89073. * Parse properties from a JSON object
  89074. * @param serializationObject defines the JSON object
  89075. */
  89076. parse(serializationObject: any): void;
  89077. }
  89078. }
  89079. declare module BABYLON {
  89080. /**
  89081. * Particle emitter emitting particles from the inside of a box.
  89082. * It emits the particles randomly between 2 given directions.
  89083. */
  89084. export class MeshParticleEmitter implements IParticleEmitterType {
  89085. private _indices;
  89086. private _positions;
  89087. private _normals;
  89088. private _storedNormal;
  89089. private _mesh;
  89090. /**
  89091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89092. */
  89093. direction1: Vector3;
  89094. /**
  89095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89096. */
  89097. direction2: Vector3;
  89098. /**
  89099. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  89100. */
  89101. useMeshNormalsForDirection: boolean;
  89102. /** Defines the mesh to use as source */
  89103. get mesh(): Nullable<AbstractMesh>;
  89104. set mesh(value: Nullable<AbstractMesh>);
  89105. /**
  89106. * Creates a new instance MeshParticleEmitter
  89107. * @param mesh defines the mesh to use as source
  89108. */
  89109. constructor(mesh?: Nullable<AbstractMesh>);
  89110. /**
  89111. * Called by the particle System when the direction is computed for the created particle.
  89112. * @param worldMatrix is the world matrix of the particle system
  89113. * @param directionToUpdate is the direction vector to update with the result
  89114. * @param particle is the particle we are computed the direction for
  89115. * @param isLocal defines if the direction should be set in local space
  89116. */
  89117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89118. /**
  89119. * Called by the particle System when the position is computed for the created particle.
  89120. * @param worldMatrix is the world matrix of the particle system
  89121. * @param positionToUpdate is the position vector to update with the result
  89122. * @param particle is the particle we are computed the position for
  89123. * @param isLocal defines if the position should be set in local space
  89124. */
  89125. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89126. /**
  89127. * Clones the current emitter and returns a copy of it
  89128. * @returns the new emitter
  89129. */
  89130. clone(): MeshParticleEmitter;
  89131. /**
  89132. * Called by the GPUParticleSystem to setup the update shader
  89133. * @param effect defines the update shader
  89134. */
  89135. applyToShader(effect: Effect): void;
  89136. /**
  89137. * Returns a string to use to update the GPU particles update shader
  89138. * @returns a string containng the defines string
  89139. */
  89140. getEffectDefines(): string;
  89141. /**
  89142. * Returns the string "BoxParticleEmitter"
  89143. * @returns a string containing the class name
  89144. */
  89145. getClassName(): string;
  89146. /**
  89147. * Serializes the particle system to a JSON object.
  89148. * @returns the JSON object
  89149. */
  89150. serialize(): any;
  89151. /**
  89152. * Parse properties from a JSON object
  89153. * @param serializationObject defines the JSON object
  89154. * @param scene defines the hosting scene
  89155. */
  89156. parse(serializationObject: any, scene: Scene): void;
  89157. }
  89158. }
  89159. declare module BABYLON {
  89160. /**
  89161. * Interface representing a particle system in Babylon.js.
  89162. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89163. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89164. */
  89165. export interface IParticleSystem {
  89166. /**
  89167. * List of animations used by the particle system.
  89168. */
  89169. animations: Animation[];
  89170. /**
  89171. * The id of the Particle system.
  89172. */
  89173. id: string;
  89174. /**
  89175. * The name of the Particle system.
  89176. */
  89177. name: string;
  89178. /**
  89179. * The emitter represents the Mesh or position we are attaching the particle system to.
  89180. */
  89181. emitter: Nullable<AbstractMesh | Vector3>;
  89182. /**
  89183. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89184. */
  89185. isBillboardBased: boolean;
  89186. /**
  89187. * The rendering group used by the Particle system to chose when to render.
  89188. */
  89189. renderingGroupId: number;
  89190. /**
  89191. * The layer mask we are rendering the particles through.
  89192. */
  89193. layerMask: number;
  89194. /**
  89195. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89196. */
  89197. updateSpeed: number;
  89198. /**
  89199. * The amount of time the particle system is running (depends of the overall update speed).
  89200. */
  89201. targetStopDuration: number;
  89202. /**
  89203. * The texture used to render each particle. (this can be a spritesheet)
  89204. */
  89205. particleTexture: Nullable<Texture>;
  89206. /**
  89207. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89208. */
  89209. blendMode: number;
  89210. /**
  89211. * Minimum life time of emitting particles.
  89212. */
  89213. minLifeTime: number;
  89214. /**
  89215. * Maximum life time of emitting particles.
  89216. */
  89217. maxLifeTime: number;
  89218. /**
  89219. * Minimum Size of emitting particles.
  89220. */
  89221. minSize: number;
  89222. /**
  89223. * Maximum Size of emitting particles.
  89224. */
  89225. maxSize: number;
  89226. /**
  89227. * Minimum scale of emitting particles on X axis.
  89228. */
  89229. minScaleX: number;
  89230. /**
  89231. * Maximum scale of emitting particles on X axis.
  89232. */
  89233. maxScaleX: number;
  89234. /**
  89235. * Minimum scale of emitting particles on Y axis.
  89236. */
  89237. minScaleY: number;
  89238. /**
  89239. * Maximum scale of emitting particles on Y axis.
  89240. */
  89241. maxScaleY: number;
  89242. /**
  89243. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89244. */
  89245. color1: Color4;
  89246. /**
  89247. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89248. */
  89249. color2: Color4;
  89250. /**
  89251. * Color the particle will have at the end of its lifetime.
  89252. */
  89253. colorDead: Color4;
  89254. /**
  89255. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89256. */
  89257. emitRate: number;
  89258. /**
  89259. * You can use gravity if you want to give an orientation to your particles.
  89260. */
  89261. gravity: Vector3;
  89262. /**
  89263. * Minimum power of emitting particles.
  89264. */
  89265. minEmitPower: number;
  89266. /**
  89267. * Maximum power of emitting particles.
  89268. */
  89269. maxEmitPower: number;
  89270. /**
  89271. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89272. */
  89273. minAngularSpeed: number;
  89274. /**
  89275. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89276. */
  89277. maxAngularSpeed: number;
  89278. /**
  89279. * Gets or sets the minimal initial rotation in radians.
  89280. */
  89281. minInitialRotation: number;
  89282. /**
  89283. * Gets or sets the maximal initial rotation in radians.
  89284. */
  89285. maxInitialRotation: number;
  89286. /**
  89287. * The particle emitter type defines the emitter used by the particle system.
  89288. * It can be for example box, sphere, or cone...
  89289. */
  89290. particleEmitterType: Nullable<IParticleEmitterType>;
  89291. /**
  89292. * Defines the delay in milliseconds before starting the system (0 by default)
  89293. */
  89294. startDelay: number;
  89295. /**
  89296. * 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
  89297. */
  89298. preWarmCycles: number;
  89299. /**
  89300. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89301. */
  89302. preWarmStepOffset: number;
  89303. /**
  89304. * 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)
  89305. */
  89306. spriteCellChangeSpeed: number;
  89307. /**
  89308. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89309. */
  89310. startSpriteCellID: number;
  89311. /**
  89312. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89313. */
  89314. endSpriteCellID: number;
  89315. /**
  89316. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89317. */
  89318. spriteCellWidth: number;
  89319. /**
  89320. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89321. */
  89322. spriteCellHeight: number;
  89323. /**
  89324. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89325. */
  89326. spriteRandomStartCell: boolean;
  89327. /**
  89328. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89329. */
  89330. isAnimationSheetEnabled: boolean;
  89331. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89332. translationPivot: Vector2;
  89333. /**
  89334. * Gets or sets a texture used to add random noise to particle positions
  89335. */
  89336. noiseTexture: Nullable<BaseTexture>;
  89337. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89338. noiseStrength: Vector3;
  89339. /**
  89340. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89341. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89342. */
  89343. billboardMode: number;
  89344. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89345. limitVelocityDamping: number;
  89346. /**
  89347. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89348. */
  89349. beginAnimationOnStart: boolean;
  89350. /**
  89351. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89352. */
  89353. beginAnimationFrom: number;
  89354. /**
  89355. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89356. */
  89357. beginAnimationTo: number;
  89358. /**
  89359. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89360. */
  89361. beginAnimationLoop: boolean;
  89362. /**
  89363. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89364. */
  89365. disposeOnStop: boolean;
  89366. /**
  89367. * Specifies if the particles are updated in emitter local space or world space
  89368. */
  89369. isLocal: boolean;
  89370. /** Snippet ID if the particle system was created from the snippet server */
  89371. snippetId: string;
  89372. /**
  89373. * Gets the maximum number of particles active at the same time.
  89374. * @returns The max number of active particles.
  89375. */
  89376. getCapacity(): number;
  89377. /**
  89378. * Gets the number of particles active at the same time.
  89379. * @returns The number of active particles.
  89380. */
  89381. getActiveCount(): number;
  89382. /**
  89383. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89384. * @returns True if it has been started, otherwise false.
  89385. */
  89386. isStarted(): boolean;
  89387. /**
  89388. * Animates the particle system for this frame.
  89389. */
  89390. animate(): void;
  89391. /**
  89392. * Renders the particle system in its current state.
  89393. * @returns the current number of particles
  89394. */
  89395. render(): number;
  89396. /**
  89397. * Dispose the particle system and frees its associated resources.
  89398. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89399. */
  89400. dispose(disposeTexture?: boolean): void;
  89401. /**
  89402. * Clones the particle system.
  89403. * @param name The name of the cloned object
  89404. * @param newEmitter The new emitter to use
  89405. * @returns the cloned particle system
  89406. */
  89407. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89408. /**
  89409. * Serializes the particle system to a JSON object
  89410. * @param serializeTexture defines if the texture must be serialized as well
  89411. * @returns the JSON object
  89412. */
  89413. serialize(serializeTexture: boolean): any;
  89414. /**
  89415. * Rebuild the particle system
  89416. */
  89417. rebuild(): void;
  89418. /** Force the system to rebuild all gradients that need to be resync */
  89419. forceRefreshGradients(): void;
  89420. /**
  89421. * Starts the particle system and begins to emit
  89422. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89423. */
  89424. start(delay?: number): void;
  89425. /**
  89426. * Stops the particle system.
  89427. */
  89428. stop(): void;
  89429. /**
  89430. * Remove all active particles
  89431. */
  89432. reset(): void;
  89433. /**
  89434. * Gets a boolean indicating that the system is stopping
  89435. * @returns true if the system is currently stopping
  89436. */
  89437. isStopping(): boolean;
  89438. /**
  89439. * Is this system ready to be used/rendered
  89440. * @return true if the system is ready
  89441. */
  89442. isReady(): boolean;
  89443. /**
  89444. * Returns the string "ParticleSystem"
  89445. * @returns a string containing the class name
  89446. */
  89447. getClassName(): string;
  89448. /**
  89449. * Adds a new color gradient
  89450. * @param gradient defines the gradient to use (between 0 and 1)
  89451. * @param color1 defines the color to affect to the specified gradient
  89452. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89453. * @returns the current particle system
  89454. */
  89455. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89456. /**
  89457. * Remove a specific color gradient
  89458. * @param gradient defines the gradient to remove
  89459. * @returns the current particle system
  89460. */
  89461. removeColorGradient(gradient: number): IParticleSystem;
  89462. /**
  89463. * Adds a new size gradient
  89464. * @param gradient defines the gradient to use (between 0 and 1)
  89465. * @param factor defines the size factor to affect to the specified gradient
  89466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89467. * @returns the current particle system
  89468. */
  89469. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89470. /**
  89471. * Remove a specific size gradient
  89472. * @param gradient defines the gradient to remove
  89473. * @returns the current particle system
  89474. */
  89475. removeSizeGradient(gradient: number): IParticleSystem;
  89476. /**
  89477. * Gets the current list of color gradients.
  89478. * You must use addColorGradient and removeColorGradient to udpate this list
  89479. * @returns the list of color gradients
  89480. */
  89481. getColorGradients(): Nullable<Array<ColorGradient>>;
  89482. /**
  89483. * Gets the current list of size gradients.
  89484. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89485. * @returns the list of size gradients
  89486. */
  89487. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89488. /**
  89489. * Gets the current list of angular speed gradients.
  89490. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89491. * @returns the list of angular speed gradients
  89492. */
  89493. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89494. /**
  89495. * Adds a new angular speed gradient
  89496. * @param gradient defines the gradient to use (between 0 and 1)
  89497. * @param factor defines the angular speed to affect to the specified gradient
  89498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89499. * @returns the current particle system
  89500. */
  89501. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89502. /**
  89503. * Remove a specific angular speed gradient
  89504. * @param gradient defines the gradient to remove
  89505. * @returns the current particle system
  89506. */
  89507. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89508. /**
  89509. * Gets the current list of velocity gradients.
  89510. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89511. * @returns the list of velocity gradients
  89512. */
  89513. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89514. /**
  89515. * Adds a new velocity gradient
  89516. * @param gradient defines the gradient to use (between 0 and 1)
  89517. * @param factor defines the velocity to affect to the specified gradient
  89518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89519. * @returns the current particle system
  89520. */
  89521. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89522. /**
  89523. * Remove a specific velocity gradient
  89524. * @param gradient defines the gradient to remove
  89525. * @returns the current particle system
  89526. */
  89527. removeVelocityGradient(gradient: number): IParticleSystem;
  89528. /**
  89529. * Gets the current list of limit velocity gradients.
  89530. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89531. * @returns the list of limit velocity gradients
  89532. */
  89533. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89534. /**
  89535. * Adds a new limit velocity gradient
  89536. * @param gradient defines the gradient to use (between 0 and 1)
  89537. * @param factor defines the limit velocity to affect to the specified gradient
  89538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89539. * @returns the current particle system
  89540. */
  89541. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89542. /**
  89543. * Remove a specific limit velocity gradient
  89544. * @param gradient defines the gradient to remove
  89545. * @returns the current particle system
  89546. */
  89547. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89548. /**
  89549. * Adds a new drag gradient
  89550. * @param gradient defines the gradient to use (between 0 and 1)
  89551. * @param factor defines the drag to affect to the specified gradient
  89552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89553. * @returns the current particle system
  89554. */
  89555. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89556. /**
  89557. * Remove a specific drag gradient
  89558. * @param gradient defines the gradient to remove
  89559. * @returns the current particle system
  89560. */
  89561. removeDragGradient(gradient: number): IParticleSystem;
  89562. /**
  89563. * Gets the current list of drag gradients.
  89564. * You must use addDragGradient and removeDragGradient to udpate this list
  89565. * @returns the list of drag gradients
  89566. */
  89567. getDragGradients(): Nullable<Array<FactorGradient>>;
  89568. /**
  89569. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89570. * @param gradient defines the gradient to use (between 0 and 1)
  89571. * @param factor defines the emit rate to affect to the specified gradient
  89572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89573. * @returns the current particle system
  89574. */
  89575. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89576. /**
  89577. * Remove a specific emit rate gradient
  89578. * @param gradient defines the gradient to remove
  89579. * @returns the current particle system
  89580. */
  89581. removeEmitRateGradient(gradient: number): IParticleSystem;
  89582. /**
  89583. * Gets the current list of emit rate gradients.
  89584. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89585. * @returns the list of emit rate gradients
  89586. */
  89587. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89588. /**
  89589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89590. * @param gradient defines the gradient to use (between 0 and 1)
  89591. * @param factor defines the start size to affect to the specified gradient
  89592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89593. * @returns the current particle system
  89594. */
  89595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89596. /**
  89597. * Remove a specific start size gradient
  89598. * @param gradient defines the gradient to remove
  89599. * @returns the current particle system
  89600. */
  89601. removeStartSizeGradient(gradient: number): IParticleSystem;
  89602. /**
  89603. * Gets the current list of start size gradients.
  89604. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89605. * @returns the list of start size gradients
  89606. */
  89607. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89608. /**
  89609. * Adds a new life time gradient
  89610. * @param gradient defines the gradient to use (between 0 and 1)
  89611. * @param factor defines the life time factor to affect to the specified gradient
  89612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89613. * @returns the current particle system
  89614. */
  89615. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89616. /**
  89617. * Remove a specific life time gradient
  89618. * @param gradient defines the gradient to remove
  89619. * @returns the current particle system
  89620. */
  89621. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89622. /**
  89623. * Gets the current list of life time gradients.
  89624. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89625. * @returns the list of life time gradients
  89626. */
  89627. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89628. /**
  89629. * Gets the current list of color gradients.
  89630. * You must use addColorGradient and removeColorGradient to udpate this list
  89631. * @returns the list of color gradients
  89632. */
  89633. getColorGradients(): Nullable<Array<ColorGradient>>;
  89634. /**
  89635. * Adds a new ramp gradient used to remap particle colors
  89636. * @param gradient defines the gradient to use (between 0 and 1)
  89637. * @param color defines the color to affect to the specified gradient
  89638. * @returns the current particle system
  89639. */
  89640. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89641. /**
  89642. * Gets the current list of ramp gradients.
  89643. * You must use addRampGradient and removeRampGradient to udpate this list
  89644. * @returns the list of ramp gradients
  89645. */
  89646. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89647. /** Gets or sets a boolean indicating that ramp gradients must be used
  89648. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89649. */
  89650. useRampGradients: boolean;
  89651. /**
  89652. * Adds a new color remap gradient
  89653. * @param gradient defines the gradient to use (between 0 and 1)
  89654. * @param min defines the color remap minimal range
  89655. * @param max defines the color remap maximal range
  89656. * @returns the current particle system
  89657. */
  89658. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89659. /**
  89660. * Gets the current list of color remap gradients.
  89661. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89662. * @returns the list of color remap gradients
  89663. */
  89664. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89665. /**
  89666. * Adds a new alpha remap gradient
  89667. * @param gradient defines the gradient to use (between 0 and 1)
  89668. * @param min defines the alpha remap minimal range
  89669. * @param max defines the alpha remap maximal range
  89670. * @returns the current particle system
  89671. */
  89672. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89673. /**
  89674. * Gets the current list of alpha remap gradients.
  89675. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89676. * @returns the list of alpha remap gradients
  89677. */
  89678. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89679. /**
  89680. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89681. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89682. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89683. * @returns the emitter
  89684. */
  89685. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89686. /**
  89687. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89688. * @param radius The radius of the hemisphere to emit from
  89689. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89690. * @returns the emitter
  89691. */
  89692. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89693. /**
  89694. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89695. * @param radius The radius of the sphere to emit from
  89696. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89697. * @returns the emitter
  89698. */
  89699. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89700. /**
  89701. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89702. * @param radius The radius of the sphere to emit from
  89703. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89704. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89705. * @returns the emitter
  89706. */
  89707. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89708. /**
  89709. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89710. * @param radius The radius of the emission cylinder
  89711. * @param height The height of the emission cylinder
  89712. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89713. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89714. * @returns the emitter
  89715. */
  89716. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89717. /**
  89718. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89719. * @param radius The radius of the cylinder to emit from
  89720. * @param height The height of the emission cylinder
  89721. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89722. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89723. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89724. * @returns the emitter
  89725. */
  89726. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89727. /**
  89728. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89729. * @param radius The radius of the cone to emit from
  89730. * @param angle The base angle of the cone
  89731. * @returns the emitter
  89732. */
  89733. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89734. /**
  89735. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89736. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89737. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89738. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89739. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89740. * @returns the emitter
  89741. */
  89742. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89743. /**
  89744. * Get hosting scene
  89745. * @returns the scene
  89746. */
  89747. getScene(): Scene;
  89748. }
  89749. }
  89750. declare module BABYLON {
  89751. /**
  89752. * 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.
  89753. * @see https://doc.babylonjs.com/how_to/transformnode
  89754. */
  89755. export class TransformNode extends Node {
  89756. /**
  89757. * Object will not rotate to face the camera
  89758. */
  89759. static BILLBOARDMODE_NONE: number;
  89760. /**
  89761. * Object will rotate to face the camera but only on the x axis
  89762. */
  89763. static BILLBOARDMODE_X: number;
  89764. /**
  89765. * Object will rotate to face the camera but only on the y axis
  89766. */
  89767. static BILLBOARDMODE_Y: number;
  89768. /**
  89769. * Object will rotate to face the camera but only on the z axis
  89770. */
  89771. static BILLBOARDMODE_Z: number;
  89772. /**
  89773. * Object will rotate to face the camera
  89774. */
  89775. static BILLBOARDMODE_ALL: number;
  89776. /**
  89777. * Object will rotate to face the camera's position instead of orientation
  89778. */
  89779. static BILLBOARDMODE_USE_POSITION: number;
  89780. private _forward;
  89781. private _forwardInverted;
  89782. private _up;
  89783. private _right;
  89784. private _rightInverted;
  89785. private _position;
  89786. private _rotation;
  89787. private _rotationQuaternion;
  89788. protected _scaling: Vector3;
  89789. protected _isDirty: boolean;
  89790. private _transformToBoneReferal;
  89791. private _isAbsoluteSynced;
  89792. private _billboardMode;
  89793. /**
  89794. * Gets or sets the billboard mode. Default is 0.
  89795. *
  89796. * | Value | Type | Description |
  89797. * | --- | --- | --- |
  89798. * | 0 | BILLBOARDMODE_NONE | |
  89799. * | 1 | BILLBOARDMODE_X | |
  89800. * | 2 | BILLBOARDMODE_Y | |
  89801. * | 4 | BILLBOARDMODE_Z | |
  89802. * | 7 | BILLBOARDMODE_ALL | |
  89803. *
  89804. */
  89805. get billboardMode(): number;
  89806. set billboardMode(value: number);
  89807. private _preserveParentRotationForBillboard;
  89808. /**
  89809. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  89810. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  89811. */
  89812. get preserveParentRotationForBillboard(): boolean;
  89813. set preserveParentRotationForBillboard(value: boolean);
  89814. /**
  89815. * 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
  89816. */
  89817. scalingDeterminant: number;
  89818. private _infiniteDistance;
  89819. /**
  89820. * Gets or sets the distance of the object to max, often used by skybox
  89821. */
  89822. get infiniteDistance(): boolean;
  89823. set infiniteDistance(value: boolean);
  89824. /**
  89825. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89826. * By default the system will update normals to compensate
  89827. */
  89828. ignoreNonUniformScaling: boolean;
  89829. /**
  89830. * 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
  89831. */
  89832. reIntegrateRotationIntoRotationQuaternion: boolean;
  89833. /** @hidden */
  89834. _poseMatrix: Nullable<Matrix>;
  89835. /** @hidden */
  89836. _localMatrix: Matrix;
  89837. private _usePivotMatrix;
  89838. private _absolutePosition;
  89839. private _absoluteScaling;
  89840. private _absoluteRotationQuaternion;
  89841. private _pivotMatrix;
  89842. private _pivotMatrixInverse;
  89843. protected _postMultiplyPivotMatrix: boolean;
  89844. protected _isWorldMatrixFrozen: boolean;
  89845. /** @hidden */
  89846. _indexInSceneTransformNodesArray: number;
  89847. /**
  89848. * An event triggered after the world matrix is updated
  89849. */
  89850. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  89851. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  89852. /**
  89853. * Gets a string identifying the name of the class
  89854. * @returns "TransformNode" string
  89855. */
  89856. getClassName(): string;
  89857. /**
  89858. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89859. */
  89860. get position(): Vector3;
  89861. set position(newPosition: Vector3);
  89862. /**
  89863. * 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)).
  89864. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89865. */
  89866. get rotation(): Vector3;
  89867. set rotation(newRotation: Vector3);
  89868. /**
  89869. * 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)).
  89870. */
  89871. get scaling(): Vector3;
  89872. set scaling(newScaling: Vector3);
  89873. /**
  89874. * 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).
  89875. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89876. */
  89877. get rotationQuaternion(): Nullable<Quaternion>;
  89878. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  89879. /**
  89880. * The forward direction of that transform in world space.
  89881. */
  89882. get forward(): Vector3;
  89883. /**
  89884. * The up direction of that transform in world space.
  89885. */
  89886. get up(): Vector3;
  89887. /**
  89888. * The right direction of that transform in world space.
  89889. */
  89890. get right(): Vector3;
  89891. /**
  89892. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89893. * @param matrix the matrix to copy the pose from
  89894. * @returns this TransformNode.
  89895. */
  89896. updatePoseMatrix(matrix: Matrix): TransformNode;
  89897. /**
  89898. * Returns the mesh Pose matrix.
  89899. * @returns the pose matrix
  89900. */
  89901. getPoseMatrix(): Matrix;
  89902. /** @hidden */
  89903. _isSynchronized(): boolean;
  89904. /** @hidden */
  89905. _initCache(): void;
  89906. /**
  89907. * Flag the transform node as dirty (Forcing it to update everything)
  89908. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89909. * @returns this transform node
  89910. */
  89911. markAsDirty(property: string): TransformNode;
  89912. /**
  89913. * Returns the current mesh absolute position.
  89914. * Returns a Vector3.
  89915. */
  89916. get absolutePosition(): Vector3;
  89917. /**
  89918. * Returns the current mesh absolute scaling.
  89919. * Returns a Vector3.
  89920. */
  89921. get absoluteScaling(): Vector3;
  89922. /**
  89923. * Returns the current mesh absolute rotation.
  89924. * Returns a Quaternion.
  89925. */
  89926. get absoluteRotationQuaternion(): Quaternion;
  89927. /**
  89928. * Sets a new matrix to apply before all other transformation
  89929. * @param matrix defines the transform matrix
  89930. * @returns the current TransformNode
  89931. */
  89932. setPreTransformMatrix(matrix: Matrix): TransformNode;
  89933. /**
  89934. * Sets a new pivot matrix to the current node
  89935. * @param matrix defines the new pivot matrix to use
  89936. * @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
  89937. * @returns the current TransformNode
  89938. */
  89939. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  89940. /**
  89941. * Returns the mesh pivot matrix.
  89942. * Default : Identity.
  89943. * @returns the matrix
  89944. */
  89945. getPivotMatrix(): Matrix;
  89946. /**
  89947. * Instantiate (when possible) or clone that node with its hierarchy
  89948. * @param newParent defines the new parent to use for the instance (or clone)
  89949. * @param options defines options to configure how copy is done
  89950. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  89951. * @returns an instance (or a clone) of the current node with its hiearchy
  89952. */
  89953. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  89954. doNotInstantiate: boolean;
  89955. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  89956. /**
  89957. * Prevents the World matrix to be computed any longer
  89958. * @param newWorldMatrix defines an optional matrix to use as world matrix
  89959. * @returns the TransformNode.
  89960. */
  89961. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  89962. /**
  89963. * Allows back the World matrix computation.
  89964. * @returns the TransformNode.
  89965. */
  89966. unfreezeWorldMatrix(): this;
  89967. /**
  89968. * True if the World matrix has been frozen.
  89969. */
  89970. get isWorldMatrixFrozen(): boolean;
  89971. /**
  89972. * Retuns the mesh absolute position in the World.
  89973. * @returns a Vector3.
  89974. */
  89975. getAbsolutePosition(): Vector3;
  89976. /**
  89977. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89978. * @param absolutePosition the absolute position to set
  89979. * @returns the TransformNode.
  89980. */
  89981. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89982. /**
  89983. * Sets the mesh position in its local space.
  89984. * @param vector3 the position to set in localspace
  89985. * @returns the TransformNode.
  89986. */
  89987. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  89988. /**
  89989. * Returns the mesh position in the local space from the current World matrix values.
  89990. * @returns a new Vector3.
  89991. */
  89992. getPositionExpressedInLocalSpace(): Vector3;
  89993. /**
  89994. * Translates the mesh along the passed Vector3 in its local space.
  89995. * @param vector3 the distance to translate in localspace
  89996. * @returns the TransformNode.
  89997. */
  89998. locallyTranslate(vector3: Vector3): TransformNode;
  89999. private static _lookAtVectorCache;
  90000. /**
  90001. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  90002. * @param targetPoint the position (must be in same space as current mesh) to look at
  90003. * @param yawCor optional yaw (y-axis) correction in radians
  90004. * @param pitchCor optional pitch (x-axis) correction in radians
  90005. * @param rollCor optional roll (z-axis) correction in radians
  90006. * @param space the choosen space of the target
  90007. * @returns the TransformNode.
  90008. */
  90009. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  90010. /**
  90011. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90012. * This Vector3 is expressed in the World space.
  90013. * @param localAxis axis to rotate
  90014. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90015. */
  90016. getDirection(localAxis: Vector3): Vector3;
  90017. /**
  90018. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  90019. * localAxis is expressed in the mesh local space.
  90020. * result is computed in the Wordl space from the mesh World matrix.
  90021. * @param localAxis axis to rotate
  90022. * @param result the resulting transformnode
  90023. * @returns this TransformNode.
  90024. */
  90025. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  90026. /**
  90027. * Sets this transform node rotation to the given local axis.
  90028. * @param localAxis the axis in local space
  90029. * @param yawCor optional yaw (y-axis) correction in radians
  90030. * @param pitchCor optional pitch (x-axis) correction in radians
  90031. * @param rollCor optional roll (z-axis) correction in radians
  90032. * @returns this TransformNode
  90033. */
  90034. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  90035. /**
  90036. * Sets a new pivot point to the current node
  90037. * @param point defines the new pivot point to use
  90038. * @param space defines if the point is in world or local space (local by default)
  90039. * @returns the current TransformNode
  90040. */
  90041. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  90042. /**
  90043. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  90044. * @returns the pivot point
  90045. */
  90046. getPivotPoint(): Vector3;
  90047. /**
  90048. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  90049. * @param result the vector3 to store the result
  90050. * @returns this TransformNode.
  90051. */
  90052. getPivotPointToRef(result: Vector3): TransformNode;
  90053. /**
  90054. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  90055. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  90056. */
  90057. getAbsolutePivotPoint(): Vector3;
  90058. /**
  90059. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  90060. * @param result vector3 to store the result
  90061. * @returns this TransformNode.
  90062. */
  90063. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  90064. /**
  90065. * Defines the passed node as the parent of the current node.
  90066. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  90067. * @see https://doc.babylonjs.com/how_to/parenting
  90068. * @param node the node ot set as the parent
  90069. * @returns this TransformNode.
  90070. */
  90071. setParent(node: Nullable<Node>): TransformNode;
  90072. private _nonUniformScaling;
  90073. /**
  90074. * True if the scaling property of this object is non uniform eg. (1,2,1)
  90075. */
  90076. get nonUniformScaling(): boolean;
  90077. /** @hidden */
  90078. _updateNonUniformScalingState(value: boolean): boolean;
  90079. /**
  90080. * Attach the current TransformNode to another TransformNode associated with a bone
  90081. * @param bone Bone affecting the TransformNode
  90082. * @param affectedTransformNode TransformNode associated with the bone
  90083. * @returns this object
  90084. */
  90085. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  90086. /**
  90087. * Detach the transform node if its associated with a bone
  90088. * @returns this object
  90089. */
  90090. detachFromBone(): TransformNode;
  90091. private static _rotationAxisCache;
  90092. /**
  90093. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  90094. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90095. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90096. * The passed axis is also normalized.
  90097. * @param axis the axis to rotate around
  90098. * @param amount the amount to rotate in radians
  90099. * @param space Space to rotate in (Default: local)
  90100. * @returns the TransformNode.
  90101. */
  90102. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90103. /**
  90104. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  90105. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90106. * The passed axis is also normalized. .
  90107. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90108. * @param point the point to rotate around
  90109. * @param axis the axis to rotate around
  90110. * @param amount the amount to rotate in radians
  90111. * @returns the TransformNode
  90112. */
  90113. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  90114. /**
  90115. * Translates the mesh along the axis vector for the passed distance in the given space.
  90116. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90117. * @param axis the axis to translate in
  90118. * @param distance the distance to translate
  90119. * @param space Space to rotate in (Default: local)
  90120. * @returns the TransformNode.
  90121. */
  90122. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90123. /**
  90124. * Adds a rotation step to the mesh current rotation.
  90125. * x, y, z are Euler angles expressed in radians.
  90126. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90127. * This means this rotation is made in the mesh local space only.
  90128. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90129. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90130. * ```javascript
  90131. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90132. * ```
  90133. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90134. * 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.
  90135. * @param x Rotation to add
  90136. * @param y Rotation to add
  90137. * @param z Rotation to add
  90138. * @returns the TransformNode.
  90139. */
  90140. addRotation(x: number, y: number, z: number): TransformNode;
  90141. /**
  90142. * @hidden
  90143. */
  90144. protected _getEffectiveParent(): Nullable<Node>;
  90145. /**
  90146. * Computes the world matrix of the node
  90147. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90148. * @returns the world matrix
  90149. */
  90150. computeWorldMatrix(force?: boolean): Matrix;
  90151. /**
  90152. * Resets this nodeTransform's local matrix to Matrix.Identity().
  90153. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  90154. */
  90155. resetLocalMatrix(independentOfChildren?: boolean): void;
  90156. protected _afterComputeWorldMatrix(): void;
  90157. /**
  90158. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  90159. * @param func callback function to add
  90160. *
  90161. * @returns the TransformNode.
  90162. */
  90163. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90164. /**
  90165. * Removes a registered callback function.
  90166. * @param func callback function to remove
  90167. * @returns the TransformNode.
  90168. */
  90169. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90170. /**
  90171. * Gets the position of the current mesh in camera space
  90172. * @param camera defines the camera to use
  90173. * @returns a position
  90174. */
  90175. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  90176. /**
  90177. * Returns the distance from the mesh to the active camera
  90178. * @param camera defines the camera to use
  90179. * @returns the distance
  90180. */
  90181. getDistanceToCamera(camera?: Nullable<Camera>): number;
  90182. /**
  90183. * Clone the current transform node
  90184. * @param name Name of the new clone
  90185. * @param newParent New parent for the clone
  90186. * @param doNotCloneChildren Do not clone children hierarchy
  90187. * @returns the new transform node
  90188. */
  90189. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  90190. /**
  90191. * Serializes the objects information.
  90192. * @param currentSerializationObject defines the object to serialize in
  90193. * @returns the serialized object
  90194. */
  90195. serialize(currentSerializationObject?: any): any;
  90196. /**
  90197. * Returns a new TransformNode object parsed from the source provided.
  90198. * @param parsedTransformNode is the source.
  90199. * @param scene the scne the object belongs to
  90200. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90201. * @returns a new TransformNode object parsed from the source provided.
  90202. */
  90203. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  90204. /**
  90205. * Get all child-transformNodes of this node
  90206. * @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
  90207. * @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
  90208. * @returns an array of TransformNode
  90209. */
  90210. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  90211. /**
  90212. * Releases resources associated with this transform node.
  90213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90215. */
  90216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90217. /**
  90218. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90219. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90220. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90221. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90222. * @returns the current mesh
  90223. */
  90224. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  90225. private _syncAbsoluteScalingAndRotation;
  90226. }
  90227. }
  90228. declare module BABYLON {
  90229. /**
  90230. * Class used to override all child animations of a given target
  90231. */
  90232. export class AnimationPropertiesOverride {
  90233. /**
  90234. * Gets or sets a value indicating if animation blending must be used
  90235. */
  90236. enableBlending: boolean;
  90237. /**
  90238. * Gets or sets the blending speed to use when enableBlending is true
  90239. */
  90240. blendingSpeed: number;
  90241. /**
  90242. * Gets or sets the default loop mode to use
  90243. */
  90244. loopMode: number;
  90245. }
  90246. }
  90247. declare module BABYLON {
  90248. /**
  90249. * Class used to store bone information
  90250. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90251. */
  90252. export class Bone extends Node {
  90253. /**
  90254. * defines the bone name
  90255. */
  90256. name: string;
  90257. private static _tmpVecs;
  90258. private static _tmpQuat;
  90259. private static _tmpMats;
  90260. /**
  90261. * Gets the list of child bones
  90262. */
  90263. children: Bone[];
  90264. /** Gets the animations associated with this bone */
  90265. animations: Animation[];
  90266. /**
  90267. * Gets or sets bone length
  90268. */
  90269. length: number;
  90270. /**
  90271. * @hidden Internal only
  90272. * Set this value to map this bone to a different index in the transform matrices
  90273. * Set this value to -1 to exclude the bone from the transform matrices
  90274. */
  90275. _index: Nullable<number>;
  90276. private _skeleton;
  90277. private _localMatrix;
  90278. private _restPose;
  90279. private _baseMatrix;
  90280. private _absoluteTransform;
  90281. private _invertedAbsoluteTransform;
  90282. private _parent;
  90283. private _scalingDeterminant;
  90284. private _worldTransform;
  90285. private _localScaling;
  90286. private _localRotation;
  90287. private _localPosition;
  90288. private _needToDecompose;
  90289. private _needToCompose;
  90290. /** @hidden */
  90291. _linkedTransformNode: Nullable<TransformNode>;
  90292. /** @hidden */
  90293. _waitingTransformNodeId: Nullable<string>;
  90294. /** @hidden */
  90295. get _matrix(): Matrix;
  90296. /** @hidden */
  90297. set _matrix(value: Matrix);
  90298. /**
  90299. * Create a new bone
  90300. * @param name defines the bone name
  90301. * @param skeleton defines the parent skeleton
  90302. * @param parentBone defines the parent (can be null if the bone is the root)
  90303. * @param localMatrix defines the local matrix
  90304. * @param restPose defines the rest pose matrix
  90305. * @param baseMatrix defines the base matrix
  90306. * @param index defines index of the bone in the hiearchy
  90307. */
  90308. constructor(
  90309. /**
  90310. * defines the bone name
  90311. */
  90312. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  90313. /**
  90314. * Gets the current object class name.
  90315. * @return the class name
  90316. */
  90317. getClassName(): string;
  90318. /**
  90319. * Gets the parent skeleton
  90320. * @returns a skeleton
  90321. */
  90322. getSkeleton(): Skeleton;
  90323. /**
  90324. * Gets parent bone
  90325. * @returns a bone or null if the bone is the root of the bone hierarchy
  90326. */
  90327. getParent(): Nullable<Bone>;
  90328. /**
  90329. * Returns an array containing the root bones
  90330. * @returns an array containing the root bones
  90331. */
  90332. getChildren(): Array<Bone>;
  90333. /**
  90334. * Gets the node index in matrix array generated for rendering
  90335. * @returns the node index
  90336. */
  90337. getIndex(): number;
  90338. /**
  90339. * Sets the parent bone
  90340. * @param parent defines the parent (can be null if the bone is the root)
  90341. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90342. */
  90343. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  90344. /**
  90345. * Gets the local matrix
  90346. * @returns a matrix
  90347. */
  90348. getLocalMatrix(): Matrix;
  90349. /**
  90350. * Gets the base matrix (initial matrix which remains unchanged)
  90351. * @returns a matrix
  90352. */
  90353. getBaseMatrix(): Matrix;
  90354. /**
  90355. * Gets the rest pose matrix
  90356. * @returns a matrix
  90357. */
  90358. getRestPose(): Matrix;
  90359. /**
  90360. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  90361. */
  90362. getWorldMatrix(): Matrix;
  90363. /**
  90364. * Sets the local matrix to rest pose matrix
  90365. */
  90366. returnToRest(): void;
  90367. /**
  90368. * Gets the inverse of the absolute transform matrix.
  90369. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  90370. * @returns a matrix
  90371. */
  90372. getInvertedAbsoluteTransform(): Matrix;
  90373. /**
  90374. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  90375. * @returns a matrix
  90376. */
  90377. getAbsoluteTransform(): Matrix;
  90378. /**
  90379. * Links with the given transform node.
  90380. * The local matrix of this bone is copied from the transform node every frame.
  90381. * @param transformNode defines the transform node to link to
  90382. */
  90383. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  90384. /**
  90385. * Gets the node used to drive the bone's transformation
  90386. * @returns a transform node or null
  90387. */
  90388. getTransformNode(): Nullable<TransformNode>;
  90389. /** Gets or sets current position (in local space) */
  90390. get position(): Vector3;
  90391. set position(newPosition: Vector3);
  90392. /** Gets or sets current rotation (in local space) */
  90393. get rotation(): Vector3;
  90394. set rotation(newRotation: Vector3);
  90395. /** Gets or sets current rotation quaternion (in local space) */
  90396. get rotationQuaternion(): Quaternion;
  90397. set rotationQuaternion(newRotation: Quaternion);
  90398. /** Gets or sets current scaling (in local space) */
  90399. get scaling(): Vector3;
  90400. set scaling(newScaling: Vector3);
  90401. /**
  90402. * Gets the animation properties override
  90403. */
  90404. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90405. private _decompose;
  90406. private _compose;
  90407. /**
  90408. * Update the base and local matrices
  90409. * @param matrix defines the new base or local matrix
  90410. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90411. * @param updateLocalMatrix defines if the local matrix should be updated
  90412. */
  90413. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  90414. /** @hidden */
  90415. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  90416. /**
  90417. * Flag the bone as dirty (Forcing it to update everything)
  90418. */
  90419. markAsDirty(): void;
  90420. /** @hidden */
  90421. _markAsDirtyAndCompose(): void;
  90422. private _markAsDirtyAndDecompose;
  90423. /**
  90424. * Translate the bone in local or world space
  90425. * @param vec The amount to translate the bone
  90426. * @param space The space that the translation is in
  90427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90428. */
  90429. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90430. /**
  90431. * Set the postion of the bone in local or world space
  90432. * @param position The position to set the bone
  90433. * @param space The space that the position is in
  90434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90435. */
  90436. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90437. /**
  90438. * Set the absolute position of the bone (world space)
  90439. * @param position The position to set the bone
  90440. * @param mesh The mesh that this bone is attached to
  90441. */
  90442. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  90443. /**
  90444. * Scale the bone on the x, y and z axes (in local space)
  90445. * @param x The amount to scale the bone on the x axis
  90446. * @param y The amount to scale the bone on the y axis
  90447. * @param z The amount to scale the bone on the z axis
  90448. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  90449. */
  90450. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  90451. /**
  90452. * Set the bone scaling in local space
  90453. * @param scale defines the scaling vector
  90454. */
  90455. setScale(scale: Vector3): void;
  90456. /**
  90457. * Gets the current scaling in local space
  90458. * @returns the current scaling vector
  90459. */
  90460. getScale(): Vector3;
  90461. /**
  90462. * Gets the current scaling in local space and stores it in a target vector
  90463. * @param result defines the target vector
  90464. */
  90465. getScaleToRef(result: Vector3): void;
  90466. /**
  90467. * Set the yaw, pitch, and roll of the bone in local or world space
  90468. * @param yaw The rotation of the bone on the y axis
  90469. * @param pitch The rotation of the bone on the x axis
  90470. * @param roll The rotation of the bone on the z axis
  90471. * @param space The space that the axes of rotation are in
  90472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90473. */
  90474. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  90475. /**
  90476. * Add a rotation to the bone on an axis in local or world space
  90477. * @param axis The axis to rotate the bone on
  90478. * @param amount The amount to rotate the bone
  90479. * @param space The space that the axis is in
  90480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90481. */
  90482. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  90483. /**
  90484. * Set the rotation of the bone to a particular axis angle in local or world space
  90485. * @param axis The axis to rotate the bone on
  90486. * @param angle The angle that the bone should be rotated to
  90487. * @param space The space that the axis is in
  90488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90489. */
  90490. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  90491. /**
  90492. * Set the euler rotation of the bone in local of world space
  90493. * @param rotation The euler rotation that the bone should be set to
  90494. * @param space The space that the rotation is in
  90495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90496. */
  90497. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90498. /**
  90499. * Set the quaternion rotation of the bone in local of world space
  90500. * @param quat The quaternion rotation that the bone should be set to
  90501. * @param space The space that the rotation is in
  90502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90503. */
  90504. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  90505. /**
  90506. * Set the rotation matrix of the bone in local of world space
  90507. * @param rotMat The rotation matrix that the bone should be set to
  90508. * @param space The space that the rotation is in
  90509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90510. */
  90511. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  90512. private _rotateWithMatrix;
  90513. private _getNegativeRotationToRef;
  90514. /**
  90515. * Get the position of the bone in local or world space
  90516. * @param space The space that the returned position is in
  90517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90518. * @returns The position of the bone
  90519. */
  90520. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90521. /**
  90522. * Copy the position of the bone to a vector3 in local or world space
  90523. * @param space The space that the returned position is in
  90524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90525. * @param result The vector3 to copy the position to
  90526. */
  90527. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  90528. /**
  90529. * Get the absolute position of the bone (world space)
  90530. * @param mesh The mesh that this bone is attached to
  90531. * @returns The absolute position of the bone
  90532. */
  90533. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  90534. /**
  90535. * Copy the absolute position of the bone (world space) to the result param
  90536. * @param mesh The mesh that this bone is attached to
  90537. * @param result The vector3 to copy the absolute position to
  90538. */
  90539. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  90540. /**
  90541. * Compute the absolute transforms of this bone and its children
  90542. */
  90543. computeAbsoluteTransforms(): void;
  90544. /**
  90545. * Get the world direction from an axis that is in the local space of the bone
  90546. * @param localAxis The local direction that is used to compute the world direction
  90547. * @param mesh The mesh that this bone is attached to
  90548. * @returns The world direction
  90549. */
  90550. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90551. /**
  90552. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  90553. * @param localAxis The local direction that is used to compute the world direction
  90554. * @param mesh The mesh that this bone is attached to
  90555. * @param result The vector3 that the world direction will be copied to
  90556. */
  90557. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90558. /**
  90559. * Get the euler rotation of the bone in local or world space
  90560. * @param space The space that the rotation should be in
  90561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90562. * @returns The euler rotation
  90563. */
  90564. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90565. /**
  90566. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  90567. * @param space The space that the rotation should be in
  90568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90569. * @param result The vector3 that the rotation should be copied to
  90570. */
  90571. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90572. /**
  90573. * Get the quaternion rotation of the bone in either local or world space
  90574. * @param space The space that the rotation should be in
  90575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90576. * @returns The quaternion rotation
  90577. */
  90578. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  90579. /**
  90580. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  90581. * @param space The space that the rotation should be in
  90582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90583. * @param result The quaternion that the rotation should be copied to
  90584. */
  90585. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  90586. /**
  90587. * Get the rotation matrix of the bone in local or world space
  90588. * @param space The space that the rotation should be in
  90589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90590. * @returns The rotation matrix
  90591. */
  90592. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  90593. /**
  90594. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  90595. * @param space The space that the rotation should be in
  90596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90597. * @param result The quaternion that the rotation should be copied to
  90598. */
  90599. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  90600. /**
  90601. * Get the world position of a point that is in the local space of the bone
  90602. * @param position The local position
  90603. * @param mesh The mesh that this bone is attached to
  90604. * @returns The world position
  90605. */
  90606. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90607. /**
  90608. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  90609. * @param position The local position
  90610. * @param mesh The mesh that this bone is attached to
  90611. * @param result The vector3 that the world position should be copied to
  90612. */
  90613. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90614. /**
  90615. * Get the local position of a point that is in world space
  90616. * @param position The world position
  90617. * @param mesh The mesh that this bone is attached to
  90618. * @returns The local position
  90619. */
  90620. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90621. /**
  90622. * Get the local position of a point that is in world space and copy it to the result param
  90623. * @param position The world position
  90624. * @param mesh The mesh that this bone is attached to
  90625. * @param result The vector3 that the local position should be copied to
  90626. */
  90627. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90628. }
  90629. }
  90630. declare module BABYLON {
  90631. /**
  90632. * Defines a runtime animation
  90633. */
  90634. export class RuntimeAnimation {
  90635. private _events;
  90636. /**
  90637. * The current frame of the runtime animation
  90638. */
  90639. private _currentFrame;
  90640. /**
  90641. * The animation used by the runtime animation
  90642. */
  90643. private _animation;
  90644. /**
  90645. * The target of the runtime animation
  90646. */
  90647. private _target;
  90648. /**
  90649. * The initiating animatable
  90650. */
  90651. private _host;
  90652. /**
  90653. * The original value of the runtime animation
  90654. */
  90655. private _originalValue;
  90656. /**
  90657. * The original blend value of the runtime animation
  90658. */
  90659. private _originalBlendValue;
  90660. /**
  90661. * The offsets cache of the runtime animation
  90662. */
  90663. private _offsetsCache;
  90664. /**
  90665. * The high limits cache of the runtime animation
  90666. */
  90667. private _highLimitsCache;
  90668. /**
  90669. * Specifies if the runtime animation has been stopped
  90670. */
  90671. private _stopped;
  90672. /**
  90673. * The blending factor of the runtime animation
  90674. */
  90675. private _blendingFactor;
  90676. /**
  90677. * The BabylonJS scene
  90678. */
  90679. private _scene;
  90680. /**
  90681. * The current value of the runtime animation
  90682. */
  90683. private _currentValue;
  90684. /** @hidden */
  90685. _animationState: _IAnimationState;
  90686. /**
  90687. * The active target of the runtime animation
  90688. */
  90689. private _activeTargets;
  90690. private _currentActiveTarget;
  90691. private _directTarget;
  90692. /**
  90693. * The target path of the runtime animation
  90694. */
  90695. private _targetPath;
  90696. /**
  90697. * The weight of the runtime animation
  90698. */
  90699. private _weight;
  90700. /**
  90701. * The ratio offset of the runtime animation
  90702. */
  90703. private _ratioOffset;
  90704. /**
  90705. * The previous delay of the runtime animation
  90706. */
  90707. private _previousDelay;
  90708. /**
  90709. * The previous ratio of the runtime animation
  90710. */
  90711. private _previousRatio;
  90712. private _enableBlending;
  90713. private _keys;
  90714. private _minFrame;
  90715. private _maxFrame;
  90716. private _minValue;
  90717. private _maxValue;
  90718. private _targetIsArray;
  90719. /**
  90720. * Gets the current frame of the runtime animation
  90721. */
  90722. get currentFrame(): number;
  90723. /**
  90724. * Gets the weight of the runtime animation
  90725. */
  90726. get weight(): number;
  90727. /**
  90728. * Gets the current value of the runtime animation
  90729. */
  90730. get currentValue(): any;
  90731. /**
  90732. * Gets the target path of the runtime animation
  90733. */
  90734. get targetPath(): string;
  90735. /**
  90736. * Gets the actual target of the runtime animation
  90737. */
  90738. get target(): any;
  90739. /**
  90740. * Gets the additive state of the runtime animation
  90741. */
  90742. get isAdditive(): boolean;
  90743. /** @hidden */
  90744. _onLoop: () => void;
  90745. /**
  90746. * Create a new RuntimeAnimation object
  90747. * @param target defines the target of the animation
  90748. * @param animation defines the source animation object
  90749. * @param scene defines the hosting scene
  90750. * @param host defines the initiating Animatable
  90751. */
  90752. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  90753. private _preparePath;
  90754. /**
  90755. * Gets the animation from the runtime animation
  90756. */
  90757. get animation(): Animation;
  90758. /**
  90759. * Resets the runtime animation to the beginning
  90760. * @param restoreOriginal defines whether to restore the target property to the original value
  90761. */
  90762. reset(restoreOriginal?: boolean): void;
  90763. /**
  90764. * Specifies if the runtime animation is stopped
  90765. * @returns Boolean specifying if the runtime animation is stopped
  90766. */
  90767. isStopped(): boolean;
  90768. /**
  90769. * Disposes of the runtime animation
  90770. */
  90771. dispose(): void;
  90772. /**
  90773. * Apply the interpolated value to the target
  90774. * @param currentValue defines the value computed by the animation
  90775. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  90776. */
  90777. setValue(currentValue: any, weight: number): void;
  90778. private _getOriginalValues;
  90779. private _setValue;
  90780. /**
  90781. * Gets the loop pmode of the runtime animation
  90782. * @returns Loop Mode
  90783. */
  90784. private _getCorrectLoopMode;
  90785. /**
  90786. * Move the current animation to a given frame
  90787. * @param frame defines the frame to move to
  90788. */
  90789. goToFrame(frame: number): void;
  90790. /**
  90791. * @hidden Internal use only
  90792. */
  90793. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  90794. /**
  90795. * Execute the current animation
  90796. * @param delay defines the delay to add to the current frame
  90797. * @param from defines the lower bound of the animation range
  90798. * @param to defines the upper bound of the animation range
  90799. * @param loop defines if the current animation must loop
  90800. * @param speedRatio defines the current speed ratio
  90801. * @param weight defines the weight of the animation (default is -1 so no weight)
  90802. * @param onLoop optional callback called when animation loops
  90803. * @returns a boolean indicating if the animation is running
  90804. */
  90805. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  90806. }
  90807. }
  90808. declare module BABYLON {
  90809. /**
  90810. * Class used to store an actual running animation
  90811. */
  90812. export class Animatable {
  90813. /** defines the target object */
  90814. target: any;
  90815. /** defines the starting frame number (default is 0) */
  90816. fromFrame: number;
  90817. /** defines the ending frame number (default is 100) */
  90818. toFrame: number;
  90819. /** defines if the animation must loop (default is false) */
  90820. loopAnimation: boolean;
  90821. /** defines a callback to call when animation ends if it is not looping */
  90822. onAnimationEnd?: (() => void) | null | undefined;
  90823. /** defines a callback to call when animation loops */
  90824. onAnimationLoop?: (() => void) | null | undefined;
  90825. /** defines whether the animation should be evaluated additively */
  90826. isAdditive: boolean;
  90827. private _localDelayOffset;
  90828. private _pausedDelay;
  90829. private _runtimeAnimations;
  90830. private _paused;
  90831. private _scene;
  90832. private _speedRatio;
  90833. private _weight;
  90834. private _syncRoot;
  90835. /**
  90836. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  90837. * This will only apply for non looping animation (default is true)
  90838. */
  90839. disposeOnEnd: boolean;
  90840. /**
  90841. * Gets a boolean indicating if the animation has started
  90842. */
  90843. animationStarted: boolean;
  90844. /**
  90845. * Observer raised when the animation ends
  90846. */
  90847. onAnimationEndObservable: Observable<Animatable>;
  90848. /**
  90849. * Observer raised when the animation loops
  90850. */
  90851. onAnimationLoopObservable: Observable<Animatable>;
  90852. /**
  90853. * Gets the root Animatable used to synchronize and normalize animations
  90854. */
  90855. get syncRoot(): Nullable<Animatable>;
  90856. /**
  90857. * Gets the current frame of the first RuntimeAnimation
  90858. * Used to synchronize Animatables
  90859. */
  90860. get masterFrame(): number;
  90861. /**
  90862. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  90863. */
  90864. get weight(): number;
  90865. set weight(value: number);
  90866. /**
  90867. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  90868. */
  90869. get speedRatio(): number;
  90870. set speedRatio(value: number);
  90871. /**
  90872. * Creates a new Animatable
  90873. * @param scene defines the hosting scene
  90874. * @param target defines the target object
  90875. * @param fromFrame defines the starting frame number (default is 0)
  90876. * @param toFrame defines the ending frame number (default is 100)
  90877. * @param loopAnimation defines if the animation must loop (default is false)
  90878. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  90879. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  90880. * @param animations defines a group of animation to add to the new Animatable
  90881. * @param onAnimationLoop defines a callback to call when animation loops
  90882. * @param isAdditive defines whether the animation should be evaluated additively
  90883. */
  90884. constructor(scene: Scene,
  90885. /** defines the target object */
  90886. target: any,
  90887. /** defines the starting frame number (default is 0) */
  90888. fromFrame?: number,
  90889. /** defines the ending frame number (default is 100) */
  90890. toFrame?: number,
  90891. /** defines if the animation must loop (default is false) */
  90892. loopAnimation?: boolean, speedRatio?: number,
  90893. /** defines a callback to call when animation ends if it is not looping */
  90894. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  90895. /** defines a callback to call when animation loops */
  90896. onAnimationLoop?: (() => void) | null | undefined,
  90897. /** defines whether the animation should be evaluated additively */
  90898. isAdditive?: boolean);
  90899. /**
  90900. * Synchronize and normalize current Animatable with a source Animatable
  90901. * This is useful when using animation weights and when animations are not of the same length
  90902. * @param root defines the root Animatable to synchronize with
  90903. * @returns the current Animatable
  90904. */
  90905. syncWith(root: Animatable): Animatable;
  90906. /**
  90907. * Gets the list of runtime animations
  90908. * @returns an array of RuntimeAnimation
  90909. */
  90910. getAnimations(): RuntimeAnimation[];
  90911. /**
  90912. * Adds more animations to the current animatable
  90913. * @param target defines the target of the animations
  90914. * @param animations defines the new animations to add
  90915. */
  90916. appendAnimations(target: any, animations: Animation[]): void;
  90917. /**
  90918. * Gets the source animation for a specific property
  90919. * @param property defines the propertyu to look for
  90920. * @returns null or the source animation for the given property
  90921. */
  90922. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  90923. /**
  90924. * Gets the runtime animation for a specific property
  90925. * @param property defines the propertyu to look for
  90926. * @returns null or the runtime animation for the given property
  90927. */
  90928. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  90929. /**
  90930. * Resets the animatable to its original state
  90931. */
  90932. reset(): void;
  90933. /**
  90934. * Allows the animatable to blend with current running animations
  90935. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90936. * @param blendingSpeed defines the blending speed to use
  90937. */
  90938. enableBlending(blendingSpeed: number): void;
  90939. /**
  90940. * Disable animation blending
  90941. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90942. */
  90943. disableBlending(): void;
  90944. /**
  90945. * Jump directly to a given frame
  90946. * @param frame defines the frame to jump to
  90947. */
  90948. goToFrame(frame: number): void;
  90949. /**
  90950. * Pause the animation
  90951. */
  90952. pause(): void;
  90953. /**
  90954. * Restart the animation
  90955. */
  90956. restart(): void;
  90957. private _raiseOnAnimationEnd;
  90958. /**
  90959. * Stop and delete the current animation
  90960. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  90961. * @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)
  90962. */
  90963. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  90964. /**
  90965. * Wait asynchronously for the animation to end
  90966. * @returns a promise which will be fullfilled when the animation ends
  90967. */
  90968. waitAsync(): Promise<Animatable>;
  90969. /** @hidden */
  90970. _animate(delay: number): boolean;
  90971. }
  90972. interface Scene {
  90973. /** @hidden */
  90974. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  90975. /** @hidden */
  90976. _processLateAnimationBindingsForMatrices(holder: {
  90977. totalWeight: number;
  90978. totalAdditiveWeight: number;
  90979. animations: RuntimeAnimation[];
  90980. additiveAnimations: RuntimeAnimation[];
  90981. originalValue: Matrix;
  90982. }): any;
  90983. /** @hidden */
  90984. _processLateAnimationBindingsForQuaternions(holder: {
  90985. totalWeight: number;
  90986. totalAdditiveWeight: number;
  90987. animations: RuntimeAnimation[];
  90988. additiveAnimations: RuntimeAnimation[];
  90989. originalValue: Quaternion;
  90990. }, refQuaternion: Quaternion): Quaternion;
  90991. /** @hidden */
  90992. _processLateAnimationBindings(): void;
  90993. /**
  90994. * Will start the animation sequence of a given target
  90995. * @param target defines the target
  90996. * @param from defines from which frame should animation start
  90997. * @param to defines until which frame should animation run.
  90998. * @param weight defines the weight to apply to the animation (1.0 by default)
  90999. * @param loop defines if the animation loops
  91000. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  91001. * @param onAnimationEnd defines the function to be executed when the animation ends
  91002. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  91003. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  91004. * @param onAnimationLoop defines the callback to call when an animation loops
  91005. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  91006. * @returns the animatable object created for this animation
  91007. */
  91008. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  91009. /**
  91010. * Will start the animation sequence of a given target
  91011. * @param target defines the target
  91012. * @param from defines from which frame should animation start
  91013. * @param to defines until which frame should animation run.
  91014. * @param loop defines if the animation loops
  91015. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  91016. * @param onAnimationEnd defines the function to be executed when the animation ends
  91017. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  91018. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  91019. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  91020. * @param onAnimationLoop defines the callback to call when an animation loops
  91021. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  91022. * @returns the animatable object created for this animation
  91023. */
  91024. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  91025. /**
  91026. * Will start the animation sequence of a given target and its hierarchy
  91027. * @param target defines the target
  91028. * @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.
  91029. * @param from defines from which frame should animation start
  91030. * @param to defines until which frame should animation run.
  91031. * @param loop defines if the animation loops
  91032. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  91033. * @param onAnimationEnd defines the function to be executed when the animation ends
  91034. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  91035. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  91036. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  91037. * @param onAnimationLoop defines the callback to call when an animation loops
  91038. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  91039. * @returns the list of created animatables
  91040. */
  91041. 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, isAdditive?: boolean): Animatable[];
  91042. /**
  91043. * Begin a new animation on a given node
  91044. * @param target defines the target where the animation will take place
  91045. * @param animations defines the list of animations to start
  91046. * @param from defines the initial value
  91047. * @param to defines the final value
  91048. * @param loop defines if you want animation to loop (off by default)
  91049. * @param speedRatio defines the speed ratio to apply to all animations
  91050. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91051. * @param onAnimationLoop defines the callback to call when an animation loops
  91052. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  91053. * @returns the list of created animatables
  91054. */
  91055. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  91056. /**
  91057. * Begin a new animation on a given node and its hierarchy
  91058. * @param target defines the root node where the animation will take place
  91059. * @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.
  91060. * @param animations defines the list of animations to start
  91061. * @param from defines the initial value
  91062. * @param to defines the final value
  91063. * @param loop defines if you want animation to loop (off by default)
  91064. * @param speedRatio defines the speed ratio to apply to all animations
  91065. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91066. * @param onAnimationLoop defines the callback to call when an animation loops
  91067. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  91068. * @returns the list of animatables created for all nodes
  91069. */
  91070. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  91071. /**
  91072. * Gets the animatable associated with a specific target
  91073. * @param target defines the target of the animatable
  91074. * @returns the required animatable if found
  91075. */
  91076. getAnimatableByTarget(target: any): Nullable<Animatable>;
  91077. /**
  91078. * Gets all animatables associated with a given target
  91079. * @param target defines the target to look animatables for
  91080. * @returns an array of Animatables
  91081. */
  91082. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  91083. /**
  91084. * Stops and removes all animations that have been applied to the scene
  91085. */
  91086. stopAllAnimations(): void;
  91087. /**
  91088. * Gets the current delta time used by animation engine
  91089. */
  91090. deltaTime: number;
  91091. }
  91092. interface Bone {
  91093. /**
  91094. * Copy an animation range from another bone
  91095. * @param source defines the source bone
  91096. * @param rangeName defines the range name to copy
  91097. * @param frameOffset defines the frame offset
  91098. * @param rescaleAsRequired defines if rescaling must be applied if required
  91099. * @param skelDimensionsRatio defines the scaling ratio
  91100. * @returns true if operation was successful
  91101. */
  91102. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  91103. }
  91104. }
  91105. declare module BABYLON {
  91106. /**
  91107. * Class used to handle skinning animations
  91108. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91109. */
  91110. export class Skeleton implements IAnimatable {
  91111. /** defines the skeleton name */
  91112. name: string;
  91113. /** defines the skeleton Id */
  91114. id: string;
  91115. /**
  91116. * Defines the list of child bones
  91117. */
  91118. bones: Bone[];
  91119. /**
  91120. * Defines an estimate of the dimension of the skeleton at rest
  91121. */
  91122. dimensionsAtRest: Vector3;
  91123. /**
  91124. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  91125. */
  91126. needInitialSkinMatrix: boolean;
  91127. /**
  91128. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  91129. */
  91130. overrideMesh: Nullable<AbstractMesh>;
  91131. /**
  91132. * Gets the list of animations attached to this skeleton
  91133. */
  91134. animations: Array<Animation>;
  91135. private _scene;
  91136. private _isDirty;
  91137. private _transformMatrices;
  91138. private _transformMatrixTexture;
  91139. private _meshesWithPoseMatrix;
  91140. private _animatables;
  91141. private _identity;
  91142. private _synchronizedWithMesh;
  91143. private _ranges;
  91144. private _lastAbsoluteTransformsUpdateId;
  91145. private _canUseTextureForBones;
  91146. private _uniqueId;
  91147. /** @hidden */
  91148. _numBonesWithLinkedTransformNode: number;
  91149. /** @hidden */
  91150. _hasWaitingData: Nullable<boolean>;
  91151. /**
  91152. * Specifies if the skeleton should be serialized
  91153. */
  91154. doNotSerialize: boolean;
  91155. private _useTextureToStoreBoneMatrices;
  91156. /**
  91157. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  91158. * Please note that this option is not available if the hardware does not support it
  91159. */
  91160. get useTextureToStoreBoneMatrices(): boolean;
  91161. set useTextureToStoreBoneMatrices(value: boolean);
  91162. private _animationPropertiesOverride;
  91163. /**
  91164. * Gets or sets the animation properties override
  91165. */
  91166. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  91167. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  91168. /**
  91169. * List of inspectable custom properties (used by the Inspector)
  91170. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91171. */
  91172. inspectableCustomProperties: IInspectable[];
  91173. /**
  91174. * An observable triggered before computing the skeleton's matrices
  91175. */
  91176. onBeforeComputeObservable: Observable<Skeleton>;
  91177. /**
  91178. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  91179. */
  91180. get isUsingTextureForMatrices(): boolean;
  91181. /**
  91182. * Gets the unique ID of this skeleton
  91183. */
  91184. get uniqueId(): number;
  91185. /**
  91186. * Creates a new skeleton
  91187. * @param name defines the skeleton name
  91188. * @param id defines the skeleton Id
  91189. * @param scene defines the hosting scene
  91190. */
  91191. constructor(
  91192. /** defines the skeleton name */
  91193. name: string,
  91194. /** defines the skeleton Id */
  91195. id: string, scene: Scene);
  91196. /**
  91197. * Gets the current object class name.
  91198. * @return the class name
  91199. */
  91200. getClassName(): string;
  91201. /**
  91202. * Returns an array containing the root bones
  91203. * @returns an array containing the root bones
  91204. */
  91205. getChildren(): Array<Bone>;
  91206. /**
  91207. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  91208. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91209. * @returns a Float32Array containing matrices data
  91210. */
  91211. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  91212. /**
  91213. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  91214. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91215. * @returns a raw texture containing the data
  91216. */
  91217. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  91218. /**
  91219. * Gets the current hosting scene
  91220. * @returns a scene object
  91221. */
  91222. getScene(): Scene;
  91223. /**
  91224. * Gets a string representing the current skeleton data
  91225. * @param fullDetails defines a boolean indicating if we want a verbose version
  91226. * @returns a string representing the current skeleton data
  91227. */
  91228. toString(fullDetails?: boolean): string;
  91229. /**
  91230. * Get bone's index searching by name
  91231. * @param name defines bone's name to search for
  91232. * @return the indice of the bone. Returns -1 if not found
  91233. */
  91234. getBoneIndexByName(name: string): number;
  91235. /**
  91236. * Creater a new animation range
  91237. * @param name defines the name of the range
  91238. * @param from defines the start key
  91239. * @param to defines the end key
  91240. */
  91241. createAnimationRange(name: string, from: number, to: number): void;
  91242. /**
  91243. * Delete a specific animation range
  91244. * @param name defines the name of the range
  91245. * @param deleteFrames defines if frames must be removed as well
  91246. */
  91247. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91248. /**
  91249. * Gets a specific animation range
  91250. * @param name defines the name of the range to look for
  91251. * @returns the requested animation range or null if not found
  91252. */
  91253. getAnimationRange(name: string): Nullable<AnimationRange>;
  91254. /**
  91255. * Gets the list of all animation ranges defined on this skeleton
  91256. * @returns an array
  91257. */
  91258. getAnimationRanges(): Nullable<AnimationRange>[];
  91259. /**
  91260. * Copy animation range from a source skeleton.
  91261. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  91262. * @param source defines the source skeleton
  91263. * @param name defines the name of the range to copy
  91264. * @param rescaleAsRequired defines if rescaling must be applied if required
  91265. * @returns true if operation was successful
  91266. */
  91267. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  91268. /**
  91269. * Forces the skeleton to go to rest pose
  91270. */
  91271. returnToRest(): void;
  91272. private _getHighestAnimationFrame;
  91273. /**
  91274. * Begin a specific animation range
  91275. * @param name defines the name of the range to start
  91276. * @param loop defines if looping must be turned on (false by default)
  91277. * @param speedRatio defines the speed ratio to apply (1 by default)
  91278. * @param onAnimationEnd defines a callback which will be called when animation will end
  91279. * @returns a new animatable
  91280. */
  91281. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91282. /**
  91283. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  91284. * @param skeleton defines the Skeleton containing the animation range to convert
  91285. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  91286. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  91287. * @returns the original skeleton
  91288. */
  91289. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  91290. /** @hidden */
  91291. _markAsDirty(): void;
  91292. /** @hidden */
  91293. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91294. /** @hidden */
  91295. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91296. private _computeTransformMatrices;
  91297. /**
  91298. * Build all resources required to render a skeleton
  91299. */
  91300. prepare(): void;
  91301. /**
  91302. * Gets the list of animatables currently running for this skeleton
  91303. * @returns an array of animatables
  91304. */
  91305. getAnimatables(): IAnimatable[];
  91306. /**
  91307. * Clone the current skeleton
  91308. * @param name defines the name of the new skeleton
  91309. * @param id defines the id of the new skeleton
  91310. * @returns the new skeleton
  91311. */
  91312. clone(name: string, id?: string): Skeleton;
  91313. /**
  91314. * Enable animation blending for this skeleton
  91315. * @param blendingSpeed defines the blending speed to apply
  91316. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  91317. */
  91318. enableBlending(blendingSpeed?: number): void;
  91319. /**
  91320. * Releases all resources associated with the current skeleton
  91321. */
  91322. dispose(): void;
  91323. /**
  91324. * Serialize the skeleton in a JSON object
  91325. * @returns a JSON object
  91326. */
  91327. serialize(): any;
  91328. /**
  91329. * Creates a new skeleton from serialized data
  91330. * @param parsedSkeleton defines the serialized data
  91331. * @param scene defines the hosting scene
  91332. * @returns a new skeleton
  91333. */
  91334. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  91335. /**
  91336. * Compute all node absolute transforms
  91337. * @param forceUpdate defines if computation must be done even if cache is up to date
  91338. */
  91339. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  91340. /**
  91341. * Gets the root pose matrix
  91342. * @returns a matrix
  91343. */
  91344. getPoseMatrix(): Nullable<Matrix>;
  91345. /**
  91346. * Sorts bones per internal index
  91347. */
  91348. sortBones(): void;
  91349. private _sortBones;
  91350. }
  91351. }
  91352. declare module BABYLON {
  91353. /**
  91354. * Creates an instance based on a source mesh.
  91355. */
  91356. export class InstancedMesh extends AbstractMesh {
  91357. private _sourceMesh;
  91358. private _currentLOD;
  91359. /** @hidden */
  91360. _indexInSourceMeshInstanceArray: number;
  91361. constructor(name: string, source: Mesh);
  91362. /**
  91363. * Returns the string "InstancedMesh".
  91364. */
  91365. getClassName(): string;
  91366. /** Gets the list of lights affecting that mesh */
  91367. get lightSources(): Light[];
  91368. _resyncLightSources(): void;
  91369. _resyncLightSource(light: Light): void;
  91370. _removeLightSource(light: Light, dispose: boolean): void;
  91371. /**
  91372. * If the source mesh receives shadows
  91373. */
  91374. get receiveShadows(): boolean;
  91375. /**
  91376. * The material of the source mesh
  91377. */
  91378. get material(): Nullable<Material>;
  91379. /**
  91380. * Visibility of the source mesh
  91381. */
  91382. get visibility(): number;
  91383. /**
  91384. * Skeleton of the source mesh
  91385. */
  91386. get skeleton(): Nullable<Skeleton>;
  91387. /**
  91388. * Rendering ground id of the source mesh
  91389. */
  91390. get renderingGroupId(): number;
  91391. set renderingGroupId(value: number);
  91392. /**
  91393. * Returns the total number of vertices (integer).
  91394. */
  91395. getTotalVertices(): number;
  91396. /**
  91397. * Returns a positive integer : the total number of indices in this mesh geometry.
  91398. * @returns the numner of indices or zero if the mesh has no geometry.
  91399. */
  91400. getTotalIndices(): number;
  91401. /**
  91402. * The source mesh of the instance
  91403. */
  91404. get sourceMesh(): Mesh;
  91405. /**
  91406. * Is this node ready to be used/rendered
  91407. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91408. * @return {boolean} is it ready
  91409. */
  91410. isReady(completeCheck?: boolean): boolean;
  91411. /**
  91412. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91413. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91414. * @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.
  91415. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91416. */
  91417. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91418. /**
  91419. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91420. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91421. * The `data` are either a numeric array either a Float32Array.
  91422. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91423. * 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).
  91424. * Note that a new underlying VertexBuffer object is created each call.
  91425. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91426. *
  91427. * Possible `kind` values :
  91428. * - VertexBuffer.PositionKind
  91429. * - VertexBuffer.UVKind
  91430. * - VertexBuffer.UV2Kind
  91431. * - VertexBuffer.UV3Kind
  91432. * - VertexBuffer.UV4Kind
  91433. * - VertexBuffer.UV5Kind
  91434. * - VertexBuffer.UV6Kind
  91435. * - VertexBuffer.ColorKind
  91436. * - VertexBuffer.MatricesIndicesKind
  91437. * - VertexBuffer.MatricesIndicesExtraKind
  91438. * - VertexBuffer.MatricesWeightsKind
  91439. * - VertexBuffer.MatricesWeightsExtraKind
  91440. *
  91441. * Returns the Mesh.
  91442. */
  91443. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91444. /**
  91445. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91446. * If the mesh has no geometry, it is simply returned as it is.
  91447. * The `data` are either a numeric array either a Float32Array.
  91448. * No new underlying VertexBuffer object is created.
  91449. * 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.
  91450. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91451. *
  91452. * Possible `kind` values :
  91453. * - VertexBuffer.PositionKind
  91454. * - VertexBuffer.UVKind
  91455. * - VertexBuffer.UV2Kind
  91456. * - VertexBuffer.UV3Kind
  91457. * - VertexBuffer.UV4Kind
  91458. * - VertexBuffer.UV5Kind
  91459. * - VertexBuffer.UV6Kind
  91460. * - VertexBuffer.ColorKind
  91461. * - VertexBuffer.MatricesIndicesKind
  91462. * - VertexBuffer.MatricesIndicesExtraKind
  91463. * - VertexBuffer.MatricesWeightsKind
  91464. * - VertexBuffer.MatricesWeightsExtraKind
  91465. *
  91466. * Returns the Mesh.
  91467. */
  91468. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91469. /**
  91470. * Sets the mesh indices.
  91471. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91472. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91473. * This method creates a new index buffer each call.
  91474. * Returns the Mesh.
  91475. */
  91476. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91477. /**
  91478. * Boolean : True if the mesh owns the requested kind of data.
  91479. */
  91480. isVerticesDataPresent(kind: string): boolean;
  91481. /**
  91482. * Returns an array of indices (IndicesArray).
  91483. */
  91484. getIndices(): Nullable<IndicesArray>;
  91485. get _positions(): Nullable<Vector3[]>;
  91486. /**
  91487. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91488. * This means the mesh underlying bounding box and sphere are recomputed.
  91489. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91490. * @returns the current mesh
  91491. */
  91492. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91493. /** @hidden */
  91494. _preActivate(): InstancedMesh;
  91495. /** @hidden */
  91496. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91497. /** @hidden */
  91498. _postActivate(): void;
  91499. getWorldMatrix(): Matrix;
  91500. get isAnInstance(): boolean;
  91501. /**
  91502. * Returns the current associated LOD AbstractMesh.
  91503. */
  91504. getLOD(camera: Camera): AbstractMesh;
  91505. /** @hidden */
  91506. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91507. /** @hidden */
  91508. _syncSubMeshes(): InstancedMesh;
  91509. /** @hidden */
  91510. _generatePointsArray(): boolean;
  91511. /**
  91512. * Creates a new InstancedMesh from the current mesh.
  91513. * - name (string) : the cloned mesh name
  91514. * - newParent (optional Node) : the optional Node to parent the clone to.
  91515. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91516. *
  91517. * Returns the clone.
  91518. */
  91519. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91520. /**
  91521. * Disposes the InstancedMesh.
  91522. * Returns nothing.
  91523. */
  91524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91525. }
  91526. interface Mesh {
  91527. /**
  91528. * Register a custom buffer that will be instanced
  91529. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91530. * @param kind defines the buffer kind
  91531. * @param stride defines the stride in floats
  91532. */
  91533. registerInstancedBuffer(kind: string, stride: number): void;
  91534. /** @hidden */
  91535. _userInstancedBuffersStorage: {
  91536. data: {
  91537. [key: string]: Float32Array;
  91538. };
  91539. sizes: {
  91540. [key: string]: number;
  91541. };
  91542. vertexBuffers: {
  91543. [key: string]: Nullable<VertexBuffer>;
  91544. };
  91545. strides: {
  91546. [key: string]: number;
  91547. };
  91548. };
  91549. }
  91550. interface AbstractMesh {
  91551. /**
  91552. * Object used to store instanced buffers defined by user
  91553. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91554. */
  91555. instancedBuffers: {
  91556. [key: string]: any;
  91557. };
  91558. }
  91559. }
  91560. declare module BABYLON {
  91561. /**
  91562. * Defines the options associated with the creation of a shader material.
  91563. */
  91564. export interface IShaderMaterialOptions {
  91565. /**
  91566. * Does the material work in alpha blend mode
  91567. */
  91568. needAlphaBlending: boolean;
  91569. /**
  91570. * Does the material work in alpha test mode
  91571. */
  91572. needAlphaTesting: boolean;
  91573. /**
  91574. * The list of attribute names used in the shader
  91575. */
  91576. attributes: string[];
  91577. /**
  91578. * The list of unifrom names used in the shader
  91579. */
  91580. uniforms: string[];
  91581. /**
  91582. * The list of UBO names used in the shader
  91583. */
  91584. uniformBuffers: string[];
  91585. /**
  91586. * The list of sampler names used in the shader
  91587. */
  91588. samplers: string[];
  91589. /**
  91590. * The list of defines used in the shader
  91591. */
  91592. defines: string[];
  91593. }
  91594. /**
  91595. * 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.
  91596. *
  91597. * This returned material effects how the mesh will look based on the code in the shaders.
  91598. *
  91599. * @see http://doc.babylonjs.com/how_to/shader_material
  91600. */
  91601. export class ShaderMaterial extends Material {
  91602. private _shaderPath;
  91603. private _options;
  91604. private _textures;
  91605. private _textureArrays;
  91606. private _floats;
  91607. private _ints;
  91608. private _floatsArrays;
  91609. private _colors3;
  91610. private _colors3Arrays;
  91611. private _colors4;
  91612. private _colors4Arrays;
  91613. private _vectors2;
  91614. private _vectors3;
  91615. private _vectors4;
  91616. private _matrices;
  91617. private _matrixArrays;
  91618. private _matrices3x3;
  91619. private _matrices2x2;
  91620. private _vectors2Arrays;
  91621. private _vectors3Arrays;
  91622. private _vectors4Arrays;
  91623. private _cachedWorldViewMatrix;
  91624. private _cachedWorldViewProjectionMatrix;
  91625. private _renderId;
  91626. private _multiview;
  91627. private _cachedDefines;
  91628. /**
  91629. * Instantiate a new shader material.
  91630. * 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.
  91631. * This returned material effects how the mesh will look based on the code in the shaders.
  91632. * @see http://doc.babylonjs.com/how_to/shader_material
  91633. * @param name Define the name of the material in the scene
  91634. * @param scene Define the scene the material belongs to
  91635. * @param shaderPath Defines the route to the shader code in one of three ways:
  91636. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91637. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91638. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91639. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91640. * @param options Define the options used to create the shader
  91641. */
  91642. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91643. /**
  91644. * Gets the shader path used to define the shader code
  91645. * It can be modified to trigger a new compilation
  91646. */
  91647. get shaderPath(): any;
  91648. /**
  91649. * Sets the shader path used to define the shader code
  91650. * It can be modified to trigger a new compilation
  91651. */
  91652. set shaderPath(shaderPath: any);
  91653. /**
  91654. * Gets the options used to compile the shader.
  91655. * They can be modified to trigger a new compilation
  91656. */
  91657. get options(): IShaderMaterialOptions;
  91658. /**
  91659. * Gets the current class name of the material e.g. "ShaderMaterial"
  91660. * Mainly use in serialization.
  91661. * @returns the class name
  91662. */
  91663. getClassName(): string;
  91664. /**
  91665. * Specifies if the material will require alpha blending
  91666. * @returns a boolean specifying if alpha blending is needed
  91667. */
  91668. needAlphaBlending(): boolean;
  91669. /**
  91670. * Specifies if this material should be rendered in alpha test mode
  91671. * @returns a boolean specifying if an alpha test is needed.
  91672. */
  91673. needAlphaTesting(): boolean;
  91674. private _checkUniform;
  91675. /**
  91676. * Set a texture in the shader.
  91677. * @param name Define the name of the uniform samplers as defined in the shader
  91678. * @param texture Define the texture to bind to this sampler
  91679. * @return the material itself allowing "fluent" like uniform updates
  91680. */
  91681. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  91682. /**
  91683. * Set a texture array in the shader.
  91684. * @param name Define the name of the uniform sampler array as defined in the shader
  91685. * @param textures Define the list of textures to bind to this sampler
  91686. * @return the material itself allowing "fluent" like uniform updates
  91687. */
  91688. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  91689. /**
  91690. * Set a float in the shader.
  91691. * @param name Define the name of the uniform as defined in the shader
  91692. * @param value Define the value to give to the uniform
  91693. * @return the material itself allowing "fluent" like uniform updates
  91694. */
  91695. setFloat(name: string, value: number): ShaderMaterial;
  91696. /**
  91697. * Set a int in the shader.
  91698. * @param name Define the name of the uniform as defined in the shader
  91699. * @param value Define the value to give to the uniform
  91700. * @return the material itself allowing "fluent" like uniform updates
  91701. */
  91702. setInt(name: string, value: number): ShaderMaterial;
  91703. /**
  91704. * Set an array of floats in the shader.
  91705. * @param name Define the name of the uniform as defined in the shader
  91706. * @param value Define the value to give to the uniform
  91707. * @return the material itself allowing "fluent" like uniform updates
  91708. */
  91709. setFloats(name: string, value: number[]): ShaderMaterial;
  91710. /**
  91711. * Set a vec3 in the shader from a Color3.
  91712. * @param name Define the name of the uniform as defined in the shader
  91713. * @param value Define the value to give to the uniform
  91714. * @return the material itself allowing "fluent" like uniform updates
  91715. */
  91716. setColor3(name: string, value: Color3): ShaderMaterial;
  91717. /**
  91718. * Set a vec3 array in the shader from a Color3 array.
  91719. * @param name Define the name of the uniform as defined in the shader
  91720. * @param value Define the value to give to the uniform
  91721. * @return the material itself allowing "fluent" like uniform updates
  91722. */
  91723. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  91724. /**
  91725. * Set a vec4 in the shader from a Color4.
  91726. * @param name Define the name of the uniform as defined in the shader
  91727. * @param value Define the value to give to the uniform
  91728. * @return the material itself allowing "fluent" like uniform updates
  91729. */
  91730. setColor4(name: string, value: Color4): ShaderMaterial;
  91731. /**
  91732. * Set a vec4 array in the shader from a Color4 array.
  91733. * @param name Define the name of the uniform as defined in the shader
  91734. * @param value Define the value to give to the uniform
  91735. * @return the material itself allowing "fluent" like uniform updates
  91736. */
  91737. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  91738. /**
  91739. * Set a vec2 in the shader from a Vector2.
  91740. * @param name Define the name of the uniform as defined in the shader
  91741. * @param value Define the value to give to the uniform
  91742. * @return the material itself allowing "fluent" like uniform updates
  91743. */
  91744. setVector2(name: string, value: Vector2): ShaderMaterial;
  91745. /**
  91746. * Set a vec3 in the shader from a Vector3.
  91747. * @param name Define the name of the uniform as defined in the shader
  91748. * @param value Define the value to give to the uniform
  91749. * @return the material itself allowing "fluent" like uniform updates
  91750. */
  91751. setVector3(name: string, value: Vector3): ShaderMaterial;
  91752. /**
  91753. * Set a vec4 in the shader from a Vector4.
  91754. * @param name Define the name of the uniform as defined in the shader
  91755. * @param value Define the value to give to the uniform
  91756. * @return the material itself allowing "fluent" like uniform updates
  91757. */
  91758. setVector4(name: string, value: Vector4): ShaderMaterial;
  91759. /**
  91760. * Set a mat4 in the shader from a Matrix.
  91761. * @param name Define the name of the uniform as defined in the shader
  91762. * @param value Define the value to give to the uniform
  91763. * @return the material itself allowing "fluent" like uniform updates
  91764. */
  91765. setMatrix(name: string, value: Matrix): ShaderMaterial;
  91766. /**
  91767. * Set a float32Array in the shader from a matrix array.
  91768. * @param name Define the name of the uniform as defined in the shader
  91769. * @param value Define the value to give to the uniform
  91770. * @return the material itself allowing "fluent" like uniform updates
  91771. */
  91772. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  91773. /**
  91774. * Set a mat3 in the shader from a Float32Array.
  91775. * @param name Define the name of the uniform as defined in the shader
  91776. * @param value Define the value to give to the uniform
  91777. * @return the material itself allowing "fluent" like uniform updates
  91778. */
  91779. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  91780. /**
  91781. * Set a mat2 in the shader from a Float32Array.
  91782. * @param name Define the name of the uniform as defined in the shader
  91783. * @param value Define the value to give to the uniform
  91784. * @return the material itself allowing "fluent" like uniform updates
  91785. */
  91786. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  91787. /**
  91788. * Set a vec2 array in the shader from a number array.
  91789. * @param name Define the name of the uniform as defined in the shader
  91790. * @param value Define the value to give to the uniform
  91791. * @return the material itself allowing "fluent" like uniform updates
  91792. */
  91793. setArray2(name: string, value: number[]): ShaderMaterial;
  91794. /**
  91795. * Set a vec3 array in the shader from a number array.
  91796. * @param name Define the name of the uniform as defined in the shader
  91797. * @param value Define the value to give to the uniform
  91798. * @return the material itself allowing "fluent" like uniform updates
  91799. */
  91800. setArray3(name: string, value: number[]): ShaderMaterial;
  91801. /**
  91802. * Set a vec4 array in the shader from a number array.
  91803. * @param name Define the name of the uniform as defined in the shader
  91804. * @param value Define the value to give to the uniform
  91805. * @return the material itself allowing "fluent" like uniform updates
  91806. */
  91807. setArray4(name: string, value: number[]): ShaderMaterial;
  91808. private _checkCache;
  91809. /**
  91810. * Specifies that the submesh is ready to be used
  91811. * @param mesh defines the mesh to check
  91812. * @param subMesh defines which submesh to check
  91813. * @param useInstances specifies that instances should be used
  91814. * @returns a boolean indicating that the submesh is ready or not
  91815. */
  91816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91817. /**
  91818. * Checks if the material is ready to render the requested mesh
  91819. * @param mesh Define the mesh to render
  91820. * @param useInstances Define whether or not the material is used with instances
  91821. * @returns true if ready, otherwise false
  91822. */
  91823. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91824. /**
  91825. * Binds the world matrix to the material
  91826. * @param world defines the world transformation matrix
  91827. * @param effectOverride - If provided, use this effect instead of internal effect
  91828. */
  91829. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  91830. /**
  91831. * Binds the submesh to this material by preparing the effect and shader to draw
  91832. * @param world defines the world transformation matrix
  91833. * @param mesh defines the mesh containing the submesh
  91834. * @param subMesh defines the submesh to bind the material to
  91835. */
  91836. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91837. /**
  91838. * Binds the material to the mesh
  91839. * @param world defines the world transformation matrix
  91840. * @param mesh defines the mesh to bind the material to
  91841. * @param effectOverride - If provided, use this effect instead of internal effect
  91842. */
  91843. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  91844. protected _afterBind(mesh?: Mesh): void;
  91845. /**
  91846. * Gets the active textures from the material
  91847. * @returns an array of textures
  91848. */
  91849. getActiveTextures(): BaseTexture[];
  91850. /**
  91851. * Specifies if the material uses a texture
  91852. * @param texture defines the texture to check against the material
  91853. * @returns a boolean specifying if the material uses the texture
  91854. */
  91855. hasTexture(texture: BaseTexture): boolean;
  91856. /**
  91857. * Makes a duplicate of the material, and gives it a new name
  91858. * @param name defines the new name for the duplicated material
  91859. * @returns the cloned material
  91860. */
  91861. clone(name: string): ShaderMaterial;
  91862. /**
  91863. * Disposes the material
  91864. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91865. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91866. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91867. */
  91868. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91869. /**
  91870. * Serializes this material in a JSON representation
  91871. * @returns the serialized material object
  91872. */
  91873. serialize(): any;
  91874. /**
  91875. * Creates a shader material from parsed shader material data
  91876. * @param source defines the JSON represnetation of the material
  91877. * @param scene defines the hosting scene
  91878. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91879. * @returns a new material
  91880. */
  91881. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91882. }
  91883. }
  91884. declare module BABYLON {
  91885. /** @hidden */
  91886. export var colorPixelShader: {
  91887. name: string;
  91888. shader: string;
  91889. };
  91890. }
  91891. declare module BABYLON {
  91892. /** @hidden */
  91893. export var colorVertexShader: {
  91894. name: string;
  91895. shader: string;
  91896. };
  91897. }
  91898. declare module BABYLON {
  91899. /**
  91900. * Line mesh
  91901. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91902. */
  91903. export class LinesMesh extends Mesh {
  91904. /**
  91905. * If vertex color should be applied to the mesh
  91906. */
  91907. readonly useVertexColor?: boolean | undefined;
  91908. /**
  91909. * If vertex alpha should be applied to the mesh
  91910. */
  91911. readonly useVertexAlpha?: boolean | undefined;
  91912. /**
  91913. * Color of the line (Default: White)
  91914. */
  91915. color: Color3;
  91916. /**
  91917. * Alpha of the line (Default: 1)
  91918. */
  91919. alpha: number;
  91920. /**
  91921. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91922. * This margin is expressed in world space coordinates, so its value may vary.
  91923. * Default value is 0.1
  91924. */
  91925. intersectionThreshold: number;
  91926. private _colorShader;
  91927. private color4;
  91928. /**
  91929. * Creates a new LinesMesh
  91930. * @param name defines the name
  91931. * @param scene defines the hosting scene
  91932. * @param parent defines the parent mesh if any
  91933. * @param source defines the optional source LinesMesh used to clone data from
  91934. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91935. * When false, achieved by calling a clone(), also passing False.
  91936. * This will make creation of children, recursive.
  91937. * @param useVertexColor defines if this LinesMesh supports vertex color
  91938. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91939. */
  91940. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91941. /**
  91942. * If vertex color should be applied to the mesh
  91943. */
  91944. useVertexColor?: boolean | undefined,
  91945. /**
  91946. * If vertex alpha should be applied to the mesh
  91947. */
  91948. useVertexAlpha?: boolean | undefined);
  91949. private _addClipPlaneDefine;
  91950. private _removeClipPlaneDefine;
  91951. isReady(): boolean;
  91952. /**
  91953. * Returns the string "LineMesh"
  91954. */
  91955. getClassName(): string;
  91956. /**
  91957. * @hidden
  91958. */
  91959. get material(): Material;
  91960. /**
  91961. * @hidden
  91962. */
  91963. set material(value: Material);
  91964. /**
  91965. * @hidden
  91966. */
  91967. get checkCollisions(): boolean;
  91968. /** @hidden */
  91969. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91970. /** @hidden */
  91971. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91972. /**
  91973. * Disposes of the line mesh
  91974. * @param doNotRecurse If children should be disposed
  91975. */
  91976. dispose(doNotRecurse?: boolean): void;
  91977. /**
  91978. * Returns a new LineMesh object cloned from the current one.
  91979. */
  91980. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  91981. /**
  91982. * Creates a new InstancedLinesMesh object from the mesh model.
  91983. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91984. * @param name defines the name of the new instance
  91985. * @returns a new InstancedLinesMesh
  91986. */
  91987. createInstance(name: string): InstancedLinesMesh;
  91988. }
  91989. /**
  91990. * Creates an instance based on a source LinesMesh
  91991. */
  91992. export class InstancedLinesMesh extends InstancedMesh {
  91993. /**
  91994. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91995. * This margin is expressed in world space coordinates, so its value may vary.
  91996. * Initilized with the intersectionThreshold value of the source LinesMesh
  91997. */
  91998. intersectionThreshold: number;
  91999. constructor(name: string, source: LinesMesh);
  92000. /**
  92001. * Returns the string "InstancedLinesMesh".
  92002. */
  92003. getClassName(): string;
  92004. }
  92005. }
  92006. declare module BABYLON {
  92007. /** @hidden */
  92008. export var linePixelShader: {
  92009. name: string;
  92010. shader: string;
  92011. };
  92012. }
  92013. declare module BABYLON {
  92014. /** @hidden */
  92015. export var lineVertexShader: {
  92016. name: string;
  92017. shader: string;
  92018. };
  92019. }
  92020. declare module BABYLON {
  92021. interface AbstractMesh {
  92022. /**
  92023. * Gets the edgesRenderer associated with the mesh
  92024. */
  92025. edgesRenderer: Nullable<EdgesRenderer>;
  92026. }
  92027. interface LinesMesh {
  92028. /**
  92029. * Enables the edge rendering mode on the mesh.
  92030. * This mode makes the mesh edges visible
  92031. * @param epsilon defines the maximal distance between two angles to detect a face
  92032. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92033. * @returns the currentAbstractMesh
  92034. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92035. */
  92036. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92037. }
  92038. interface InstancedLinesMesh {
  92039. /**
  92040. * Enables the edge rendering mode on the mesh.
  92041. * This mode makes the mesh edges visible
  92042. * @param epsilon defines the maximal distance between two angles to detect a face
  92043. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92044. * @returns the current InstancedLinesMesh
  92045. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92046. */
  92047. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  92048. }
  92049. /**
  92050. * Defines the minimum contract an Edges renderer should follow.
  92051. */
  92052. export interface IEdgesRenderer extends IDisposable {
  92053. /**
  92054. * Gets or sets a boolean indicating if the edgesRenderer is active
  92055. */
  92056. isEnabled: boolean;
  92057. /**
  92058. * Renders the edges of the attached mesh,
  92059. */
  92060. render(): void;
  92061. /**
  92062. * Checks wether or not the edges renderer is ready to render.
  92063. * @return true if ready, otherwise false.
  92064. */
  92065. isReady(): boolean;
  92066. }
  92067. /**
  92068. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92069. */
  92070. export class EdgesRenderer implements IEdgesRenderer {
  92071. /**
  92072. * Define the size of the edges with an orthographic camera
  92073. */
  92074. edgesWidthScalerForOrthographic: number;
  92075. /**
  92076. * Define the size of the edges with a perspective camera
  92077. */
  92078. edgesWidthScalerForPerspective: number;
  92079. protected _source: AbstractMesh;
  92080. protected _linesPositions: number[];
  92081. protected _linesNormals: number[];
  92082. protected _linesIndices: number[];
  92083. protected _epsilon: number;
  92084. protected _indicesCount: number;
  92085. protected _lineShader: ShaderMaterial;
  92086. protected _ib: DataBuffer;
  92087. protected _buffers: {
  92088. [key: string]: Nullable<VertexBuffer>;
  92089. };
  92090. protected _checkVerticesInsteadOfIndices: boolean;
  92091. private _meshRebuildObserver;
  92092. private _meshDisposeObserver;
  92093. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92094. isEnabled: boolean;
  92095. /**
  92096. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92097. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92098. * @param source Mesh used to create edges
  92099. * @param epsilon sum of angles in adjacency to check for edge
  92100. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92101. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92102. */
  92103. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92104. protected _prepareRessources(): void;
  92105. /** @hidden */
  92106. _rebuild(): void;
  92107. /**
  92108. * Releases the required resources for the edges renderer
  92109. */
  92110. dispose(): void;
  92111. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92112. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92113. /**
  92114. * Checks if the pair of p0 and p1 is en edge
  92115. * @param faceIndex
  92116. * @param edge
  92117. * @param faceNormals
  92118. * @param p0
  92119. * @param p1
  92120. * @private
  92121. */
  92122. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92123. /**
  92124. * push line into the position, normal and index buffer
  92125. * @protected
  92126. */
  92127. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92128. /**
  92129. * Generates lines edges from adjacencjes
  92130. * @private
  92131. */
  92132. _generateEdgesLines(): void;
  92133. /**
  92134. * Checks wether or not the edges renderer is ready to render.
  92135. * @return true if ready, otherwise false.
  92136. */
  92137. isReady(): boolean;
  92138. /**
  92139. * Renders the edges of the attached mesh,
  92140. */
  92141. render(): void;
  92142. }
  92143. /**
  92144. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92145. */
  92146. export class LineEdgesRenderer extends EdgesRenderer {
  92147. /**
  92148. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92149. * @param source LineMesh used to generate edges
  92150. * @param epsilon not important (specified angle for edge detection)
  92151. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92152. */
  92153. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92154. /**
  92155. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92156. */
  92157. _generateEdgesLines(): void;
  92158. }
  92159. }
  92160. declare module BABYLON {
  92161. /**
  92162. * This represents the object necessary to create a rendering group.
  92163. * This is exclusively used and created by the rendering manager.
  92164. * To modify the behavior, you use the available helpers in your scene or meshes.
  92165. * @hidden
  92166. */
  92167. export class RenderingGroup {
  92168. index: number;
  92169. private static _zeroVector;
  92170. private _scene;
  92171. private _opaqueSubMeshes;
  92172. private _transparentSubMeshes;
  92173. private _alphaTestSubMeshes;
  92174. private _depthOnlySubMeshes;
  92175. private _particleSystems;
  92176. private _spriteManagers;
  92177. private _opaqueSortCompareFn;
  92178. private _alphaTestSortCompareFn;
  92179. private _transparentSortCompareFn;
  92180. private _renderOpaque;
  92181. private _renderAlphaTest;
  92182. private _renderTransparent;
  92183. /** @hidden */
  92184. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92185. onBeforeTransparentRendering: () => void;
  92186. /**
  92187. * Set the opaque sort comparison function.
  92188. * If null the sub meshes will be render in the order they were created
  92189. */
  92190. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92191. /**
  92192. * Set the alpha test sort comparison function.
  92193. * If null the sub meshes will be render in the order they were created
  92194. */
  92195. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92196. /**
  92197. * Set the transparent sort comparison function.
  92198. * If null the sub meshes will be render in the order they were created
  92199. */
  92200. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92201. /**
  92202. * Creates a new rendering group.
  92203. * @param index The rendering group index
  92204. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92205. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92206. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92207. */
  92208. 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>);
  92209. /**
  92210. * Render all the sub meshes contained in the group.
  92211. * @param customRenderFunction Used to override the default render behaviour of the group.
  92212. * @returns true if rendered some submeshes.
  92213. */
  92214. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92215. /**
  92216. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92217. * @param subMeshes The submeshes to render
  92218. */
  92219. private renderOpaqueSorted;
  92220. /**
  92221. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92222. * @param subMeshes The submeshes to render
  92223. */
  92224. private renderAlphaTestSorted;
  92225. /**
  92226. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92227. * @param subMeshes The submeshes to render
  92228. */
  92229. private renderTransparentSorted;
  92230. /**
  92231. * Renders the submeshes in a specified order.
  92232. * @param subMeshes The submeshes to sort before render
  92233. * @param sortCompareFn The comparison function use to sort
  92234. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92235. * @param transparent Specifies to activate blending if true
  92236. */
  92237. private static renderSorted;
  92238. /**
  92239. * Renders the submeshes in the order they were dispatched (no sort applied).
  92240. * @param subMeshes The submeshes to render
  92241. */
  92242. private static renderUnsorted;
  92243. /**
  92244. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92245. * are rendered back to front if in the same alpha index.
  92246. *
  92247. * @param a The first submesh
  92248. * @param b The second submesh
  92249. * @returns The result of the comparison
  92250. */
  92251. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92252. /**
  92253. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92254. * are rendered back to front.
  92255. *
  92256. * @param a The first submesh
  92257. * @param b The second submesh
  92258. * @returns The result of the comparison
  92259. */
  92260. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92261. /**
  92262. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92263. * are rendered front to back (prevent overdraw).
  92264. *
  92265. * @param a The first submesh
  92266. * @param b The second submesh
  92267. * @returns The result of the comparison
  92268. */
  92269. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92270. /**
  92271. * Resets the different lists of submeshes to prepare a new frame.
  92272. */
  92273. prepare(): void;
  92274. dispose(): void;
  92275. /**
  92276. * Inserts the submesh in its correct queue depending on its material.
  92277. * @param subMesh The submesh to dispatch
  92278. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92279. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92280. */
  92281. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92282. dispatchSprites(spriteManager: ISpriteManager): void;
  92283. dispatchParticles(particleSystem: IParticleSystem): void;
  92284. private _renderParticles;
  92285. private _renderSprites;
  92286. }
  92287. }
  92288. declare module BABYLON {
  92289. /**
  92290. * Interface describing the different options available in the rendering manager
  92291. * regarding Auto Clear between groups.
  92292. */
  92293. export interface IRenderingManagerAutoClearSetup {
  92294. /**
  92295. * Defines whether or not autoclear is enable.
  92296. */
  92297. autoClear: boolean;
  92298. /**
  92299. * Defines whether or not to autoclear the depth buffer.
  92300. */
  92301. depth: boolean;
  92302. /**
  92303. * Defines whether or not to autoclear the stencil buffer.
  92304. */
  92305. stencil: boolean;
  92306. }
  92307. /**
  92308. * This class is used by the onRenderingGroupObservable
  92309. */
  92310. export class RenderingGroupInfo {
  92311. /**
  92312. * The Scene that being rendered
  92313. */
  92314. scene: Scene;
  92315. /**
  92316. * The camera currently used for the rendering pass
  92317. */
  92318. camera: Nullable<Camera>;
  92319. /**
  92320. * The ID of the renderingGroup being processed
  92321. */
  92322. renderingGroupId: number;
  92323. }
  92324. /**
  92325. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92326. * It is enable to manage the different groups as well as the different necessary sort functions.
  92327. * This should not be used directly aside of the few static configurations
  92328. */
  92329. export class RenderingManager {
  92330. /**
  92331. * The max id used for rendering groups (not included)
  92332. */
  92333. static MAX_RENDERINGGROUPS: number;
  92334. /**
  92335. * The min id used for rendering groups (included)
  92336. */
  92337. static MIN_RENDERINGGROUPS: number;
  92338. /**
  92339. * Used to globally prevent autoclearing scenes.
  92340. */
  92341. static AUTOCLEAR: boolean;
  92342. /**
  92343. * @hidden
  92344. */
  92345. _useSceneAutoClearSetup: boolean;
  92346. private _scene;
  92347. private _renderingGroups;
  92348. private _depthStencilBufferAlreadyCleaned;
  92349. private _autoClearDepthStencil;
  92350. private _customOpaqueSortCompareFn;
  92351. private _customAlphaTestSortCompareFn;
  92352. private _customTransparentSortCompareFn;
  92353. private _renderingGroupInfo;
  92354. /**
  92355. * Instantiates a new rendering group for a particular scene
  92356. * @param scene Defines the scene the groups belongs to
  92357. */
  92358. constructor(scene: Scene);
  92359. private _clearDepthStencilBuffer;
  92360. /**
  92361. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92362. * @hidden
  92363. */
  92364. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92365. /**
  92366. * Resets the different information of the group to prepare a new frame
  92367. * @hidden
  92368. */
  92369. reset(): void;
  92370. /**
  92371. * Dispose and release the group and its associated resources.
  92372. * @hidden
  92373. */
  92374. dispose(): void;
  92375. /**
  92376. * Clear the info related to rendering groups preventing retention points during dispose.
  92377. */
  92378. freeRenderingGroups(): void;
  92379. private _prepareRenderingGroup;
  92380. /**
  92381. * Add a sprite manager to the rendering manager in order to render it this frame.
  92382. * @param spriteManager Define the sprite manager to render
  92383. */
  92384. dispatchSprites(spriteManager: ISpriteManager): void;
  92385. /**
  92386. * Add a particle system to the rendering manager in order to render it this frame.
  92387. * @param particleSystem Define the particle system to render
  92388. */
  92389. dispatchParticles(particleSystem: IParticleSystem): void;
  92390. /**
  92391. * Add a submesh to the manager in order to render it this frame
  92392. * @param subMesh The submesh to dispatch
  92393. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92394. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92395. */
  92396. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92397. /**
  92398. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92399. * This allowed control for front to back rendering or reversly depending of the special needs.
  92400. *
  92401. * @param renderingGroupId The rendering group id corresponding to its index
  92402. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92403. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92404. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92405. */
  92406. 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;
  92407. /**
  92408. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92409. *
  92410. * @param renderingGroupId The rendering group id corresponding to its index
  92411. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92412. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92413. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92414. */
  92415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92416. /**
  92417. * Gets the current auto clear configuration for one rendering group of the rendering
  92418. * manager.
  92419. * @param index the rendering group index to get the information for
  92420. * @returns The auto clear setup for the requested rendering group
  92421. */
  92422. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92423. }
  92424. }
  92425. declare module BABYLON {
  92426. /**
  92427. * Defines the options associated with the creation of a custom shader for a shadow generator.
  92428. */
  92429. export interface ICustomShaderOptions {
  92430. /**
  92431. * Gets or sets the custom shader name to use
  92432. */
  92433. shaderName: string;
  92434. /**
  92435. * The list of attribute names used in the shader
  92436. */
  92437. attributes?: string[];
  92438. /**
  92439. * The list of unifrom names used in the shader
  92440. */
  92441. uniforms?: string[];
  92442. /**
  92443. * The list of sampler names used in the shader
  92444. */
  92445. samplers?: string[];
  92446. /**
  92447. * The list of defines used in the shader
  92448. */
  92449. defines?: string[];
  92450. }
  92451. /**
  92452. * Interface to implement to create a shadow generator compatible with BJS.
  92453. */
  92454. export interface IShadowGenerator {
  92455. /**
  92456. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92457. * @returns The render target texture if present otherwise, null
  92458. */
  92459. getShadowMap(): Nullable<RenderTargetTexture>;
  92460. /**
  92461. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92462. * @param subMesh The submesh we want to render in the shadow map
  92463. * @param useInstances Defines wether will draw in the map using instances
  92464. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92465. * @returns true if ready otherwise, false
  92466. */
  92467. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92468. /**
  92469. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92470. * @param defines Defines of the material we want to update
  92471. * @param lightIndex Index of the light in the enabled light list of the material
  92472. */
  92473. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  92474. /**
  92475. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92476. * defined in the generator but impacting the effect).
  92477. * It implies the unifroms available on the materials are the standard BJS ones.
  92478. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92479. * @param effect The effect we are binfing the information for
  92480. */
  92481. bindShadowLight(lightIndex: string, effect: Effect): void;
  92482. /**
  92483. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92484. * (eq to shadow prjection matrix * light transform matrix)
  92485. * @returns The transform matrix used to create the shadow map
  92486. */
  92487. getTransformMatrix(): Matrix;
  92488. /**
  92489. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92490. * Cube and 2D textures for instance.
  92491. */
  92492. recreateShadowMap(): void;
  92493. /**
  92494. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92495. * @param onCompiled Callback triggered at the and of the effects compilation
  92496. * @param options Sets of optional options forcing the compilation with different modes
  92497. */
  92498. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92499. useInstances: boolean;
  92500. }>): void;
  92501. /**
  92502. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92503. * @param options Sets of optional options forcing the compilation with different modes
  92504. * @returns A promise that resolves when the compilation completes
  92505. */
  92506. forceCompilationAsync(options?: Partial<{
  92507. useInstances: boolean;
  92508. }>): Promise<void>;
  92509. /**
  92510. * Serializes the shadow generator setup to a json object.
  92511. * @returns The serialized JSON object
  92512. */
  92513. serialize(): any;
  92514. /**
  92515. * Disposes the Shadow map and related Textures and effects.
  92516. */
  92517. dispose(): void;
  92518. }
  92519. /**
  92520. * Default implementation IShadowGenerator.
  92521. * This is the main object responsible of generating shadows in the framework.
  92522. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  92523. */
  92524. export class ShadowGenerator implements IShadowGenerator {
  92525. /**
  92526. * Name of the shadow generator class
  92527. */
  92528. static CLASSNAME: string;
  92529. /**
  92530. * Shadow generator mode None: no filtering applied.
  92531. */
  92532. static readonly FILTER_NONE: number;
  92533. /**
  92534. * Shadow generator mode ESM: Exponential Shadow Mapping.
  92535. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92536. */
  92537. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  92538. /**
  92539. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  92540. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  92541. */
  92542. static readonly FILTER_POISSONSAMPLING: number;
  92543. /**
  92544. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  92545. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92546. */
  92547. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  92548. /**
  92549. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  92550. * edge artifacts on steep falloff.
  92551. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92552. */
  92553. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  92554. /**
  92555. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  92556. * edge artifacts on steep falloff.
  92557. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92558. */
  92559. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  92560. /**
  92561. * Shadow generator mode PCF: Percentage Closer Filtering
  92562. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92563. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  92564. */
  92565. static readonly FILTER_PCF: number;
  92566. /**
  92567. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  92568. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92569. * Contact Hardening
  92570. */
  92571. static readonly FILTER_PCSS: number;
  92572. /**
  92573. * Reserved for PCF and PCSS
  92574. * Highest Quality.
  92575. *
  92576. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  92577. *
  92578. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  92579. */
  92580. static readonly QUALITY_HIGH: number;
  92581. /**
  92582. * Reserved for PCF and PCSS
  92583. * Good tradeoff for quality/perf cross devices
  92584. *
  92585. * Execute PCF on a 3*3 kernel.
  92586. *
  92587. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  92588. */
  92589. static readonly QUALITY_MEDIUM: number;
  92590. /**
  92591. * Reserved for PCF and PCSS
  92592. * The lowest quality but the fastest.
  92593. *
  92594. * Execute PCF on a 1*1 kernel.
  92595. *
  92596. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  92597. */
  92598. static readonly QUALITY_LOW: number;
  92599. /** Gets or sets the custom shader name to use */
  92600. customShaderOptions: ICustomShaderOptions;
  92601. /**
  92602. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  92603. */
  92604. onBeforeShadowMapRenderObservable: Observable<Effect>;
  92605. /**
  92606. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  92607. */
  92608. onAfterShadowMapRenderObservable: Observable<Effect>;
  92609. /**
  92610. * Observable triggered before a mesh is rendered in the shadow map.
  92611. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  92612. */
  92613. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  92614. /**
  92615. * Observable triggered after a mesh is rendered in the shadow map.
  92616. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  92617. */
  92618. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  92619. protected _bias: number;
  92620. /**
  92621. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  92622. */
  92623. get bias(): number;
  92624. /**
  92625. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  92626. */
  92627. set bias(bias: number);
  92628. protected _normalBias: number;
  92629. /**
  92630. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92631. */
  92632. get normalBias(): number;
  92633. /**
  92634. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92635. */
  92636. set normalBias(normalBias: number);
  92637. protected _blurBoxOffset: number;
  92638. /**
  92639. * Gets the blur box offset: offset applied during the blur pass.
  92640. * Only useful if useKernelBlur = false
  92641. */
  92642. get blurBoxOffset(): number;
  92643. /**
  92644. * Sets the blur box offset: offset applied during the blur pass.
  92645. * Only useful if useKernelBlur = false
  92646. */
  92647. set blurBoxOffset(value: number);
  92648. protected _blurScale: number;
  92649. /**
  92650. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  92651. * 2 means half of the size.
  92652. */
  92653. get blurScale(): number;
  92654. /**
  92655. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  92656. * 2 means half of the size.
  92657. */
  92658. set blurScale(value: number);
  92659. protected _blurKernel: number;
  92660. /**
  92661. * Gets the blur kernel: kernel size of the blur pass.
  92662. * Only useful if useKernelBlur = true
  92663. */
  92664. get blurKernel(): number;
  92665. /**
  92666. * Sets the blur kernel: kernel size of the blur pass.
  92667. * Only useful if useKernelBlur = true
  92668. */
  92669. set blurKernel(value: number);
  92670. protected _useKernelBlur: boolean;
  92671. /**
  92672. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  92673. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92674. */
  92675. get useKernelBlur(): boolean;
  92676. /**
  92677. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  92678. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92679. */
  92680. set useKernelBlur(value: boolean);
  92681. protected _depthScale: number;
  92682. /**
  92683. * Gets the depth scale used in ESM mode.
  92684. */
  92685. get depthScale(): number;
  92686. /**
  92687. * Sets the depth scale used in ESM mode.
  92688. * This can override the scale stored on the light.
  92689. */
  92690. set depthScale(value: number);
  92691. protected _validateFilter(filter: number): number;
  92692. protected _filter: number;
  92693. /**
  92694. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  92695. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92696. */
  92697. get filter(): number;
  92698. /**
  92699. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  92700. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92701. */
  92702. set filter(value: number);
  92703. /**
  92704. * Gets if the current filter is set to Poisson Sampling.
  92705. */
  92706. get usePoissonSampling(): boolean;
  92707. /**
  92708. * Sets the current filter to Poisson Sampling.
  92709. */
  92710. set usePoissonSampling(value: boolean);
  92711. /**
  92712. * Gets if the current filter is set to ESM.
  92713. */
  92714. get useExponentialShadowMap(): boolean;
  92715. /**
  92716. * Sets the current filter is to ESM.
  92717. */
  92718. set useExponentialShadowMap(value: boolean);
  92719. /**
  92720. * Gets if the current filter is set to filtered ESM.
  92721. */
  92722. get useBlurExponentialShadowMap(): boolean;
  92723. /**
  92724. * Gets if the current filter is set to filtered ESM.
  92725. */
  92726. set useBlurExponentialShadowMap(value: boolean);
  92727. /**
  92728. * Gets if the current filter is set to "close ESM" (using the inverse of the
  92729. * exponential to prevent steep falloff artifacts).
  92730. */
  92731. get useCloseExponentialShadowMap(): boolean;
  92732. /**
  92733. * Sets the current filter to "close ESM" (using the inverse of the
  92734. * exponential to prevent steep falloff artifacts).
  92735. */
  92736. set useCloseExponentialShadowMap(value: boolean);
  92737. /**
  92738. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  92739. * exponential to prevent steep falloff artifacts).
  92740. */
  92741. get useBlurCloseExponentialShadowMap(): boolean;
  92742. /**
  92743. * Sets the current filter to filtered "close ESM" (using the inverse of the
  92744. * exponential to prevent steep falloff artifacts).
  92745. */
  92746. set useBlurCloseExponentialShadowMap(value: boolean);
  92747. /**
  92748. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  92749. */
  92750. get usePercentageCloserFiltering(): boolean;
  92751. /**
  92752. * Sets the current filter to "PCF" (percentage closer filtering).
  92753. */
  92754. set usePercentageCloserFiltering(value: boolean);
  92755. protected _filteringQuality: number;
  92756. /**
  92757. * Gets the PCF or PCSS Quality.
  92758. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92759. */
  92760. get filteringQuality(): number;
  92761. /**
  92762. * Sets the PCF or PCSS Quality.
  92763. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92764. */
  92765. set filteringQuality(filteringQuality: number);
  92766. /**
  92767. * Gets if the current filter is set to "PCSS" (contact hardening).
  92768. */
  92769. get useContactHardeningShadow(): boolean;
  92770. /**
  92771. * Sets the current filter to "PCSS" (contact hardening).
  92772. */
  92773. set useContactHardeningShadow(value: boolean);
  92774. protected _contactHardeningLightSizeUVRatio: number;
  92775. /**
  92776. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92777. * Using a ratio helps keeping shape stability independently of the map size.
  92778. *
  92779. * It does not account for the light projection as it was having too much
  92780. * instability during the light setup or during light position changes.
  92781. *
  92782. * Only valid if useContactHardeningShadow is true.
  92783. */
  92784. get contactHardeningLightSizeUVRatio(): number;
  92785. /**
  92786. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92787. * Using a ratio helps keeping shape stability independently of the map size.
  92788. *
  92789. * It does not account for the light projection as it was having too much
  92790. * instability during the light setup or during light position changes.
  92791. *
  92792. * Only valid if useContactHardeningShadow is true.
  92793. */
  92794. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  92795. protected _darkness: number;
  92796. /** Gets or sets the actual darkness of a shadow */
  92797. get darkness(): number;
  92798. set darkness(value: number);
  92799. /**
  92800. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  92801. * 0 means strongest and 1 would means no shadow.
  92802. * @returns the darkness.
  92803. */
  92804. getDarkness(): number;
  92805. /**
  92806. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  92807. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  92808. * @returns the shadow generator allowing fluent coding.
  92809. */
  92810. setDarkness(darkness: number): ShadowGenerator;
  92811. protected _transparencyShadow: boolean;
  92812. /** Gets or sets the ability to have transparent shadow */
  92813. get transparencyShadow(): boolean;
  92814. set transparencyShadow(value: boolean);
  92815. /**
  92816. * Sets the ability to have transparent shadow (boolean).
  92817. * @param transparent True if transparent else False
  92818. * @returns the shadow generator allowing fluent coding
  92819. */
  92820. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  92821. /**
  92822. * Enables or disables shadows with varying strength based on the transparency
  92823. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  92824. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  92825. * mesh.visibility * alphaTexture.a
  92826. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  92827. */
  92828. enableSoftTransparentShadow: boolean;
  92829. protected _shadowMap: Nullable<RenderTargetTexture>;
  92830. protected _shadowMap2: Nullable<RenderTargetTexture>;
  92831. /**
  92832. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92833. * @returns The render target texture if present otherwise, null
  92834. */
  92835. getShadowMap(): Nullable<RenderTargetTexture>;
  92836. /**
  92837. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  92838. * @returns The render target texture if the shadow map is present otherwise, null
  92839. */
  92840. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  92841. /**
  92842. * Gets the class name of that object
  92843. * @returns "ShadowGenerator"
  92844. */
  92845. getClassName(): string;
  92846. /**
  92847. * Helper function to add a mesh and its descendants to the list of shadow casters.
  92848. * @param mesh Mesh to add
  92849. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  92850. * @returns the Shadow Generator itself
  92851. */
  92852. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92853. /**
  92854. * Helper function to remove a mesh and its descendants from the list of shadow casters
  92855. * @param mesh Mesh to remove
  92856. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  92857. * @returns the Shadow Generator itself
  92858. */
  92859. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92860. /**
  92861. * Controls the extent to which the shadows fade out at the edge of the frustum
  92862. */
  92863. frustumEdgeFalloff: number;
  92864. protected _light: IShadowLight;
  92865. /**
  92866. * Returns the associated light object.
  92867. * @returns the light generating the shadow
  92868. */
  92869. getLight(): IShadowLight;
  92870. /**
  92871. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  92872. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  92873. * It might on the other hand introduce peter panning.
  92874. */
  92875. forceBackFacesOnly: boolean;
  92876. protected _scene: Scene;
  92877. protected _lightDirection: Vector3;
  92878. protected _effect: Effect;
  92879. protected _viewMatrix: Matrix;
  92880. protected _projectionMatrix: Matrix;
  92881. protected _transformMatrix: Matrix;
  92882. protected _cachedPosition: Vector3;
  92883. protected _cachedDirection: Vector3;
  92884. protected _cachedDefines: string;
  92885. protected _currentRenderID: number;
  92886. protected _boxBlurPostprocess: Nullable<PostProcess>;
  92887. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  92888. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  92889. protected _blurPostProcesses: PostProcess[];
  92890. protected _mapSize: number;
  92891. protected _currentFaceIndex: number;
  92892. protected _currentFaceIndexCache: number;
  92893. protected _textureType: number;
  92894. protected _defaultTextureMatrix: Matrix;
  92895. protected _storedUniqueId: Nullable<number>;
  92896. /** @hidden */
  92897. static _SceneComponentInitialization: (scene: Scene) => void;
  92898. /**
  92899. * Creates a ShadowGenerator object.
  92900. * A ShadowGenerator is the required tool to use the shadows.
  92901. * Each light casting shadows needs to use its own ShadowGenerator.
  92902. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  92903. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  92904. * @param light The light object generating the shadows.
  92905. * @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.
  92906. */
  92907. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  92908. protected _initializeGenerator(): void;
  92909. protected _createTargetRenderTexture(): void;
  92910. protected _initializeShadowMap(): void;
  92911. protected _initializeBlurRTTAndPostProcesses(): void;
  92912. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  92913. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  92914. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  92915. protected _applyFilterValues(): void;
  92916. /**
  92917. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92918. * @param onCompiled Callback triggered at the and of the effects compilation
  92919. * @param options Sets of optional options forcing the compilation with different modes
  92920. */
  92921. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92922. useInstances: boolean;
  92923. }>): void;
  92924. /**
  92925. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92926. * @param options Sets of optional options forcing the compilation with different modes
  92927. * @returns A promise that resolves when the compilation completes
  92928. */
  92929. forceCompilationAsync(options?: Partial<{
  92930. useInstances: boolean;
  92931. }>): Promise<void>;
  92932. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  92933. private _prepareShadowDefines;
  92934. /**
  92935. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92936. * @param subMesh The submesh we want to render in the shadow map
  92937. * @param useInstances Defines wether will draw in the map using instances
  92938. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92939. * @returns true if ready otherwise, false
  92940. */
  92941. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92942. /**
  92943. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92944. * @param defines Defines of the material we want to update
  92945. * @param lightIndex Index of the light in the enabled light list of the material
  92946. */
  92947. prepareDefines(defines: any, lightIndex: number): void;
  92948. /**
  92949. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92950. * defined in the generator but impacting the effect).
  92951. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92952. * @param effect The effect we are binfing the information for
  92953. */
  92954. bindShadowLight(lightIndex: string, effect: Effect): void;
  92955. /**
  92956. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92957. * (eq to shadow prjection matrix * light transform matrix)
  92958. * @returns The transform matrix used to create the shadow map
  92959. */
  92960. getTransformMatrix(): Matrix;
  92961. /**
  92962. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92963. * Cube and 2D textures for instance.
  92964. */
  92965. recreateShadowMap(): void;
  92966. protected _disposeBlurPostProcesses(): void;
  92967. protected _disposeRTTandPostProcesses(): void;
  92968. /**
  92969. * Disposes the ShadowGenerator.
  92970. * Returns nothing.
  92971. */
  92972. dispose(): void;
  92973. /**
  92974. * Serializes the shadow generator setup to a json object.
  92975. * @returns The serialized JSON object
  92976. */
  92977. serialize(): any;
  92978. /**
  92979. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  92980. * @param parsedShadowGenerator The JSON object to parse
  92981. * @param scene The scene to create the shadow map for
  92982. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  92983. * @returns The parsed shadow generator
  92984. */
  92985. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  92986. }
  92987. }
  92988. declare module BABYLON {
  92989. /**
  92990. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  92991. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  92992. * 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.
  92993. */
  92994. export abstract class Light extends Node {
  92995. /**
  92996. * Falloff Default: light is falling off following the material specification:
  92997. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  92998. */
  92999. static readonly FALLOFF_DEFAULT: number;
  93000. /**
  93001. * Falloff Physical: light is falling off following the inverse squared distance law.
  93002. */
  93003. static readonly FALLOFF_PHYSICAL: number;
  93004. /**
  93005. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  93006. * to enhance interoperability with other engines.
  93007. */
  93008. static readonly FALLOFF_GLTF: number;
  93009. /**
  93010. * Falloff Standard: light is falling off like in the standard material
  93011. * to enhance interoperability with other materials.
  93012. */
  93013. static readonly FALLOFF_STANDARD: number;
  93014. /**
  93015. * If every light affecting the material is in this lightmapMode,
  93016. * material.lightmapTexture adds or multiplies
  93017. * (depends on material.useLightmapAsShadowmap)
  93018. * after every other light calculations.
  93019. */
  93020. static readonly LIGHTMAP_DEFAULT: number;
  93021. /**
  93022. * material.lightmapTexture as only diffuse lighting from this light
  93023. * adds only specular lighting from this light
  93024. * adds dynamic shadows
  93025. */
  93026. static readonly LIGHTMAP_SPECULAR: number;
  93027. /**
  93028. * material.lightmapTexture as only lighting
  93029. * no light calculation from this light
  93030. * only adds dynamic shadows from this light
  93031. */
  93032. static readonly LIGHTMAP_SHADOWSONLY: number;
  93033. /**
  93034. * Each light type uses the default quantity according to its type:
  93035. * point/spot lights use luminous intensity
  93036. * directional lights use illuminance
  93037. */
  93038. static readonly INTENSITYMODE_AUTOMATIC: number;
  93039. /**
  93040. * lumen (lm)
  93041. */
  93042. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  93043. /**
  93044. * candela (lm/sr)
  93045. */
  93046. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  93047. /**
  93048. * lux (lm/m^2)
  93049. */
  93050. static readonly INTENSITYMODE_ILLUMINANCE: number;
  93051. /**
  93052. * nit (cd/m^2)
  93053. */
  93054. static readonly INTENSITYMODE_LUMINANCE: number;
  93055. /**
  93056. * Light type const id of the point light.
  93057. */
  93058. static readonly LIGHTTYPEID_POINTLIGHT: number;
  93059. /**
  93060. * Light type const id of the directional light.
  93061. */
  93062. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  93063. /**
  93064. * Light type const id of the spot light.
  93065. */
  93066. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  93067. /**
  93068. * Light type const id of the hemispheric light.
  93069. */
  93070. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  93071. /**
  93072. * Diffuse gives the basic color to an object.
  93073. */
  93074. diffuse: Color3;
  93075. /**
  93076. * Specular produces a highlight color on an object.
  93077. * Note: This is note affecting PBR materials.
  93078. */
  93079. specular: Color3;
  93080. /**
  93081. * Defines the falloff type for this light. This lets overrriding how punctual light are
  93082. * falling off base on range or angle.
  93083. * This can be set to any values in Light.FALLOFF_x.
  93084. *
  93085. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  93086. * other types of materials.
  93087. */
  93088. falloffType: number;
  93089. /**
  93090. * Strength of the light.
  93091. * Note: By default it is define in the framework own unit.
  93092. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  93093. */
  93094. intensity: number;
  93095. private _range;
  93096. protected _inverseSquaredRange: number;
  93097. /**
  93098. * Defines how far from the source the light is impacting in scene units.
  93099. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93100. */
  93101. get range(): number;
  93102. /**
  93103. * Defines how far from the source the light is impacting in scene units.
  93104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93105. */
  93106. set range(value: number);
  93107. /**
  93108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  93109. * of light.
  93110. */
  93111. private _photometricScale;
  93112. private _intensityMode;
  93113. /**
  93114. * Gets the photometric scale used to interpret the intensity.
  93115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93116. */
  93117. get intensityMode(): number;
  93118. /**
  93119. * Sets the photometric scale used to interpret the intensity.
  93120. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93121. */
  93122. set intensityMode(value: number);
  93123. private _radius;
  93124. /**
  93125. * Gets the light radius used by PBR Materials to simulate soft area lights.
  93126. */
  93127. get radius(): number;
  93128. /**
  93129. * sets the light radius used by PBR Materials to simulate soft area lights.
  93130. */
  93131. set radius(value: number);
  93132. private _renderPriority;
  93133. /**
  93134. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  93135. * exceeding the number allowed of the materials.
  93136. */
  93137. renderPriority: number;
  93138. private _shadowEnabled;
  93139. /**
  93140. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93141. * the current shadow generator.
  93142. */
  93143. get shadowEnabled(): boolean;
  93144. /**
  93145. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93146. * the current shadow generator.
  93147. */
  93148. set shadowEnabled(value: boolean);
  93149. private _includedOnlyMeshes;
  93150. /**
  93151. * Gets the only meshes impacted by this light.
  93152. */
  93153. get includedOnlyMeshes(): AbstractMesh[];
  93154. /**
  93155. * Sets the only meshes impacted by this light.
  93156. */
  93157. set includedOnlyMeshes(value: AbstractMesh[]);
  93158. private _excludedMeshes;
  93159. /**
  93160. * Gets the meshes not impacted by this light.
  93161. */
  93162. get excludedMeshes(): AbstractMesh[];
  93163. /**
  93164. * Sets the meshes not impacted by this light.
  93165. */
  93166. set excludedMeshes(value: AbstractMesh[]);
  93167. private _excludeWithLayerMask;
  93168. /**
  93169. * Gets the layer id use to find what meshes are not impacted by the light.
  93170. * Inactive if 0
  93171. */
  93172. get excludeWithLayerMask(): number;
  93173. /**
  93174. * Sets the layer id use to find what meshes are not impacted by the light.
  93175. * Inactive if 0
  93176. */
  93177. set excludeWithLayerMask(value: number);
  93178. private _includeOnlyWithLayerMask;
  93179. /**
  93180. * Gets the layer id use to find what meshes are impacted by the light.
  93181. * Inactive if 0
  93182. */
  93183. get includeOnlyWithLayerMask(): number;
  93184. /**
  93185. * Sets the layer id use to find what meshes are impacted by the light.
  93186. * Inactive if 0
  93187. */
  93188. set includeOnlyWithLayerMask(value: number);
  93189. private _lightmapMode;
  93190. /**
  93191. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93192. */
  93193. get lightmapMode(): number;
  93194. /**
  93195. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93196. */
  93197. set lightmapMode(value: number);
  93198. /**
  93199. * Shadow generator associted to the light.
  93200. * @hidden Internal use only.
  93201. */
  93202. _shadowGenerator: Nullable<IShadowGenerator>;
  93203. /**
  93204. * @hidden Internal use only.
  93205. */
  93206. _excludedMeshesIds: string[];
  93207. /**
  93208. * @hidden Internal use only.
  93209. */
  93210. _includedOnlyMeshesIds: string[];
  93211. /**
  93212. * The current light unifom buffer.
  93213. * @hidden Internal use only.
  93214. */
  93215. _uniformBuffer: UniformBuffer;
  93216. /** @hidden */
  93217. _renderId: number;
  93218. /**
  93219. * Creates a Light object in the scene.
  93220. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93221. * @param name The firendly name of the light
  93222. * @param scene The scene the light belongs too
  93223. */
  93224. constructor(name: string, scene: Scene);
  93225. protected abstract _buildUniformLayout(): void;
  93226. /**
  93227. * Sets the passed Effect "effect" with the Light information.
  93228. * @param effect The effect to update
  93229. * @param lightIndex The index of the light in the effect to update
  93230. * @returns The light
  93231. */
  93232. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  93233. /**
  93234. * Sets the passed Effect "effect" with the Light textures.
  93235. * @param effect The effect to update
  93236. * @param lightIndex The index of the light in the effect to update
  93237. * @returns The light
  93238. */
  93239. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  93240. /**
  93241. * Binds the lights information from the scene to the effect for the given mesh.
  93242. * @param lightIndex Light index
  93243. * @param scene The scene where the light belongs to
  93244. * @param effect The effect we are binding the data to
  93245. * @param useSpecular Defines if specular is supported
  93246. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  93247. */
  93248. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  93249. /**
  93250. * Sets the passed Effect "effect" with the Light information.
  93251. * @param effect The effect to update
  93252. * @param lightDataUniformName The uniform used to store light data (position or direction)
  93253. * @returns The light
  93254. */
  93255. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  93256. /**
  93257. * Returns the string "Light".
  93258. * @returns the class name
  93259. */
  93260. getClassName(): string;
  93261. /** @hidden */
  93262. readonly _isLight: boolean;
  93263. /**
  93264. * Converts the light information to a readable string for debug purpose.
  93265. * @param fullDetails Supports for multiple levels of logging within scene loading
  93266. * @returns the human readable light info
  93267. */
  93268. toString(fullDetails?: boolean): string;
  93269. /** @hidden */
  93270. protected _syncParentEnabledState(): void;
  93271. /**
  93272. * Set the enabled state of this node.
  93273. * @param value - the new enabled state
  93274. */
  93275. setEnabled(value: boolean): void;
  93276. /**
  93277. * Returns the Light associated shadow generator if any.
  93278. * @return the associated shadow generator.
  93279. */
  93280. getShadowGenerator(): Nullable<IShadowGenerator>;
  93281. /**
  93282. * Returns a Vector3, the absolute light position in the World.
  93283. * @returns the world space position of the light
  93284. */
  93285. getAbsolutePosition(): Vector3;
  93286. /**
  93287. * Specifies if the light will affect the passed mesh.
  93288. * @param mesh The mesh to test against the light
  93289. * @return true the mesh is affected otherwise, false.
  93290. */
  93291. canAffectMesh(mesh: AbstractMesh): boolean;
  93292. /**
  93293. * Sort function to order lights for rendering.
  93294. * @param a First Light object to compare to second.
  93295. * @param b Second Light object to compare first.
  93296. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  93297. */
  93298. static CompareLightsPriority(a: Light, b: Light): number;
  93299. /**
  93300. * Releases resources associated with this node.
  93301. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93302. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93303. */
  93304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93305. /**
  93306. * Returns the light type ID (integer).
  93307. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93308. */
  93309. getTypeID(): number;
  93310. /**
  93311. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  93312. * @returns the scaled intensity in intensity mode unit
  93313. */
  93314. getScaledIntensity(): number;
  93315. /**
  93316. * Returns a new Light object, named "name", from the current one.
  93317. * @param name The name of the cloned light
  93318. * @param newParent The parent of this light, if it has one
  93319. * @returns the new created light
  93320. */
  93321. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  93322. /**
  93323. * Serializes the current light into a Serialization object.
  93324. * @returns the serialized object.
  93325. */
  93326. serialize(): any;
  93327. /**
  93328. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93329. * This new light is named "name" and added to the passed scene.
  93330. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93331. * @param name The friendly name of the light
  93332. * @param scene The scene the new light will belong to
  93333. * @returns the constructor function
  93334. */
  93335. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93336. /**
  93337. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93338. * @param parsedLight The JSON representation of the light
  93339. * @param scene The scene to create the parsed light in
  93340. * @returns the created light after parsing
  93341. */
  93342. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93343. private _hookArrayForExcluded;
  93344. private _hookArrayForIncludedOnly;
  93345. private _resyncMeshes;
  93346. /**
  93347. * Forces the meshes to update their light related information in their rendering used effects
  93348. * @hidden Internal Use Only
  93349. */
  93350. _markMeshesAsLightDirty(): void;
  93351. /**
  93352. * Recomputes the cached photometric scale if needed.
  93353. */
  93354. private _computePhotometricScale;
  93355. /**
  93356. * Returns the Photometric Scale according to the light type and intensity mode.
  93357. */
  93358. private _getPhotometricScale;
  93359. /**
  93360. * Reorder the light in the scene according to their defined priority.
  93361. * @hidden Internal Use Only
  93362. */
  93363. _reorderLightsInScene(): void;
  93364. /**
  93365. * Prepares the list of defines specific to the light type.
  93366. * @param defines the list of defines
  93367. * @param lightIndex defines the index of the light for the effect
  93368. */
  93369. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93370. }
  93371. }
  93372. declare module BABYLON {
  93373. /**
  93374. * Interface used to define Action
  93375. */
  93376. export interface IAction {
  93377. /**
  93378. * Trigger for the action
  93379. */
  93380. trigger: number;
  93381. /** Options of the trigger */
  93382. triggerOptions: any;
  93383. /**
  93384. * Gets the trigger parameters
  93385. * @returns the trigger parameters
  93386. */
  93387. getTriggerParameter(): any;
  93388. /**
  93389. * Internal only - executes current action event
  93390. * @hidden
  93391. */
  93392. _executeCurrent(evt?: ActionEvent): void;
  93393. /**
  93394. * Serialize placeholder for child classes
  93395. * @param parent of child
  93396. * @returns the serialized object
  93397. */
  93398. serialize(parent: any): any;
  93399. /**
  93400. * Internal only
  93401. * @hidden
  93402. */
  93403. _prepare(): void;
  93404. /**
  93405. * Internal only - manager for action
  93406. * @hidden
  93407. */
  93408. _actionManager: AbstractActionManager;
  93409. /**
  93410. * Adds action to chain of actions, may be a DoNothingAction
  93411. * @param action defines the next action to execute
  93412. * @returns The action passed in
  93413. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93414. */
  93415. then(action: IAction): IAction;
  93416. }
  93417. /**
  93418. * The action to be carried out following a trigger
  93419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  93420. */
  93421. export class Action implements IAction {
  93422. /** the trigger, with or without parameters, for the action */
  93423. triggerOptions: any;
  93424. /**
  93425. * Trigger for the action
  93426. */
  93427. trigger: number;
  93428. /**
  93429. * Internal only - manager for action
  93430. * @hidden
  93431. */
  93432. _actionManager: ActionManager;
  93433. private _nextActiveAction;
  93434. private _child;
  93435. private _condition?;
  93436. private _triggerParameter;
  93437. /**
  93438. * An event triggered prior to action being executed.
  93439. */
  93440. onBeforeExecuteObservable: Observable<Action>;
  93441. /**
  93442. * Creates a new Action
  93443. * @param triggerOptions the trigger, with or without parameters, for the action
  93444. * @param condition an optional determinant of action
  93445. */
  93446. constructor(
  93447. /** the trigger, with or without parameters, for the action */
  93448. triggerOptions: any, condition?: Condition);
  93449. /**
  93450. * Internal only
  93451. * @hidden
  93452. */
  93453. _prepare(): void;
  93454. /**
  93455. * Gets the trigger parameters
  93456. * @returns the trigger parameters
  93457. */
  93458. getTriggerParameter(): any;
  93459. /**
  93460. * Internal only - executes current action event
  93461. * @hidden
  93462. */
  93463. _executeCurrent(evt?: ActionEvent): void;
  93464. /**
  93465. * Execute placeholder for child classes
  93466. * @param evt optional action event
  93467. */
  93468. execute(evt?: ActionEvent): void;
  93469. /**
  93470. * Skips to next active action
  93471. */
  93472. skipToNextActiveAction(): void;
  93473. /**
  93474. * Adds action to chain of actions, may be a DoNothingAction
  93475. * @param action defines the next action to execute
  93476. * @returns The action passed in
  93477. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93478. */
  93479. then(action: Action): Action;
  93480. /**
  93481. * Internal only
  93482. * @hidden
  93483. */
  93484. _getProperty(propertyPath: string): string;
  93485. /**
  93486. * Internal only
  93487. * @hidden
  93488. */
  93489. _getEffectiveTarget(target: any, propertyPath: string): any;
  93490. /**
  93491. * Serialize placeholder for child classes
  93492. * @param parent of child
  93493. * @returns the serialized object
  93494. */
  93495. serialize(parent: any): any;
  93496. /**
  93497. * Internal only called by serialize
  93498. * @hidden
  93499. */
  93500. protected _serialize(serializedAction: any, parent?: any): any;
  93501. /**
  93502. * Internal only
  93503. * @hidden
  93504. */
  93505. static _SerializeValueAsString: (value: any) => string;
  93506. /**
  93507. * Internal only
  93508. * @hidden
  93509. */
  93510. static _GetTargetProperty: (target: Node | Scene) => {
  93511. name: string;
  93512. targetType: string;
  93513. value: string;
  93514. };
  93515. }
  93516. }
  93517. declare module BABYLON {
  93518. /**
  93519. * A Condition applied to an Action
  93520. */
  93521. export class Condition {
  93522. /**
  93523. * Internal only - manager for action
  93524. * @hidden
  93525. */
  93526. _actionManager: ActionManager;
  93527. /**
  93528. * Internal only
  93529. * @hidden
  93530. */
  93531. _evaluationId: number;
  93532. /**
  93533. * Internal only
  93534. * @hidden
  93535. */
  93536. _currentResult: boolean;
  93537. /**
  93538. * Creates a new Condition
  93539. * @param actionManager the manager of the action the condition is applied to
  93540. */
  93541. constructor(actionManager: ActionManager);
  93542. /**
  93543. * Check if the current condition is valid
  93544. * @returns a boolean
  93545. */
  93546. isValid(): boolean;
  93547. /**
  93548. * Internal only
  93549. * @hidden
  93550. */
  93551. _getProperty(propertyPath: string): string;
  93552. /**
  93553. * Internal only
  93554. * @hidden
  93555. */
  93556. _getEffectiveTarget(target: any, propertyPath: string): any;
  93557. /**
  93558. * Serialize placeholder for child classes
  93559. * @returns the serialized object
  93560. */
  93561. serialize(): any;
  93562. /**
  93563. * Internal only
  93564. * @hidden
  93565. */
  93566. protected _serialize(serializedCondition: any): any;
  93567. }
  93568. /**
  93569. * Defines specific conditional operators as extensions of Condition
  93570. */
  93571. export class ValueCondition extends Condition {
  93572. /** path to specify the property of the target the conditional operator uses */
  93573. propertyPath: string;
  93574. /** the value compared by the conditional operator against the current value of the property */
  93575. value: any;
  93576. /** the conditional operator, default ValueCondition.IsEqual */
  93577. operator: number;
  93578. /**
  93579. * Internal only
  93580. * @hidden
  93581. */
  93582. private static _IsEqual;
  93583. /**
  93584. * Internal only
  93585. * @hidden
  93586. */
  93587. private static _IsDifferent;
  93588. /**
  93589. * Internal only
  93590. * @hidden
  93591. */
  93592. private static _IsGreater;
  93593. /**
  93594. * Internal only
  93595. * @hidden
  93596. */
  93597. private static _IsLesser;
  93598. /**
  93599. * returns the number for IsEqual
  93600. */
  93601. static get IsEqual(): number;
  93602. /**
  93603. * Returns the number for IsDifferent
  93604. */
  93605. static get IsDifferent(): number;
  93606. /**
  93607. * Returns the number for IsGreater
  93608. */
  93609. static get IsGreater(): number;
  93610. /**
  93611. * Returns the number for IsLesser
  93612. */
  93613. static get IsLesser(): number;
  93614. /**
  93615. * Internal only The action manager for the condition
  93616. * @hidden
  93617. */
  93618. _actionManager: ActionManager;
  93619. /**
  93620. * Internal only
  93621. * @hidden
  93622. */
  93623. private _target;
  93624. /**
  93625. * Internal only
  93626. * @hidden
  93627. */
  93628. private _effectiveTarget;
  93629. /**
  93630. * Internal only
  93631. * @hidden
  93632. */
  93633. private _property;
  93634. /**
  93635. * Creates a new ValueCondition
  93636. * @param actionManager manager for the action the condition applies to
  93637. * @param target for the action
  93638. * @param propertyPath path to specify the property of the target the conditional operator uses
  93639. * @param value the value compared by the conditional operator against the current value of the property
  93640. * @param operator the conditional operator, default ValueCondition.IsEqual
  93641. */
  93642. constructor(actionManager: ActionManager, target: any,
  93643. /** path to specify the property of the target the conditional operator uses */
  93644. propertyPath: string,
  93645. /** the value compared by the conditional operator against the current value of the property */
  93646. value: any,
  93647. /** the conditional operator, default ValueCondition.IsEqual */
  93648. operator?: number);
  93649. /**
  93650. * Compares the given value with the property value for the specified conditional operator
  93651. * @returns the result of the comparison
  93652. */
  93653. isValid(): boolean;
  93654. /**
  93655. * Serialize the ValueCondition into a JSON compatible object
  93656. * @returns serialization object
  93657. */
  93658. serialize(): any;
  93659. /**
  93660. * Gets the name of the conditional operator for the ValueCondition
  93661. * @param operator the conditional operator
  93662. * @returns the name
  93663. */
  93664. static GetOperatorName(operator: number): string;
  93665. }
  93666. /**
  93667. * Defines a predicate condition as an extension of Condition
  93668. */
  93669. export class PredicateCondition extends Condition {
  93670. /** defines the predicate function used to validate the condition */
  93671. predicate: () => boolean;
  93672. /**
  93673. * Internal only - manager for action
  93674. * @hidden
  93675. */
  93676. _actionManager: ActionManager;
  93677. /**
  93678. * Creates a new PredicateCondition
  93679. * @param actionManager manager for the action the condition applies to
  93680. * @param predicate defines the predicate function used to validate the condition
  93681. */
  93682. constructor(actionManager: ActionManager,
  93683. /** defines the predicate function used to validate the condition */
  93684. predicate: () => boolean);
  93685. /**
  93686. * @returns the validity of the predicate condition
  93687. */
  93688. isValid(): boolean;
  93689. }
  93690. /**
  93691. * Defines a state condition as an extension of Condition
  93692. */
  93693. export class StateCondition extends Condition {
  93694. /** Value to compare with target state */
  93695. value: string;
  93696. /**
  93697. * Internal only - manager for action
  93698. * @hidden
  93699. */
  93700. _actionManager: ActionManager;
  93701. /**
  93702. * Internal only
  93703. * @hidden
  93704. */
  93705. private _target;
  93706. /**
  93707. * Creates a new StateCondition
  93708. * @param actionManager manager for the action the condition applies to
  93709. * @param target of the condition
  93710. * @param value to compare with target state
  93711. */
  93712. constructor(actionManager: ActionManager, target: any,
  93713. /** Value to compare with target state */
  93714. value: string);
  93715. /**
  93716. * Gets a boolean indicating if the current condition is met
  93717. * @returns the validity of the state
  93718. */
  93719. isValid(): boolean;
  93720. /**
  93721. * Serialize the StateCondition into a JSON compatible object
  93722. * @returns serialization object
  93723. */
  93724. serialize(): any;
  93725. }
  93726. }
  93727. declare module BABYLON {
  93728. /**
  93729. * This defines an action responsible to toggle a boolean once triggered.
  93730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93731. */
  93732. export class SwitchBooleanAction extends Action {
  93733. /**
  93734. * The path to the boolean property in the target object
  93735. */
  93736. propertyPath: string;
  93737. private _target;
  93738. private _effectiveTarget;
  93739. private _property;
  93740. /**
  93741. * Instantiate the action
  93742. * @param triggerOptions defines the trigger options
  93743. * @param target defines the object containing the boolean
  93744. * @param propertyPath defines the path to the boolean property in the target object
  93745. * @param condition defines the trigger related conditions
  93746. */
  93747. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  93748. /** @hidden */
  93749. _prepare(): void;
  93750. /**
  93751. * Execute the action toggle the boolean value.
  93752. */
  93753. execute(): void;
  93754. /**
  93755. * Serializes the actions and its related information.
  93756. * @param parent defines the object to serialize in
  93757. * @returns the serialized object
  93758. */
  93759. serialize(parent: any): any;
  93760. }
  93761. /**
  93762. * This defines an action responsible to set a the state field of the target
  93763. * to a desired value once triggered.
  93764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93765. */
  93766. export class SetStateAction extends Action {
  93767. /**
  93768. * The value to store in the state field.
  93769. */
  93770. value: string;
  93771. private _target;
  93772. /**
  93773. * Instantiate the action
  93774. * @param triggerOptions defines the trigger options
  93775. * @param target defines the object containing the state property
  93776. * @param value defines the value to store in the state field
  93777. * @param condition defines the trigger related conditions
  93778. */
  93779. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  93780. /**
  93781. * Execute the action and store the value on the target state property.
  93782. */
  93783. execute(): void;
  93784. /**
  93785. * Serializes the actions and its related information.
  93786. * @param parent defines the object to serialize in
  93787. * @returns the serialized object
  93788. */
  93789. serialize(parent: any): any;
  93790. }
  93791. /**
  93792. * This defines an action responsible to set a property of the target
  93793. * to a desired value once triggered.
  93794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93795. */
  93796. export class SetValueAction extends Action {
  93797. /**
  93798. * The path of the property to set in the target.
  93799. */
  93800. propertyPath: string;
  93801. /**
  93802. * The value to set in the property
  93803. */
  93804. value: any;
  93805. private _target;
  93806. private _effectiveTarget;
  93807. private _property;
  93808. /**
  93809. * Instantiate the action
  93810. * @param triggerOptions defines the trigger options
  93811. * @param target defines the object containing the property
  93812. * @param propertyPath defines the path of the property to set in the target
  93813. * @param value defines the value to set in the property
  93814. * @param condition defines the trigger related conditions
  93815. */
  93816. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93817. /** @hidden */
  93818. _prepare(): void;
  93819. /**
  93820. * Execute the action and set the targetted property to the desired value.
  93821. */
  93822. execute(): void;
  93823. /**
  93824. * Serializes the actions and its related information.
  93825. * @param parent defines the object to serialize in
  93826. * @returns the serialized object
  93827. */
  93828. serialize(parent: any): any;
  93829. }
  93830. /**
  93831. * This defines an action responsible to increment the target value
  93832. * to a desired value once triggered.
  93833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93834. */
  93835. export class IncrementValueAction extends Action {
  93836. /**
  93837. * The path of the property to increment in the target.
  93838. */
  93839. propertyPath: string;
  93840. /**
  93841. * The value we should increment the property by.
  93842. */
  93843. value: any;
  93844. private _target;
  93845. private _effectiveTarget;
  93846. private _property;
  93847. /**
  93848. * Instantiate the action
  93849. * @param triggerOptions defines the trigger options
  93850. * @param target defines the object containing the property
  93851. * @param propertyPath defines the path of the property to increment in the target
  93852. * @param value defines the value value we should increment the property by
  93853. * @param condition defines the trigger related conditions
  93854. */
  93855. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93856. /** @hidden */
  93857. _prepare(): void;
  93858. /**
  93859. * Execute the action and increment the target of the value amount.
  93860. */
  93861. execute(): void;
  93862. /**
  93863. * Serializes the actions and its related information.
  93864. * @param parent defines the object to serialize in
  93865. * @returns the serialized object
  93866. */
  93867. serialize(parent: any): any;
  93868. }
  93869. /**
  93870. * This defines an action responsible to start an animation once triggered.
  93871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93872. */
  93873. export class PlayAnimationAction extends Action {
  93874. /**
  93875. * Where the animation should start (animation frame)
  93876. */
  93877. from: number;
  93878. /**
  93879. * Where the animation should stop (animation frame)
  93880. */
  93881. to: number;
  93882. /**
  93883. * Define if the animation should loop or stop after the first play.
  93884. */
  93885. loop?: boolean;
  93886. private _target;
  93887. /**
  93888. * Instantiate the action
  93889. * @param triggerOptions defines the trigger options
  93890. * @param target defines the target animation or animation name
  93891. * @param from defines from where the animation should start (animation frame)
  93892. * @param end defines where the animation should stop (animation frame)
  93893. * @param loop defines if the animation should loop or stop after the first play
  93894. * @param condition defines the trigger related conditions
  93895. */
  93896. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  93897. /** @hidden */
  93898. _prepare(): void;
  93899. /**
  93900. * Execute the action and play the animation.
  93901. */
  93902. execute(): void;
  93903. /**
  93904. * Serializes the actions and its related information.
  93905. * @param parent defines the object to serialize in
  93906. * @returns the serialized object
  93907. */
  93908. serialize(parent: any): any;
  93909. }
  93910. /**
  93911. * This defines an action responsible to stop an animation once triggered.
  93912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93913. */
  93914. export class StopAnimationAction extends Action {
  93915. private _target;
  93916. /**
  93917. * Instantiate the action
  93918. * @param triggerOptions defines the trigger options
  93919. * @param target defines the target animation or animation name
  93920. * @param condition defines the trigger related conditions
  93921. */
  93922. constructor(triggerOptions: any, target: any, condition?: Condition);
  93923. /** @hidden */
  93924. _prepare(): void;
  93925. /**
  93926. * Execute the action and stop the animation.
  93927. */
  93928. execute(): void;
  93929. /**
  93930. * Serializes the actions and its related information.
  93931. * @param parent defines the object to serialize in
  93932. * @returns the serialized object
  93933. */
  93934. serialize(parent: any): any;
  93935. }
  93936. /**
  93937. * This defines an action responsible that does nothing once triggered.
  93938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93939. */
  93940. export class DoNothingAction extends Action {
  93941. /**
  93942. * Instantiate the action
  93943. * @param triggerOptions defines the trigger options
  93944. * @param condition defines the trigger related conditions
  93945. */
  93946. constructor(triggerOptions?: any, condition?: Condition);
  93947. /**
  93948. * Execute the action and do nothing.
  93949. */
  93950. execute(): void;
  93951. /**
  93952. * Serializes the actions and its related information.
  93953. * @param parent defines the object to serialize in
  93954. * @returns the serialized object
  93955. */
  93956. serialize(parent: any): any;
  93957. }
  93958. /**
  93959. * This defines an action responsible to trigger several actions once triggered.
  93960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93961. */
  93962. export class CombineAction extends Action {
  93963. /**
  93964. * The list of aggregated animations to run.
  93965. */
  93966. children: Action[];
  93967. /**
  93968. * Instantiate the action
  93969. * @param triggerOptions defines the trigger options
  93970. * @param children defines the list of aggregated animations to run
  93971. * @param condition defines the trigger related conditions
  93972. */
  93973. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  93974. /** @hidden */
  93975. _prepare(): void;
  93976. /**
  93977. * Execute the action and executes all the aggregated actions.
  93978. */
  93979. execute(evt: ActionEvent): void;
  93980. /**
  93981. * Serializes the actions and its related information.
  93982. * @param parent defines the object to serialize in
  93983. * @returns the serialized object
  93984. */
  93985. serialize(parent: any): any;
  93986. }
  93987. /**
  93988. * This defines an action responsible to run code (external event) once triggered.
  93989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93990. */
  93991. export class ExecuteCodeAction extends Action {
  93992. /**
  93993. * The callback function to run.
  93994. */
  93995. func: (evt: ActionEvent) => void;
  93996. /**
  93997. * Instantiate the action
  93998. * @param triggerOptions defines the trigger options
  93999. * @param func defines the callback function to run
  94000. * @param condition defines the trigger related conditions
  94001. */
  94002. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  94003. /**
  94004. * Execute the action and run the attached code.
  94005. */
  94006. execute(evt: ActionEvent): void;
  94007. }
  94008. /**
  94009. * This defines an action responsible to set the parent property of the target once triggered.
  94010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94011. */
  94012. export class SetParentAction extends Action {
  94013. private _parent;
  94014. private _target;
  94015. /**
  94016. * Instantiate the action
  94017. * @param triggerOptions defines the trigger options
  94018. * @param target defines the target containing the parent property
  94019. * @param parent defines from where the animation should start (animation frame)
  94020. * @param condition defines the trigger related conditions
  94021. */
  94022. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  94023. /** @hidden */
  94024. _prepare(): void;
  94025. /**
  94026. * Execute the action and set the parent property.
  94027. */
  94028. execute(): void;
  94029. /**
  94030. * Serializes the actions and its related information.
  94031. * @param parent defines the object to serialize in
  94032. * @returns the serialized object
  94033. */
  94034. serialize(parent: any): any;
  94035. }
  94036. }
  94037. declare module BABYLON {
  94038. /**
  94039. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  94040. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  94041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94042. */
  94043. export class ActionManager extends AbstractActionManager {
  94044. /**
  94045. * Nothing
  94046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94047. */
  94048. static readonly NothingTrigger: number;
  94049. /**
  94050. * On pick
  94051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94052. */
  94053. static readonly OnPickTrigger: number;
  94054. /**
  94055. * On left pick
  94056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94057. */
  94058. static readonly OnLeftPickTrigger: number;
  94059. /**
  94060. * On right pick
  94061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94062. */
  94063. static readonly OnRightPickTrigger: number;
  94064. /**
  94065. * On center pick
  94066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94067. */
  94068. static readonly OnCenterPickTrigger: number;
  94069. /**
  94070. * On pick down
  94071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94072. */
  94073. static readonly OnPickDownTrigger: number;
  94074. /**
  94075. * On double pick
  94076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94077. */
  94078. static readonly OnDoublePickTrigger: number;
  94079. /**
  94080. * On pick up
  94081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94082. */
  94083. static readonly OnPickUpTrigger: number;
  94084. /**
  94085. * On pick out.
  94086. * This trigger will only be raised if you also declared a OnPickDown
  94087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94088. */
  94089. static readonly OnPickOutTrigger: number;
  94090. /**
  94091. * On long press
  94092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94093. */
  94094. static readonly OnLongPressTrigger: number;
  94095. /**
  94096. * On pointer over
  94097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94098. */
  94099. static readonly OnPointerOverTrigger: number;
  94100. /**
  94101. * On pointer out
  94102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94103. */
  94104. static readonly OnPointerOutTrigger: number;
  94105. /**
  94106. * On every frame
  94107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94108. */
  94109. static readonly OnEveryFrameTrigger: number;
  94110. /**
  94111. * On intersection enter
  94112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94113. */
  94114. static readonly OnIntersectionEnterTrigger: number;
  94115. /**
  94116. * On intersection exit
  94117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94118. */
  94119. static readonly OnIntersectionExitTrigger: number;
  94120. /**
  94121. * On key down
  94122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94123. */
  94124. static readonly OnKeyDownTrigger: number;
  94125. /**
  94126. * On key up
  94127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94128. */
  94129. static readonly OnKeyUpTrigger: number;
  94130. private _scene;
  94131. /**
  94132. * Creates a new action manager
  94133. * @param scene defines the hosting scene
  94134. */
  94135. constructor(scene: Scene);
  94136. /**
  94137. * Releases all associated resources
  94138. */
  94139. dispose(): void;
  94140. /**
  94141. * Gets hosting scene
  94142. * @returns the hosting scene
  94143. */
  94144. getScene(): Scene;
  94145. /**
  94146. * Does this action manager handles actions of any of the given triggers
  94147. * @param triggers defines the triggers to be tested
  94148. * @return a boolean indicating whether one (or more) of the triggers is handled
  94149. */
  94150. hasSpecificTriggers(triggers: number[]): boolean;
  94151. /**
  94152. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94153. * speed.
  94154. * @param triggerA defines the trigger to be tested
  94155. * @param triggerB defines the trigger to be tested
  94156. * @return a boolean indicating whether one (or more) of the triggers is handled
  94157. */
  94158. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94159. /**
  94160. * Does this action manager handles actions of a given trigger
  94161. * @param trigger defines the trigger to be tested
  94162. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94163. * @return whether the trigger is handled
  94164. */
  94165. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94166. /**
  94167. * Does this action manager has pointer triggers
  94168. */
  94169. get hasPointerTriggers(): boolean;
  94170. /**
  94171. * Does this action manager has pick triggers
  94172. */
  94173. get hasPickTriggers(): boolean;
  94174. /**
  94175. * Registers an action to this action manager
  94176. * @param action defines the action to be registered
  94177. * @return the action amended (prepared) after registration
  94178. */
  94179. registerAction(action: IAction): Nullable<IAction>;
  94180. /**
  94181. * Unregisters an action to this action manager
  94182. * @param action defines the action to be unregistered
  94183. * @return a boolean indicating whether the action has been unregistered
  94184. */
  94185. unregisterAction(action: IAction): Boolean;
  94186. /**
  94187. * Process a specific trigger
  94188. * @param trigger defines the trigger to process
  94189. * @param evt defines the event details to be processed
  94190. */
  94191. processTrigger(trigger: number, evt?: IActionEvent): void;
  94192. /** @hidden */
  94193. _getEffectiveTarget(target: any, propertyPath: string): any;
  94194. /** @hidden */
  94195. _getProperty(propertyPath: string): string;
  94196. /**
  94197. * Serialize this manager to a JSON object
  94198. * @param name defines the property name to store this manager
  94199. * @returns a JSON representation of this manager
  94200. */
  94201. serialize(name: string): any;
  94202. /**
  94203. * Creates a new ActionManager from a JSON data
  94204. * @param parsedActions defines the JSON data to read from
  94205. * @param object defines the hosting mesh
  94206. * @param scene defines the hosting scene
  94207. */
  94208. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  94209. /**
  94210. * Get a trigger name by index
  94211. * @param trigger defines the trigger index
  94212. * @returns a trigger name
  94213. */
  94214. static GetTriggerName(trigger: number): string;
  94215. }
  94216. }
  94217. declare module BABYLON {
  94218. /**
  94219. * Class used to represent a sprite
  94220. * @see http://doc.babylonjs.com/babylon101/sprites
  94221. */
  94222. export class Sprite implements IAnimatable {
  94223. /** defines the name */
  94224. name: string;
  94225. /** Gets or sets the current world position */
  94226. position: Vector3;
  94227. /** Gets or sets the main color */
  94228. color: Color4;
  94229. /** Gets or sets the width */
  94230. width: number;
  94231. /** Gets or sets the height */
  94232. height: number;
  94233. /** Gets or sets rotation angle */
  94234. angle: number;
  94235. /** Gets or sets the cell index in the sprite sheet */
  94236. cellIndex: number;
  94237. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  94238. cellRef: string;
  94239. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  94240. invertU: boolean;
  94241. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  94242. invertV: boolean;
  94243. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  94244. disposeWhenFinishedAnimating: boolean;
  94245. /** Gets the list of attached animations */
  94246. animations: Nullable<Array<Animation>>;
  94247. /** Gets or sets a boolean indicating if the sprite can be picked */
  94248. isPickable: boolean;
  94249. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  94250. useAlphaForPicking: boolean;
  94251. /** @hidden */
  94252. _xOffset: number;
  94253. /** @hidden */
  94254. _yOffset: number;
  94255. /** @hidden */
  94256. _xSize: number;
  94257. /** @hidden */
  94258. _ySize: number;
  94259. /**
  94260. * Gets or sets the associated action manager
  94261. */
  94262. actionManager: Nullable<ActionManager>;
  94263. /**
  94264. * An event triggered when the control has been disposed
  94265. */
  94266. onDisposeObservable: Observable<Sprite>;
  94267. private _animationStarted;
  94268. private _loopAnimation;
  94269. private _fromIndex;
  94270. private _toIndex;
  94271. private _delay;
  94272. private _direction;
  94273. private _manager;
  94274. private _time;
  94275. private _onAnimationEnd;
  94276. /**
  94277. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  94278. */
  94279. isVisible: boolean;
  94280. /**
  94281. * Gets or sets the sprite size
  94282. */
  94283. get size(): number;
  94284. set size(value: number);
  94285. /**
  94286. * Gets or sets the unique id of the sprite
  94287. */
  94288. uniqueId: number;
  94289. /**
  94290. * Gets the manager of this sprite
  94291. */
  94292. get manager(): ISpriteManager;
  94293. /**
  94294. * Creates a new Sprite
  94295. * @param name defines the name
  94296. * @param manager defines the manager
  94297. */
  94298. constructor(
  94299. /** defines the name */
  94300. name: string, manager: ISpriteManager);
  94301. /**
  94302. * Returns the string "Sprite"
  94303. * @returns "Sprite"
  94304. */
  94305. getClassName(): string;
  94306. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  94307. get fromIndex(): number;
  94308. set fromIndex(value: number);
  94309. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  94310. get toIndex(): number;
  94311. set toIndex(value: number);
  94312. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  94313. get loopAnimation(): boolean;
  94314. set loopAnimation(value: boolean);
  94315. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  94316. get delay(): number;
  94317. set delay(value: number);
  94318. /**
  94319. * Starts an animation
  94320. * @param from defines the initial key
  94321. * @param to defines the end key
  94322. * @param loop defines if the animation must loop
  94323. * @param delay defines the start delay (in ms)
  94324. * @param onAnimationEnd defines a callback to call when animation ends
  94325. */
  94326. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  94327. /** Stops current animation (if any) */
  94328. stopAnimation(): void;
  94329. /** @hidden */
  94330. _animate(deltaTime: number): void;
  94331. /** Release associated resources */
  94332. dispose(): void;
  94333. }
  94334. }
  94335. declare module BABYLON {
  94336. /**
  94337. * Information about the result of picking within a scene
  94338. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  94339. */
  94340. export class PickingInfo {
  94341. /** @hidden */
  94342. _pickingUnavailable: boolean;
  94343. /**
  94344. * If the pick collided with an object
  94345. */
  94346. hit: boolean;
  94347. /**
  94348. * Distance away where the pick collided
  94349. */
  94350. distance: number;
  94351. /**
  94352. * The location of pick collision
  94353. */
  94354. pickedPoint: Nullable<Vector3>;
  94355. /**
  94356. * The mesh corresponding the the pick collision
  94357. */
  94358. pickedMesh: Nullable<AbstractMesh>;
  94359. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  94360. bu: number;
  94361. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  94362. bv: number;
  94363. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  94364. faceId: number;
  94365. /** Id of the the submesh that was picked */
  94366. subMeshId: number;
  94367. /** If a sprite was picked, this will be the sprite the pick collided with */
  94368. pickedSprite: Nullable<Sprite>;
  94369. /**
  94370. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  94371. */
  94372. originMesh: Nullable<AbstractMesh>;
  94373. /**
  94374. * The ray that was used to perform the picking.
  94375. */
  94376. ray: Nullable<Ray>;
  94377. /**
  94378. * Gets the normal correspodning to the face the pick collided with
  94379. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  94380. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  94381. * @returns The normal correspodning to the face the pick collided with
  94382. */
  94383. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  94384. /**
  94385. * Gets the texture coordinates of where the pick occured
  94386. * @returns the vector containing the coordnates of the texture
  94387. */
  94388. getTextureCoordinates(): Nullable<Vector2>;
  94389. }
  94390. }
  94391. declare module BABYLON {
  94392. /**
  94393. * Gather the list of pointer event types as constants.
  94394. */
  94395. export class PointerEventTypes {
  94396. /**
  94397. * 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.
  94398. */
  94399. static readonly POINTERDOWN: number;
  94400. /**
  94401. * The pointerup event is fired when a pointer is no longer active.
  94402. */
  94403. static readonly POINTERUP: number;
  94404. /**
  94405. * The pointermove event is fired when a pointer changes coordinates.
  94406. */
  94407. static readonly POINTERMOVE: number;
  94408. /**
  94409. * The pointerwheel event is fired when a mouse wheel has been rotated.
  94410. */
  94411. static readonly POINTERWHEEL: number;
  94412. /**
  94413. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  94414. */
  94415. static readonly POINTERPICK: number;
  94416. /**
  94417. * The pointertap event is fired when a the object has been touched and released without drag.
  94418. */
  94419. static readonly POINTERTAP: number;
  94420. /**
  94421. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  94422. */
  94423. static readonly POINTERDOUBLETAP: number;
  94424. }
  94425. /**
  94426. * Base class of pointer info types.
  94427. */
  94428. export class PointerInfoBase {
  94429. /**
  94430. * Defines the type of event (PointerEventTypes)
  94431. */
  94432. type: number;
  94433. /**
  94434. * Defines the related dom event
  94435. */
  94436. event: PointerEvent | MouseWheelEvent;
  94437. /**
  94438. * Instantiates the base class of pointers info.
  94439. * @param type Defines the type of event (PointerEventTypes)
  94440. * @param event Defines the related dom event
  94441. */
  94442. constructor(
  94443. /**
  94444. * Defines the type of event (PointerEventTypes)
  94445. */
  94446. type: number,
  94447. /**
  94448. * Defines the related dom event
  94449. */
  94450. event: PointerEvent | MouseWheelEvent);
  94451. }
  94452. /**
  94453. * This class is used to store pointer related info for the onPrePointerObservable event.
  94454. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  94455. */
  94456. export class PointerInfoPre extends PointerInfoBase {
  94457. /**
  94458. * Ray from a pointer if availible (eg. 6dof controller)
  94459. */
  94460. ray: Nullable<Ray>;
  94461. /**
  94462. * Defines the local position of the pointer on the canvas.
  94463. */
  94464. localPosition: Vector2;
  94465. /**
  94466. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  94467. */
  94468. skipOnPointerObservable: boolean;
  94469. /**
  94470. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  94471. * @param type Defines the type of event (PointerEventTypes)
  94472. * @param event Defines the related dom event
  94473. * @param localX Defines the local x coordinates of the pointer when the event occured
  94474. * @param localY Defines the local y coordinates of the pointer when the event occured
  94475. */
  94476. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  94477. }
  94478. /**
  94479. * This type contains all the data related to a pointer event in Babylon.js.
  94480. * 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.
  94481. */
  94482. export class PointerInfo extends PointerInfoBase {
  94483. /**
  94484. * Defines the picking info associated to the info (if any)\
  94485. */
  94486. pickInfo: Nullable<PickingInfo>;
  94487. /**
  94488. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  94489. * @param type Defines the type of event (PointerEventTypes)
  94490. * @param event Defines the related dom event
  94491. * @param pickInfo Defines the picking info associated to the info (if any)\
  94492. */
  94493. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  94494. /**
  94495. * Defines the picking info associated to the info (if any)\
  94496. */
  94497. pickInfo: Nullable<PickingInfo>);
  94498. }
  94499. /**
  94500. * Data relating to a touch event on the screen.
  94501. */
  94502. export interface PointerTouch {
  94503. /**
  94504. * X coordinate of touch.
  94505. */
  94506. x: number;
  94507. /**
  94508. * Y coordinate of touch.
  94509. */
  94510. y: number;
  94511. /**
  94512. * Id of touch. Unique for each finger.
  94513. */
  94514. pointerId: number;
  94515. /**
  94516. * Event type passed from DOM.
  94517. */
  94518. type: any;
  94519. }
  94520. }
  94521. declare module BABYLON {
  94522. /**
  94523. * Manage the mouse inputs to control the movement of a free camera.
  94524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94525. */
  94526. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  94527. /**
  94528. * Define if touch is enabled in the mouse input
  94529. */
  94530. touchEnabled: boolean;
  94531. /**
  94532. * Defines the camera the input is attached to.
  94533. */
  94534. camera: FreeCamera;
  94535. /**
  94536. * Defines the buttons associated with the input to handle camera move.
  94537. */
  94538. buttons: number[];
  94539. /**
  94540. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  94541. */
  94542. angularSensibility: number;
  94543. private _pointerInput;
  94544. private _onMouseMove;
  94545. private _observer;
  94546. private previousPosition;
  94547. /**
  94548. * Observable for when a pointer move event occurs containing the move offset
  94549. */
  94550. onPointerMovedObservable: Observable<{
  94551. offsetX: number;
  94552. offsetY: number;
  94553. }>;
  94554. /**
  94555. * @hidden
  94556. * If the camera should be rotated automatically based on pointer movement
  94557. */
  94558. _allowCameraRotation: boolean;
  94559. /**
  94560. * Manage the mouse inputs to control the movement of a free camera.
  94561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94562. * @param touchEnabled Defines if touch is enabled or not
  94563. */
  94564. constructor(
  94565. /**
  94566. * Define if touch is enabled in the mouse input
  94567. */
  94568. touchEnabled?: boolean);
  94569. /**
  94570. * Attach the input controls to a specific dom element to get the input from.
  94571. * @param element Defines the element the controls should be listened from
  94572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94573. */
  94574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94575. /**
  94576. * Called on JS contextmenu event.
  94577. * Override this method to provide functionality.
  94578. */
  94579. protected onContextMenu(evt: PointerEvent): void;
  94580. /**
  94581. * Detach the current controls from the specified dom element.
  94582. * @param element Defines the element to stop listening the inputs from
  94583. */
  94584. detachControl(element: Nullable<HTMLElement>): void;
  94585. /**
  94586. * Gets the class name of the current intput.
  94587. * @returns the class name
  94588. */
  94589. getClassName(): string;
  94590. /**
  94591. * Get the friendly name associated with the input class.
  94592. * @returns the input friendly name
  94593. */
  94594. getSimpleName(): string;
  94595. }
  94596. }
  94597. declare module BABYLON {
  94598. /**
  94599. * Manage the touch inputs to control the movement of a free camera.
  94600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94601. */
  94602. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  94603. /**
  94604. * Defines the camera the input is attached to.
  94605. */
  94606. camera: FreeCamera;
  94607. /**
  94608. * Defines the touch sensibility for rotation.
  94609. * The higher the faster.
  94610. */
  94611. touchAngularSensibility: number;
  94612. /**
  94613. * Defines the touch sensibility for move.
  94614. * The higher the faster.
  94615. */
  94616. touchMoveSensibility: number;
  94617. private _offsetX;
  94618. private _offsetY;
  94619. private _pointerPressed;
  94620. private _pointerInput;
  94621. private _observer;
  94622. private _onLostFocus;
  94623. /**
  94624. * Attach the input controls to a specific dom element to get the input from.
  94625. * @param element Defines the element the controls should be listened from
  94626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94627. */
  94628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94629. /**
  94630. * Detach the current controls from the specified dom element.
  94631. * @param element Defines the element to stop listening the inputs from
  94632. */
  94633. detachControl(element: Nullable<HTMLElement>): void;
  94634. /**
  94635. * Update the current camera state depending on the inputs that have been used this frame.
  94636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94637. */
  94638. checkInputs(): void;
  94639. /**
  94640. * Gets the class name of the current intput.
  94641. * @returns the class name
  94642. */
  94643. getClassName(): string;
  94644. /**
  94645. * Get the friendly name associated with the input class.
  94646. * @returns the input friendly name
  94647. */
  94648. getSimpleName(): string;
  94649. }
  94650. }
  94651. declare module BABYLON {
  94652. /**
  94653. * Default Inputs manager for the FreeCamera.
  94654. * It groups all the default supported inputs for ease of use.
  94655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94656. */
  94657. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  94658. /**
  94659. * @hidden
  94660. */
  94661. _mouseInput: Nullable<FreeCameraMouseInput>;
  94662. /**
  94663. * Instantiates a new FreeCameraInputsManager.
  94664. * @param camera Defines the camera the inputs belong to
  94665. */
  94666. constructor(camera: FreeCamera);
  94667. /**
  94668. * Add keyboard input support to the input manager.
  94669. * @returns the current input manager
  94670. */
  94671. addKeyboard(): FreeCameraInputsManager;
  94672. /**
  94673. * Add mouse input support to the input manager.
  94674. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  94675. * @returns the current input manager
  94676. */
  94677. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  94678. /**
  94679. * Removes the mouse input support from the manager
  94680. * @returns the current input manager
  94681. */
  94682. removeMouse(): FreeCameraInputsManager;
  94683. /**
  94684. * Add touch input support to the input manager.
  94685. * @returns the current input manager
  94686. */
  94687. addTouch(): FreeCameraInputsManager;
  94688. /**
  94689. * Remove all attached input methods from a camera
  94690. */
  94691. clear(): void;
  94692. }
  94693. }
  94694. declare module BABYLON {
  94695. /**
  94696. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94697. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  94698. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94699. */
  94700. export class FreeCamera extends TargetCamera {
  94701. /**
  94702. * Define the collision ellipsoid of the camera.
  94703. * This is helpful to simulate a camera body like the player body around the camera
  94704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94705. */
  94706. ellipsoid: Vector3;
  94707. /**
  94708. * Define an offset for the position of the ellipsoid around the camera.
  94709. * This can be helpful to determine the center of the body near the gravity center of the body
  94710. * instead of its head.
  94711. */
  94712. ellipsoidOffset: Vector3;
  94713. /**
  94714. * Enable or disable collisions of the camera with the rest of the scene objects.
  94715. */
  94716. checkCollisions: boolean;
  94717. /**
  94718. * Enable or disable gravity on the camera.
  94719. */
  94720. applyGravity: boolean;
  94721. /**
  94722. * Define the input manager associated to the camera.
  94723. */
  94724. inputs: FreeCameraInputsManager;
  94725. /**
  94726. * Gets the input sensibility for a mouse input. (default is 2000.0)
  94727. * Higher values reduce sensitivity.
  94728. */
  94729. get angularSensibility(): number;
  94730. /**
  94731. * Sets the input sensibility for a mouse input. (default is 2000.0)
  94732. * Higher values reduce sensitivity.
  94733. */
  94734. set angularSensibility(value: number);
  94735. /**
  94736. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94737. */
  94738. get keysUp(): number[];
  94739. set keysUp(value: number[]);
  94740. /**
  94741. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94742. */
  94743. get keysUpward(): number[];
  94744. set keysUpward(value: number[]);
  94745. /**
  94746. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94747. */
  94748. get keysDown(): number[];
  94749. set keysDown(value: number[]);
  94750. /**
  94751. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94752. */
  94753. get keysDownward(): number[];
  94754. set keysDownward(value: number[]);
  94755. /**
  94756. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94757. */
  94758. get keysLeft(): number[];
  94759. set keysLeft(value: number[]);
  94760. /**
  94761. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94762. */
  94763. get keysRight(): number[];
  94764. set keysRight(value: number[]);
  94765. /**
  94766. * Event raised when the camera collide with a mesh in the scene.
  94767. */
  94768. onCollide: (collidedMesh: AbstractMesh) => void;
  94769. private _collider;
  94770. private _needMoveForGravity;
  94771. private _oldPosition;
  94772. private _diffPosition;
  94773. private _newPosition;
  94774. /** @hidden */
  94775. _localDirection: Vector3;
  94776. /** @hidden */
  94777. _transformedDirection: Vector3;
  94778. /**
  94779. * Instantiates a Free Camera.
  94780. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94781. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  94782. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94783. * @param name Define the name of the camera in the scene
  94784. * @param position Define the start position of the camera in the scene
  94785. * @param scene Define the scene the camera belongs to
  94786. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94787. */
  94788. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94789. /**
  94790. * Attached controls to the current camera.
  94791. * @param element Defines the element the controls should be listened from
  94792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94793. */
  94794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94795. /**
  94796. * Detach the current controls from the camera.
  94797. * The camera will stop reacting to inputs.
  94798. * @param element Defines the element to stop listening the inputs from
  94799. */
  94800. detachControl(element: HTMLElement): void;
  94801. private _collisionMask;
  94802. /**
  94803. * Define a collision mask to limit the list of object the camera can collide with
  94804. */
  94805. get collisionMask(): number;
  94806. set collisionMask(mask: number);
  94807. /** @hidden */
  94808. _collideWithWorld(displacement: Vector3): void;
  94809. private _onCollisionPositionChange;
  94810. /** @hidden */
  94811. _checkInputs(): void;
  94812. /** @hidden */
  94813. _decideIfNeedsToMove(): boolean;
  94814. /** @hidden */
  94815. _updatePosition(): void;
  94816. /**
  94817. * Destroy the camera and release the current resources hold by it.
  94818. */
  94819. dispose(): void;
  94820. /**
  94821. * Gets the current object class name.
  94822. * @return the class name
  94823. */
  94824. getClassName(): string;
  94825. }
  94826. }
  94827. declare module BABYLON {
  94828. /**
  94829. * Represents a gamepad control stick position
  94830. */
  94831. export class StickValues {
  94832. /**
  94833. * The x component of the control stick
  94834. */
  94835. x: number;
  94836. /**
  94837. * The y component of the control stick
  94838. */
  94839. y: number;
  94840. /**
  94841. * Initializes the gamepad x and y control stick values
  94842. * @param x The x component of the gamepad control stick value
  94843. * @param y The y component of the gamepad control stick value
  94844. */
  94845. constructor(
  94846. /**
  94847. * The x component of the control stick
  94848. */
  94849. x: number,
  94850. /**
  94851. * The y component of the control stick
  94852. */
  94853. y: number);
  94854. }
  94855. /**
  94856. * An interface which manages callbacks for gamepad button changes
  94857. */
  94858. export interface GamepadButtonChanges {
  94859. /**
  94860. * Called when a gamepad has been changed
  94861. */
  94862. changed: boolean;
  94863. /**
  94864. * Called when a gamepad press event has been triggered
  94865. */
  94866. pressChanged: boolean;
  94867. /**
  94868. * Called when a touch event has been triggered
  94869. */
  94870. touchChanged: boolean;
  94871. /**
  94872. * Called when a value has changed
  94873. */
  94874. valueChanged: boolean;
  94875. }
  94876. /**
  94877. * Represents a gamepad
  94878. */
  94879. export class Gamepad {
  94880. /**
  94881. * The id of the gamepad
  94882. */
  94883. id: string;
  94884. /**
  94885. * The index of the gamepad
  94886. */
  94887. index: number;
  94888. /**
  94889. * The browser gamepad
  94890. */
  94891. browserGamepad: any;
  94892. /**
  94893. * Specifies what type of gamepad this represents
  94894. */
  94895. type: number;
  94896. private _leftStick;
  94897. private _rightStick;
  94898. /** @hidden */
  94899. _isConnected: boolean;
  94900. private _leftStickAxisX;
  94901. private _leftStickAxisY;
  94902. private _rightStickAxisX;
  94903. private _rightStickAxisY;
  94904. /**
  94905. * Triggered when the left control stick has been changed
  94906. */
  94907. private _onleftstickchanged;
  94908. /**
  94909. * Triggered when the right control stick has been changed
  94910. */
  94911. private _onrightstickchanged;
  94912. /**
  94913. * Represents a gamepad controller
  94914. */
  94915. static GAMEPAD: number;
  94916. /**
  94917. * Represents a generic controller
  94918. */
  94919. static GENERIC: number;
  94920. /**
  94921. * Represents an XBox controller
  94922. */
  94923. static XBOX: number;
  94924. /**
  94925. * Represents a pose-enabled controller
  94926. */
  94927. static POSE_ENABLED: number;
  94928. /**
  94929. * Represents an Dual Shock controller
  94930. */
  94931. static DUALSHOCK: number;
  94932. /**
  94933. * Specifies whether the left control stick should be Y-inverted
  94934. */
  94935. protected _invertLeftStickY: boolean;
  94936. /**
  94937. * Specifies if the gamepad has been connected
  94938. */
  94939. get isConnected(): boolean;
  94940. /**
  94941. * Initializes the gamepad
  94942. * @param id The id of the gamepad
  94943. * @param index The index of the gamepad
  94944. * @param browserGamepad The browser gamepad
  94945. * @param leftStickX The x component of the left joystick
  94946. * @param leftStickY The y component of the left joystick
  94947. * @param rightStickX The x component of the right joystick
  94948. * @param rightStickY The y component of the right joystick
  94949. */
  94950. constructor(
  94951. /**
  94952. * The id of the gamepad
  94953. */
  94954. id: string,
  94955. /**
  94956. * The index of the gamepad
  94957. */
  94958. index: number,
  94959. /**
  94960. * The browser gamepad
  94961. */
  94962. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  94963. /**
  94964. * Callback triggered when the left joystick has changed
  94965. * @param callback
  94966. */
  94967. onleftstickchanged(callback: (values: StickValues) => void): void;
  94968. /**
  94969. * Callback triggered when the right joystick has changed
  94970. * @param callback
  94971. */
  94972. onrightstickchanged(callback: (values: StickValues) => void): void;
  94973. /**
  94974. * Gets the left joystick
  94975. */
  94976. get leftStick(): StickValues;
  94977. /**
  94978. * Sets the left joystick values
  94979. */
  94980. set leftStick(newValues: StickValues);
  94981. /**
  94982. * Gets the right joystick
  94983. */
  94984. get rightStick(): StickValues;
  94985. /**
  94986. * Sets the right joystick value
  94987. */
  94988. set rightStick(newValues: StickValues);
  94989. /**
  94990. * Updates the gamepad joystick positions
  94991. */
  94992. update(): void;
  94993. /**
  94994. * Disposes the gamepad
  94995. */
  94996. dispose(): void;
  94997. }
  94998. /**
  94999. * Represents a generic gamepad
  95000. */
  95001. export class GenericPad extends Gamepad {
  95002. private _buttons;
  95003. private _onbuttondown;
  95004. private _onbuttonup;
  95005. /**
  95006. * Observable triggered when a button has been pressed
  95007. */
  95008. onButtonDownObservable: Observable<number>;
  95009. /**
  95010. * Observable triggered when a button has been released
  95011. */
  95012. onButtonUpObservable: Observable<number>;
  95013. /**
  95014. * Callback triggered when a button has been pressed
  95015. * @param callback Called when a button has been pressed
  95016. */
  95017. onbuttondown(callback: (buttonPressed: number) => void): void;
  95018. /**
  95019. * Callback triggered when a button has been released
  95020. * @param callback Called when a button has been released
  95021. */
  95022. onbuttonup(callback: (buttonReleased: number) => void): void;
  95023. /**
  95024. * Initializes the generic gamepad
  95025. * @param id The id of the generic gamepad
  95026. * @param index The index of the generic gamepad
  95027. * @param browserGamepad The browser gamepad
  95028. */
  95029. constructor(id: string, index: number, browserGamepad: any);
  95030. private _setButtonValue;
  95031. /**
  95032. * Updates the generic gamepad
  95033. */
  95034. update(): void;
  95035. /**
  95036. * Disposes the generic gamepad
  95037. */
  95038. dispose(): void;
  95039. }
  95040. }
  95041. declare module BABYLON {
  95042. /**
  95043. * Defines the types of pose enabled controllers that are supported
  95044. */
  95045. export enum PoseEnabledControllerType {
  95046. /**
  95047. * HTC Vive
  95048. */
  95049. VIVE = 0,
  95050. /**
  95051. * Oculus Rift
  95052. */
  95053. OCULUS = 1,
  95054. /**
  95055. * Windows mixed reality
  95056. */
  95057. WINDOWS = 2,
  95058. /**
  95059. * Samsung gear VR
  95060. */
  95061. GEAR_VR = 3,
  95062. /**
  95063. * Google Daydream
  95064. */
  95065. DAYDREAM = 4,
  95066. /**
  95067. * Generic
  95068. */
  95069. GENERIC = 5
  95070. }
  95071. /**
  95072. * Defines the MutableGamepadButton interface for the state of a gamepad button
  95073. */
  95074. export interface MutableGamepadButton {
  95075. /**
  95076. * Value of the button/trigger
  95077. */
  95078. value: number;
  95079. /**
  95080. * If the button/trigger is currently touched
  95081. */
  95082. touched: boolean;
  95083. /**
  95084. * If the button/trigger is currently pressed
  95085. */
  95086. pressed: boolean;
  95087. }
  95088. /**
  95089. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  95090. * @hidden
  95091. */
  95092. export interface ExtendedGamepadButton extends GamepadButton {
  95093. /**
  95094. * If the button/trigger is currently pressed
  95095. */
  95096. readonly pressed: boolean;
  95097. /**
  95098. * If the button/trigger is currently touched
  95099. */
  95100. readonly touched: boolean;
  95101. /**
  95102. * Value of the button/trigger
  95103. */
  95104. readonly value: number;
  95105. }
  95106. /** @hidden */
  95107. export interface _GamePadFactory {
  95108. /**
  95109. * Returns whether or not the current gamepad can be created for this type of controller.
  95110. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  95111. * @returns true if it can be created, otherwise false
  95112. */
  95113. canCreate(gamepadInfo: any): boolean;
  95114. /**
  95115. * Creates a new instance of the Gamepad.
  95116. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  95117. * @returns the new gamepad instance
  95118. */
  95119. create(gamepadInfo: any): Gamepad;
  95120. }
  95121. /**
  95122. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  95123. */
  95124. export class PoseEnabledControllerHelper {
  95125. /** @hidden */
  95126. static _ControllerFactories: _GamePadFactory[];
  95127. /** @hidden */
  95128. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  95129. /**
  95130. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  95131. * @param vrGamepad the gamepad to initialized
  95132. * @returns a vr controller of the type the gamepad identified as
  95133. */
  95134. static InitiateController(vrGamepad: any): Gamepad;
  95135. }
  95136. /**
  95137. * Defines the PoseEnabledController object that contains state of a vr capable controller
  95138. */
  95139. export class PoseEnabledController extends Gamepad implements PoseControlled {
  95140. /**
  95141. * If the controller is used in a webXR session
  95142. */
  95143. isXR: boolean;
  95144. private _deviceRoomPosition;
  95145. private _deviceRoomRotationQuaternion;
  95146. /**
  95147. * The device position in babylon space
  95148. */
  95149. devicePosition: Vector3;
  95150. /**
  95151. * The device rotation in babylon space
  95152. */
  95153. deviceRotationQuaternion: Quaternion;
  95154. /**
  95155. * The scale factor of the device in babylon space
  95156. */
  95157. deviceScaleFactor: number;
  95158. /**
  95159. * (Likely devicePosition should be used instead) The device position in its room space
  95160. */
  95161. position: Vector3;
  95162. /**
  95163. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  95164. */
  95165. rotationQuaternion: Quaternion;
  95166. /**
  95167. * The type of controller (Eg. Windows mixed reality)
  95168. */
  95169. controllerType: PoseEnabledControllerType;
  95170. protected _calculatedPosition: Vector3;
  95171. private _calculatedRotation;
  95172. /**
  95173. * The raw pose from the device
  95174. */
  95175. rawPose: DevicePose;
  95176. private _trackPosition;
  95177. private _maxRotationDistFromHeadset;
  95178. private _draggedRoomRotation;
  95179. /**
  95180. * @hidden
  95181. */
  95182. _disableTrackPosition(fixedPosition: Vector3): void;
  95183. /**
  95184. * Internal, the mesh attached to the controller
  95185. * @hidden
  95186. */
  95187. _mesh: Nullable<AbstractMesh>;
  95188. private _poseControlledCamera;
  95189. private _leftHandSystemQuaternion;
  95190. /**
  95191. * Internal, matrix used to convert room space to babylon space
  95192. * @hidden
  95193. */
  95194. _deviceToWorld: Matrix;
  95195. /**
  95196. * Node to be used when casting a ray from the controller
  95197. * @hidden
  95198. */
  95199. _pointingPoseNode: Nullable<TransformNode>;
  95200. /**
  95201. * Name of the child mesh that can be used to cast a ray from the controller
  95202. */
  95203. static readonly POINTING_POSE: string;
  95204. /**
  95205. * Creates a new PoseEnabledController from a gamepad
  95206. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  95207. */
  95208. constructor(browserGamepad: any);
  95209. private _workingMatrix;
  95210. /**
  95211. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  95212. */
  95213. update(): void;
  95214. /**
  95215. * Updates only the pose device and mesh without doing any button event checking
  95216. */
  95217. protected _updatePoseAndMesh(): void;
  95218. /**
  95219. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  95220. * @param poseData raw pose fromthe device
  95221. */
  95222. updateFromDevice(poseData: DevicePose): void;
  95223. /**
  95224. * @hidden
  95225. */
  95226. _meshAttachedObservable: Observable<AbstractMesh>;
  95227. /**
  95228. * Attaches a mesh to the controller
  95229. * @param mesh the mesh to be attached
  95230. */
  95231. attachToMesh(mesh: AbstractMesh): void;
  95232. /**
  95233. * Attaches the controllers mesh to a camera
  95234. * @param camera the camera the mesh should be attached to
  95235. */
  95236. attachToPoseControlledCamera(camera: TargetCamera): void;
  95237. /**
  95238. * Disposes of the controller
  95239. */
  95240. dispose(): void;
  95241. /**
  95242. * The mesh that is attached to the controller
  95243. */
  95244. get mesh(): Nullable<AbstractMesh>;
  95245. /**
  95246. * Gets the ray of the controller in the direction the controller is pointing
  95247. * @param length the length the resulting ray should be
  95248. * @returns a ray in the direction the controller is pointing
  95249. */
  95250. getForwardRay(length?: number): Ray;
  95251. }
  95252. }
  95253. declare module BABYLON {
  95254. /**
  95255. * Defines the WebVRController object that represents controllers tracked in 3D space
  95256. */
  95257. export abstract class WebVRController extends PoseEnabledController {
  95258. /**
  95259. * Internal, the default controller model for the controller
  95260. */
  95261. protected _defaultModel: Nullable<AbstractMesh>;
  95262. /**
  95263. * Fired when the trigger state has changed
  95264. */
  95265. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  95266. /**
  95267. * Fired when the main button state has changed
  95268. */
  95269. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95270. /**
  95271. * Fired when the secondary button state has changed
  95272. */
  95273. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95274. /**
  95275. * Fired when the pad state has changed
  95276. */
  95277. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  95278. /**
  95279. * Fired when controllers stick values have changed
  95280. */
  95281. onPadValuesChangedObservable: Observable<StickValues>;
  95282. /**
  95283. * Array of button availible on the controller
  95284. */
  95285. protected _buttons: Array<MutableGamepadButton>;
  95286. private _onButtonStateChange;
  95287. /**
  95288. * Fired when a controller button's state has changed
  95289. * @param callback the callback containing the button that was modified
  95290. */
  95291. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  95292. /**
  95293. * X and Y axis corresponding to the controllers joystick
  95294. */
  95295. pad: StickValues;
  95296. /**
  95297. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  95298. */
  95299. hand: string;
  95300. /**
  95301. * The default controller model for the controller
  95302. */
  95303. get defaultModel(): Nullable<AbstractMesh>;
  95304. /**
  95305. * Creates a new WebVRController from a gamepad
  95306. * @param vrGamepad the gamepad that the WebVRController should be created from
  95307. */
  95308. constructor(vrGamepad: any);
  95309. /**
  95310. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  95311. */
  95312. update(): void;
  95313. /**
  95314. * Function to be called when a button is modified
  95315. */
  95316. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  95317. /**
  95318. * Loads a mesh and attaches it to the controller
  95319. * @param scene the scene the mesh should be added to
  95320. * @param meshLoaded callback for when the mesh has been loaded
  95321. */
  95322. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  95323. private _setButtonValue;
  95324. private _changes;
  95325. private _checkChanges;
  95326. /**
  95327. * Disposes of th webVRCOntroller
  95328. */
  95329. dispose(): void;
  95330. }
  95331. }
  95332. declare module BABYLON {
  95333. /**
  95334. * The HemisphericLight simulates the ambient environment light,
  95335. * so the passed direction is the light reflection direction, not the incoming direction.
  95336. */
  95337. export class HemisphericLight extends Light {
  95338. /**
  95339. * The groundColor is the light in the opposite direction to the one specified during creation.
  95340. * 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.
  95341. */
  95342. groundColor: Color3;
  95343. /**
  95344. * The light reflection direction, not the incoming direction.
  95345. */
  95346. direction: Vector3;
  95347. /**
  95348. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  95349. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  95350. * The HemisphericLight can't cast shadows.
  95351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95352. * @param name The friendly name of the light
  95353. * @param direction The direction of the light reflection
  95354. * @param scene The scene the light belongs to
  95355. */
  95356. constructor(name: string, direction: Vector3, scene: Scene);
  95357. protected _buildUniformLayout(): void;
  95358. /**
  95359. * Returns the string "HemisphericLight".
  95360. * @return The class name
  95361. */
  95362. getClassName(): string;
  95363. /**
  95364. * Sets the HemisphericLight direction towards the passed target (Vector3).
  95365. * Returns the updated direction.
  95366. * @param target The target the direction should point to
  95367. * @return The computed direction
  95368. */
  95369. setDirectionToTarget(target: Vector3): Vector3;
  95370. /**
  95371. * Returns the shadow generator associated to the light.
  95372. * @returns Always null for hemispheric lights because it does not support shadows.
  95373. */
  95374. getShadowGenerator(): Nullable<IShadowGenerator>;
  95375. /**
  95376. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  95377. * @param effect The effect to update
  95378. * @param lightIndex The index of the light in the effect to update
  95379. * @returns The hemispheric light
  95380. */
  95381. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  95382. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  95383. /**
  95384. * Computes the world matrix of the node
  95385. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95386. * @param useWasUpdatedFlag defines a reserved property
  95387. * @returns the world matrix
  95388. */
  95389. computeWorldMatrix(): Matrix;
  95390. /**
  95391. * Returns the integer 3.
  95392. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95393. */
  95394. getTypeID(): number;
  95395. /**
  95396. * Prepares the list of defines specific to the light type.
  95397. * @param defines the list of defines
  95398. * @param lightIndex defines the index of the light for the effect
  95399. */
  95400. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95401. }
  95402. }
  95403. declare module BABYLON {
  95404. /** @hidden */
  95405. export var vrMultiviewToSingleviewPixelShader: {
  95406. name: string;
  95407. shader: string;
  95408. };
  95409. }
  95410. declare module BABYLON {
  95411. /**
  95412. * Renders to multiple views with a single draw call
  95413. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  95414. */
  95415. export class MultiviewRenderTarget extends RenderTargetTexture {
  95416. /**
  95417. * Creates a multiview render target
  95418. * @param scene scene used with the render target
  95419. * @param size the size of the render target (used for each view)
  95420. */
  95421. constructor(scene: Scene, size?: number | {
  95422. width: number;
  95423. height: number;
  95424. } | {
  95425. ratio: number;
  95426. });
  95427. /**
  95428. * @hidden
  95429. * @param faceIndex the face index, if its a cube texture
  95430. */
  95431. _bindFrameBuffer(faceIndex?: number): void;
  95432. /**
  95433. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95434. * @returns the view count
  95435. */
  95436. getViewCount(): number;
  95437. }
  95438. }
  95439. declare module BABYLON {
  95440. /**
  95441. * Represents a camera frustum
  95442. */
  95443. export class Frustum {
  95444. /**
  95445. * Gets the planes representing the frustum
  95446. * @param transform matrix to be applied to the returned planes
  95447. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  95448. */
  95449. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  95450. /**
  95451. * Gets the near frustum plane transformed by the transform matrix
  95452. * @param transform transformation matrix to be applied to the resulting frustum plane
  95453. * @param frustumPlane the resuling frustum plane
  95454. */
  95455. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95456. /**
  95457. * Gets the far frustum plane transformed by the transform matrix
  95458. * @param transform transformation matrix to be applied to the resulting frustum plane
  95459. * @param frustumPlane the resuling frustum plane
  95460. */
  95461. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95462. /**
  95463. * Gets the left frustum plane transformed by the transform matrix
  95464. * @param transform transformation matrix to be applied to the resulting frustum plane
  95465. * @param frustumPlane the resuling frustum plane
  95466. */
  95467. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95468. /**
  95469. * Gets the right frustum plane transformed by the transform matrix
  95470. * @param transform transformation matrix to be applied to the resulting frustum plane
  95471. * @param frustumPlane the resuling frustum plane
  95472. */
  95473. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95474. /**
  95475. * Gets the top frustum plane transformed by the transform matrix
  95476. * @param transform transformation matrix to be applied to the resulting frustum plane
  95477. * @param frustumPlane the resuling frustum plane
  95478. */
  95479. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95480. /**
  95481. * Gets the bottom frustum plane transformed by the transform matrix
  95482. * @param transform transformation matrix to be applied to the resulting frustum plane
  95483. * @param frustumPlane the resuling frustum plane
  95484. */
  95485. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95486. /**
  95487. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  95488. * @param transform transformation matrix to be applied to the resulting frustum planes
  95489. * @param frustumPlanes the resuling frustum planes
  95490. */
  95491. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  95492. }
  95493. }
  95494. declare module BABYLON {
  95495. interface Engine {
  95496. /**
  95497. * Creates a new multiview render target
  95498. * @param width defines the width of the texture
  95499. * @param height defines the height of the texture
  95500. * @returns the created multiview texture
  95501. */
  95502. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  95503. /**
  95504. * Binds a multiview framebuffer to be drawn to
  95505. * @param multiviewTexture texture to bind
  95506. */
  95507. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  95508. }
  95509. interface Camera {
  95510. /**
  95511. * @hidden
  95512. * 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)
  95513. */
  95514. _useMultiviewToSingleView: boolean;
  95515. /**
  95516. * @hidden
  95517. * 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)
  95518. */
  95519. _multiviewTexture: Nullable<RenderTargetTexture>;
  95520. /**
  95521. * @hidden
  95522. * ensures the multiview texture of the camera exists and has the specified width/height
  95523. * @param width height to set on the multiview texture
  95524. * @param height width to set on the multiview texture
  95525. */
  95526. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  95527. }
  95528. interface Scene {
  95529. /** @hidden */
  95530. _transformMatrixR: Matrix;
  95531. /** @hidden */
  95532. _multiviewSceneUbo: Nullable<UniformBuffer>;
  95533. /** @hidden */
  95534. _createMultiviewUbo(): void;
  95535. /** @hidden */
  95536. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  95537. /** @hidden */
  95538. _renderMultiviewToSingleView(camera: Camera): void;
  95539. }
  95540. }
  95541. declare module BABYLON {
  95542. /**
  95543. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  95544. * This will not be used for webXR as it supports displaying texture arrays directly
  95545. */
  95546. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  95547. /**
  95548. * Initializes a VRMultiviewToSingleview
  95549. * @param name name of the post process
  95550. * @param camera camera to be applied to
  95551. * @param scaleFactor scaling factor to the size of the output texture
  95552. */
  95553. constructor(name: string, camera: Camera, scaleFactor: number);
  95554. }
  95555. }
  95556. declare module BABYLON {
  95557. /**
  95558. * Interface used to define additional presentation attributes
  95559. */
  95560. export interface IVRPresentationAttributes {
  95561. /**
  95562. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  95563. */
  95564. highRefreshRate: boolean;
  95565. /**
  95566. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  95567. */
  95568. foveationLevel: number;
  95569. }
  95570. interface Engine {
  95571. /** @hidden */
  95572. _vrDisplay: any;
  95573. /** @hidden */
  95574. _vrSupported: boolean;
  95575. /** @hidden */
  95576. _oldSize: Size;
  95577. /** @hidden */
  95578. _oldHardwareScaleFactor: number;
  95579. /** @hidden */
  95580. _vrExclusivePointerMode: boolean;
  95581. /** @hidden */
  95582. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  95583. /** @hidden */
  95584. _onVRDisplayPointerRestricted: () => void;
  95585. /** @hidden */
  95586. _onVRDisplayPointerUnrestricted: () => void;
  95587. /** @hidden */
  95588. _onVrDisplayConnect: Nullable<(display: any) => void>;
  95589. /** @hidden */
  95590. _onVrDisplayDisconnect: Nullable<() => void>;
  95591. /** @hidden */
  95592. _onVrDisplayPresentChange: Nullable<() => void>;
  95593. /**
  95594. * Observable signaled when VR display mode changes
  95595. */
  95596. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  95597. /**
  95598. * Observable signaled when VR request present is complete
  95599. */
  95600. onVRRequestPresentComplete: Observable<boolean>;
  95601. /**
  95602. * Observable signaled when VR request present starts
  95603. */
  95604. onVRRequestPresentStart: Observable<Engine>;
  95605. /**
  95606. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  95607. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  95608. */
  95609. isInVRExclusivePointerMode: boolean;
  95610. /**
  95611. * Gets a boolean indicating if a webVR device was detected
  95612. * @returns true if a webVR device was detected
  95613. */
  95614. isVRDevicePresent(): boolean;
  95615. /**
  95616. * Gets the current webVR device
  95617. * @returns the current webVR device (or null)
  95618. */
  95619. getVRDevice(): any;
  95620. /**
  95621. * Initializes a webVR display and starts listening to display change events
  95622. * The onVRDisplayChangedObservable will be notified upon these changes
  95623. * @returns A promise containing a VRDisplay and if vr is supported
  95624. */
  95625. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  95626. /** @hidden */
  95627. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  95628. /**
  95629. * Gets or sets the presentation attributes used to configure VR rendering
  95630. */
  95631. vrPresentationAttributes?: IVRPresentationAttributes;
  95632. /**
  95633. * Call this function to switch to webVR mode
  95634. * Will do nothing if webVR is not supported or if there is no webVR device
  95635. * @param options the webvr options provided to the camera. mainly used for multiview
  95636. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95637. */
  95638. enableVR(options: WebVROptions): void;
  95639. /** @hidden */
  95640. _onVRFullScreenTriggered(): void;
  95641. }
  95642. }
  95643. declare module BABYLON {
  95644. /**
  95645. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  95646. * IMPORTANT!! The data is right-hand data.
  95647. * @export
  95648. * @interface DevicePose
  95649. */
  95650. export interface DevicePose {
  95651. /**
  95652. * The position of the device, values in array are [x,y,z].
  95653. */
  95654. readonly position: Nullable<Float32Array>;
  95655. /**
  95656. * The linearVelocity of the device, values in array are [x,y,z].
  95657. */
  95658. readonly linearVelocity: Nullable<Float32Array>;
  95659. /**
  95660. * The linearAcceleration of the device, values in array are [x,y,z].
  95661. */
  95662. readonly linearAcceleration: Nullable<Float32Array>;
  95663. /**
  95664. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  95665. */
  95666. readonly orientation: Nullable<Float32Array>;
  95667. /**
  95668. * The angularVelocity of the device, values in array are [x,y,z].
  95669. */
  95670. readonly angularVelocity: Nullable<Float32Array>;
  95671. /**
  95672. * The angularAcceleration of the device, values in array are [x,y,z].
  95673. */
  95674. readonly angularAcceleration: Nullable<Float32Array>;
  95675. }
  95676. /**
  95677. * Interface representing a pose controlled object in Babylon.
  95678. * A pose controlled object has both regular pose values as well as pose values
  95679. * from an external device such as a VR head mounted display
  95680. */
  95681. export interface PoseControlled {
  95682. /**
  95683. * The position of the object in babylon space.
  95684. */
  95685. position: Vector3;
  95686. /**
  95687. * The rotation quaternion of the object in babylon space.
  95688. */
  95689. rotationQuaternion: Quaternion;
  95690. /**
  95691. * The position of the device in babylon space.
  95692. */
  95693. devicePosition?: Vector3;
  95694. /**
  95695. * The rotation quaternion of the device in babylon space.
  95696. */
  95697. deviceRotationQuaternion: Quaternion;
  95698. /**
  95699. * The raw pose coming from the device.
  95700. */
  95701. rawPose: Nullable<DevicePose>;
  95702. /**
  95703. * The scale of the device to be used when translating from device space to babylon space.
  95704. */
  95705. deviceScaleFactor: number;
  95706. /**
  95707. * Updates the poseControlled values based on the input device pose.
  95708. * @param poseData the pose data to update the object with
  95709. */
  95710. updateFromDevice(poseData: DevicePose): void;
  95711. }
  95712. /**
  95713. * Set of options to customize the webVRCamera
  95714. */
  95715. export interface WebVROptions {
  95716. /**
  95717. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  95718. */
  95719. trackPosition?: boolean;
  95720. /**
  95721. * Sets the scale of the vrDevice in babylon space. (default: 1)
  95722. */
  95723. positionScale?: number;
  95724. /**
  95725. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  95726. */
  95727. displayName?: string;
  95728. /**
  95729. * Should the native controller meshes be initialized. (default: true)
  95730. */
  95731. controllerMeshes?: boolean;
  95732. /**
  95733. * Creating a default HemiLight only on controllers. (default: true)
  95734. */
  95735. defaultLightingOnControllers?: boolean;
  95736. /**
  95737. * If you don't want to use the default VR button of the helper. (default: false)
  95738. */
  95739. useCustomVRButton?: boolean;
  95740. /**
  95741. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  95742. */
  95743. customVRButton?: HTMLButtonElement;
  95744. /**
  95745. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  95746. */
  95747. rayLength?: number;
  95748. /**
  95749. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  95750. */
  95751. defaultHeight?: number;
  95752. /**
  95753. * If multiview should be used if availible (default: false)
  95754. */
  95755. useMultiview?: boolean;
  95756. }
  95757. /**
  95758. * This represents a WebVR camera.
  95759. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  95760. * @example http://doc.babylonjs.com/how_to/webvr_camera
  95761. */
  95762. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  95763. private webVROptions;
  95764. /**
  95765. * @hidden
  95766. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  95767. */
  95768. _vrDevice: any;
  95769. /**
  95770. * The rawPose of the vrDevice.
  95771. */
  95772. rawPose: Nullable<DevicePose>;
  95773. private _onVREnabled;
  95774. private _specsVersion;
  95775. private _attached;
  95776. private _frameData;
  95777. protected _descendants: Array<Node>;
  95778. private _deviceRoomPosition;
  95779. /** @hidden */
  95780. _deviceRoomRotationQuaternion: Quaternion;
  95781. private _standingMatrix;
  95782. /**
  95783. * Represents device position in babylon space.
  95784. */
  95785. devicePosition: Vector3;
  95786. /**
  95787. * Represents device rotation in babylon space.
  95788. */
  95789. deviceRotationQuaternion: Quaternion;
  95790. /**
  95791. * The scale of the device to be used when translating from device space to babylon space.
  95792. */
  95793. deviceScaleFactor: number;
  95794. private _deviceToWorld;
  95795. private _worldToDevice;
  95796. /**
  95797. * References to the webVR controllers for the vrDevice.
  95798. */
  95799. controllers: Array<WebVRController>;
  95800. /**
  95801. * Emits an event when a controller is attached.
  95802. */
  95803. onControllersAttachedObservable: Observable<WebVRController[]>;
  95804. /**
  95805. * Emits an event when a controller's mesh has been loaded;
  95806. */
  95807. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95808. /**
  95809. * Emits an event when the HMD's pose has been updated.
  95810. */
  95811. onPoseUpdatedFromDeviceObservable: Observable<any>;
  95812. private _poseSet;
  95813. /**
  95814. * If the rig cameras be used as parent instead of this camera.
  95815. */
  95816. rigParenting: boolean;
  95817. private _lightOnControllers;
  95818. private _defaultHeight?;
  95819. /**
  95820. * Instantiates a WebVRFreeCamera.
  95821. * @param name The name of the WebVRFreeCamera
  95822. * @param position The starting anchor position for the camera
  95823. * @param scene The scene the camera belongs to
  95824. * @param webVROptions a set of customizable options for the webVRCamera
  95825. */
  95826. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  95827. /**
  95828. * Gets the device distance from the ground in meters.
  95829. * @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.
  95830. */
  95831. deviceDistanceToRoomGround(): number;
  95832. /**
  95833. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95834. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  95835. */
  95836. useStandingMatrix(callback?: (bool: boolean) => void): void;
  95837. /**
  95838. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95839. * @returns A promise with a boolean set to if the standing matrix is supported.
  95840. */
  95841. useStandingMatrixAsync(): Promise<boolean>;
  95842. /**
  95843. * Disposes the camera
  95844. */
  95845. dispose(): void;
  95846. /**
  95847. * Gets a vrController by name.
  95848. * @param name The name of the controller to retreive
  95849. * @returns the controller matching the name specified or null if not found
  95850. */
  95851. getControllerByName(name: string): Nullable<WebVRController>;
  95852. private _leftController;
  95853. /**
  95854. * The controller corresponding to the users left hand.
  95855. */
  95856. get leftController(): Nullable<WebVRController>;
  95857. private _rightController;
  95858. /**
  95859. * The controller corresponding to the users right hand.
  95860. */
  95861. get rightController(): Nullable<WebVRController>;
  95862. /**
  95863. * Casts a ray forward from the vrCamera's gaze.
  95864. * @param length Length of the ray (default: 100)
  95865. * @returns the ray corresponding to the gaze
  95866. */
  95867. getForwardRay(length?: number): Ray;
  95868. /**
  95869. * @hidden
  95870. * Updates the camera based on device's frame data
  95871. */
  95872. _checkInputs(): void;
  95873. /**
  95874. * Updates the poseControlled values based on the input device pose.
  95875. * @param poseData Pose coming from the device
  95876. */
  95877. updateFromDevice(poseData: DevicePose): void;
  95878. private _htmlElementAttached;
  95879. private _detachIfAttached;
  95880. /**
  95881. * WebVR's attach control will start broadcasting frames to the device.
  95882. * Note that in certain browsers (chrome for example) this function must be called
  95883. * within a user-interaction callback. Example:
  95884. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  95885. *
  95886. * @param element html element to attach the vrDevice to
  95887. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  95888. */
  95889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95890. /**
  95891. * Detaches the camera from the html element and disables VR
  95892. *
  95893. * @param element html element to detach from
  95894. */
  95895. detachControl(element: HTMLElement): void;
  95896. /**
  95897. * @returns the name of this class
  95898. */
  95899. getClassName(): string;
  95900. /**
  95901. * Calls resetPose on the vrDisplay
  95902. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  95903. */
  95904. resetToCurrentRotation(): void;
  95905. /**
  95906. * @hidden
  95907. * Updates the rig cameras (left and right eye)
  95908. */
  95909. _updateRigCameras(): void;
  95910. private _workingVector;
  95911. private _oneVector;
  95912. private _workingMatrix;
  95913. private updateCacheCalled;
  95914. private _correctPositionIfNotTrackPosition;
  95915. /**
  95916. * @hidden
  95917. * Updates the cached values of the camera
  95918. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  95919. */
  95920. _updateCache(ignoreParentClass?: boolean): void;
  95921. /**
  95922. * @hidden
  95923. * Get current device position in babylon world
  95924. */
  95925. _computeDevicePosition(): void;
  95926. /**
  95927. * Updates the current device position and rotation in the babylon world
  95928. */
  95929. update(): void;
  95930. /**
  95931. * @hidden
  95932. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  95933. * @returns an identity matrix
  95934. */
  95935. _getViewMatrix(): Matrix;
  95936. private _tmpMatrix;
  95937. /**
  95938. * This function is called by the two RIG cameras.
  95939. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  95940. * @hidden
  95941. */
  95942. _getWebVRViewMatrix(): Matrix;
  95943. /** @hidden */
  95944. _getWebVRProjectionMatrix(): Matrix;
  95945. private _onGamepadConnectedObserver;
  95946. private _onGamepadDisconnectedObserver;
  95947. private _updateCacheWhenTrackingDisabledObserver;
  95948. /**
  95949. * Initializes the controllers and their meshes
  95950. */
  95951. initControllers(): void;
  95952. }
  95953. }
  95954. declare module BABYLON {
  95955. /**
  95956. * Size options for a post process
  95957. */
  95958. export type PostProcessOptions = {
  95959. width: number;
  95960. height: number;
  95961. };
  95962. /**
  95963. * PostProcess can be used to apply a shader to a texture after it has been rendered
  95964. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95965. */
  95966. export class PostProcess {
  95967. /** Name of the PostProcess. */
  95968. name: string;
  95969. /**
  95970. * Gets or sets the unique id of the post process
  95971. */
  95972. uniqueId: number;
  95973. /**
  95974. * Width of the texture to apply the post process on
  95975. */
  95976. width: number;
  95977. /**
  95978. * Height of the texture to apply the post process on
  95979. */
  95980. height: number;
  95981. /**
  95982. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  95983. * @hidden
  95984. */
  95985. _outputTexture: Nullable<InternalTexture>;
  95986. /**
  95987. * Sampling mode used by the shader
  95988. * See https://doc.babylonjs.com/classes/3.1/texture
  95989. */
  95990. renderTargetSamplingMode: number;
  95991. /**
  95992. * Clear color to use when screen clearing
  95993. */
  95994. clearColor: Color4;
  95995. /**
  95996. * If the buffer needs to be cleared before applying the post process. (default: true)
  95997. * Should be set to false if shader will overwrite all previous pixels.
  95998. */
  95999. autoClear: boolean;
  96000. /**
  96001. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  96002. */
  96003. alphaMode: number;
  96004. /**
  96005. * Sets the setAlphaBlendConstants of the babylon engine
  96006. */
  96007. alphaConstants: Color4;
  96008. /**
  96009. * Animations to be used for the post processing
  96010. */
  96011. animations: Animation[];
  96012. /**
  96013. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  96014. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  96015. */
  96016. enablePixelPerfectMode: boolean;
  96017. /**
  96018. * Force the postprocess to be applied without taking in account viewport
  96019. */
  96020. forceFullscreenViewport: boolean;
  96021. /**
  96022. * List of inspectable custom properties (used by the Inspector)
  96023. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96024. */
  96025. inspectableCustomProperties: IInspectable[];
  96026. /**
  96027. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  96028. *
  96029. * | Value | Type | Description |
  96030. * | ----- | ----------------------------------- | ----------- |
  96031. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  96032. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  96033. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  96034. *
  96035. */
  96036. scaleMode: number;
  96037. /**
  96038. * Force textures to be a power of two (default: false)
  96039. */
  96040. alwaysForcePOT: boolean;
  96041. private _samples;
  96042. /**
  96043. * Number of sample textures (default: 1)
  96044. */
  96045. get samples(): number;
  96046. set samples(n: number);
  96047. /**
  96048. * Modify the scale of the post process to be the same as the viewport (default: false)
  96049. */
  96050. adaptScaleToCurrentViewport: boolean;
  96051. private _camera;
  96052. private _scene;
  96053. private _engine;
  96054. private _options;
  96055. private _reusable;
  96056. private _textureType;
  96057. private _textureFormat;
  96058. /**
  96059. * Smart array of input and output textures for the post process.
  96060. * @hidden
  96061. */
  96062. _textures: SmartArray<InternalTexture>;
  96063. /**
  96064. * The index in _textures that corresponds to the output texture.
  96065. * @hidden
  96066. */
  96067. _currentRenderTextureInd: number;
  96068. private _effect;
  96069. private _samplers;
  96070. private _fragmentUrl;
  96071. private _vertexUrl;
  96072. private _parameters;
  96073. private _scaleRatio;
  96074. protected _indexParameters: any;
  96075. private _shareOutputWithPostProcess;
  96076. private _texelSize;
  96077. private _forcedOutputTexture;
  96078. /**
  96079. * Returns the fragment url or shader name used in the post process.
  96080. * @returns the fragment url or name in the shader store.
  96081. */
  96082. getEffectName(): string;
  96083. /**
  96084. * An event triggered when the postprocess is activated.
  96085. */
  96086. onActivateObservable: Observable<Camera>;
  96087. private _onActivateObserver;
  96088. /**
  96089. * A function that is added to the onActivateObservable
  96090. */
  96091. set onActivate(callback: Nullable<(camera: Camera) => void>);
  96092. /**
  96093. * An event triggered when the postprocess changes its size.
  96094. */
  96095. onSizeChangedObservable: Observable<PostProcess>;
  96096. private _onSizeChangedObserver;
  96097. /**
  96098. * A function that is added to the onSizeChangedObservable
  96099. */
  96100. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  96101. /**
  96102. * An event triggered when the postprocess applies its effect.
  96103. */
  96104. onApplyObservable: Observable<Effect>;
  96105. private _onApplyObserver;
  96106. /**
  96107. * A function that is added to the onApplyObservable
  96108. */
  96109. set onApply(callback: (effect: Effect) => void);
  96110. /**
  96111. * An event triggered before rendering the postprocess
  96112. */
  96113. onBeforeRenderObservable: Observable<Effect>;
  96114. private _onBeforeRenderObserver;
  96115. /**
  96116. * A function that is added to the onBeforeRenderObservable
  96117. */
  96118. set onBeforeRender(callback: (effect: Effect) => void);
  96119. /**
  96120. * An event triggered after rendering the postprocess
  96121. */
  96122. onAfterRenderObservable: Observable<Effect>;
  96123. private _onAfterRenderObserver;
  96124. /**
  96125. * A function that is added to the onAfterRenderObservable
  96126. */
  96127. set onAfterRender(callback: (efect: Effect) => void);
  96128. /**
  96129. * 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
  96130. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  96131. */
  96132. get inputTexture(): InternalTexture;
  96133. set inputTexture(value: InternalTexture);
  96134. /**
  96135. * Gets the camera which post process is applied to.
  96136. * @returns The camera the post process is applied to.
  96137. */
  96138. getCamera(): Camera;
  96139. /**
  96140. * Gets the texel size of the postprocess.
  96141. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  96142. */
  96143. get texelSize(): Vector2;
  96144. /**
  96145. * Creates a new instance PostProcess
  96146. * @param name The name of the PostProcess.
  96147. * @param fragmentUrl The url of the fragment shader to be used.
  96148. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  96149. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  96150. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96151. * @param camera The camera to apply the render pass to.
  96152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96153. * @param engine The engine which the post process will be applied. (default: current engine)
  96154. * @param reusable If the post process can be reused on the same frame. (default: false)
  96155. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  96156. * @param textureType Type of textures used when performing the post process. (default: 0)
  96157. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  96158. * @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
  96159. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  96160. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  96161. */
  96162. constructor(
  96163. /** Name of the PostProcess. */
  96164. 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, textureFormat?: number);
  96165. /**
  96166. * Gets a string idenfifying the name of the class
  96167. * @returns "PostProcess" string
  96168. */
  96169. getClassName(): string;
  96170. /**
  96171. * Gets the engine which this post process belongs to.
  96172. * @returns The engine the post process was enabled with.
  96173. */
  96174. getEngine(): Engine;
  96175. /**
  96176. * The effect that is created when initializing the post process.
  96177. * @returns The created effect corresponding the the postprocess.
  96178. */
  96179. getEffect(): Effect;
  96180. /**
  96181. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  96182. * @param postProcess The post process to share the output with.
  96183. * @returns This post process.
  96184. */
  96185. shareOutputWith(postProcess: PostProcess): PostProcess;
  96186. /**
  96187. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  96188. * This should be called if the post process that shares output with this post process is disabled/disposed.
  96189. */
  96190. useOwnOutput(): void;
  96191. /**
  96192. * Updates the effect with the current post process compile time values and recompiles the shader.
  96193. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96194. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96195. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96196. * @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
  96197. * @param onCompiled Called when the shader has been compiled.
  96198. * @param onError Called if there is an error when compiling a shader.
  96199. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  96200. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  96201. */
  96202. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  96203. /**
  96204. * The post process is reusable if it can be used multiple times within one frame.
  96205. * @returns If the post process is reusable
  96206. */
  96207. isReusable(): boolean;
  96208. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  96209. markTextureDirty(): void;
  96210. /**
  96211. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  96212. * 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.
  96213. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  96214. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  96215. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  96216. * @returns The target texture that was bound to be written to.
  96217. */
  96218. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  96219. /**
  96220. * If the post process is supported.
  96221. */
  96222. get isSupported(): boolean;
  96223. /**
  96224. * The aspect ratio of the output texture.
  96225. */
  96226. get aspectRatio(): number;
  96227. /**
  96228. * Get a value indicating if the post-process is ready to be used
  96229. * @returns true if the post-process is ready (shader is compiled)
  96230. */
  96231. isReady(): boolean;
  96232. /**
  96233. * Binds all textures and uniforms to the shader, this will be run on every pass.
  96234. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  96235. */
  96236. apply(): Nullable<Effect>;
  96237. private _disposeTextures;
  96238. /**
  96239. * Disposes the post process.
  96240. * @param camera The camera to dispose the post process on.
  96241. */
  96242. dispose(camera?: Camera): void;
  96243. }
  96244. }
  96245. declare module BABYLON {
  96246. /** @hidden */
  96247. export var kernelBlurVaryingDeclaration: {
  96248. name: string;
  96249. shader: string;
  96250. };
  96251. }
  96252. declare module BABYLON {
  96253. /** @hidden */
  96254. export var kernelBlurFragment: {
  96255. name: string;
  96256. shader: string;
  96257. };
  96258. }
  96259. declare module BABYLON {
  96260. /** @hidden */
  96261. export var kernelBlurFragment2: {
  96262. name: string;
  96263. shader: string;
  96264. };
  96265. }
  96266. declare module BABYLON {
  96267. /** @hidden */
  96268. export var kernelBlurPixelShader: {
  96269. name: string;
  96270. shader: string;
  96271. };
  96272. }
  96273. declare module BABYLON {
  96274. /** @hidden */
  96275. export var kernelBlurVertex: {
  96276. name: string;
  96277. shader: string;
  96278. };
  96279. }
  96280. declare module BABYLON {
  96281. /** @hidden */
  96282. export var kernelBlurVertexShader: {
  96283. name: string;
  96284. shader: string;
  96285. };
  96286. }
  96287. declare module BABYLON {
  96288. /**
  96289. * The Blur Post Process which blurs an image based on a kernel and direction.
  96290. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  96291. */
  96292. export class BlurPostProcess extends PostProcess {
  96293. /** The direction in which to blur the image. */
  96294. direction: Vector2;
  96295. private blockCompilation;
  96296. protected _kernel: number;
  96297. protected _idealKernel: number;
  96298. protected _packedFloat: boolean;
  96299. private _staticDefines;
  96300. /**
  96301. * Sets the length in pixels of the blur sample region
  96302. */
  96303. set kernel(v: number);
  96304. /**
  96305. * Gets the length in pixels of the blur sample region
  96306. */
  96307. get kernel(): number;
  96308. /**
  96309. * Sets wether or not the blur needs to unpack/repack floats
  96310. */
  96311. set packedFloat(v: boolean);
  96312. /**
  96313. * Gets wether or not the blur is unpacking/repacking floats
  96314. */
  96315. get packedFloat(): boolean;
  96316. /**
  96317. * Creates a new instance BlurPostProcess
  96318. * @param name The name of the effect.
  96319. * @param direction The direction in which to blur the image.
  96320. * @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.
  96321. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96322. * @param camera The camera to apply the render pass to.
  96323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96324. * @param engine The engine which the post process will be applied. (default: current engine)
  96325. * @param reusable If the post process can be reused on the same frame. (default: false)
  96326. * @param textureType Type of textures used when performing the post process. (default: 0)
  96327. * @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)
  96328. */
  96329. constructor(name: string,
  96330. /** The direction in which to blur the image. */
  96331. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  96332. /**
  96333. * Updates the effect with the current post process compile time values and recompiles the shader.
  96334. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96335. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96336. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96337. * @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
  96338. * @param onCompiled Called when the shader has been compiled.
  96339. * @param onError Called if there is an error when compiling a shader.
  96340. */
  96341. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96342. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96343. /**
  96344. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  96345. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  96346. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  96347. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  96348. * The gaps between physical kernels are compensated for in the weighting of the samples
  96349. * @param idealKernel Ideal blur kernel.
  96350. * @return Nearest best kernel.
  96351. */
  96352. protected _nearestBestKernel(idealKernel: number): number;
  96353. /**
  96354. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  96355. * @param x The point on the Gaussian distribution to sample.
  96356. * @return the value of the Gaussian function at x.
  96357. */
  96358. protected _gaussianWeight(x: number): number;
  96359. /**
  96360. * Generates a string that can be used as a floating point number in GLSL.
  96361. * @param x Value to print.
  96362. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  96363. * @return GLSL float string.
  96364. */
  96365. protected _glslFloat(x: number, decimalFigures?: number): string;
  96366. }
  96367. }
  96368. declare module BABYLON {
  96369. /**
  96370. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96371. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96372. * You can then easily use it as a reflectionTexture on a flat surface.
  96373. * In case the surface is not a plane, please consider relying on reflection probes.
  96374. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96375. */
  96376. export class MirrorTexture extends RenderTargetTexture {
  96377. private scene;
  96378. /**
  96379. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  96380. * 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.
  96381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96382. */
  96383. mirrorPlane: Plane;
  96384. /**
  96385. * Define the blur ratio used to blur the reflection if needed.
  96386. */
  96387. set blurRatio(value: number);
  96388. get blurRatio(): number;
  96389. /**
  96390. * Define the adaptive blur kernel used to blur the reflection if needed.
  96391. * This will autocompute the closest best match for the `blurKernel`
  96392. */
  96393. set adaptiveBlurKernel(value: number);
  96394. /**
  96395. * Define the blur kernel used to blur the reflection if needed.
  96396. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96397. */
  96398. set blurKernel(value: number);
  96399. /**
  96400. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  96401. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96402. */
  96403. set blurKernelX(value: number);
  96404. get blurKernelX(): number;
  96405. /**
  96406. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  96407. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96408. */
  96409. set blurKernelY(value: number);
  96410. get blurKernelY(): number;
  96411. private _autoComputeBlurKernel;
  96412. protected _onRatioRescale(): void;
  96413. private _updateGammaSpace;
  96414. private _imageProcessingConfigChangeObserver;
  96415. private _transformMatrix;
  96416. private _mirrorMatrix;
  96417. private _savedViewMatrix;
  96418. private _blurX;
  96419. private _blurY;
  96420. private _adaptiveBlurKernel;
  96421. private _blurKernelX;
  96422. private _blurKernelY;
  96423. private _blurRatio;
  96424. /**
  96425. * Instantiates a Mirror Texture.
  96426. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96427. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96428. * You can then easily use it as a reflectionTexture on a flat surface.
  96429. * In case the surface is not a plane, please consider relying on reflection probes.
  96430. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96431. * @param name
  96432. * @param size
  96433. * @param scene
  96434. * @param generateMipMaps
  96435. * @param type
  96436. * @param samplingMode
  96437. * @param generateDepthBuffer
  96438. */
  96439. constructor(name: string, size: number | {
  96440. width: number;
  96441. height: number;
  96442. } | {
  96443. ratio: number;
  96444. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  96445. private _preparePostProcesses;
  96446. /**
  96447. * Clone the mirror texture.
  96448. * @returns the cloned texture
  96449. */
  96450. clone(): MirrorTexture;
  96451. /**
  96452. * Serialize the texture to a JSON representation you could use in Parse later on
  96453. * @returns the serialized JSON representation
  96454. */
  96455. serialize(): any;
  96456. /**
  96457. * Dispose the texture and release its associated resources.
  96458. */
  96459. dispose(): void;
  96460. }
  96461. }
  96462. declare module BABYLON {
  96463. /**
  96464. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96465. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96466. */
  96467. export class Texture extends BaseTexture {
  96468. /**
  96469. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  96470. */
  96471. static SerializeBuffers: boolean;
  96472. /** @hidden */
  96473. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  96474. /** @hidden */
  96475. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  96476. /** @hidden */
  96477. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  96478. /** nearest is mag = nearest and min = nearest and mip = linear */
  96479. static readonly NEAREST_SAMPLINGMODE: number;
  96480. /** nearest is mag = nearest and min = nearest and mip = linear */
  96481. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  96482. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96483. static readonly BILINEAR_SAMPLINGMODE: number;
  96484. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96485. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  96486. /** Trilinear is mag = linear and min = linear and mip = linear */
  96487. static readonly TRILINEAR_SAMPLINGMODE: number;
  96488. /** Trilinear is mag = linear and min = linear and mip = linear */
  96489. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  96490. /** mag = nearest and min = nearest and mip = nearest */
  96491. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  96492. /** mag = nearest and min = linear and mip = nearest */
  96493. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  96494. /** mag = nearest and min = linear and mip = linear */
  96495. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  96496. /** mag = nearest and min = linear and mip = none */
  96497. static readonly NEAREST_LINEAR: number;
  96498. /** mag = nearest and min = nearest and mip = none */
  96499. static readonly NEAREST_NEAREST: number;
  96500. /** mag = linear and min = nearest and mip = nearest */
  96501. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  96502. /** mag = linear and min = nearest and mip = linear */
  96503. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  96504. /** mag = linear and min = linear and mip = none */
  96505. static readonly LINEAR_LINEAR: number;
  96506. /** mag = linear and min = nearest and mip = none */
  96507. static readonly LINEAR_NEAREST: number;
  96508. /** Explicit coordinates mode */
  96509. static readonly EXPLICIT_MODE: number;
  96510. /** Spherical coordinates mode */
  96511. static readonly SPHERICAL_MODE: number;
  96512. /** Planar coordinates mode */
  96513. static readonly PLANAR_MODE: number;
  96514. /** Cubic coordinates mode */
  96515. static readonly CUBIC_MODE: number;
  96516. /** Projection coordinates mode */
  96517. static readonly PROJECTION_MODE: number;
  96518. /** Inverse Cubic coordinates mode */
  96519. static readonly SKYBOX_MODE: number;
  96520. /** Inverse Cubic coordinates mode */
  96521. static readonly INVCUBIC_MODE: number;
  96522. /** Equirectangular coordinates mode */
  96523. static readonly EQUIRECTANGULAR_MODE: number;
  96524. /** Equirectangular Fixed coordinates mode */
  96525. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  96526. /** Equirectangular Fixed Mirrored coordinates mode */
  96527. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96528. /** Texture is not repeating outside of 0..1 UVs */
  96529. static readonly CLAMP_ADDRESSMODE: number;
  96530. /** Texture is repeating outside of 0..1 UVs */
  96531. static readonly WRAP_ADDRESSMODE: number;
  96532. /** Texture is repeating and mirrored */
  96533. static readonly MIRROR_ADDRESSMODE: number;
  96534. /**
  96535. * 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
  96536. */
  96537. static UseSerializedUrlIfAny: boolean;
  96538. /**
  96539. * Define the url of the texture.
  96540. */
  96541. url: Nullable<string>;
  96542. /**
  96543. * Define an offset on the texture to offset the u coordinates of the UVs
  96544. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96545. */
  96546. uOffset: number;
  96547. /**
  96548. * Define an offset on the texture to offset the v coordinates of the UVs
  96549. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96550. */
  96551. vOffset: number;
  96552. /**
  96553. * Define an offset on the texture to scale the u coordinates of the UVs
  96554. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96555. */
  96556. uScale: number;
  96557. /**
  96558. * Define an offset on the texture to scale the v coordinates of the UVs
  96559. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96560. */
  96561. vScale: number;
  96562. /**
  96563. * Define an offset on the texture to rotate around the u coordinates of the UVs
  96564. * @see http://doc.babylonjs.com/how_to/more_materials
  96565. */
  96566. uAng: number;
  96567. /**
  96568. * Define an offset on the texture to rotate around the v coordinates of the UVs
  96569. * @see http://doc.babylonjs.com/how_to/more_materials
  96570. */
  96571. vAng: number;
  96572. /**
  96573. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  96574. * @see http://doc.babylonjs.com/how_to/more_materials
  96575. */
  96576. wAng: number;
  96577. /**
  96578. * Defines the center of rotation (U)
  96579. */
  96580. uRotationCenter: number;
  96581. /**
  96582. * Defines the center of rotation (V)
  96583. */
  96584. vRotationCenter: number;
  96585. /**
  96586. * Defines the center of rotation (W)
  96587. */
  96588. wRotationCenter: number;
  96589. /**
  96590. * Are mip maps generated for this texture or not.
  96591. */
  96592. get noMipmap(): boolean;
  96593. /**
  96594. * List of inspectable custom properties (used by the Inspector)
  96595. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96596. */
  96597. inspectableCustomProperties: Nullable<IInspectable[]>;
  96598. private _noMipmap;
  96599. /** @hidden */
  96600. _invertY: boolean;
  96601. private _rowGenerationMatrix;
  96602. private _cachedTextureMatrix;
  96603. private _projectionModeMatrix;
  96604. private _t0;
  96605. private _t1;
  96606. private _t2;
  96607. private _cachedUOffset;
  96608. private _cachedVOffset;
  96609. private _cachedUScale;
  96610. private _cachedVScale;
  96611. private _cachedUAng;
  96612. private _cachedVAng;
  96613. private _cachedWAng;
  96614. private _cachedProjectionMatrixId;
  96615. private _cachedCoordinatesMode;
  96616. /** @hidden */
  96617. protected _initialSamplingMode: number;
  96618. /** @hidden */
  96619. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  96620. private _deleteBuffer;
  96621. protected _format: Nullable<number>;
  96622. private _delayedOnLoad;
  96623. private _delayedOnError;
  96624. private _mimeType?;
  96625. /**
  96626. * Observable triggered once the texture has been loaded.
  96627. */
  96628. onLoadObservable: Observable<Texture>;
  96629. protected _isBlocking: boolean;
  96630. /**
  96631. * Is the texture preventing material to render while loading.
  96632. * If false, a default texture will be used instead of the loading one during the preparation step.
  96633. */
  96634. set isBlocking(value: boolean);
  96635. get isBlocking(): boolean;
  96636. /**
  96637. * Get the current sampling mode associated with the texture.
  96638. */
  96639. get samplingMode(): number;
  96640. /**
  96641. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  96642. */
  96643. get invertY(): boolean;
  96644. /**
  96645. * Instantiates a new texture.
  96646. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96647. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96648. * @param url defines the url of the picture to load as a texture
  96649. * @param sceneOrEngine defines the scene or engine the texture will belong to
  96650. * @param noMipmap defines if the texture will require mip maps or not
  96651. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  96652. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96653. * @param onLoad defines a callback triggered when the texture has been loaded
  96654. * @param onError defines a callback triggered when an error occurred during the loading session
  96655. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  96656. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  96657. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96658. * @param mimeType defines an optional mime type information
  96659. */
  96660. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  96661. /**
  96662. * Update the url (and optional buffer) of this texture if url was null during construction.
  96663. * @param url the url of the texture
  96664. * @param buffer the buffer of the texture (defaults to null)
  96665. * @param onLoad callback called when the texture is loaded (defaults to null)
  96666. */
  96667. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  96668. /**
  96669. * Finish the loading sequence of a texture flagged as delayed load.
  96670. * @hidden
  96671. */
  96672. delayLoad(): void;
  96673. private _prepareRowForTextureGeneration;
  96674. /**
  96675. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  96676. * @returns the transform matrix of the texture.
  96677. */
  96678. getTextureMatrix(uBase?: number): Matrix;
  96679. /**
  96680. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  96681. * @returns The reflection texture transform
  96682. */
  96683. getReflectionTextureMatrix(): Matrix;
  96684. /**
  96685. * Clones the texture.
  96686. * @returns the cloned texture
  96687. */
  96688. clone(): Texture;
  96689. /**
  96690. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96691. * @returns The JSON representation of the texture
  96692. */
  96693. serialize(): any;
  96694. /**
  96695. * Get the current class name of the texture useful for serialization or dynamic coding.
  96696. * @returns "Texture"
  96697. */
  96698. getClassName(): string;
  96699. /**
  96700. * Dispose the texture and release its associated resources.
  96701. */
  96702. dispose(): void;
  96703. /**
  96704. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  96705. * @param parsedTexture Define the JSON representation of the texture
  96706. * @param scene Define the scene the parsed texture should be instantiated in
  96707. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  96708. * @returns The parsed texture if successful
  96709. */
  96710. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  96711. /**
  96712. * Creates a texture from its base 64 representation.
  96713. * @param data Define the base64 payload without the data: prefix
  96714. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96715. * @param scene Define the scene the texture should belong to
  96716. * @param noMipmap Forces the texture to not create mip map information if true
  96717. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96718. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96719. * @param onLoad define a callback triggered when the texture has been loaded
  96720. * @param onError define a callback triggered when an error occurred during the loading session
  96721. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96722. * @returns the created texture
  96723. */
  96724. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  96725. /**
  96726. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  96727. * @param data Define the base64 payload without the data: prefix
  96728. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96729. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  96730. * @param scene Define the scene the texture should belong to
  96731. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  96732. * @param noMipmap Forces the texture to not create mip map information if true
  96733. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96734. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96735. * @param onLoad define a callback triggered when the texture has been loaded
  96736. * @param onError define a callback triggered when an error occurred during the loading session
  96737. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96738. * @returns the created texture
  96739. */
  96740. 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;
  96741. }
  96742. }
  96743. declare module BABYLON {
  96744. /**
  96745. * PostProcessManager is used to manage one or more post processes or post process pipelines
  96746. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  96747. */
  96748. export class PostProcessManager {
  96749. private _scene;
  96750. private _indexBuffer;
  96751. private _vertexBuffers;
  96752. /**
  96753. * Creates a new instance PostProcess
  96754. * @param scene The scene that the post process is associated with.
  96755. */
  96756. constructor(scene: Scene);
  96757. private _prepareBuffers;
  96758. private _buildIndexBuffer;
  96759. /**
  96760. * Rebuilds the vertex buffers of the manager.
  96761. * @hidden
  96762. */
  96763. _rebuild(): void;
  96764. /**
  96765. * Prepares a frame to be run through a post process.
  96766. * @param sourceTexture The input texture to the post procesess. (default: null)
  96767. * @param postProcesses An array of post processes to be run. (default: null)
  96768. * @returns True if the post processes were able to be run.
  96769. * @hidden
  96770. */
  96771. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  96772. /**
  96773. * Manually render a set of post processes to a texture.
  96774. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  96775. * @param postProcesses An array of post processes to be run.
  96776. * @param targetTexture The target texture to render to.
  96777. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  96778. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  96779. * @param lodLevel defines which lod of the texture to render to
  96780. */
  96781. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  96782. /**
  96783. * Finalize the result of the output of the postprocesses.
  96784. * @param doNotPresent If true the result will not be displayed to the screen.
  96785. * @param targetTexture The target texture to render to.
  96786. * @param faceIndex The index of the face to bind the target texture to.
  96787. * @param postProcesses The array of post processes to render.
  96788. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  96789. * @hidden
  96790. */
  96791. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  96792. /**
  96793. * Disposes of the post process manager.
  96794. */
  96795. dispose(): void;
  96796. }
  96797. }
  96798. declare module BABYLON {
  96799. /**
  96800. * This Helps creating a texture that will be created from a camera in your scene.
  96801. * It is basically a dynamic texture that could be used to create special effects for instance.
  96802. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  96803. */
  96804. export class RenderTargetTexture extends Texture {
  96805. isCube: boolean;
  96806. /**
  96807. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  96808. */
  96809. static readonly REFRESHRATE_RENDER_ONCE: number;
  96810. /**
  96811. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  96812. */
  96813. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  96814. /**
  96815. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  96816. * the central point of your effect and can save a lot of performances.
  96817. */
  96818. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  96819. /**
  96820. * Use this predicate to dynamically define the list of mesh you want to render.
  96821. * If set, the renderList property will be overwritten.
  96822. */
  96823. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  96824. private _renderList;
  96825. /**
  96826. * Use this list to define the list of mesh you want to render.
  96827. */
  96828. get renderList(): Nullable<Array<AbstractMesh>>;
  96829. set renderList(value: Nullable<Array<AbstractMesh>>);
  96830. /**
  96831. * Use this function to overload the renderList array at rendering time.
  96832. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  96833. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  96834. * the cube (if the RTT is a cube, else layerOrFace=0).
  96835. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  96836. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  96837. * hold dummy elements!
  96838. */
  96839. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  96840. private _hookArray;
  96841. /**
  96842. * Define if particles should be rendered in your texture.
  96843. */
  96844. renderParticles: boolean;
  96845. /**
  96846. * Define if sprites should be rendered in your texture.
  96847. */
  96848. renderSprites: boolean;
  96849. /**
  96850. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  96851. */
  96852. coordinatesMode: number;
  96853. /**
  96854. * Define the camera used to render the texture.
  96855. */
  96856. activeCamera: Nullable<Camera>;
  96857. /**
  96858. * Override the mesh isReady function with your own one.
  96859. */
  96860. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  96861. /**
  96862. * Override the render function of the texture with your own one.
  96863. */
  96864. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  96865. /**
  96866. * Define if camera post processes should be use while rendering the texture.
  96867. */
  96868. useCameraPostProcesses: boolean;
  96869. /**
  96870. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  96871. */
  96872. ignoreCameraViewport: boolean;
  96873. private _postProcessManager;
  96874. private _postProcesses;
  96875. private _resizeObserver;
  96876. /**
  96877. * An event triggered when the texture is unbind.
  96878. */
  96879. onBeforeBindObservable: Observable<RenderTargetTexture>;
  96880. /**
  96881. * An event triggered when the texture is unbind.
  96882. */
  96883. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  96884. private _onAfterUnbindObserver;
  96885. /**
  96886. * Set a after unbind callback in the texture.
  96887. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  96888. */
  96889. set onAfterUnbind(callback: () => void);
  96890. /**
  96891. * An event triggered before rendering the texture
  96892. */
  96893. onBeforeRenderObservable: Observable<number>;
  96894. private _onBeforeRenderObserver;
  96895. /**
  96896. * Set a before render callback in the texture.
  96897. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  96898. */
  96899. set onBeforeRender(callback: (faceIndex: number) => void);
  96900. /**
  96901. * An event triggered after rendering the texture
  96902. */
  96903. onAfterRenderObservable: Observable<number>;
  96904. private _onAfterRenderObserver;
  96905. /**
  96906. * Set a after render callback in the texture.
  96907. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  96908. */
  96909. set onAfterRender(callback: (faceIndex: number) => void);
  96910. /**
  96911. * An event triggered after the texture clear
  96912. */
  96913. onClearObservable: Observable<Engine>;
  96914. private _onClearObserver;
  96915. /**
  96916. * Set a clear callback in the texture.
  96917. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  96918. */
  96919. set onClear(callback: (Engine: Engine) => void);
  96920. /**
  96921. * An event triggered when the texture is resized.
  96922. */
  96923. onResizeObservable: Observable<RenderTargetTexture>;
  96924. /**
  96925. * Define the clear color of the Render Target if it should be different from the scene.
  96926. */
  96927. clearColor: Color4;
  96928. protected _size: number | {
  96929. width: number;
  96930. height: number;
  96931. layers?: number;
  96932. };
  96933. protected _initialSizeParameter: number | {
  96934. width: number;
  96935. height: number;
  96936. } | {
  96937. ratio: number;
  96938. };
  96939. protected _sizeRatio: Nullable<number>;
  96940. /** @hidden */
  96941. _generateMipMaps: boolean;
  96942. protected _renderingManager: RenderingManager;
  96943. /** @hidden */
  96944. _waitingRenderList: string[];
  96945. protected _doNotChangeAspectRatio: boolean;
  96946. protected _currentRefreshId: number;
  96947. protected _refreshRate: number;
  96948. protected _textureMatrix: Matrix;
  96949. protected _samples: number;
  96950. protected _renderTargetOptions: RenderTargetCreationOptions;
  96951. /**
  96952. * Gets render target creation options that were used.
  96953. */
  96954. get renderTargetOptions(): RenderTargetCreationOptions;
  96955. protected _onRatioRescale(): void;
  96956. /**
  96957. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  96958. * It must define where the camera used to render the texture is set
  96959. */
  96960. boundingBoxPosition: Vector3;
  96961. private _boundingBoxSize;
  96962. /**
  96963. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  96964. * When defined, the cubemap will switch to local mode
  96965. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96966. * @example https://www.babylonjs-playground.com/#RNASML
  96967. */
  96968. set boundingBoxSize(value: Vector3);
  96969. get boundingBoxSize(): Vector3;
  96970. /**
  96971. * In case the RTT has been created with a depth texture, get the associated
  96972. * depth texture.
  96973. * Otherwise, return null.
  96974. */
  96975. get depthStencilTexture(): Nullable<InternalTexture>;
  96976. /**
  96977. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  96978. * or used a shadow, depth texture...
  96979. * @param name The friendly name of the texture
  96980. * @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)
  96981. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  96982. * @param generateMipMaps True if mip maps need to be generated after render.
  96983. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  96984. * @param type The type of the buffer in the RTT (int, half float, float...)
  96985. * @param isCube True if a cube texture needs to be created
  96986. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  96987. * @param generateDepthBuffer True to generate a depth buffer
  96988. * @param generateStencilBuffer True to generate a stencil buffer
  96989. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  96990. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  96991. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96992. */
  96993. constructor(name: string, size: number | {
  96994. width: number;
  96995. height: number;
  96996. layers?: number;
  96997. } | {
  96998. ratio: number;
  96999. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  97000. /**
  97001. * Creates a depth stencil texture.
  97002. * This is only available in WebGL 2 or with the depth texture extension available.
  97003. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  97004. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  97005. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  97006. */
  97007. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  97008. private _processSizeParameter;
  97009. /**
  97010. * Define the number of samples to use in case of MSAA.
  97011. * It defaults to one meaning no MSAA has been enabled.
  97012. */
  97013. get samples(): number;
  97014. set samples(value: number);
  97015. /**
  97016. * Resets the refresh counter of the texture and start bak from scratch.
  97017. * Could be useful to regenerate the texture if it is setup to render only once.
  97018. */
  97019. resetRefreshCounter(): void;
  97020. /**
  97021. * Define the refresh rate of the texture or the rendering frequency.
  97022. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  97023. */
  97024. get refreshRate(): number;
  97025. set refreshRate(value: number);
  97026. /**
  97027. * Adds a post process to the render target rendering passes.
  97028. * @param postProcess define the post process to add
  97029. */
  97030. addPostProcess(postProcess: PostProcess): void;
  97031. /**
  97032. * Clear all the post processes attached to the render target
  97033. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  97034. */
  97035. clearPostProcesses(dispose?: boolean): void;
  97036. /**
  97037. * Remove one of the post process from the list of attached post processes to the texture
  97038. * @param postProcess define the post process to remove from the list
  97039. */
  97040. removePostProcess(postProcess: PostProcess): void;
  97041. /** @hidden */
  97042. _shouldRender(): boolean;
  97043. /**
  97044. * Gets the actual render size of the texture.
  97045. * @returns the width of the render size
  97046. */
  97047. getRenderSize(): number;
  97048. /**
  97049. * Gets the actual render width of the texture.
  97050. * @returns the width of the render size
  97051. */
  97052. getRenderWidth(): number;
  97053. /**
  97054. * Gets the actual render height of the texture.
  97055. * @returns the height of the render size
  97056. */
  97057. getRenderHeight(): number;
  97058. /**
  97059. * Gets the actual number of layers of the texture.
  97060. * @returns the number of layers
  97061. */
  97062. getRenderLayers(): number;
  97063. /**
  97064. * Get if the texture can be rescaled or not.
  97065. */
  97066. get canRescale(): boolean;
  97067. /**
  97068. * Resize the texture using a ratio.
  97069. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  97070. */
  97071. scale(ratio: number): void;
  97072. /**
  97073. * Get the texture reflection matrix used to rotate/transform the reflection.
  97074. * @returns the reflection matrix
  97075. */
  97076. getReflectionTextureMatrix(): Matrix;
  97077. /**
  97078. * Resize the texture to a new desired size.
  97079. * Be carrefull as it will recreate all the data in the new texture.
  97080. * @param size Define the new size. It can be:
  97081. * - a number for squared texture,
  97082. * - an object containing { width: number, height: number }
  97083. * - or an object containing a ratio { ratio: number }
  97084. */
  97085. resize(size: number | {
  97086. width: number;
  97087. height: number;
  97088. } | {
  97089. ratio: number;
  97090. }): void;
  97091. private _defaultRenderListPrepared;
  97092. /**
  97093. * Renders all the objects from the render list into the texture.
  97094. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  97095. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  97096. */
  97097. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  97098. private _bestReflectionRenderTargetDimension;
  97099. private _prepareRenderingManager;
  97100. /**
  97101. * @hidden
  97102. * @param faceIndex face index to bind to if this is a cubetexture
  97103. * @param layer defines the index of the texture to bind in the array
  97104. */
  97105. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  97106. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  97107. private renderToTarget;
  97108. /**
  97109. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97110. * This allowed control for front to back rendering or reversly depending of the special needs.
  97111. *
  97112. * @param renderingGroupId The rendering group id corresponding to its index
  97113. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97114. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97115. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97116. */
  97117. 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;
  97118. /**
  97119. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97120. *
  97121. * @param renderingGroupId The rendering group id corresponding to its index
  97122. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97123. */
  97124. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  97125. /**
  97126. * Clones the texture.
  97127. * @returns the cloned texture
  97128. */
  97129. clone(): RenderTargetTexture;
  97130. /**
  97131. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  97132. * @returns The JSON representation of the texture
  97133. */
  97134. serialize(): any;
  97135. /**
  97136. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  97137. */
  97138. disposeFramebufferObjects(): void;
  97139. /**
  97140. * Dispose the texture and release its associated resources.
  97141. */
  97142. dispose(): void;
  97143. /** @hidden */
  97144. _rebuild(): void;
  97145. /**
  97146. * Clear the info related to rendering groups preventing retention point in material dispose.
  97147. */
  97148. freeRenderingGroups(): void;
  97149. /**
  97150. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97151. * @returns the view count
  97152. */
  97153. getViewCount(): number;
  97154. }
  97155. }
  97156. declare module BABYLON {
  97157. /**
  97158. * Class used to manipulate GUIDs
  97159. */
  97160. export class GUID {
  97161. /**
  97162. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97163. * Be aware Math.random() could cause collisions, but:
  97164. * "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"
  97165. * @returns a pseudo random id
  97166. */
  97167. static RandomId(): string;
  97168. }
  97169. }
  97170. declare module BABYLON {
  97171. /**
  97172. * Options to be used when creating a shadow depth material
  97173. */
  97174. export interface IIOptionShadowDepthMaterial {
  97175. /** Variables in the vertex shader code that need to have their names remapped.
  97176. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  97177. * "var_name" should be either: worldPos or vNormalW
  97178. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  97179. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  97180. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  97181. */
  97182. remappedVariables?: string[];
  97183. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  97184. standalone?: boolean;
  97185. }
  97186. /**
  97187. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  97188. */
  97189. export class ShadowDepthWrapper {
  97190. private _scene;
  97191. private _options?;
  97192. private _baseMaterial;
  97193. private _onEffectCreatedObserver;
  97194. private _subMeshToEffect;
  97195. private _subMeshToDepthEffect;
  97196. private _meshes;
  97197. /** @hidden */
  97198. _matriceNames: any;
  97199. /** Gets the standalone status of the wrapper */
  97200. get standalone(): boolean;
  97201. /** Gets the base material the wrapper is built upon */
  97202. get baseMaterial(): Material;
  97203. /**
  97204. * Instantiate a new shadow depth wrapper.
  97205. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  97206. * generate the shadow depth map. For more information, please refer to the documentation:
  97207. * https://doc.babylonjs.com/babylon101/shadows
  97208. * @param baseMaterial Material to wrap
  97209. * @param scene Define the scene the material belongs to
  97210. * @param options Options used to create the wrapper
  97211. */
  97212. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  97213. /**
  97214. * Gets the effect to use to generate the depth map
  97215. * @param subMesh subMesh to get the effect for
  97216. * @param shadowGenerator shadow generator to get the effect for
  97217. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  97218. */
  97219. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  97220. /**
  97221. * Specifies that the submesh is ready to be used for depth rendering
  97222. * @param subMesh submesh to check
  97223. * @param defines the list of defines to take into account when checking the effect
  97224. * @param shadowGenerator combined with subMesh, it defines the effect to check
  97225. * @param useInstances specifies that instances should be used
  97226. * @returns a boolean indicating that the submesh is ready or not
  97227. */
  97228. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  97229. /**
  97230. * Disposes the resources
  97231. */
  97232. dispose(): void;
  97233. private _makeEffect;
  97234. }
  97235. }
  97236. declare module BABYLON {
  97237. /**
  97238. * Options for compiling materials.
  97239. */
  97240. export interface IMaterialCompilationOptions {
  97241. /**
  97242. * Defines whether clip planes are enabled.
  97243. */
  97244. clipPlane: boolean;
  97245. /**
  97246. * Defines whether instances are enabled.
  97247. */
  97248. useInstances: boolean;
  97249. }
  97250. /**
  97251. * Base class for the main features of a material in Babylon.js
  97252. */
  97253. export class Material implements IAnimatable {
  97254. /**
  97255. * Returns the triangle fill mode
  97256. */
  97257. static readonly TriangleFillMode: number;
  97258. /**
  97259. * Returns the wireframe mode
  97260. */
  97261. static readonly WireFrameFillMode: number;
  97262. /**
  97263. * Returns the point fill mode
  97264. */
  97265. static readonly PointFillMode: number;
  97266. /**
  97267. * Returns the point list draw mode
  97268. */
  97269. static readonly PointListDrawMode: number;
  97270. /**
  97271. * Returns the line list draw mode
  97272. */
  97273. static readonly LineListDrawMode: number;
  97274. /**
  97275. * Returns the line loop draw mode
  97276. */
  97277. static readonly LineLoopDrawMode: number;
  97278. /**
  97279. * Returns the line strip draw mode
  97280. */
  97281. static readonly LineStripDrawMode: number;
  97282. /**
  97283. * Returns the triangle strip draw mode
  97284. */
  97285. static readonly TriangleStripDrawMode: number;
  97286. /**
  97287. * Returns the triangle fan draw mode
  97288. */
  97289. static readonly TriangleFanDrawMode: number;
  97290. /**
  97291. * Stores the clock-wise side orientation
  97292. */
  97293. static readonly ClockWiseSideOrientation: number;
  97294. /**
  97295. * Stores the counter clock-wise side orientation
  97296. */
  97297. static readonly CounterClockWiseSideOrientation: number;
  97298. /**
  97299. * The dirty texture flag value
  97300. */
  97301. static readonly TextureDirtyFlag: number;
  97302. /**
  97303. * The dirty light flag value
  97304. */
  97305. static readonly LightDirtyFlag: number;
  97306. /**
  97307. * The dirty fresnel flag value
  97308. */
  97309. static readonly FresnelDirtyFlag: number;
  97310. /**
  97311. * The dirty attribute flag value
  97312. */
  97313. static readonly AttributesDirtyFlag: number;
  97314. /**
  97315. * The dirty misc flag value
  97316. */
  97317. static readonly MiscDirtyFlag: number;
  97318. /**
  97319. * The all dirty flag value
  97320. */
  97321. static readonly AllDirtyFlag: number;
  97322. /**
  97323. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  97324. */
  97325. static readonly MATERIAL_OPAQUE: number;
  97326. /**
  97327. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  97328. */
  97329. static readonly MATERIAL_ALPHATEST: number;
  97330. /**
  97331. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97332. */
  97333. static readonly MATERIAL_ALPHABLEND: number;
  97334. /**
  97335. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97336. * They are also discarded below the alpha cutoff threshold to improve performances.
  97337. */
  97338. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  97339. /**
  97340. * Custom callback helping to override the default shader used in the material.
  97341. */
  97342. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  97343. /**
  97344. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  97345. */
  97346. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  97347. /**
  97348. * The ID of the material
  97349. */
  97350. id: string;
  97351. /**
  97352. * Gets or sets the unique id of the material
  97353. */
  97354. uniqueId: number;
  97355. /**
  97356. * The name of the material
  97357. */
  97358. name: string;
  97359. /**
  97360. * Gets or sets user defined metadata
  97361. */
  97362. metadata: any;
  97363. /**
  97364. * For internal use only. Please do not use.
  97365. */
  97366. reservedDataStore: any;
  97367. /**
  97368. * Specifies if the ready state should be checked on each call
  97369. */
  97370. checkReadyOnEveryCall: boolean;
  97371. /**
  97372. * Specifies if the ready state should be checked once
  97373. */
  97374. checkReadyOnlyOnce: boolean;
  97375. /**
  97376. * The state of the material
  97377. */
  97378. state: string;
  97379. /**
  97380. * The alpha value of the material
  97381. */
  97382. protected _alpha: number;
  97383. /**
  97384. * List of inspectable custom properties (used by the Inspector)
  97385. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97386. */
  97387. inspectableCustomProperties: IInspectable[];
  97388. /**
  97389. * Sets the alpha value of the material
  97390. */
  97391. set alpha(value: number);
  97392. /**
  97393. * Gets the alpha value of the material
  97394. */
  97395. get alpha(): number;
  97396. /**
  97397. * Specifies if back face culling is enabled
  97398. */
  97399. protected _backFaceCulling: boolean;
  97400. /**
  97401. * Sets the back-face culling state
  97402. */
  97403. set backFaceCulling(value: boolean);
  97404. /**
  97405. * Gets the back-face culling state
  97406. */
  97407. get backFaceCulling(): boolean;
  97408. /**
  97409. * Stores the value for side orientation
  97410. */
  97411. sideOrientation: number;
  97412. /**
  97413. * Callback triggered when the material is compiled
  97414. */
  97415. onCompiled: Nullable<(effect: Effect) => void>;
  97416. /**
  97417. * Callback triggered when an error occurs
  97418. */
  97419. onError: Nullable<(effect: Effect, errors: string) => void>;
  97420. /**
  97421. * Callback triggered to get the render target textures
  97422. */
  97423. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  97424. /**
  97425. * Gets a boolean indicating that current material needs to register RTT
  97426. */
  97427. get hasRenderTargetTextures(): boolean;
  97428. /**
  97429. * Specifies if the material should be serialized
  97430. */
  97431. doNotSerialize: boolean;
  97432. /**
  97433. * @hidden
  97434. */
  97435. _storeEffectOnSubMeshes: boolean;
  97436. /**
  97437. * Stores the animations for the material
  97438. */
  97439. animations: Nullable<Array<Animation>>;
  97440. /**
  97441. * An event triggered when the material is disposed
  97442. */
  97443. onDisposeObservable: Observable<Material>;
  97444. /**
  97445. * An observer which watches for dispose events
  97446. */
  97447. private _onDisposeObserver;
  97448. private _onUnBindObservable;
  97449. /**
  97450. * Called during a dispose event
  97451. */
  97452. set onDispose(callback: () => void);
  97453. private _onBindObservable;
  97454. /**
  97455. * An event triggered when the material is bound
  97456. */
  97457. get onBindObservable(): Observable<AbstractMesh>;
  97458. /**
  97459. * An observer which watches for bind events
  97460. */
  97461. private _onBindObserver;
  97462. /**
  97463. * Called during a bind event
  97464. */
  97465. set onBind(callback: (Mesh: AbstractMesh) => void);
  97466. /**
  97467. * An event triggered when the material is unbound
  97468. */
  97469. get onUnBindObservable(): Observable<Material>;
  97470. protected _onEffectCreatedObservable: Nullable<Observable<{
  97471. effect: Effect;
  97472. subMesh: Nullable<SubMesh>;
  97473. }>>;
  97474. /**
  97475. * An event triggered when the effect is (re)created
  97476. */
  97477. get onEffectCreatedObservable(): Observable<{
  97478. effect: Effect;
  97479. subMesh: Nullable<SubMesh>;
  97480. }>;
  97481. /**
  97482. * Stores the value of the alpha mode
  97483. */
  97484. private _alphaMode;
  97485. /**
  97486. * Sets the value of the alpha mode.
  97487. *
  97488. * | Value | Type | Description |
  97489. * | --- | --- | --- |
  97490. * | 0 | ALPHA_DISABLE | |
  97491. * | 1 | ALPHA_ADD | |
  97492. * | 2 | ALPHA_COMBINE | |
  97493. * | 3 | ALPHA_SUBTRACT | |
  97494. * | 4 | ALPHA_MULTIPLY | |
  97495. * | 5 | ALPHA_MAXIMIZED | |
  97496. * | 6 | ALPHA_ONEONE | |
  97497. * | 7 | ALPHA_PREMULTIPLIED | |
  97498. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  97499. * | 9 | ALPHA_INTERPOLATE | |
  97500. * | 10 | ALPHA_SCREENMODE | |
  97501. *
  97502. */
  97503. set alphaMode(value: number);
  97504. /**
  97505. * Gets the value of the alpha mode
  97506. */
  97507. get alphaMode(): number;
  97508. /**
  97509. * Stores the state of the need depth pre-pass value
  97510. */
  97511. private _needDepthPrePass;
  97512. /**
  97513. * Sets the need depth pre-pass value
  97514. */
  97515. set needDepthPrePass(value: boolean);
  97516. /**
  97517. * Gets the depth pre-pass value
  97518. */
  97519. get needDepthPrePass(): boolean;
  97520. /**
  97521. * Specifies if depth writing should be disabled
  97522. */
  97523. disableDepthWrite: boolean;
  97524. /**
  97525. * Specifies if color writing should be disabled
  97526. */
  97527. disableColorWrite: boolean;
  97528. /**
  97529. * Specifies if depth writing should be forced
  97530. */
  97531. forceDepthWrite: boolean;
  97532. /**
  97533. * Specifies the depth function that should be used. 0 means the default engine function
  97534. */
  97535. depthFunction: number;
  97536. /**
  97537. * Specifies if there should be a separate pass for culling
  97538. */
  97539. separateCullingPass: boolean;
  97540. /**
  97541. * Stores the state specifing if fog should be enabled
  97542. */
  97543. private _fogEnabled;
  97544. /**
  97545. * Sets the state for enabling fog
  97546. */
  97547. set fogEnabled(value: boolean);
  97548. /**
  97549. * Gets the value of the fog enabled state
  97550. */
  97551. get fogEnabled(): boolean;
  97552. /**
  97553. * Stores the size of points
  97554. */
  97555. pointSize: number;
  97556. /**
  97557. * Stores the z offset value
  97558. */
  97559. zOffset: number;
  97560. get wireframe(): boolean;
  97561. /**
  97562. * Sets the state of wireframe mode
  97563. */
  97564. set wireframe(value: boolean);
  97565. /**
  97566. * Gets the value specifying if point clouds are enabled
  97567. */
  97568. get pointsCloud(): boolean;
  97569. /**
  97570. * Sets the state of point cloud mode
  97571. */
  97572. set pointsCloud(value: boolean);
  97573. /**
  97574. * Gets the material fill mode
  97575. */
  97576. get fillMode(): number;
  97577. /**
  97578. * Sets the material fill mode
  97579. */
  97580. set fillMode(value: number);
  97581. /**
  97582. * @hidden
  97583. * Stores the effects for the material
  97584. */
  97585. _effect: Nullable<Effect>;
  97586. /**
  97587. * Specifies if uniform buffers should be used
  97588. */
  97589. private _useUBO;
  97590. /**
  97591. * Stores a reference to the scene
  97592. */
  97593. private _scene;
  97594. /**
  97595. * Stores the fill mode state
  97596. */
  97597. private _fillMode;
  97598. /**
  97599. * Specifies if the depth write state should be cached
  97600. */
  97601. private _cachedDepthWriteState;
  97602. /**
  97603. * Specifies if the color write state should be cached
  97604. */
  97605. private _cachedColorWriteState;
  97606. /**
  97607. * Specifies if the depth function state should be cached
  97608. */
  97609. private _cachedDepthFunctionState;
  97610. /**
  97611. * Stores the uniform buffer
  97612. */
  97613. protected _uniformBuffer: UniformBuffer;
  97614. /** @hidden */
  97615. _indexInSceneMaterialArray: number;
  97616. /** @hidden */
  97617. meshMap: Nullable<{
  97618. [id: string]: AbstractMesh | undefined;
  97619. }>;
  97620. /**
  97621. * Creates a material instance
  97622. * @param name defines the name of the material
  97623. * @param scene defines the scene to reference
  97624. * @param doNotAdd specifies if the material should be added to the scene
  97625. */
  97626. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  97627. /**
  97628. * Returns a string representation of the current material
  97629. * @param fullDetails defines a boolean indicating which levels of logging is desired
  97630. * @returns a string with material information
  97631. */
  97632. toString(fullDetails?: boolean): string;
  97633. /**
  97634. * Gets the class name of the material
  97635. * @returns a string with the class name of the material
  97636. */
  97637. getClassName(): string;
  97638. /**
  97639. * Specifies if updates for the material been locked
  97640. */
  97641. get isFrozen(): boolean;
  97642. /**
  97643. * Locks updates for the material
  97644. */
  97645. freeze(): void;
  97646. /**
  97647. * Unlocks updates for the material
  97648. */
  97649. unfreeze(): void;
  97650. /**
  97651. * Specifies if the material is ready to be used
  97652. * @param mesh defines the mesh to check
  97653. * @param useInstances specifies if instances should be used
  97654. * @returns a boolean indicating if the material is ready to be used
  97655. */
  97656. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97657. /**
  97658. * Specifies that the submesh is ready to be used
  97659. * @param mesh defines the mesh to check
  97660. * @param subMesh defines which submesh to check
  97661. * @param useInstances specifies that instances should be used
  97662. * @returns a boolean indicating that the submesh is ready or not
  97663. */
  97664. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97665. /**
  97666. * Returns the material effect
  97667. * @returns the effect associated with the material
  97668. */
  97669. getEffect(): Nullable<Effect>;
  97670. /**
  97671. * Returns the current scene
  97672. * @returns a Scene
  97673. */
  97674. getScene(): Scene;
  97675. /**
  97676. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  97677. */
  97678. protected _forceAlphaTest: boolean;
  97679. /**
  97680. * The transparency mode of the material.
  97681. */
  97682. protected _transparencyMode: Nullable<number>;
  97683. /**
  97684. * Gets the current transparency mode.
  97685. */
  97686. get transparencyMode(): Nullable<number>;
  97687. /**
  97688. * Sets the transparency mode of the material.
  97689. *
  97690. * | Value | Type | Description |
  97691. * | ----- | ----------------------------------- | ----------- |
  97692. * | 0 | OPAQUE | |
  97693. * | 1 | ALPHATEST | |
  97694. * | 2 | ALPHABLEND | |
  97695. * | 3 | ALPHATESTANDBLEND | |
  97696. *
  97697. */
  97698. set transparencyMode(value: Nullable<number>);
  97699. /**
  97700. * Returns true if alpha blending should be disabled.
  97701. */
  97702. protected get _disableAlphaBlending(): boolean;
  97703. /**
  97704. * Specifies whether or not this material should be rendered in alpha blend mode.
  97705. * @returns a boolean specifying if alpha blending is needed
  97706. */
  97707. needAlphaBlending(): boolean;
  97708. /**
  97709. * Specifies if the mesh will require alpha blending
  97710. * @param mesh defines the mesh to check
  97711. * @returns a boolean specifying if alpha blending is needed for the mesh
  97712. */
  97713. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  97714. /**
  97715. * Specifies whether or not this material should be rendered in alpha test mode.
  97716. * @returns a boolean specifying if an alpha test is needed.
  97717. */
  97718. needAlphaTesting(): boolean;
  97719. /**
  97720. * Specifies if material alpha testing should be turned on for the mesh
  97721. * @param mesh defines the mesh to check
  97722. */
  97723. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  97724. /**
  97725. * Gets the texture used for the alpha test
  97726. * @returns the texture to use for alpha testing
  97727. */
  97728. getAlphaTestTexture(): Nullable<BaseTexture>;
  97729. /**
  97730. * Marks the material to indicate that it needs to be re-calculated
  97731. */
  97732. markDirty(): void;
  97733. /** @hidden */
  97734. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  97735. /**
  97736. * Binds the material to the mesh
  97737. * @param world defines the world transformation matrix
  97738. * @param mesh defines the mesh to bind the material to
  97739. */
  97740. bind(world: Matrix, mesh?: Mesh): void;
  97741. /**
  97742. * Binds the submesh to the material
  97743. * @param world defines the world transformation matrix
  97744. * @param mesh defines the mesh containing the submesh
  97745. * @param subMesh defines the submesh to bind the material to
  97746. */
  97747. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97748. /**
  97749. * Binds the world matrix to the material
  97750. * @param world defines the world transformation matrix
  97751. */
  97752. bindOnlyWorldMatrix(world: Matrix): void;
  97753. /**
  97754. * Binds the scene's uniform buffer to the effect.
  97755. * @param effect defines the effect to bind to the scene uniform buffer
  97756. * @param sceneUbo defines the uniform buffer storing scene data
  97757. */
  97758. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  97759. /**
  97760. * Binds the view matrix to the effect
  97761. * @param effect defines the effect to bind the view matrix to
  97762. */
  97763. bindView(effect: Effect): void;
  97764. /**
  97765. * Binds the view projection matrix to the effect
  97766. * @param effect defines the effect to bind the view projection matrix to
  97767. */
  97768. bindViewProjection(effect: Effect): void;
  97769. /**
  97770. * Processes to execute after binding the material to a mesh
  97771. * @param mesh defines the rendered mesh
  97772. */
  97773. protected _afterBind(mesh?: Mesh): void;
  97774. /**
  97775. * Unbinds the material from the mesh
  97776. */
  97777. unbind(): void;
  97778. /**
  97779. * Gets the active textures from the material
  97780. * @returns an array of textures
  97781. */
  97782. getActiveTextures(): BaseTexture[];
  97783. /**
  97784. * Specifies if the material uses a texture
  97785. * @param texture defines the texture to check against the material
  97786. * @returns a boolean specifying if the material uses the texture
  97787. */
  97788. hasTexture(texture: BaseTexture): boolean;
  97789. /**
  97790. * Makes a duplicate of the material, and gives it a new name
  97791. * @param name defines the new name for the duplicated material
  97792. * @returns the cloned material
  97793. */
  97794. clone(name: string): Nullable<Material>;
  97795. /**
  97796. * Gets the meshes bound to the material
  97797. * @returns an array of meshes bound to the material
  97798. */
  97799. getBindedMeshes(): AbstractMesh[];
  97800. /**
  97801. * Force shader compilation
  97802. * @param mesh defines the mesh associated with this material
  97803. * @param onCompiled defines a function to execute once the material is compiled
  97804. * @param options defines the options to configure the compilation
  97805. * @param onError defines a function to execute if the material fails compiling
  97806. */
  97807. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  97808. /**
  97809. * Force shader compilation
  97810. * @param mesh defines the mesh that will use this material
  97811. * @param options defines additional options for compiling the shaders
  97812. * @returns a promise that resolves when the compilation completes
  97813. */
  97814. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  97815. private static readonly _AllDirtyCallBack;
  97816. private static readonly _ImageProcessingDirtyCallBack;
  97817. private static readonly _TextureDirtyCallBack;
  97818. private static readonly _FresnelDirtyCallBack;
  97819. private static readonly _MiscDirtyCallBack;
  97820. private static readonly _LightsDirtyCallBack;
  97821. private static readonly _AttributeDirtyCallBack;
  97822. private static _FresnelAndMiscDirtyCallBack;
  97823. private static _TextureAndMiscDirtyCallBack;
  97824. private static readonly _DirtyCallbackArray;
  97825. private static readonly _RunDirtyCallBacks;
  97826. /**
  97827. * Marks a define in the material to indicate that it needs to be re-computed
  97828. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  97829. */
  97830. markAsDirty(flag: number): void;
  97831. /**
  97832. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  97833. * @param func defines a function which checks material defines against the submeshes
  97834. */
  97835. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  97836. /**
  97837. * Indicates that we need to re-calculated for all submeshes
  97838. */
  97839. protected _markAllSubMeshesAsAllDirty(): void;
  97840. /**
  97841. * Indicates that image processing needs to be re-calculated for all submeshes
  97842. */
  97843. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  97844. /**
  97845. * Indicates that textures need to be re-calculated for all submeshes
  97846. */
  97847. protected _markAllSubMeshesAsTexturesDirty(): void;
  97848. /**
  97849. * Indicates that fresnel needs to be re-calculated for all submeshes
  97850. */
  97851. protected _markAllSubMeshesAsFresnelDirty(): void;
  97852. /**
  97853. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  97854. */
  97855. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  97856. /**
  97857. * Indicates that lights need to be re-calculated for all submeshes
  97858. */
  97859. protected _markAllSubMeshesAsLightsDirty(): void;
  97860. /**
  97861. * Indicates that attributes need to be re-calculated for all submeshes
  97862. */
  97863. protected _markAllSubMeshesAsAttributesDirty(): void;
  97864. /**
  97865. * Indicates that misc needs to be re-calculated for all submeshes
  97866. */
  97867. protected _markAllSubMeshesAsMiscDirty(): void;
  97868. /**
  97869. * Indicates that textures and misc need to be re-calculated for all submeshes
  97870. */
  97871. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  97872. /**
  97873. * Disposes the material
  97874. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97875. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97876. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97877. */
  97878. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97879. /** @hidden */
  97880. private releaseVertexArrayObject;
  97881. /**
  97882. * Serializes this material
  97883. * @returns the serialized material object
  97884. */
  97885. serialize(): any;
  97886. /**
  97887. * Creates a material from parsed material data
  97888. * @param parsedMaterial defines parsed material data
  97889. * @param scene defines the hosting scene
  97890. * @param rootUrl defines the root URL to use to load textures
  97891. * @returns a new material
  97892. */
  97893. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  97894. }
  97895. }
  97896. declare module BABYLON {
  97897. /**
  97898. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97899. * separate meshes. This can be use to improve performances.
  97900. * @see http://doc.babylonjs.com/how_to/multi_materials
  97901. */
  97902. export class MultiMaterial extends Material {
  97903. private _subMaterials;
  97904. /**
  97905. * Gets or Sets the list of Materials used within the multi material.
  97906. * They need to be ordered according to the submeshes order in the associated mesh
  97907. */
  97908. get subMaterials(): Nullable<Material>[];
  97909. set subMaterials(value: Nullable<Material>[]);
  97910. /**
  97911. * Function used to align with Node.getChildren()
  97912. * @returns the list of Materials used within the multi material
  97913. */
  97914. getChildren(): Nullable<Material>[];
  97915. /**
  97916. * Instantiates a new Multi Material
  97917. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97918. * separate meshes. This can be use to improve performances.
  97919. * @see http://doc.babylonjs.com/how_to/multi_materials
  97920. * @param name Define the name in the scene
  97921. * @param scene Define the scene the material belongs to
  97922. */
  97923. constructor(name: string, scene: Scene);
  97924. private _hookArray;
  97925. /**
  97926. * Get one of the submaterial by its index in the submaterials array
  97927. * @param index The index to look the sub material at
  97928. * @returns The Material if the index has been defined
  97929. */
  97930. getSubMaterial(index: number): Nullable<Material>;
  97931. /**
  97932. * Get the list of active textures for the whole sub materials list.
  97933. * @returns All the textures that will be used during the rendering
  97934. */
  97935. getActiveTextures(): BaseTexture[];
  97936. /**
  97937. * Gets the current class name of the material e.g. "MultiMaterial"
  97938. * Mainly use in serialization.
  97939. * @returns the class name
  97940. */
  97941. getClassName(): string;
  97942. /**
  97943. * Checks if the material is ready to render the requested sub mesh
  97944. * @param mesh Define the mesh the submesh belongs to
  97945. * @param subMesh Define the sub mesh to look readyness for
  97946. * @param useInstances Define whether or not the material is used with instances
  97947. * @returns true if ready, otherwise false
  97948. */
  97949. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97950. /**
  97951. * Clones the current material and its related sub materials
  97952. * @param name Define the name of the newly cloned material
  97953. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  97954. * @returns the cloned material
  97955. */
  97956. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  97957. /**
  97958. * Serializes the materials into a JSON representation.
  97959. * @returns the JSON representation
  97960. */
  97961. serialize(): any;
  97962. /**
  97963. * Dispose the material and release its associated resources
  97964. * @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)
  97965. * @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)
  97966. * @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)
  97967. */
  97968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  97969. /**
  97970. * Creates a MultiMaterial from parsed MultiMaterial data.
  97971. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  97972. * @param scene defines the hosting scene
  97973. * @returns a new MultiMaterial
  97974. */
  97975. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  97976. }
  97977. }
  97978. declare module BABYLON {
  97979. /**
  97980. * Base class for submeshes
  97981. */
  97982. export class BaseSubMesh {
  97983. /** @hidden */
  97984. _materialDefines: Nullable<MaterialDefines>;
  97985. /** @hidden */
  97986. _materialEffect: Nullable<Effect>;
  97987. /** @hidden */
  97988. _effectOverride: Nullable<Effect>;
  97989. /**
  97990. * Gets material defines used by the effect associated to the sub mesh
  97991. */
  97992. get materialDefines(): Nullable<MaterialDefines>;
  97993. /**
  97994. * Sets material defines used by the effect associated to the sub mesh
  97995. */
  97996. set materialDefines(defines: Nullable<MaterialDefines>);
  97997. /**
  97998. * Gets associated effect
  97999. */
  98000. get effect(): Nullable<Effect>;
  98001. /**
  98002. * Sets associated effect (effect used to render this submesh)
  98003. * @param effect defines the effect to associate with
  98004. * @param defines defines the set of defines used to compile this effect
  98005. */
  98006. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  98007. }
  98008. /**
  98009. * Defines a subdivision inside a mesh
  98010. */
  98011. export class SubMesh extends BaseSubMesh implements ICullable {
  98012. /** the material index to use */
  98013. materialIndex: number;
  98014. /** vertex index start */
  98015. verticesStart: number;
  98016. /** vertices count */
  98017. verticesCount: number;
  98018. /** index start */
  98019. indexStart: number;
  98020. /** indices count */
  98021. indexCount: number;
  98022. /** @hidden */
  98023. _linesIndexCount: number;
  98024. private _mesh;
  98025. private _renderingMesh;
  98026. private _boundingInfo;
  98027. private _linesIndexBuffer;
  98028. /** @hidden */
  98029. _lastColliderWorldVertices: Nullable<Vector3[]>;
  98030. /** @hidden */
  98031. _trianglePlanes: Plane[];
  98032. /** @hidden */
  98033. _lastColliderTransformMatrix: Nullable<Matrix>;
  98034. /** @hidden */
  98035. _renderId: number;
  98036. /** @hidden */
  98037. _alphaIndex: number;
  98038. /** @hidden */
  98039. _distanceToCamera: number;
  98040. /** @hidden */
  98041. _id: number;
  98042. private _currentMaterial;
  98043. /**
  98044. * Add a new submesh to a mesh
  98045. * @param materialIndex defines the material index to use
  98046. * @param verticesStart defines vertex index start
  98047. * @param verticesCount defines vertices count
  98048. * @param indexStart defines index start
  98049. * @param indexCount defines indices count
  98050. * @param mesh defines the parent mesh
  98051. * @param renderingMesh defines an optional rendering mesh
  98052. * @param createBoundingBox defines if bounding box should be created for this submesh
  98053. * @returns the new submesh
  98054. */
  98055. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  98056. /**
  98057. * Creates a new submesh
  98058. * @param materialIndex defines the material index to use
  98059. * @param verticesStart defines vertex index start
  98060. * @param verticesCount defines vertices count
  98061. * @param indexStart defines index start
  98062. * @param indexCount defines indices count
  98063. * @param mesh defines the parent mesh
  98064. * @param renderingMesh defines an optional rendering mesh
  98065. * @param createBoundingBox defines if bounding box should be created for this submesh
  98066. */
  98067. constructor(
  98068. /** the material index to use */
  98069. materialIndex: number,
  98070. /** vertex index start */
  98071. verticesStart: number,
  98072. /** vertices count */
  98073. verticesCount: number,
  98074. /** index start */
  98075. indexStart: number,
  98076. /** indices count */
  98077. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  98078. /**
  98079. * Returns true if this submesh covers the entire parent mesh
  98080. * @ignorenaming
  98081. */
  98082. get IsGlobal(): boolean;
  98083. /**
  98084. * Returns the submesh BoudingInfo object
  98085. * @returns current bounding info (or mesh's one if the submesh is global)
  98086. */
  98087. getBoundingInfo(): BoundingInfo;
  98088. /**
  98089. * Sets the submesh BoundingInfo
  98090. * @param boundingInfo defines the new bounding info to use
  98091. * @returns the SubMesh
  98092. */
  98093. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  98094. /**
  98095. * Returns the mesh of the current submesh
  98096. * @return the parent mesh
  98097. */
  98098. getMesh(): AbstractMesh;
  98099. /**
  98100. * Returns the rendering mesh of the submesh
  98101. * @returns the rendering mesh (could be different from parent mesh)
  98102. */
  98103. getRenderingMesh(): Mesh;
  98104. /**
  98105. * Returns the submesh material
  98106. * @returns null or the current material
  98107. */
  98108. getMaterial(): Nullable<Material>;
  98109. /**
  98110. * Sets a new updated BoundingInfo object to the submesh
  98111. * @param data defines an optional position array to use to determine the bounding info
  98112. * @returns the SubMesh
  98113. */
  98114. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  98115. /** @hidden */
  98116. _checkCollision(collider: Collider): boolean;
  98117. /**
  98118. * Updates the submesh BoundingInfo
  98119. * @param world defines the world matrix to use to update the bounding info
  98120. * @returns the submesh
  98121. */
  98122. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  98123. /**
  98124. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  98125. * @param frustumPlanes defines the frustum planes
  98126. * @returns true if the submesh is intersecting with the frustum
  98127. */
  98128. isInFrustum(frustumPlanes: Plane[]): boolean;
  98129. /**
  98130. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  98131. * @param frustumPlanes defines the frustum planes
  98132. * @returns true if the submesh is inside the frustum
  98133. */
  98134. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98135. /**
  98136. * Renders the submesh
  98137. * @param enableAlphaMode defines if alpha needs to be used
  98138. * @returns the submesh
  98139. */
  98140. render(enableAlphaMode: boolean): SubMesh;
  98141. /**
  98142. * @hidden
  98143. */
  98144. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  98145. /**
  98146. * Checks if the submesh intersects with a ray
  98147. * @param ray defines the ray to test
  98148. * @returns true is the passed ray intersects the submesh bounding box
  98149. */
  98150. canIntersects(ray: Ray): boolean;
  98151. /**
  98152. * Intersects current submesh with a ray
  98153. * @param ray defines the ray to test
  98154. * @param positions defines mesh's positions array
  98155. * @param indices defines mesh's indices array
  98156. * @param fastCheck defines if the first intersection will be used (and not the closest)
  98157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98158. * @returns intersection info or null if no intersection
  98159. */
  98160. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  98161. /** @hidden */
  98162. private _intersectLines;
  98163. /** @hidden */
  98164. private _intersectUnIndexedLines;
  98165. /** @hidden */
  98166. private _intersectTriangles;
  98167. /** @hidden */
  98168. private _intersectUnIndexedTriangles;
  98169. /** @hidden */
  98170. _rebuild(): void;
  98171. /**
  98172. * Creates a new submesh from the passed mesh
  98173. * @param newMesh defines the new hosting mesh
  98174. * @param newRenderingMesh defines an optional rendering mesh
  98175. * @returns the new submesh
  98176. */
  98177. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  98178. /**
  98179. * Release associated resources
  98180. */
  98181. dispose(): void;
  98182. /**
  98183. * Gets the class name
  98184. * @returns the string "SubMesh".
  98185. */
  98186. getClassName(): string;
  98187. /**
  98188. * Creates a new submesh from indices data
  98189. * @param materialIndex the index of the main mesh material
  98190. * @param startIndex the index where to start the copy in the mesh indices array
  98191. * @param indexCount the number of indices to copy then from the startIndex
  98192. * @param mesh the main mesh to create the submesh from
  98193. * @param renderingMesh the optional rendering mesh
  98194. * @returns a new submesh
  98195. */
  98196. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  98197. }
  98198. }
  98199. declare module BABYLON {
  98200. /**
  98201. * Class used to represent data loading progression
  98202. */
  98203. export class SceneLoaderFlags {
  98204. private static _ForceFullSceneLoadingForIncremental;
  98205. private static _ShowLoadingScreen;
  98206. private static _CleanBoneMatrixWeights;
  98207. private static _loggingLevel;
  98208. /**
  98209. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98210. */
  98211. static get ForceFullSceneLoadingForIncremental(): boolean;
  98212. static set ForceFullSceneLoadingForIncremental(value: boolean);
  98213. /**
  98214. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98215. */
  98216. static get ShowLoadingScreen(): boolean;
  98217. static set ShowLoadingScreen(value: boolean);
  98218. /**
  98219. * Defines the current logging level (while loading the scene)
  98220. * @ignorenaming
  98221. */
  98222. static get loggingLevel(): number;
  98223. static set loggingLevel(value: number);
  98224. /**
  98225. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98226. */
  98227. static get CleanBoneMatrixWeights(): boolean;
  98228. static set CleanBoneMatrixWeights(value: boolean);
  98229. }
  98230. }
  98231. declare module BABYLON {
  98232. /**
  98233. * Class used to store geometry data (vertex buffers + index buffer)
  98234. */
  98235. export class Geometry implements IGetSetVerticesData {
  98236. /**
  98237. * Gets or sets the ID of the geometry
  98238. */
  98239. id: string;
  98240. /**
  98241. * Gets or sets the unique ID of the geometry
  98242. */
  98243. uniqueId: number;
  98244. /**
  98245. * Gets the delay loading state of the geometry (none by default which means not delayed)
  98246. */
  98247. delayLoadState: number;
  98248. /**
  98249. * Gets the file containing the data to load when running in delay load state
  98250. */
  98251. delayLoadingFile: Nullable<string>;
  98252. /**
  98253. * Callback called when the geometry is updated
  98254. */
  98255. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  98256. private _scene;
  98257. private _engine;
  98258. private _meshes;
  98259. private _totalVertices;
  98260. /** @hidden */
  98261. _indices: IndicesArray;
  98262. /** @hidden */
  98263. _vertexBuffers: {
  98264. [key: string]: VertexBuffer;
  98265. };
  98266. private _isDisposed;
  98267. private _extend;
  98268. private _boundingBias;
  98269. /** @hidden */
  98270. _delayInfo: Array<string>;
  98271. private _indexBuffer;
  98272. private _indexBufferIsUpdatable;
  98273. /** @hidden */
  98274. _boundingInfo: Nullable<BoundingInfo>;
  98275. /** @hidden */
  98276. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  98277. /** @hidden */
  98278. _softwareSkinningFrameId: number;
  98279. private _vertexArrayObjects;
  98280. private _updatable;
  98281. /** @hidden */
  98282. _positions: Nullable<Vector3[]>;
  98283. /**
  98284. * 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
  98285. */
  98286. get boundingBias(): Vector2;
  98287. /**
  98288. * 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
  98289. */
  98290. set boundingBias(value: Vector2);
  98291. /**
  98292. * Static function used to attach a new empty geometry to a mesh
  98293. * @param mesh defines the mesh to attach the geometry to
  98294. * @returns the new Geometry
  98295. */
  98296. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  98297. /** Get the list of meshes using this geometry */
  98298. get meshes(): Mesh[];
  98299. /**
  98300. * Creates a new geometry
  98301. * @param id defines the unique ID
  98302. * @param scene defines the hosting scene
  98303. * @param vertexData defines the VertexData used to get geometry data
  98304. * @param updatable defines if geometry must be updatable (false by default)
  98305. * @param mesh defines the mesh that will be associated with the geometry
  98306. */
  98307. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  98308. /**
  98309. * Gets the current extend of the geometry
  98310. */
  98311. get extend(): {
  98312. minimum: Vector3;
  98313. maximum: Vector3;
  98314. };
  98315. /**
  98316. * Gets the hosting scene
  98317. * @returns the hosting Scene
  98318. */
  98319. getScene(): Scene;
  98320. /**
  98321. * Gets the hosting engine
  98322. * @returns the hosting Engine
  98323. */
  98324. getEngine(): Engine;
  98325. /**
  98326. * Defines if the geometry is ready to use
  98327. * @returns true if the geometry is ready to be used
  98328. */
  98329. isReady(): boolean;
  98330. /**
  98331. * Gets a value indicating that the geometry should not be serialized
  98332. */
  98333. get doNotSerialize(): boolean;
  98334. /** @hidden */
  98335. _rebuild(): void;
  98336. /**
  98337. * Affects all geometry data in one call
  98338. * @param vertexData defines the geometry data
  98339. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  98340. */
  98341. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  98342. /**
  98343. * Set specific vertex data
  98344. * @param kind defines the data kind (Position, normal, etc...)
  98345. * @param data defines the vertex data to use
  98346. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98347. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98348. */
  98349. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  98350. /**
  98351. * Removes a specific vertex data
  98352. * @param kind defines the data kind (Position, normal, etc...)
  98353. */
  98354. removeVerticesData(kind: string): void;
  98355. /**
  98356. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  98357. * @param buffer defines the vertex buffer to use
  98358. * @param totalVertices defines the total number of vertices for position kind (could be null)
  98359. */
  98360. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  98361. /**
  98362. * Update a specific vertex buffer
  98363. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  98364. * It will do nothing if the buffer is not updatable
  98365. * @param kind defines the data kind (Position, normal, etc...)
  98366. * @param data defines the data to use
  98367. * @param offset defines the offset in the target buffer where to store the data
  98368. * @param useBytes set to true if the offset is in bytes
  98369. */
  98370. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  98371. /**
  98372. * Update a specific vertex buffer
  98373. * This function will create a new buffer if the current one is not updatable
  98374. * @param kind defines the data kind (Position, normal, etc...)
  98375. * @param data defines the data to use
  98376. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  98377. */
  98378. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  98379. private _updateBoundingInfo;
  98380. /** @hidden */
  98381. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  98382. /**
  98383. * Gets total number of vertices
  98384. * @returns the total number of vertices
  98385. */
  98386. getTotalVertices(): number;
  98387. /**
  98388. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98389. * @param kind defines the data kind (Position, normal, etc...)
  98390. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98391. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98392. * @returns a float array containing vertex data
  98393. */
  98394. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98395. /**
  98396. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  98397. * @param kind defines the data kind (Position, normal, etc...)
  98398. * @returns true if the vertex buffer with the specified kind is updatable
  98399. */
  98400. isVertexBufferUpdatable(kind: string): boolean;
  98401. /**
  98402. * Gets a specific vertex buffer
  98403. * @param kind defines the data kind (Position, normal, etc...)
  98404. * @returns a VertexBuffer
  98405. */
  98406. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98407. /**
  98408. * Returns all vertex buffers
  98409. * @return an object holding all vertex buffers indexed by kind
  98410. */
  98411. getVertexBuffers(): Nullable<{
  98412. [key: string]: VertexBuffer;
  98413. }>;
  98414. /**
  98415. * Gets a boolean indicating if specific vertex buffer is present
  98416. * @param kind defines the data kind (Position, normal, etc...)
  98417. * @returns true if data is present
  98418. */
  98419. isVerticesDataPresent(kind: string): boolean;
  98420. /**
  98421. * Gets a list of all attached data kinds (Position, normal, etc...)
  98422. * @returns a list of string containing all kinds
  98423. */
  98424. getVerticesDataKinds(): string[];
  98425. /**
  98426. * Update index buffer
  98427. * @param indices defines the indices to store in the index buffer
  98428. * @param offset defines the offset in the target buffer where to store the data
  98429. * @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)
  98430. */
  98431. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  98432. /**
  98433. * Creates a new index buffer
  98434. * @param indices defines the indices to store in the index buffer
  98435. * @param totalVertices defines the total number of vertices (could be null)
  98436. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98437. */
  98438. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  98439. /**
  98440. * Return the total number of indices
  98441. * @returns the total number of indices
  98442. */
  98443. getTotalIndices(): number;
  98444. /**
  98445. * Gets the index buffer array
  98446. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98447. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98448. * @returns the index buffer array
  98449. */
  98450. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98451. /**
  98452. * Gets the index buffer
  98453. * @return the index buffer
  98454. */
  98455. getIndexBuffer(): Nullable<DataBuffer>;
  98456. /** @hidden */
  98457. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  98458. /**
  98459. * Release the associated resources for a specific mesh
  98460. * @param mesh defines the source mesh
  98461. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  98462. */
  98463. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  98464. /**
  98465. * Apply current geometry to a given mesh
  98466. * @param mesh defines the mesh to apply geometry to
  98467. */
  98468. applyToMesh(mesh: Mesh): void;
  98469. private _updateExtend;
  98470. private _applyToMesh;
  98471. private notifyUpdate;
  98472. /**
  98473. * Load the geometry if it was flagged as delay loaded
  98474. * @param scene defines the hosting scene
  98475. * @param onLoaded defines a callback called when the geometry is loaded
  98476. */
  98477. load(scene: Scene, onLoaded?: () => void): void;
  98478. private _queueLoad;
  98479. /**
  98480. * Invert the geometry to move from a right handed system to a left handed one.
  98481. */
  98482. toLeftHanded(): void;
  98483. /** @hidden */
  98484. _resetPointsArrayCache(): void;
  98485. /** @hidden */
  98486. _generatePointsArray(): boolean;
  98487. /**
  98488. * Gets a value indicating if the geometry is disposed
  98489. * @returns true if the geometry was disposed
  98490. */
  98491. isDisposed(): boolean;
  98492. private _disposeVertexArrayObjects;
  98493. /**
  98494. * Free all associated resources
  98495. */
  98496. dispose(): void;
  98497. /**
  98498. * Clone the current geometry into a new geometry
  98499. * @param id defines the unique ID of the new geometry
  98500. * @returns a new geometry object
  98501. */
  98502. copy(id: string): Geometry;
  98503. /**
  98504. * Serialize the current geometry info (and not the vertices data) into a JSON object
  98505. * @return a JSON representation of the current geometry data (without the vertices data)
  98506. */
  98507. serialize(): any;
  98508. private toNumberArray;
  98509. /**
  98510. * Serialize all vertices data into a JSON oject
  98511. * @returns a JSON representation of the current geometry data
  98512. */
  98513. serializeVerticeData(): any;
  98514. /**
  98515. * Extracts a clone of a mesh geometry
  98516. * @param mesh defines the source mesh
  98517. * @param id defines the unique ID of the new geometry object
  98518. * @returns the new geometry object
  98519. */
  98520. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  98521. /**
  98522. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  98523. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98524. * Be aware Math.random() could cause collisions, but:
  98525. * "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"
  98526. * @returns a string containing a new GUID
  98527. */
  98528. static RandomId(): string;
  98529. /** @hidden */
  98530. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  98531. private static _CleanMatricesWeights;
  98532. /**
  98533. * Create a new geometry from persisted data (Using .babylon file format)
  98534. * @param parsedVertexData defines the persisted data
  98535. * @param scene defines the hosting scene
  98536. * @param rootUrl defines the root url to use to load assets (like delayed data)
  98537. * @returns the new geometry object
  98538. */
  98539. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  98540. }
  98541. }
  98542. declare module BABYLON {
  98543. /**
  98544. * Define an interface for all classes that will get and set the data on vertices
  98545. */
  98546. export interface IGetSetVerticesData {
  98547. /**
  98548. * Gets a boolean indicating if specific vertex data is present
  98549. * @param kind defines the vertex data kind to use
  98550. * @returns true is data kind is present
  98551. */
  98552. isVerticesDataPresent(kind: string): boolean;
  98553. /**
  98554. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98555. * @param kind defines the data kind (Position, normal, etc...)
  98556. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98558. * @returns a float array containing vertex data
  98559. */
  98560. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98561. /**
  98562. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98563. * @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.
  98564. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98565. * @returns the indices array or an empty array if the mesh has no geometry
  98566. */
  98567. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98568. /**
  98569. * Set specific vertex data
  98570. * @param kind defines the data kind (Position, normal, etc...)
  98571. * @param data defines the vertex data to use
  98572. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98573. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98574. */
  98575. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  98576. /**
  98577. * Update a specific associated vertex buffer
  98578. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98579. * - VertexBuffer.PositionKind
  98580. * - VertexBuffer.UVKind
  98581. * - VertexBuffer.UV2Kind
  98582. * - VertexBuffer.UV3Kind
  98583. * - VertexBuffer.UV4Kind
  98584. * - VertexBuffer.UV5Kind
  98585. * - VertexBuffer.UV6Kind
  98586. * - VertexBuffer.ColorKind
  98587. * - VertexBuffer.MatricesIndicesKind
  98588. * - VertexBuffer.MatricesIndicesExtraKind
  98589. * - VertexBuffer.MatricesWeightsKind
  98590. * - VertexBuffer.MatricesWeightsExtraKind
  98591. * @param data defines the data source
  98592. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98593. * @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)
  98594. */
  98595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  98596. /**
  98597. * Creates a new index buffer
  98598. * @param indices defines the indices to store in the index buffer
  98599. * @param totalVertices defines the total number of vertices (could be null)
  98600. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98601. */
  98602. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  98603. }
  98604. /**
  98605. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  98606. */
  98607. export class VertexData {
  98608. /**
  98609. * Mesh side orientation : usually the external or front surface
  98610. */
  98611. static readonly FRONTSIDE: number;
  98612. /**
  98613. * Mesh side orientation : usually the internal or back surface
  98614. */
  98615. static readonly BACKSIDE: number;
  98616. /**
  98617. * Mesh side orientation : both internal and external or front and back surfaces
  98618. */
  98619. static readonly DOUBLESIDE: number;
  98620. /**
  98621. * Mesh side orientation : by default, `FRONTSIDE`
  98622. */
  98623. static readonly DEFAULTSIDE: number;
  98624. /**
  98625. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  98626. */
  98627. positions: Nullable<FloatArray>;
  98628. /**
  98629. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  98630. */
  98631. normals: Nullable<FloatArray>;
  98632. /**
  98633. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  98634. */
  98635. tangents: Nullable<FloatArray>;
  98636. /**
  98637. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98638. */
  98639. uvs: Nullable<FloatArray>;
  98640. /**
  98641. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98642. */
  98643. uvs2: Nullable<FloatArray>;
  98644. /**
  98645. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98646. */
  98647. uvs3: Nullable<FloatArray>;
  98648. /**
  98649. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98650. */
  98651. uvs4: Nullable<FloatArray>;
  98652. /**
  98653. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98654. */
  98655. uvs5: Nullable<FloatArray>;
  98656. /**
  98657. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98658. */
  98659. uvs6: Nullable<FloatArray>;
  98660. /**
  98661. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  98662. */
  98663. colors: Nullable<FloatArray>;
  98664. /**
  98665. * 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).
  98666. */
  98667. matricesIndices: Nullable<FloatArray>;
  98668. /**
  98669. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  98670. */
  98671. matricesWeights: Nullable<FloatArray>;
  98672. /**
  98673. * An array extending the number of possible indices
  98674. */
  98675. matricesIndicesExtra: Nullable<FloatArray>;
  98676. /**
  98677. * An array extending the number of possible weights when the number of indices is extended
  98678. */
  98679. matricesWeightsExtra: Nullable<FloatArray>;
  98680. /**
  98681. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  98682. */
  98683. indices: Nullable<IndicesArray>;
  98684. /**
  98685. * Uses the passed data array to set the set the values for the specified kind of data
  98686. * @param data a linear array of floating numbers
  98687. * @param kind the type of data that is being set, eg positions, colors etc
  98688. */
  98689. set(data: FloatArray, kind: string): void;
  98690. /**
  98691. * Associates the vertexData to the passed Mesh.
  98692. * Sets it as updatable or not (default `false`)
  98693. * @param mesh the mesh the vertexData is applied to
  98694. * @param updatable when used and having the value true allows new data to update the vertexData
  98695. * @returns the VertexData
  98696. */
  98697. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  98698. /**
  98699. * Associates the vertexData to the passed Geometry.
  98700. * Sets it as updatable or not (default `false`)
  98701. * @param geometry the geometry the vertexData is applied to
  98702. * @param updatable when used and having the value true allows new data to update the vertexData
  98703. * @returns VertexData
  98704. */
  98705. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  98706. /**
  98707. * Updates the associated mesh
  98708. * @param mesh the mesh to be updated
  98709. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98710. * @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
  98711. * @returns VertexData
  98712. */
  98713. updateMesh(mesh: Mesh): VertexData;
  98714. /**
  98715. * Updates the associated geometry
  98716. * @param geometry the geometry to be updated
  98717. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98718. * @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
  98719. * @returns VertexData.
  98720. */
  98721. updateGeometry(geometry: Geometry): VertexData;
  98722. private _applyTo;
  98723. private _update;
  98724. /**
  98725. * Transforms each position and each normal of the vertexData according to the passed Matrix
  98726. * @param matrix the transforming matrix
  98727. * @returns the VertexData
  98728. */
  98729. transform(matrix: Matrix): VertexData;
  98730. /**
  98731. * Merges the passed VertexData into the current one
  98732. * @param other the VertexData to be merged into the current one
  98733. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  98734. * @returns the modified VertexData
  98735. */
  98736. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  98737. private _mergeElement;
  98738. private _validate;
  98739. /**
  98740. * Serializes the VertexData
  98741. * @returns a serialized object
  98742. */
  98743. serialize(): any;
  98744. /**
  98745. * Extracts the vertexData from a mesh
  98746. * @param mesh the mesh from which to extract the VertexData
  98747. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  98748. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98749. * @returns the object VertexData associated to the passed mesh
  98750. */
  98751. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98752. /**
  98753. * Extracts the vertexData from the geometry
  98754. * @param geometry the geometry from which to extract the VertexData
  98755. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  98756. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98757. * @returns the object VertexData associated to the passed mesh
  98758. */
  98759. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98760. private static _ExtractFrom;
  98761. /**
  98762. * Creates the VertexData for a Ribbon
  98763. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  98764. * * pathArray array of paths, each of which an array of successive Vector3
  98765. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  98766. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  98767. * * 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
  98768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98769. * * 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)
  98770. * * 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)
  98771. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  98772. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  98773. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  98774. * @returns the VertexData of the ribbon
  98775. */
  98776. static CreateRibbon(options: {
  98777. pathArray: Vector3[][];
  98778. closeArray?: boolean;
  98779. closePath?: boolean;
  98780. offset?: number;
  98781. sideOrientation?: number;
  98782. frontUVs?: Vector4;
  98783. backUVs?: Vector4;
  98784. invertUV?: boolean;
  98785. uvs?: Vector2[];
  98786. colors?: Color4[];
  98787. }): VertexData;
  98788. /**
  98789. * Creates the VertexData for a box
  98790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98791. * * size sets the width, height and depth of the box to the value of size, optional default 1
  98792. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  98793. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  98794. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  98795. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98796. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98798. * * 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)
  98799. * * 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)
  98800. * @returns the VertexData of the box
  98801. */
  98802. static CreateBox(options: {
  98803. size?: number;
  98804. width?: number;
  98805. height?: number;
  98806. depth?: number;
  98807. faceUV?: Vector4[];
  98808. faceColors?: Color4[];
  98809. sideOrientation?: number;
  98810. frontUVs?: Vector4;
  98811. backUVs?: Vector4;
  98812. }): VertexData;
  98813. /**
  98814. * Creates the VertexData for a tiled box
  98815. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98816. * * faceTiles sets the pattern, tile size and number of tiles for a face
  98817. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98818. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98820. * @returns the VertexData of the box
  98821. */
  98822. static CreateTiledBox(options: {
  98823. pattern?: number;
  98824. width?: number;
  98825. height?: number;
  98826. depth?: number;
  98827. tileSize?: number;
  98828. tileWidth?: number;
  98829. tileHeight?: number;
  98830. alignHorizontal?: number;
  98831. alignVertical?: number;
  98832. faceUV?: Vector4[];
  98833. faceColors?: Color4[];
  98834. sideOrientation?: number;
  98835. }): VertexData;
  98836. /**
  98837. * Creates the VertexData for a tiled plane
  98838. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98839. * * pattern a limited pattern arrangement depending on the number
  98840. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  98841. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  98842. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  98843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98844. * * 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)
  98845. * * 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)
  98846. * @returns the VertexData of the tiled plane
  98847. */
  98848. static CreateTiledPlane(options: {
  98849. pattern?: number;
  98850. tileSize?: number;
  98851. tileWidth?: number;
  98852. tileHeight?: number;
  98853. size?: number;
  98854. width?: number;
  98855. height?: number;
  98856. alignHorizontal?: number;
  98857. alignVertical?: number;
  98858. sideOrientation?: number;
  98859. frontUVs?: Vector4;
  98860. backUVs?: Vector4;
  98861. }): VertexData;
  98862. /**
  98863. * Creates the VertexData for an ellipsoid, defaults to a sphere
  98864. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98865. * * segments sets the number of horizontal strips optional, default 32
  98866. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  98867. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  98868. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  98869. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  98870. * * 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
  98871. * * 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
  98872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98873. * * 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)
  98874. * * 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)
  98875. * @returns the VertexData of the ellipsoid
  98876. */
  98877. static CreateSphere(options: {
  98878. segments?: number;
  98879. diameter?: number;
  98880. diameterX?: number;
  98881. diameterY?: number;
  98882. diameterZ?: number;
  98883. arc?: number;
  98884. slice?: number;
  98885. sideOrientation?: number;
  98886. frontUVs?: Vector4;
  98887. backUVs?: Vector4;
  98888. }): VertexData;
  98889. /**
  98890. * Creates the VertexData for a cylinder, cone or prism
  98891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98892. * * height sets the height (y direction) of the cylinder, optional, default 2
  98893. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  98894. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  98895. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  98896. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98897. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  98898. * * 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
  98899. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98900. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98901. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  98902. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  98903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98904. * * 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)
  98905. * * 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)
  98906. * @returns the VertexData of the cylinder, cone or prism
  98907. */
  98908. static CreateCylinder(options: {
  98909. height?: number;
  98910. diameterTop?: number;
  98911. diameterBottom?: number;
  98912. diameter?: number;
  98913. tessellation?: number;
  98914. subdivisions?: number;
  98915. arc?: number;
  98916. faceColors?: Color4[];
  98917. faceUV?: Vector4[];
  98918. hasRings?: boolean;
  98919. enclose?: boolean;
  98920. sideOrientation?: number;
  98921. frontUVs?: Vector4;
  98922. backUVs?: Vector4;
  98923. }): VertexData;
  98924. /**
  98925. * Creates the VertexData for a torus
  98926. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98927. * * diameter the diameter of the torus, optional default 1
  98928. * * thickness the diameter of the tube forming the torus, optional default 0.5
  98929. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98931. * * 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)
  98932. * * 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)
  98933. * @returns the VertexData of the torus
  98934. */
  98935. static CreateTorus(options: {
  98936. diameter?: number;
  98937. thickness?: number;
  98938. tessellation?: number;
  98939. sideOrientation?: number;
  98940. frontUVs?: Vector4;
  98941. backUVs?: Vector4;
  98942. }): VertexData;
  98943. /**
  98944. * Creates the VertexData of the LineSystem
  98945. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  98946. * - lines an array of lines, each line being an array of successive Vector3
  98947. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  98948. * @returns the VertexData of the LineSystem
  98949. */
  98950. static CreateLineSystem(options: {
  98951. lines: Vector3[][];
  98952. colors?: Nullable<Color4[][]>;
  98953. }): VertexData;
  98954. /**
  98955. * Create the VertexData for a DashedLines
  98956. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  98957. * - points an array successive Vector3
  98958. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  98959. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  98960. * - dashNb the intended total number of dashes, optional, default 200
  98961. * @returns the VertexData for the DashedLines
  98962. */
  98963. static CreateDashedLines(options: {
  98964. points: Vector3[];
  98965. dashSize?: number;
  98966. gapSize?: number;
  98967. dashNb?: number;
  98968. }): VertexData;
  98969. /**
  98970. * Creates the VertexData for a Ground
  98971. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98972. * - width the width (x direction) of the ground, optional, default 1
  98973. * - height the height (z direction) of the ground, optional, default 1
  98974. * - subdivisions the number of subdivisions per side, optional, default 1
  98975. * @returns the VertexData of the Ground
  98976. */
  98977. static CreateGround(options: {
  98978. width?: number;
  98979. height?: number;
  98980. subdivisions?: number;
  98981. subdivisionsX?: number;
  98982. subdivisionsY?: number;
  98983. }): VertexData;
  98984. /**
  98985. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  98986. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98987. * * xmin the ground minimum X coordinate, optional, default -1
  98988. * * zmin the ground minimum Z coordinate, optional, default -1
  98989. * * xmax the ground maximum X coordinate, optional, default 1
  98990. * * zmax the ground maximum Z coordinate, optional, default 1
  98991. * * 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}
  98992. * * 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}
  98993. * @returns the VertexData of the TiledGround
  98994. */
  98995. static CreateTiledGround(options: {
  98996. xmin: number;
  98997. zmin: number;
  98998. xmax: number;
  98999. zmax: number;
  99000. subdivisions?: {
  99001. w: number;
  99002. h: number;
  99003. };
  99004. precision?: {
  99005. w: number;
  99006. h: number;
  99007. };
  99008. }): VertexData;
  99009. /**
  99010. * Creates the VertexData of the Ground designed from a heightmap
  99011. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  99012. * * width the width (x direction) of the ground
  99013. * * height the height (z direction) of the ground
  99014. * * subdivisions the number of subdivisions per side
  99015. * * minHeight the minimum altitude on the ground, optional, default 0
  99016. * * maxHeight the maximum altitude on the ground, optional default 1
  99017. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  99018. * * buffer the array holding the image color data
  99019. * * bufferWidth the width of image
  99020. * * bufferHeight the height of image
  99021. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  99022. * @returns the VertexData of the Ground designed from a heightmap
  99023. */
  99024. static CreateGroundFromHeightMap(options: {
  99025. width: number;
  99026. height: number;
  99027. subdivisions: number;
  99028. minHeight: number;
  99029. maxHeight: number;
  99030. colorFilter: Color3;
  99031. buffer: Uint8Array;
  99032. bufferWidth: number;
  99033. bufferHeight: number;
  99034. alphaFilter: number;
  99035. }): VertexData;
  99036. /**
  99037. * Creates the VertexData for a Plane
  99038. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  99039. * * size sets the width and height of the plane to the value of size, optional default 1
  99040. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  99041. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  99042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99043. * * 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)
  99044. * * 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)
  99045. * @returns the VertexData of the box
  99046. */
  99047. static CreatePlane(options: {
  99048. size?: number;
  99049. width?: number;
  99050. height?: number;
  99051. sideOrientation?: number;
  99052. frontUVs?: Vector4;
  99053. backUVs?: Vector4;
  99054. }): VertexData;
  99055. /**
  99056. * Creates the VertexData of the Disc or regular Polygon
  99057. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  99058. * * radius the radius of the disc, optional default 0.5
  99059. * * tessellation the number of polygon sides, optional, default 64
  99060. * * 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
  99061. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99062. * * 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)
  99063. * * 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)
  99064. * @returns the VertexData of the box
  99065. */
  99066. static CreateDisc(options: {
  99067. radius?: number;
  99068. tessellation?: number;
  99069. arc?: number;
  99070. sideOrientation?: number;
  99071. frontUVs?: Vector4;
  99072. backUVs?: Vector4;
  99073. }): VertexData;
  99074. /**
  99075. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  99076. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  99077. * @param polygon a mesh built from polygonTriangulation.build()
  99078. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99079. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  99080. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  99081. * @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)
  99082. * @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)
  99083. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  99084. * @returns the VertexData of the Polygon
  99085. */
  99086. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  99087. /**
  99088. * Creates the VertexData of the IcoSphere
  99089. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  99090. * * radius the radius of the IcoSphere, optional default 1
  99091. * * radiusX allows stretching in the x direction, optional, default radius
  99092. * * radiusY allows stretching in the y direction, optional, default radius
  99093. * * radiusZ allows stretching in the z direction, optional, default radius
  99094. * * flat when true creates a flat shaded mesh, optional, default true
  99095. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  99096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99097. * * 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)
  99098. * * 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)
  99099. * @returns the VertexData of the IcoSphere
  99100. */
  99101. static CreateIcoSphere(options: {
  99102. radius?: number;
  99103. radiusX?: number;
  99104. radiusY?: number;
  99105. radiusZ?: number;
  99106. flat?: boolean;
  99107. subdivisions?: number;
  99108. sideOrientation?: number;
  99109. frontUVs?: Vector4;
  99110. backUVs?: Vector4;
  99111. }): VertexData;
  99112. /**
  99113. * Creates the VertexData for a Polyhedron
  99114. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  99115. * * type provided types are:
  99116. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  99117. * * 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)
  99118. * * size the size of the IcoSphere, optional default 1
  99119. * * sizeX allows stretching in the x direction, optional, default size
  99120. * * sizeY allows stretching in the y direction, optional, default size
  99121. * * sizeZ allows stretching in the z direction, optional, default size
  99122. * * 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
  99123. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  99124. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  99125. * * flat when true creates a flat shaded mesh, optional, default true
  99126. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  99127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99128. * * 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)
  99129. * * 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)
  99130. * @returns the VertexData of the Polyhedron
  99131. */
  99132. static CreatePolyhedron(options: {
  99133. type?: number;
  99134. size?: number;
  99135. sizeX?: number;
  99136. sizeY?: number;
  99137. sizeZ?: number;
  99138. custom?: any;
  99139. faceUV?: Vector4[];
  99140. faceColors?: Color4[];
  99141. flat?: boolean;
  99142. sideOrientation?: number;
  99143. frontUVs?: Vector4;
  99144. backUVs?: Vector4;
  99145. }): VertexData;
  99146. /**
  99147. * Creates the VertexData for a TorusKnot
  99148. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  99149. * * radius the radius of the torus knot, optional, default 2
  99150. * * tube the thickness of the tube, optional, default 0.5
  99151. * * radialSegments the number of sides on each tube segments, optional, default 32
  99152. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  99153. * * p the number of windings around the z axis, optional, default 2
  99154. * * q the number of windings around the x axis, optional, default 3
  99155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99156. * * 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)
  99157. * * 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)
  99158. * @returns the VertexData of the Torus Knot
  99159. */
  99160. static CreateTorusKnot(options: {
  99161. radius?: number;
  99162. tube?: number;
  99163. radialSegments?: number;
  99164. tubularSegments?: number;
  99165. p?: number;
  99166. q?: number;
  99167. sideOrientation?: number;
  99168. frontUVs?: Vector4;
  99169. backUVs?: Vector4;
  99170. }): VertexData;
  99171. /**
  99172. * Compute normals for given positions and indices
  99173. * @param positions an array of vertex positions, [...., x, y, z, ......]
  99174. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  99175. * @param normals an array of vertex normals, [...., x, y, z, ......]
  99176. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  99177. * * facetNormals : optional array of facet normals (vector3)
  99178. * * facetPositions : optional array of facet positions (vector3)
  99179. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  99180. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  99181. * * bInfo : optional bounding info, required for facetPartitioning computation
  99182. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  99183. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  99184. * * useRightHandedSystem: optional boolean to for right handed system computation
  99185. * * depthSort : optional boolean to enable the facet depth sort computation
  99186. * * distanceTo : optional Vector3 to compute the facet depth from this location
  99187. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  99188. */
  99189. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  99190. facetNormals?: any;
  99191. facetPositions?: any;
  99192. facetPartitioning?: any;
  99193. ratio?: number;
  99194. bInfo?: any;
  99195. bbSize?: Vector3;
  99196. subDiv?: any;
  99197. useRightHandedSystem?: boolean;
  99198. depthSort?: boolean;
  99199. distanceTo?: Vector3;
  99200. depthSortedFacets?: any;
  99201. }): void;
  99202. /** @hidden */
  99203. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  99204. /**
  99205. * Applies VertexData created from the imported parameters to the geometry
  99206. * @param parsedVertexData the parsed data from an imported file
  99207. * @param geometry the geometry to apply the VertexData to
  99208. */
  99209. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  99210. }
  99211. }
  99212. declare module BABYLON {
  99213. /**
  99214. * Defines a target to use with MorphTargetManager
  99215. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99216. */
  99217. export class MorphTarget implements IAnimatable {
  99218. /** defines the name of the target */
  99219. name: string;
  99220. /**
  99221. * Gets or sets the list of animations
  99222. */
  99223. animations: Animation[];
  99224. private _scene;
  99225. private _positions;
  99226. private _normals;
  99227. private _tangents;
  99228. private _uvs;
  99229. private _influence;
  99230. private _uniqueId;
  99231. /**
  99232. * Observable raised when the influence changes
  99233. */
  99234. onInfluenceChanged: Observable<boolean>;
  99235. /** @hidden */
  99236. _onDataLayoutChanged: Observable<void>;
  99237. /**
  99238. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  99239. */
  99240. get influence(): number;
  99241. set influence(influence: number);
  99242. /**
  99243. * Gets or sets the id of the morph Target
  99244. */
  99245. id: string;
  99246. private _animationPropertiesOverride;
  99247. /**
  99248. * Gets or sets the animation properties override
  99249. */
  99250. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99251. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99252. /**
  99253. * Creates a new MorphTarget
  99254. * @param name defines the name of the target
  99255. * @param influence defines the influence to use
  99256. * @param scene defines the scene the morphtarget belongs to
  99257. */
  99258. constructor(
  99259. /** defines the name of the target */
  99260. name: string, influence?: number, scene?: Nullable<Scene>);
  99261. /**
  99262. * Gets the unique ID of this manager
  99263. */
  99264. get uniqueId(): number;
  99265. /**
  99266. * Gets a boolean defining if the target contains position data
  99267. */
  99268. get hasPositions(): boolean;
  99269. /**
  99270. * Gets a boolean defining if the target contains normal data
  99271. */
  99272. get hasNormals(): boolean;
  99273. /**
  99274. * Gets a boolean defining if the target contains tangent data
  99275. */
  99276. get hasTangents(): boolean;
  99277. /**
  99278. * Gets a boolean defining if the target contains texture coordinates data
  99279. */
  99280. get hasUVs(): boolean;
  99281. /**
  99282. * Affects position data to this target
  99283. * @param data defines the position data to use
  99284. */
  99285. setPositions(data: Nullable<FloatArray>): void;
  99286. /**
  99287. * Gets the position data stored in this target
  99288. * @returns a FloatArray containing the position data (or null if not present)
  99289. */
  99290. getPositions(): Nullable<FloatArray>;
  99291. /**
  99292. * Affects normal data to this target
  99293. * @param data defines the normal data to use
  99294. */
  99295. setNormals(data: Nullable<FloatArray>): void;
  99296. /**
  99297. * Gets the normal data stored in this target
  99298. * @returns a FloatArray containing the normal data (or null if not present)
  99299. */
  99300. getNormals(): Nullable<FloatArray>;
  99301. /**
  99302. * Affects tangent data to this target
  99303. * @param data defines the tangent data to use
  99304. */
  99305. setTangents(data: Nullable<FloatArray>): void;
  99306. /**
  99307. * Gets the tangent data stored in this target
  99308. * @returns a FloatArray containing the tangent data (or null if not present)
  99309. */
  99310. getTangents(): Nullable<FloatArray>;
  99311. /**
  99312. * Affects texture coordinates data to this target
  99313. * @param data defines the texture coordinates data to use
  99314. */
  99315. setUVs(data: Nullable<FloatArray>): void;
  99316. /**
  99317. * Gets the texture coordinates data stored in this target
  99318. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  99319. */
  99320. getUVs(): Nullable<FloatArray>;
  99321. /**
  99322. * Clone the current target
  99323. * @returns a new MorphTarget
  99324. */
  99325. clone(): MorphTarget;
  99326. /**
  99327. * Serializes the current target into a Serialization object
  99328. * @returns the serialized object
  99329. */
  99330. serialize(): any;
  99331. /**
  99332. * Returns the string "MorphTarget"
  99333. * @returns "MorphTarget"
  99334. */
  99335. getClassName(): string;
  99336. /**
  99337. * Creates a new target from serialized data
  99338. * @param serializationObject defines the serialized data to use
  99339. * @returns a new MorphTarget
  99340. */
  99341. static Parse(serializationObject: any): MorphTarget;
  99342. /**
  99343. * Creates a MorphTarget from mesh data
  99344. * @param mesh defines the source mesh
  99345. * @param name defines the name to use for the new target
  99346. * @param influence defines the influence to attach to the target
  99347. * @returns a new MorphTarget
  99348. */
  99349. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  99350. }
  99351. }
  99352. declare module BABYLON {
  99353. /**
  99354. * This class is used to deform meshes using morphing between different targets
  99355. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99356. */
  99357. export class MorphTargetManager {
  99358. private _targets;
  99359. private _targetInfluenceChangedObservers;
  99360. private _targetDataLayoutChangedObservers;
  99361. private _activeTargets;
  99362. private _scene;
  99363. private _influences;
  99364. private _supportsNormals;
  99365. private _supportsTangents;
  99366. private _supportsUVs;
  99367. private _vertexCount;
  99368. private _uniqueId;
  99369. private _tempInfluences;
  99370. /**
  99371. * Gets or sets a boolean indicating if normals must be morphed
  99372. */
  99373. enableNormalMorphing: boolean;
  99374. /**
  99375. * Gets or sets a boolean indicating if tangents must be morphed
  99376. */
  99377. enableTangentMorphing: boolean;
  99378. /**
  99379. * Gets or sets a boolean indicating if UV must be morphed
  99380. */
  99381. enableUVMorphing: boolean;
  99382. /**
  99383. * Creates a new MorphTargetManager
  99384. * @param scene defines the current scene
  99385. */
  99386. constructor(scene?: Nullable<Scene>);
  99387. /**
  99388. * Gets the unique ID of this manager
  99389. */
  99390. get uniqueId(): number;
  99391. /**
  99392. * Gets the number of vertices handled by this manager
  99393. */
  99394. get vertexCount(): number;
  99395. /**
  99396. * Gets a boolean indicating if this manager supports morphing of normals
  99397. */
  99398. get supportsNormals(): boolean;
  99399. /**
  99400. * Gets a boolean indicating if this manager supports morphing of tangents
  99401. */
  99402. get supportsTangents(): boolean;
  99403. /**
  99404. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  99405. */
  99406. get supportsUVs(): boolean;
  99407. /**
  99408. * Gets the number of targets stored in this manager
  99409. */
  99410. get numTargets(): number;
  99411. /**
  99412. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99413. */
  99414. get numInfluencers(): number;
  99415. /**
  99416. * Gets the list of influences (one per target)
  99417. */
  99418. get influences(): Float32Array;
  99419. /**
  99420. * Gets the active target at specified index. An active target is a target with an influence > 0
  99421. * @param index defines the index to check
  99422. * @returns the requested target
  99423. */
  99424. getActiveTarget(index: number): MorphTarget;
  99425. /**
  99426. * Gets the target at specified index
  99427. * @param index defines the index to check
  99428. * @returns the requested target
  99429. */
  99430. getTarget(index: number): MorphTarget;
  99431. /**
  99432. * Add a new target to this manager
  99433. * @param target defines the target to add
  99434. */
  99435. addTarget(target: MorphTarget): void;
  99436. /**
  99437. * Removes a target from the manager
  99438. * @param target defines the target to remove
  99439. */
  99440. removeTarget(target: MorphTarget): void;
  99441. /**
  99442. * Clone the current manager
  99443. * @returns a new MorphTargetManager
  99444. */
  99445. clone(): MorphTargetManager;
  99446. /**
  99447. * Serializes the current manager into a Serialization object
  99448. * @returns the serialized object
  99449. */
  99450. serialize(): any;
  99451. private _syncActiveTargets;
  99452. /**
  99453. * Syncrhonize the targets with all the meshes using this morph target manager
  99454. */
  99455. synchronize(): void;
  99456. /**
  99457. * Creates a new MorphTargetManager from serialized data
  99458. * @param serializationObject defines the serialized data
  99459. * @param scene defines the hosting scene
  99460. * @returns the new MorphTargetManager
  99461. */
  99462. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  99463. }
  99464. }
  99465. declare module BABYLON {
  99466. /**
  99467. * Class used to represent a specific level of detail of a mesh
  99468. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  99469. */
  99470. export class MeshLODLevel {
  99471. /** Defines the distance where this level should start being displayed */
  99472. distance: number;
  99473. /** Defines the mesh to use to render this level */
  99474. mesh: Nullable<Mesh>;
  99475. /**
  99476. * Creates a new LOD level
  99477. * @param distance defines the distance where this level should star being displayed
  99478. * @param mesh defines the mesh to use to render this level
  99479. */
  99480. constructor(
  99481. /** Defines the distance where this level should start being displayed */
  99482. distance: number,
  99483. /** Defines the mesh to use to render this level */
  99484. mesh: Nullable<Mesh>);
  99485. }
  99486. }
  99487. declare module BABYLON {
  99488. /**
  99489. * Mesh representing the gorund
  99490. */
  99491. export class GroundMesh extends Mesh {
  99492. /** If octree should be generated */
  99493. generateOctree: boolean;
  99494. private _heightQuads;
  99495. /** @hidden */
  99496. _subdivisionsX: number;
  99497. /** @hidden */
  99498. _subdivisionsY: number;
  99499. /** @hidden */
  99500. _width: number;
  99501. /** @hidden */
  99502. _height: number;
  99503. /** @hidden */
  99504. _minX: number;
  99505. /** @hidden */
  99506. _maxX: number;
  99507. /** @hidden */
  99508. _minZ: number;
  99509. /** @hidden */
  99510. _maxZ: number;
  99511. constructor(name: string, scene: Scene);
  99512. /**
  99513. * "GroundMesh"
  99514. * @returns "GroundMesh"
  99515. */
  99516. getClassName(): string;
  99517. /**
  99518. * The minimum of x and y subdivisions
  99519. */
  99520. get subdivisions(): number;
  99521. /**
  99522. * X subdivisions
  99523. */
  99524. get subdivisionsX(): number;
  99525. /**
  99526. * Y subdivisions
  99527. */
  99528. get subdivisionsY(): number;
  99529. /**
  99530. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  99531. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99532. * @param chunksCount the number of subdivisions for x and y
  99533. * @param octreeBlocksSize (Default: 32)
  99534. */
  99535. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  99536. /**
  99537. * Returns a height (y) value in the Worl system :
  99538. * the ground altitude at the coordinates (x, z) expressed in the World system.
  99539. * @param x x coordinate
  99540. * @param z z coordinate
  99541. * @returns the ground y position if (x, z) are outside the ground surface.
  99542. */
  99543. getHeightAtCoordinates(x: number, z: number): number;
  99544. /**
  99545. * Returns a normalized vector (Vector3) orthogonal to the ground
  99546. * at the ground coordinates (x, z) expressed in the World system.
  99547. * @param x x coordinate
  99548. * @param z z coordinate
  99549. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  99550. */
  99551. getNormalAtCoordinates(x: number, z: number): Vector3;
  99552. /**
  99553. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  99554. * at the ground coordinates (x, z) expressed in the World system.
  99555. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  99556. * @param x x coordinate
  99557. * @param z z coordinate
  99558. * @param ref vector to store the result
  99559. * @returns the GroundMesh.
  99560. */
  99561. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  99562. /**
  99563. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  99564. * if the ground has been updated.
  99565. * This can be used in the render loop.
  99566. * @returns the GroundMesh.
  99567. */
  99568. updateCoordinateHeights(): GroundMesh;
  99569. private _getFacetAt;
  99570. private _initHeightQuads;
  99571. private _computeHeightQuads;
  99572. /**
  99573. * Serializes this ground mesh
  99574. * @param serializationObject object to write serialization to
  99575. */
  99576. serialize(serializationObject: any): void;
  99577. /**
  99578. * Parses a serialized ground mesh
  99579. * @param parsedMesh the serialized mesh
  99580. * @param scene the scene to create the ground mesh in
  99581. * @returns the created ground mesh
  99582. */
  99583. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  99584. }
  99585. }
  99586. declare module BABYLON {
  99587. /**
  99588. * Interface for Physics-Joint data
  99589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99590. */
  99591. export interface PhysicsJointData {
  99592. /**
  99593. * The main pivot of the joint
  99594. */
  99595. mainPivot?: Vector3;
  99596. /**
  99597. * The connected pivot of the joint
  99598. */
  99599. connectedPivot?: Vector3;
  99600. /**
  99601. * The main axis of the joint
  99602. */
  99603. mainAxis?: Vector3;
  99604. /**
  99605. * The connected axis of the joint
  99606. */
  99607. connectedAxis?: Vector3;
  99608. /**
  99609. * The collision of the joint
  99610. */
  99611. collision?: boolean;
  99612. /**
  99613. * Native Oimo/Cannon/Energy data
  99614. */
  99615. nativeParams?: any;
  99616. }
  99617. /**
  99618. * This is a holder class for the physics joint created by the physics plugin
  99619. * It holds a set of functions to control the underlying joint
  99620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99621. */
  99622. export class PhysicsJoint {
  99623. /**
  99624. * The type of the physics joint
  99625. */
  99626. type: number;
  99627. /**
  99628. * The data for the physics joint
  99629. */
  99630. jointData: PhysicsJointData;
  99631. private _physicsJoint;
  99632. protected _physicsPlugin: IPhysicsEnginePlugin;
  99633. /**
  99634. * Initializes the physics joint
  99635. * @param type The type of the physics joint
  99636. * @param jointData The data for the physics joint
  99637. */
  99638. constructor(
  99639. /**
  99640. * The type of the physics joint
  99641. */
  99642. type: number,
  99643. /**
  99644. * The data for the physics joint
  99645. */
  99646. jointData: PhysicsJointData);
  99647. /**
  99648. * Gets the physics joint
  99649. */
  99650. get physicsJoint(): any;
  99651. /**
  99652. * Sets the physics joint
  99653. */
  99654. set physicsJoint(newJoint: any);
  99655. /**
  99656. * Sets the physics plugin
  99657. */
  99658. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  99659. /**
  99660. * Execute a function that is physics-plugin specific.
  99661. * @param {Function} func the function that will be executed.
  99662. * It accepts two parameters: the physics world and the physics joint
  99663. */
  99664. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  99665. /**
  99666. * Distance-Joint type
  99667. */
  99668. static DistanceJoint: number;
  99669. /**
  99670. * Hinge-Joint type
  99671. */
  99672. static HingeJoint: number;
  99673. /**
  99674. * Ball-and-Socket joint type
  99675. */
  99676. static BallAndSocketJoint: number;
  99677. /**
  99678. * Wheel-Joint type
  99679. */
  99680. static WheelJoint: number;
  99681. /**
  99682. * Slider-Joint type
  99683. */
  99684. static SliderJoint: number;
  99685. /**
  99686. * Prismatic-Joint type
  99687. */
  99688. static PrismaticJoint: number;
  99689. /**
  99690. * Universal-Joint type
  99691. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  99692. */
  99693. static UniversalJoint: number;
  99694. /**
  99695. * Hinge-Joint 2 type
  99696. */
  99697. static Hinge2Joint: number;
  99698. /**
  99699. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  99700. */
  99701. static PointToPointJoint: number;
  99702. /**
  99703. * Spring-Joint type
  99704. */
  99705. static SpringJoint: number;
  99706. /**
  99707. * Lock-Joint type
  99708. */
  99709. static LockJoint: number;
  99710. }
  99711. /**
  99712. * A class representing a physics distance joint
  99713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99714. */
  99715. export class DistanceJoint extends PhysicsJoint {
  99716. /**
  99717. *
  99718. * @param jointData The data for the Distance-Joint
  99719. */
  99720. constructor(jointData: DistanceJointData);
  99721. /**
  99722. * Update the predefined distance.
  99723. * @param maxDistance The maximum preferred distance
  99724. * @param minDistance The minimum preferred distance
  99725. */
  99726. updateDistance(maxDistance: number, minDistance?: number): void;
  99727. }
  99728. /**
  99729. * Represents a Motor-Enabled Joint
  99730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99731. */
  99732. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  99733. /**
  99734. * Initializes the Motor-Enabled Joint
  99735. * @param type The type of the joint
  99736. * @param jointData The physica joint data for the joint
  99737. */
  99738. constructor(type: number, jointData: PhysicsJointData);
  99739. /**
  99740. * Set the motor values.
  99741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99742. * @param force the force to apply
  99743. * @param maxForce max force for this motor.
  99744. */
  99745. setMotor(force?: number, maxForce?: number): void;
  99746. /**
  99747. * Set the motor's limits.
  99748. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99749. * @param upperLimit The upper limit of the motor
  99750. * @param lowerLimit The lower limit of the motor
  99751. */
  99752. setLimit(upperLimit: number, lowerLimit?: number): void;
  99753. }
  99754. /**
  99755. * This class represents a single physics Hinge-Joint
  99756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99757. */
  99758. export class HingeJoint extends MotorEnabledJoint {
  99759. /**
  99760. * Initializes the Hinge-Joint
  99761. * @param jointData The joint data for the Hinge-Joint
  99762. */
  99763. constructor(jointData: PhysicsJointData);
  99764. /**
  99765. * Set the motor values.
  99766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99767. * @param {number} force the force to apply
  99768. * @param {number} maxForce max force for this motor.
  99769. */
  99770. setMotor(force?: number, maxForce?: number): void;
  99771. /**
  99772. * Set the motor's limits.
  99773. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99774. * @param upperLimit The upper limit of the motor
  99775. * @param lowerLimit The lower limit of the motor
  99776. */
  99777. setLimit(upperLimit: number, lowerLimit?: number): void;
  99778. }
  99779. /**
  99780. * This class represents a dual hinge physics joint (same as wheel joint)
  99781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99782. */
  99783. export class Hinge2Joint extends MotorEnabledJoint {
  99784. /**
  99785. * Initializes the Hinge2-Joint
  99786. * @param jointData The joint data for the Hinge2-Joint
  99787. */
  99788. constructor(jointData: PhysicsJointData);
  99789. /**
  99790. * Set the motor values.
  99791. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99792. * @param {number} targetSpeed the speed the motor is to reach
  99793. * @param {number} maxForce max force for this motor.
  99794. * @param {motorIndex} the motor's index, 0 or 1.
  99795. */
  99796. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  99797. /**
  99798. * Set the motor limits.
  99799. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99800. * @param {number} upperLimit the upper limit
  99801. * @param {number} lowerLimit lower limit
  99802. * @param {motorIndex} the motor's index, 0 or 1.
  99803. */
  99804. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99805. }
  99806. /**
  99807. * Interface for a motor enabled joint
  99808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99809. */
  99810. export interface IMotorEnabledJoint {
  99811. /**
  99812. * Physics joint
  99813. */
  99814. physicsJoint: any;
  99815. /**
  99816. * Sets the motor of the motor-enabled joint
  99817. * @param force The force of the motor
  99818. * @param maxForce The maximum force of the motor
  99819. * @param motorIndex The index of the motor
  99820. */
  99821. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  99822. /**
  99823. * Sets the limit of the motor
  99824. * @param upperLimit The upper limit of the motor
  99825. * @param lowerLimit The lower limit of the motor
  99826. * @param motorIndex The index of the motor
  99827. */
  99828. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99829. }
  99830. /**
  99831. * Joint data for a Distance-Joint
  99832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99833. */
  99834. export interface DistanceJointData extends PhysicsJointData {
  99835. /**
  99836. * Max distance the 2 joint objects can be apart
  99837. */
  99838. maxDistance: number;
  99839. }
  99840. /**
  99841. * Joint data from a spring joint
  99842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99843. */
  99844. export interface SpringJointData extends PhysicsJointData {
  99845. /**
  99846. * Length of the spring
  99847. */
  99848. length: number;
  99849. /**
  99850. * Stiffness of the spring
  99851. */
  99852. stiffness: number;
  99853. /**
  99854. * Damping of the spring
  99855. */
  99856. damping: number;
  99857. /** this callback will be called when applying the force to the impostors. */
  99858. forceApplicationCallback: () => void;
  99859. }
  99860. }
  99861. declare module BABYLON {
  99862. /**
  99863. * Holds the data for the raycast result
  99864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99865. */
  99866. export class PhysicsRaycastResult {
  99867. private _hasHit;
  99868. private _hitDistance;
  99869. private _hitNormalWorld;
  99870. private _hitPointWorld;
  99871. private _rayFromWorld;
  99872. private _rayToWorld;
  99873. /**
  99874. * Gets if there was a hit
  99875. */
  99876. get hasHit(): boolean;
  99877. /**
  99878. * Gets the distance from the hit
  99879. */
  99880. get hitDistance(): number;
  99881. /**
  99882. * Gets the hit normal/direction in the world
  99883. */
  99884. get hitNormalWorld(): Vector3;
  99885. /**
  99886. * Gets the hit point in the world
  99887. */
  99888. get hitPointWorld(): Vector3;
  99889. /**
  99890. * Gets the ray "start point" of the ray in the world
  99891. */
  99892. get rayFromWorld(): Vector3;
  99893. /**
  99894. * Gets the ray "end point" of the ray in the world
  99895. */
  99896. get rayToWorld(): Vector3;
  99897. /**
  99898. * Sets the hit data (normal & point in world space)
  99899. * @param hitNormalWorld defines the normal in world space
  99900. * @param hitPointWorld defines the point in world space
  99901. */
  99902. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  99903. /**
  99904. * Sets the distance from the start point to the hit point
  99905. * @param distance
  99906. */
  99907. setHitDistance(distance: number): void;
  99908. /**
  99909. * Calculates the distance manually
  99910. */
  99911. calculateHitDistance(): void;
  99912. /**
  99913. * Resets all the values to default
  99914. * @param from The from point on world space
  99915. * @param to The to point on world space
  99916. */
  99917. reset(from?: Vector3, to?: Vector3): void;
  99918. }
  99919. /**
  99920. * Interface for the size containing width and height
  99921. */
  99922. interface IXYZ {
  99923. /**
  99924. * X
  99925. */
  99926. x: number;
  99927. /**
  99928. * Y
  99929. */
  99930. y: number;
  99931. /**
  99932. * Z
  99933. */
  99934. z: number;
  99935. }
  99936. }
  99937. declare module BABYLON {
  99938. /**
  99939. * Interface used to describe a physics joint
  99940. */
  99941. export interface PhysicsImpostorJoint {
  99942. /** Defines the main impostor to which the joint is linked */
  99943. mainImpostor: PhysicsImpostor;
  99944. /** Defines the impostor that is connected to the main impostor using this joint */
  99945. connectedImpostor: PhysicsImpostor;
  99946. /** Defines the joint itself */
  99947. joint: PhysicsJoint;
  99948. }
  99949. /** @hidden */
  99950. export interface IPhysicsEnginePlugin {
  99951. world: any;
  99952. name: string;
  99953. setGravity(gravity: Vector3): void;
  99954. setTimeStep(timeStep: number): void;
  99955. getTimeStep(): number;
  99956. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  99957. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99958. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99959. generatePhysicsBody(impostor: PhysicsImpostor): void;
  99960. removePhysicsBody(impostor: PhysicsImpostor): void;
  99961. generateJoint(joint: PhysicsImpostorJoint): void;
  99962. removeJoint(joint: PhysicsImpostorJoint): void;
  99963. isSupported(): boolean;
  99964. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  99965. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  99966. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99967. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99968. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99969. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99970. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  99971. getBodyMass(impostor: PhysicsImpostor): number;
  99972. getBodyFriction(impostor: PhysicsImpostor): number;
  99973. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  99974. getBodyRestitution(impostor: PhysicsImpostor): number;
  99975. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  99976. getBodyPressure?(impostor: PhysicsImpostor): number;
  99977. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  99978. getBodyStiffness?(impostor: PhysicsImpostor): number;
  99979. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  99980. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  99981. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  99982. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  99983. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  99984. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99985. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99986. sleepBody(impostor: PhysicsImpostor): void;
  99987. wakeUpBody(impostor: PhysicsImpostor): void;
  99988. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99989. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  99990. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  99991. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99992. getRadius(impostor: PhysicsImpostor): number;
  99993. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  99994. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  99995. dispose(): void;
  99996. }
  99997. /**
  99998. * Interface used to define a physics engine
  99999. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  100000. */
  100001. export interface IPhysicsEngine {
  100002. /**
  100003. * Gets the gravity vector used by the simulation
  100004. */
  100005. gravity: Vector3;
  100006. /**
  100007. * Sets the gravity vector used by the simulation
  100008. * @param gravity defines the gravity vector to use
  100009. */
  100010. setGravity(gravity: Vector3): void;
  100011. /**
  100012. * Set the time step of the physics engine.
  100013. * Default is 1/60.
  100014. * To slow it down, enter 1/600 for example.
  100015. * To speed it up, 1/30
  100016. * @param newTimeStep the new timestep to apply to this world.
  100017. */
  100018. setTimeStep(newTimeStep: number): void;
  100019. /**
  100020. * Get the time step of the physics engine.
  100021. * @returns the current time step
  100022. */
  100023. getTimeStep(): number;
  100024. /**
  100025. * Set the sub time step of the physics engine.
  100026. * Default is 0 meaning there is no sub steps
  100027. * To increase physics resolution precision, set a small value (like 1 ms)
  100028. * @param subTimeStep defines the new sub timestep used for physics resolution.
  100029. */
  100030. setSubTimeStep(subTimeStep: number): void;
  100031. /**
  100032. * Get the sub time step of the physics engine.
  100033. * @returns the current sub time step
  100034. */
  100035. getSubTimeStep(): number;
  100036. /**
  100037. * Release all resources
  100038. */
  100039. dispose(): void;
  100040. /**
  100041. * Gets the name of the current physics plugin
  100042. * @returns the name of the plugin
  100043. */
  100044. getPhysicsPluginName(): string;
  100045. /**
  100046. * Adding a new impostor for the impostor tracking.
  100047. * This will be done by the impostor itself.
  100048. * @param impostor the impostor to add
  100049. */
  100050. addImpostor(impostor: PhysicsImpostor): void;
  100051. /**
  100052. * Remove an impostor from the engine.
  100053. * This impostor and its mesh will not longer be updated by the physics engine.
  100054. * @param impostor the impostor to remove
  100055. */
  100056. removeImpostor(impostor: PhysicsImpostor): void;
  100057. /**
  100058. * Add a joint to the physics engine
  100059. * @param mainImpostor defines the main impostor to which the joint is added.
  100060. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  100061. * @param joint defines the joint that will connect both impostors.
  100062. */
  100063. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  100064. /**
  100065. * Removes a joint from the simulation
  100066. * @param mainImpostor defines the impostor used with the joint
  100067. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  100068. * @param joint defines the joint to remove
  100069. */
  100070. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  100071. /**
  100072. * Gets the current plugin used to run the simulation
  100073. * @returns current plugin
  100074. */
  100075. getPhysicsPlugin(): IPhysicsEnginePlugin;
  100076. /**
  100077. * Gets the list of physic impostors
  100078. * @returns an array of PhysicsImpostor
  100079. */
  100080. getImpostors(): Array<PhysicsImpostor>;
  100081. /**
  100082. * Gets the impostor for a physics enabled object
  100083. * @param object defines the object impersonated by the impostor
  100084. * @returns the PhysicsImpostor or null if not found
  100085. */
  100086. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100087. /**
  100088. * Gets the impostor for a physics body object
  100089. * @param body defines physics body used by the impostor
  100090. * @returns the PhysicsImpostor or null if not found
  100091. */
  100092. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  100093. /**
  100094. * Does a raycast in the physics world
  100095. * @param from when should the ray start?
  100096. * @param to when should the ray end?
  100097. * @returns PhysicsRaycastResult
  100098. */
  100099. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  100100. /**
  100101. * Called by the scene. No need to call it.
  100102. * @param delta defines the timespam between frames
  100103. */
  100104. _step(delta: number): void;
  100105. }
  100106. }
  100107. declare module BABYLON {
  100108. /**
  100109. * The interface for the physics imposter parameters
  100110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100111. */
  100112. export interface PhysicsImpostorParameters {
  100113. /**
  100114. * The mass of the physics imposter
  100115. */
  100116. mass: number;
  100117. /**
  100118. * The friction of the physics imposter
  100119. */
  100120. friction?: number;
  100121. /**
  100122. * The coefficient of restitution of the physics imposter
  100123. */
  100124. restitution?: number;
  100125. /**
  100126. * The native options of the physics imposter
  100127. */
  100128. nativeOptions?: any;
  100129. /**
  100130. * Specifies if the parent should be ignored
  100131. */
  100132. ignoreParent?: boolean;
  100133. /**
  100134. * Specifies if bi-directional transformations should be disabled
  100135. */
  100136. disableBidirectionalTransformation?: boolean;
  100137. /**
  100138. * The pressure inside the physics imposter, soft object only
  100139. */
  100140. pressure?: number;
  100141. /**
  100142. * The stiffness the physics imposter, soft object only
  100143. */
  100144. stiffness?: number;
  100145. /**
  100146. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  100147. */
  100148. velocityIterations?: number;
  100149. /**
  100150. * The number of iterations used in maintaining consistent vertex positions, soft object only
  100151. */
  100152. positionIterations?: number;
  100153. /**
  100154. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  100155. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  100156. * Add to fix multiple points
  100157. */
  100158. fixedPoints?: number;
  100159. /**
  100160. * The collision margin around a soft object
  100161. */
  100162. margin?: number;
  100163. /**
  100164. * The collision margin around a soft object
  100165. */
  100166. damping?: number;
  100167. /**
  100168. * The path for a rope based on an extrusion
  100169. */
  100170. path?: any;
  100171. /**
  100172. * The shape of an extrusion used for a rope based on an extrusion
  100173. */
  100174. shape?: any;
  100175. }
  100176. /**
  100177. * Interface for a physics-enabled object
  100178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100179. */
  100180. export interface IPhysicsEnabledObject {
  100181. /**
  100182. * The position of the physics-enabled object
  100183. */
  100184. position: Vector3;
  100185. /**
  100186. * The rotation of the physics-enabled object
  100187. */
  100188. rotationQuaternion: Nullable<Quaternion>;
  100189. /**
  100190. * The scale of the physics-enabled object
  100191. */
  100192. scaling: Vector3;
  100193. /**
  100194. * The rotation of the physics-enabled object
  100195. */
  100196. rotation?: Vector3;
  100197. /**
  100198. * The parent of the physics-enabled object
  100199. */
  100200. parent?: any;
  100201. /**
  100202. * The bounding info of the physics-enabled object
  100203. * @returns The bounding info of the physics-enabled object
  100204. */
  100205. getBoundingInfo(): BoundingInfo;
  100206. /**
  100207. * Computes the world matrix
  100208. * @param force Specifies if the world matrix should be computed by force
  100209. * @returns A world matrix
  100210. */
  100211. computeWorldMatrix(force: boolean): Matrix;
  100212. /**
  100213. * Gets the world matrix
  100214. * @returns A world matrix
  100215. */
  100216. getWorldMatrix?(): Matrix;
  100217. /**
  100218. * Gets the child meshes
  100219. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  100220. * @returns An array of abstract meshes
  100221. */
  100222. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  100223. /**
  100224. * Gets the vertex data
  100225. * @param kind The type of vertex data
  100226. * @returns A nullable array of numbers, or a float32 array
  100227. */
  100228. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  100229. /**
  100230. * Gets the indices from the mesh
  100231. * @returns A nullable array of index arrays
  100232. */
  100233. getIndices?(): Nullable<IndicesArray>;
  100234. /**
  100235. * Gets the scene from the mesh
  100236. * @returns the indices array or null
  100237. */
  100238. getScene?(): Scene;
  100239. /**
  100240. * Gets the absolute position from the mesh
  100241. * @returns the absolute position
  100242. */
  100243. getAbsolutePosition(): Vector3;
  100244. /**
  100245. * Gets the absolute pivot point from the mesh
  100246. * @returns the absolute pivot point
  100247. */
  100248. getAbsolutePivotPoint(): Vector3;
  100249. /**
  100250. * Rotates the mesh
  100251. * @param axis The axis of rotation
  100252. * @param amount The amount of rotation
  100253. * @param space The space of the rotation
  100254. * @returns The rotation transform node
  100255. */
  100256. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  100257. /**
  100258. * Translates the mesh
  100259. * @param axis The axis of translation
  100260. * @param distance The distance of translation
  100261. * @param space The space of the translation
  100262. * @returns The transform node
  100263. */
  100264. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  100265. /**
  100266. * Sets the absolute position of the mesh
  100267. * @param absolutePosition The absolute position of the mesh
  100268. * @returns The transform node
  100269. */
  100270. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  100271. /**
  100272. * Gets the class name of the mesh
  100273. * @returns The class name
  100274. */
  100275. getClassName(): string;
  100276. }
  100277. /**
  100278. * Represents a physics imposter
  100279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100280. */
  100281. export class PhysicsImpostor {
  100282. /**
  100283. * The physics-enabled object used as the physics imposter
  100284. */
  100285. object: IPhysicsEnabledObject;
  100286. /**
  100287. * The type of the physics imposter
  100288. */
  100289. type: number;
  100290. private _options;
  100291. private _scene?;
  100292. /**
  100293. * The default object size of the imposter
  100294. */
  100295. static DEFAULT_OBJECT_SIZE: Vector3;
  100296. /**
  100297. * The identity quaternion of the imposter
  100298. */
  100299. static IDENTITY_QUATERNION: Quaternion;
  100300. /** @hidden */
  100301. _pluginData: any;
  100302. private _physicsEngine;
  100303. private _physicsBody;
  100304. private _bodyUpdateRequired;
  100305. private _onBeforePhysicsStepCallbacks;
  100306. private _onAfterPhysicsStepCallbacks;
  100307. /** @hidden */
  100308. _onPhysicsCollideCallbacks: Array<{
  100309. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  100310. otherImpostors: Array<PhysicsImpostor>;
  100311. }>;
  100312. private _deltaPosition;
  100313. private _deltaRotation;
  100314. private _deltaRotationConjugated;
  100315. /** @hidden */
  100316. _isFromLine: boolean;
  100317. private _parent;
  100318. private _isDisposed;
  100319. private static _tmpVecs;
  100320. private static _tmpQuat;
  100321. /**
  100322. * Specifies if the physics imposter is disposed
  100323. */
  100324. get isDisposed(): boolean;
  100325. /**
  100326. * Gets the mass of the physics imposter
  100327. */
  100328. get mass(): number;
  100329. set mass(value: number);
  100330. /**
  100331. * Gets the coefficient of friction
  100332. */
  100333. get friction(): number;
  100334. /**
  100335. * Sets the coefficient of friction
  100336. */
  100337. set friction(value: number);
  100338. /**
  100339. * Gets the coefficient of restitution
  100340. */
  100341. get restitution(): number;
  100342. /**
  100343. * Sets the coefficient of restitution
  100344. */
  100345. set restitution(value: number);
  100346. /**
  100347. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  100348. */
  100349. get pressure(): number;
  100350. /**
  100351. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  100352. */
  100353. set pressure(value: number);
  100354. /**
  100355. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100356. */
  100357. get stiffness(): number;
  100358. /**
  100359. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100360. */
  100361. set stiffness(value: number);
  100362. /**
  100363. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100364. */
  100365. get velocityIterations(): number;
  100366. /**
  100367. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100368. */
  100369. set velocityIterations(value: number);
  100370. /**
  100371. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100372. */
  100373. get positionIterations(): number;
  100374. /**
  100375. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100376. */
  100377. set positionIterations(value: number);
  100378. /**
  100379. * The unique id of the physics imposter
  100380. * set by the physics engine when adding this impostor to the array
  100381. */
  100382. uniqueId: number;
  100383. /**
  100384. * @hidden
  100385. */
  100386. soft: boolean;
  100387. /**
  100388. * @hidden
  100389. */
  100390. segments: number;
  100391. private _joints;
  100392. /**
  100393. * Initializes the physics imposter
  100394. * @param object The physics-enabled object used as the physics imposter
  100395. * @param type The type of the physics imposter
  100396. * @param _options The options for the physics imposter
  100397. * @param _scene The Babylon scene
  100398. */
  100399. constructor(
  100400. /**
  100401. * The physics-enabled object used as the physics imposter
  100402. */
  100403. object: IPhysicsEnabledObject,
  100404. /**
  100405. * The type of the physics imposter
  100406. */
  100407. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  100408. /**
  100409. * This function will completly initialize this impostor.
  100410. * It will create a new body - but only if this mesh has no parent.
  100411. * If it has, this impostor will not be used other than to define the impostor
  100412. * of the child mesh.
  100413. * @hidden
  100414. */
  100415. _init(): void;
  100416. private _getPhysicsParent;
  100417. /**
  100418. * Should a new body be generated.
  100419. * @returns boolean specifying if body initialization is required
  100420. */
  100421. isBodyInitRequired(): boolean;
  100422. /**
  100423. * Sets the updated scaling
  100424. * @param updated Specifies if the scaling is updated
  100425. */
  100426. setScalingUpdated(): void;
  100427. /**
  100428. * Force a regeneration of this or the parent's impostor's body.
  100429. * Use under cautious - This will remove all joints already implemented.
  100430. */
  100431. forceUpdate(): void;
  100432. /**
  100433. * Gets the body that holds this impostor. Either its own, or its parent.
  100434. */
  100435. get physicsBody(): any;
  100436. /**
  100437. * Get the parent of the physics imposter
  100438. * @returns Physics imposter or null
  100439. */
  100440. get parent(): Nullable<PhysicsImpostor>;
  100441. /**
  100442. * Sets the parent of the physics imposter
  100443. */
  100444. set parent(value: Nullable<PhysicsImpostor>);
  100445. /**
  100446. * Set the physics body. Used mainly by the physics engine/plugin
  100447. */
  100448. set physicsBody(physicsBody: any);
  100449. /**
  100450. * Resets the update flags
  100451. */
  100452. resetUpdateFlags(): void;
  100453. /**
  100454. * Gets the object extend size
  100455. * @returns the object extend size
  100456. */
  100457. getObjectExtendSize(): Vector3;
  100458. /**
  100459. * Gets the object center
  100460. * @returns The object center
  100461. */
  100462. getObjectCenter(): Vector3;
  100463. /**
  100464. * Get a specific parameter from the options parameters
  100465. * @param paramName The object parameter name
  100466. * @returns The object parameter
  100467. */
  100468. getParam(paramName: string): any;
  100469. /**
  100470. * Sets a specific parameter in the options given to the physics plugin
  100471. * @param paramName The parameter name
  100472. * @param value The value of the parameter
  100473. */
  100474. setParam(paramName: string, value: number): void;
  100475. /**
  100476. * Specifically change the body's mass option. Won't recreate the physics body object
  100477. * @param mass The mass of the physics imposter
  100478. */
  100479. setMass(mass: number): void;
  100480. /**
  100481. * Gets the linear velocity
  100482. * @returns linear velocity or null
  100483. */
  100484. getLinearVelocity(): Nullable<Vector3>;
  100485. /**
  100486. * Sets the linear velocity
  100487. * @param velocity linear velocity or null
  100488. */
  100489. setLinearVelocity(velocity: Nullable<Vector3>): void;
  100490. /**
  100491. * Gets the angular velocity
  100492. * @returns angular velocity or null
  100493. */
  100494. getAngularVelocity(): Nullable<Vector3>;
  100495. /**
  100496. * Sets the angular velocity
  100497. * @param velocity The velocity or null
  100498. */
  100499. setAngularVelocity(velocity: Nullable<Vector3>): void;
  100500. /**
  100501. * Execute a function with the physics plugin native code
  100502. * Provide a function the will have two variables - the world object and the physics body object
  100503. * @param func The function to execute with the physics plugin native code
  100504. */
  100505. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  100506. /**
  100507. * Register a function that will be executed before the physics world is stepping forward
  100508. * @param func The function to execute before the physics world is stepped forward
  100509. */
  100510. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100511. /**
  100512. * Unregister a function that will be executed before the physics world is stepping forward
  100513. * @param func The function to execute before the physics world is stepped forward
  100514. */
  100515. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100516. /**
  100517. * Register a function that will be executed after the physics step
  100518. * @param func The function to execute after physics step
  100519. */
  100520. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100521. /**
  100522. * Unregisters a function that will be executed after the physics step
  100523. * @param func The function to execute after physics step
  100524. */
  100525. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100526. /**
  100527. * register a function that will be executed when this impostor collides against a different body
  100528. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  100529. * @param func Callback that is executed on collision
  100530. */
  100531. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  100532. /**
  100533. * Unregisters the physics imposter on contact
  100534. * @param collideAgainst The physics object to collide against
  100535. * @param func Callback to execute on collision
  100536. */
  100537. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  100538. private _tmpQuat;
  100539. private _tmpQuat2;
  100540. /**
  100541. * Get the parent rotation
  100542. * @returns The parent rotation
  100543. */
  100544. getParentsRotation(): Quaternion;
  100545. /**
  100546. * this function is executed by the physics engine.
  100547. */
  100548. beforeStep: () => void;
  100549. /**
  100550. * this function is executed by the physics engine
  100551. */
  100552. afterStep: () => void;
  100553. /**
  100554. * Legacy collision detection event support
  100555. */
  100556. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  100557. /**
  100558. * event and body object due to cannon's event-based architecture.
  100559. */
  100560. onCollide: (e: {
  100561. body: any;
  100562. }) => void;
  100563. /**
  100564. * Apply a force
  100565. * @param force The force to apply
  100566. * @param contactPoint The contact point for the force
  100567. * @returns The physics imposter
  100568. */
  100569. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100570. /**
  100571. * Apply an impulse
  100572. * @param force The impulse force
  100573. * @param contactPoint The contact point for the impulse force
  100574. * @returns The physics imposter
  100575. */
  100576. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100577. /**
  100578. * A help function to create a joint
  100579. * @param otherImpostor A physics imposter used to create a joint
  100580. * @param jointType The type of joint
  100581. * @param jointData The data for the joint
  100582. * @returns The physics imposter
  100583. */
  100584. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  100585. /**
  100586. * Add a joint to this impostor with a different impostor
  100587. * @param otherImpostor A physics imposter used to add a joint
  100588. * @param joint The joint to add
  100589. * @returns The physics imposter
  100590. */
  100591. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  100592. /**
  100593. * Add an anchor to a cloth impostor
  100594. * @param otherImpostor rigid impostor to anchor to
  100595. * @param width ratio across width from 0 to 1
  100596. * @param height ratio up height from 0 to 1
  100597. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  100598. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  100599. * @returns impostor the soft imposter
  100600. */
  100601. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100602. /**
  100603. * Add a hook to a rope impostor
  100604. * @param otherImpostor rigid impostor to anchor to
  100605. * @param length ratio across rope from 0 to 1
  100606. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  100607. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  100608. * @returns impostor the rope imposter
  100609. */
  100610. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100611. /**
  100612. * Will keep this body still, in a sleep mode.
  100613. * @returns the physics imposter
  100614. */
  100615. sleep(): PhysicsImpostor;
  100616. /**
  100617. * Wake the body up.
  100618. * @returns The physics imposter
  100619. */
  100620. wakeUp(): PhysicsImpostor;
  100621. /**
  100622. * Clones the physics imposter
  100623. * @param newObject The physics imposter clones to this physics-enabled object
  100624. * @returns A nullable physics imposter
  100625. */
  100626. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100627. /**
  100628. * Disposes the physics imposter
  100629. */
  100630. dispose(): void;
  100631. /**
  100632. * Sets the delta position
  100633. * @param position The delta position amount
  100634. */
  100635. setDeltaPosition(position: Vector3): void;
  100636. /**
  100637. * Sets the delta rotation
  100638. * @param rotation The delta rotation amount
  100639. */
  100640. setDeltaRotation(rotation: Quaternion): void;
  100641. /**
  100642. * Gets the box size of the physics imposter and stores the result in the input parameter
  100643. * @param result Stores the box size
  100644. * @returns The physics imposter
  100645. */
  100646. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  100647. /**
  100648. * Gets the radius of the physics imposter
  100649. * @returns Radius of the physics imposter
  100650. */
  100651. getRadius(): number;
  100652. /**
  100653. * Sync a bone with this impostor
  100654. * @param bone The bone to sync to the impostor.
  100655. * @param boneMesh The mesh that the bone is influencing.
  100656. * @param jointPivot The pivot of the joint / bone in local space.
  100657. * @param distToJoint Optional distance from the impostor to the joint.
  100658. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100659. */
  100660. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  100661. /**
  100662. * Sync impostor to a bone
  100663. * @param bone The bone that the impostor will be synced to.
  100664. * @param boneMesh The mesh that the bone is influencing.
  100665. * @param jointPivot The pivot of the joint / bone in local space.
  100666. * @param distToJoint Optional distance from the impostor to the joint.
  100667. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100668. * @param boneAxis Optional vector3 axis the bone is aligned with
  100669. */
  100670. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  100671. /**
  100672. * No-Imposter type
  100673. */
  100674. static NoImpostor: number;
  100675. /**
  100676. * Sphere-Imposter type
  100677. */
  100678. static SphereImpostor: number;
  100679. /**
  100680. * Box-Imposter type
  100681. */
  100682. static BoxImpostor: number;
  100683. /**
  100684. * Plane-Imposter type
  100685. */
  100686. static PlaneImpostor: number;
  100687. /**
  100688. * Mesh-imposter type
  100689. */
  100690. static MeshImpostor: number;
  100691. /**
  100692. * Capsule-Impostor type (Ammo.js plugin only)
  100693. */
  100694. static CapsuleImpostor: number;
  100695. /**
  100696. * Cylinder-Imposter type
  100697. */
  100698. static CylinderImpostor: number;
  100699. /**
  100700. * Particle-Imposter type
  100701. */
  100702. static ParticleImpostor: number;
  100703. /**
  100704. * Heightmap-Imposter type
  100705. */
  100706. static HeightmapImpostor: number;
  100707. /**
  100708. * ConvexHull-Impostor type (Ammo.js plugin only)
  100709. */
  100710. static ConvexHullImpostor: number;
  100711. /**
  100712. * Custom-Imposter type (Ammo.js plugin only)
  100713. */
  100714. static CustomImpostor: number;
  100715. /**
  100716. * Rope-Imposter type
  100717. */
  100718. static RopeImpostor: number;
  100719. /**
  100720. * Cloth-Imposter type
  100721. */
  100722. static ClothImpostor: number;
  100723. /**
  100724. * Softbody-Imposter type
  100725. */
  100726. static SoftbodyImpostor: number;
  100727. }
  100728. }
  100729. declare module BABYLON {
  100730. /**
  100731. * @hidden
  100732. **/
  100733. export class _CreationDataStorage {
  100734. closePath?: boolean;
  100735. closeArray?: boolean;
  100736. idx: number[];
  100737. dashSize: number;
  100738. gapSize: number;
  100739. path3D: Path3D;
  100740. pathArray: Vector3[][];
  100741. arc: number;
  100742. radius: number;
  100743. cap: number;
  100744. tessellation: number;
  100745. }
  100746. /**
  100747. * @hidden
  100748. **/
  100749. class _InstanceDataStorage {
  100750. visibleInstances: any;
  100751. batchCache: _InstancesBatch;
  100752. instancesBufferSize: number;
  100753. instancesBuffer: Nullable<Buffer>;
  100754. instancesData: Float32Array;
  100755. overridenInstanceCount: number;
  100756. isFrozen: boolean;
  100757. previousBatch: Nullable<_InstancesBatch>;
  100758. hardwareInstancedRendering: boolean;
  100759. sideOrientation: number;
  100760. manualUpdate: boolean;
  100761. }
  100762. /**
  100763. * @hidden
  100764. **/
  100765. export class _InstancesBatch {
  100766. mustReturn: boolean;
  100767. visibleInstances: Nullable<InstancedMesh[]>[];
  100768. renderSelf: boolean[];
  100769. hardwareInstancedRendering: boolean[];
  100770. }
  100771. /**
  100772. * Class used to represent renderable models
  100773. */
  100774. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  100775. /**
  100776. * Mesh side orientation : usually the external or front surface
  100777. */
  100778. static readonly FRONTSIDE: number;
  100779. /**
  100780. * Mesh side orientation : usually the internal or back surface
  100781. */
  100782. static readonly BACKSIDE: number;
  100783. /**
  100784. * Mesh side orientation : both internal and external or front and back surfaces
  100785. */
  100786. static readonly DOUBLESIDE: number;
  100787. /**
  100788. * Mesh side orientation : by default, `FRONTSIDE`
  100789. */
  100790. static readonly DEFAULTSIDE: number;
  100791. /**
  100792. * Mesh cap setting : no cap
  100793. */
  100794. static readonly NO_CAP: number;
  100795. /**
  100796. * Mesh cap setting : one cap at the beginning of the mesh
  100797. */
  100798. static readonly CAP_START: number;
  100799. /**
  100800. * Mesh cap setting : one cap at the end of the mesh
  100801. */
  100802. static readonly CAP_END: number;
  100803. /**
  100804. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  100805. */
  100806. static readonly CAP_ALL: number;
  100807. /**
  100808. * Mesh pattern setting : no flip or rotate
  100809. */
  100810. static readonly NO_FLIP: number;
  100811. /**
  100812. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  100813. */
  100814. static readonly FLIP_TILE: number;
  100815. /**
  100816. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  100817. */
  100818. static readonly ROTATE_TILE: number;
  100819. /**
  100820. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  100821. */
  100822. static readonly FLIP_ROW: number;
  100823. /**
  100824. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  100825. */
  100826. static readonly ROTATE_ROW: number;
  100827. /**
  100828. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  100829. */
  100830. static readonly FLIP_N_ROTATE_TILE: number;
  100831. /**
  100832. * Mesh pattern setting : rotate pattern and rotate
  100833. */
  100834. static readonly FLIP_N_ROTATE_ROW: number;
  100835. /**
  100836. * Mesh tile positioning : part tiles same on left/right or top/bottom
  100837. */
  100838. static readonly CENTER: number;
  100839. /**
  100840. * Mesh tile positioning : part tiles on left
  100841. */
  100842. static readonly LEFT: number;
  100843. /**
  100844. * Mesh tile positioning : part tiles on right
  100845. */
  100846. static readonly RIGHT: number;
  100847. /**
  100848. * Mesh tile positioning : part tiles on top
  100849. */
  100850. static readonly TOP: number;
  100851. /**
  100852. * Mesh tile positioning : part tiles on bottom
  100853. */
  100854. static readonly BOTTOM: number;
  100855. /**
  100856. * Gets the default side orientation.
  100857. * @param orientation the orientation to value to attempt to get
  100858. * @returns the default orientation
  100859. * @hidden
  100860. */
  100861. static _GetDefaultSideOrientation(orientation?: number): number;
  100862. private _internalMeshDataInfo;
  100863. /**
  100864. * An event triggered before rendering the mesh
  100865. */
  100866. get onBeforeRenderObservable(): Observable<Mesh>;
  100867. /**
  100868. * An event triggered before binding the mesh
  100869. */
  100870. get onBeforeBindObservable(): Observable<Mesh>;
  100871. /**
  100872. * An event triggered after rendering the mesh
  100873. */
  100874. get onAfterRenderObservable(): Observable<Mesh>;
  100875. /**
  100876. * An event triggered before drawing the mesh
  100877. */
  100878. get onBeforeDrawObservable(): Observable<Mesh>;
  100879. private _onBeforeDrawObserver;
  100880. /**
  100881. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  100882. */
  100883. set onBeforeDraw(callback: () => void);
  100884. get hasInstances(): boolean;
  100885. /**
  100886. * Gets the delay loading state of the mesh (when delay loading is turned on)
  100887. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  100888. */
  100889. delayLoadState: number;
  100890. /**
  100891. * Gets the list of instances created from this mesh
  100892. * it is not supposed to be modified manually.
  100893. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  100894. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100895. */
  100896. instances: InstancedMesh[];
  100897. /**
  100898. * Gets the file containing delay loading data for this mesh
  100899. */
  100900. delayLoadingFile: string;
  100901. /** @hidden */
  100902. _binaryInfo: any;
  100903. /**
  100904. * User defined function used to change how LOD level selection is done
  100905. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  100906. */
  100907. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  100908. /**
  100909. * Gets or sets the morph target manager
  100910. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100911. */
  100912. get morphTargetManager(): Nullable<MorphTargetManager>;
  100913. set morphTargetManager(value: Nullable<MorphTargetManager>);
  100914. /** @hidden */
  100915. _creationDataStorage: Nullable<_CreationDataStorage>;
  100916. /** @hidden */
  100917. _geometry: Nullable<Geometry>;
  100918. /** @hidden */
  100919. _delayInfo: Array<string>;
  100920. /** @hidden */
  100921. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  100922. /** @hidden */
  100923. _instanceDataStorage: _InstanceDataStorage;
  100924. private _effectiveMaterial;
  100925. /** @hidden */
  100926. _shouldGenerateFlatShading: boolean;
  100927. /** @hidden */
  100928. _originalBuilderSideOrientation: number;
  100929. /**
  100930. * Use this property to change the original side orientation defined at construction time
  100931. */
  100932. overrideMaterialSideOrientation: Nullable<number>;
  100933. /**
  100934. * Gets the source mesh (the one used to clone this one from)
  100935. */
  100936. get source(): Nullable<Mesh>;
  100937. /**
  100938. * Gets or sets a boolean indicating that this mesh does not use index buffer
  100939. */
  100940. get isUnIndexed(): boolean;
  100941. set isUnIndexed(value: boolean);
  100942. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  100943. get worldMatrixInstancedBuffer(): Float32Array;
  100944. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  100945. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  100946. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  100947. /**
  100948. * @constructor
  100949. * @param name The value used by scene.getMeshByName() to do a lookup.
  100950. * @param scene The scene to add this mesh to.
  100951. * @param parent The parent of this mesh, if it has one
  100952. * @param source An optional Mesh from which geometry is shared, cloned.
  100953. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  100954. * When false, achieved by calling a clone(), also passing False.
  100955. * This will make creation of children, recursive.
  100956. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  100957. */
  100958. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  100959. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  100960. doNotInstantiate: boolean;
  100961. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  100962. /**
  100963. * Gets the class name
  100964. * @returns the string "Mesh".
  100965. */
  100966. getClassName(): string;
  100967. /** @hidden */
  100968. get _isMesh(): boolean;
  100969. /**
  100970. * Returns a description of this mesh
  100971. * @param fullDetails define if full details about this mesh must be used
  100972. * @returns a descriptive string representing this mesh
  100973. */
  100974. toString(fullDetails?: boolean): string;
  100975. /** @hidden */
  100976. _unBindEffect(): void;
  100977. /**
  100978. * Gets a boolean indicating if this mesh has LOD
  100979. */
  100980. get hasLODLevels(): boolean;
  100981. /**
  100982. * Gets the list of MeshLODLevel associated with the current mesh
  100983. * @returns an array of MeshLODLevel
  100984. */
  100985. getLODLevels(): MeshLODLevel[];
  100986. private _sortLODLevels;
  100987. /**
  100988. * Add a mesh as LOD level triggered at the given distance.
  100989. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100990. * @param distance The distance from the center of the object to show this level
  100991. * @param mesh The mesh to be added as LOD level (can be null)
  100992. * @return This mesh (for chaining)
  100993. */
  100994. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  100995. /**
  100996. * Returns the LOD level mesh at the passed distance or null if not found.
  100997. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100998. * @param distance The distance from the center of the object to show this level
  100999. * @returns a Mesh or `null`
  101000. */
  101001. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  101002. /**
  101003. * Remove a mesh from the LOD array
  101004. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  101005. * @param mesh defines the mesh to be removed
  101006. * @return This mesh (for chaining)
  101007. */
  101008. removeLODLevel(mesh: Mesh): Mesh;
  101009. /**
  101010. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  101011. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  101012. * @param camera defines the camera to use to compute distance
  101013. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  101014. * @return This mesh (for chaining)
  101015. */
  101016. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  101017. /**
  101018. * Gets the mesh internal Geometry object
  101019. */
  101020. get geometry(): Nullable<Geometry>;
  101021. /**
  101022. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  101023. * @returns the total number of vertices
  101024. */
  101025. getTotalVertices(): number;
  101026. /**
  101027. * Returns the content of an associated vertex buffer
  101028. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  101029. * - VertexBuffer.PositionKind
  101030. * - VertexBuffer.UVKind
  101031. * - VertexBuffer.UV2Kind
  101032. * - VertexBuffer.UV3Kind
  101033. * - VertexBuffer.UV4Kind
  101034. * - VertexBuffer.UV5Kind
  101035. * - VertexBuffer.UV6Kind
  101036. * - VertexBuffer.ColorKind
  101037. * - VertexBuffer.MatricesIndicesKind
  101038. * - VertexBuffer.MatricesIndicesExtraKind
  101039. * - VertexBuffer.MatricesWeightsKind
  101040. * - VertexBuffer.MatricesWeightsExtraKind
  101041. * @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
  101042. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  101043. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  101044. */
  101045. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101046. /**
  101047. * Returns the mesh VertexBuffer object from the requested `kind`
  101048. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  101049. * - VertexBuffer.PositionKind
  101050. * - VertexBuffer.NormalKind
  101051. * - VertexBuffer.UVKind
  101052. * - VertexBuffer.UV2Kind
  101053. * - VertexBuffer.UV3Kind
  101054. * - VertexBuffer.UV4Kind
  101055. * - VertexBuffer.UV5Kind
  101056. * - VertexBuffer.UV6Kind
  101057. * - VertexBuffer.ColorKind
  101058. * - VertexBuffer.MatricesIndicesKind
  101059. * - VertexBuffer.MatricesIndicesExtraKind
  101060. * - VertexBuffer.MatricesWeightsKind
  101061. * - VertexBuffer.MatricesWeightsExtraKind
  101062. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  101063. */
  101064. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  101065. /**
  101066. * Tests if a specific vertex buffer is associated with this mesh
  101067. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  101068. * - VertexBuffer.PositionKind
  101069. * - VertexBuffer.NormalKind
  101070. * - VertexBuffer.UVKind
  101071. * - VertexBuffer.UV2Kind
  101072. * - VertexBuffer.UV3Kind
  101073. * - VertexBuffer.UV4Kind
  101074. * - VertexBuffer.UV5Kind
  101075. * - VertexBuffer.UV6Kind
  101076. * - VertexBuffer.ColorKind
  101077. * - VertexBuffer.MatricesIndicesKind
  101078. * - VertexBuffer.MatricesIndicesExtraKind
  101079. * - VertexBuffer.MatricesWeightsKind
  101080. * - VertexBuffer.MatricesWeightsExtraKind
  101081. * @returns a boolean
  101082. */
  101083. isVerticesDataPresent(kind: string): boolean;
  101084. /**
  101085. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  101086. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  101087. * - VertexBuffer.PositionKind
  101088. * - VertexBuffer.UVKind
  101089. * - VertexBuffer.UV2Kind
  101090. * - VertexBuffer.UV3Kind
  101091. * - VertexBuffer.UV4Kind
  101092. * - VertexBuffer.UV5Kind
  101093. * - VertexBuffer.UV6Kind
  101094. * - VertexBuffer.ColorKind
  101095. * - VertexBuffer.MatricesIndicesKind
  101096. * - VertexBuffer.MatricesIndicesExtraKind
  101097. * - VertexBuffer.MatricesWeightsKind
  101098. * - VertexBuffer.MatricesWeightsExtraKind
  101099. * @returns a boolean
  101100. */
  101101. isVertexBufferUpdatable(kind: string): boolean;
  101102. /**
  101103. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  101104. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  101105. * - VertexBuffer.PositionKind
  101106. * - VertexBuffer.NormalKind
  101107. * - VertexBuffer.UVKind
  101108. * - VertexBuffer.UV2Kind
  101109. * - VertexBuffer.UV3Kind
  101110. * - VertexBuffer.UV4Kind
  101111. * - VertexBuffer.UV5Kind
  101112. * - VertexBuffer.UV6Kind
  101113. * - VertexBuffer.ColorKind
  101114. * - VertexBuffer.MatricesIndicesKind
  101115. * - VertexBuffer.MatricesIndicesExtraKind
  101116. * - VertexBuffer.MatricesWeightsKind
  101117. * - VertexBuffer.MatricesWeightsExtraKind
  101118. * @returns an array of strings
  101119. */
  101120. getVerticesDataKinds(): string[];
  101121. /**
  101122. * Returns a positive integer : the total number of indices in this mesh geometry.
  101123. * @returns the numner of indices or zero if the mesh has no geometry.
  101124. */
  101125. getTotalIndices(): number;
  101126. /**
  101127. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  101128. * @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.
  101129. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101130. * @returns the indices array or an empty array if the mesh has no geometry
  101131. */
  101132. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101133. get isBlocked(): boolean;
  101134. /**
  101135. * Determine if the current mesh is ready to be rendered
  101136. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101137. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  101138. * @returns true if all associated assets are ready (material, textures, shaders)
  101139. */
  101140. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  101141. /**
  101142. * 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.
  101143. */
  101144. get areNormalsFrozen(): boolean;
  101145. /**
  101146. * 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.
  101147. * @returns the current mesh
  101148. */
  101149. freezeNormals(): Mesh;
  101150. /**
  101151. * 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
  101152. * @returns the current mesh
  101153. */
  101154. unfreezeNormals(): Mesh;
  101155. /**
  101156. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  101157. */
  101158. set overridenInstanceCount(count: number);
  101159. /** @hidden */
  101160. _preActivate(): Mesh;
  101161. /** @hidden */
  101162. _preActivateForIntermediateRendering(renderId: number): Mesh;
  101163. /** @hidden */
  101164. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  101165. /**
  101166. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101167. * This means the mesh underlying bounding box and sphere are recomputed.
  101168. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101169. * @returns the current mesh
  101170. */
  101171. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  101172. /** @hidden */
  101173. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  101174. /**
  101175. * This function will subdivide the mesh into multiple submeshes
  101176. * @param count defines the expected number of submeshes
  101177. */
  101178. subdivide(count: number): void;
  101179. /**
  101180. * Copy a FloatArray into a specific associated vertex buffer
  101181. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101182. * - VertexBuffer.PositionKind
  101183. * - VertexBuffer.UVKind
  101184. * - VertexBuffer.UV2Kind
  101185. * - VertexBuffer.UV3Kind
  101186. * - VertexBuffer.UV4Kind
  101187. * - VertexBuffer.UV5Kind
  101188. * - VertexBuffer.UV6Kind
  101189. * - VertexBuffer.ColorKind
  101190. * - VertexBuffer.MatricesIndicesKind
  101191. * - VertexBuffer.MatricesIndicesExtraKind
  101192. * - VertexBuffer.MatricesWeightsKind
  101193. * - VertexBuffer.MatricesWeightsExtraKind
  101194. * @param data defines the data source
  101195. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101196. * @param stride defines the data stride size (can be null)
  101197. * @returns the current mesh
  101198. */
  101199. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101200. /**
  101201. * Delete a vertex buffer associated with this mesh
  101202. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  101203. * - VertexBuffer.PositionKind
  101204. * - VertexBuffer.UVKind
  101205. * - VertexBuffer.UV2Kind
  101206. * - VertexBuffer.UV3Kind
  101207. * - VertexBuffer.UV4Kind
  101208. * - VertexBuffer.UV5Kind
  101209. * - VertexBuffer.UV6Kind
  101210. * - VertexBuffer.ColorKind
  101211. * - VertexBuffer.MatricesIndicesKind
  101212. * - VertexBuffer.MatricesIndicesExtraKind
  101213. * - VertexBuffer.MatricesWeightsKind
  101214. * - VertexBuffer.MatricesWeightsExtraKind
  101215. */
  101216. removeVerticesData(kind: string): void;
  101217. /**
  101218. * Flags an associated vertex buffer as updatable
  101219. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  101220. * - VertexBuffer.PositionKind
  101221. * - VertexBuffer.UVKind
  101222. * - VertexBuffer.UV2Kind
  101223. * - VertexBuffer.UV3Kind
  101224. * - VertexBuffer.UV4Kind
  101225. * - VertexBuffer.UV5Kind
  101226. * - VertexBuffer.UV6Kind
  101227. * - VertexBuffer.ColorKind
  101228. * - VertexBuffer.MatricesIndicesKind
  101229. * - VertexBuffer.MatricesIndicesExtraKind
  101230. * - VertexBuffer.MatricesWeightsKind
  101231. * - VertexBuffer.MatricesWeightsExtraKind
  101232. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101233. */
  101234. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  101235. /**
  101236. * Sets the mesh global Vertex Buffer
  101237. * @param buffer defines the buffer to use
  101238. * @returns the current mesh
  101239. */
  101240. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  101241. /**
  101242. * Update a specific associated vertex buffer
  101243. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101244. * - VertexBuffer.PositionKind
  101245. * - VertexBuffer.UVKind
  101246. * - VertexBuffer.UV2Kind
  101247. * - VertexBuffer.UV3Kind
  101248. * - VertexBuffer.UV4Kind
  101249. * - VertexBuffer.UV5Kind
  101250. * - VertexBuffer.UV6Kind
  101251. * - VertexBuffer.ColorKind
  101252. * - VertexBuffer.MatricesIndicesKind
  101253. * - VertexBuffer.MatricesIndicesExtraKind
  101254. * - VertexBuffer.MatricesWeightsKind
  101255. * - VertexBuffer.MatricesWeightsExtraKind
  101256. * @param data defines the data source
  101257. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  101258. * @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)
  101259. * @returns the current mesh
  101260. */
  101261. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101262. /**
  101263. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  101264. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  101265. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  101266. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  101267. * @returns the current mesh
  101268. */
  101269. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  101270. /**
  101271. * Creates a un-shared specific occurence of the geometry for the mesh.
  101272. * @returns the current mesh
  101273. */
  101274. makeGeometryUnique(): Mesh;
  101275. /**
  101276. * Set the index buffer of this mesh
  101277. * @param indices defines the source data
  101278. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  101279. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  101280. * @returns the current mesh
  101281. */
  101282. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  101283. /**
  101284. * Update the current index buffer
  101285. * @param indices defines the source data
  101286. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101287. * @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)
  101288. * @returns the current mesh
  101289. */
  101290. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101291. /**
  101292. * Invert the geometry to move from a right handed system to a left handed one.
  101293. * @returns the current mesh
  101294. */
  101295. toLeftHanded(): Mesh;
  101296. /** @hidden */
  101297. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  101298. /** @hidden */
  101299. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  101300. /**
  101301. * Registers for this mesh a javascript function called just before the rendering process
  101302. * @param func defines the function to call before rendering this mesh
  101303. * @returns the current mesh
  101304. */
  101305. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101306. /**
  101307. * Disposes a previously registered javascript function called before the rendering
  101308. * @param func defines the function to remove
  101309. * @returns the current mesh
  101310. */
  101311. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101312. /**
  101313. * Registers for this mesh a javascript function called just after the rendering is complete
  101314. * @param func defines the function to call after rendering this mesh
  101315. * @returns the current mesh
  101316. */
  101317. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101318. /**
  101319. * Disposes a previously registered javascript function called after the rendering.
  101320. * @param func defines the function to remove
  101321. * @returns the current mesh
  101322. */
  101323. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101324. /** @hidden */
  101325. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  101326. /** @hidden */
  101327. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  101328. /** @hidden */
  101329. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  101330. /** @hidden */
  101331. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  101332. /** @hidden */
  101333. _rebuild(): void;
  101334. /** @hidden */
  101335. _freeze(): void;
  101336. /** @hidden */
  101337. _unFreeze(): void;
  101338. /**
  101339. * 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
  101340. * @param subMesh defines the subMesh to render
  101341. * @param enableAlphaMode defines if alpha mode can be changed
  101342. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  101343. * @returns the current mesh
  101344. */
  101345. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  101346. private _onBeforeDraw;
  101347. /**
  101348. * Renormalize the mesh and patch it up if there are no weights
  101349. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  101350. * However in the case of zero weights then we set just a single influence to 1.
  101351. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  101352. */
  101353. cleanMatrixWeights(): void;
  101354. private normalizeSkinFourWeights;
  101355. private normalizeSkinWeightsAndExtra;
  101356. /**
  101357. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  101358. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  101359. * the user know there was an issue with importing the mesh
  101360. * @returns a validation object with skinned, valid and report string
  101361. */
  101362. validateSkinning(): {
  101363. skinned: boolean;
  101364. valid: boolean;
  101365. report: string;
  101366. };
  101367. /** @hidden */
  101368. _checkDelayState(): Mesh;
  101369. private _queueLoad;
  101370. /**
  101371. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101372. * A mesh is in the frustum if its bounding box intersects the frustum
  101373. * @param frustumPlanes defines the frustum to test
  101374. * @returns true if the mesh is in the frustum planes
  101375. */
  101376. isInFrustum(frustumPlanes: Plane[]): boolean;
  101377. /**
  101378. * Sets the mesh material by the material or multiMaterial `id` property
  101379. * @param id is a string identifying the material or the multiMaterial
  101380. * @returns the current mesh
  101381. */
  101382. setMaterialByID(id: string): Mesh;
  101383. /**
  101384. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  101385. * @returns an array of IAnimatable
  101386. */
  101387. getAnimatables(): IAnimatable[];
  101388. /**
  101389. * Modifies the mesh geometry according to the passed transformation matrix.
  101390. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  101391. * The mesh normals are modified using the same transformation.
  101392. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101393. * @param transform defines the transform matrix to use
  101394. * @see http://doc.babylonjs.com/resources/baking_transformations
  101395. * @returns the current mesh
  101396. */
  101397. bakeTransformIntoVertices(transform: Matrix): Mesh;
  101398. /**
  101399. * Modifies the mesh geometry according to its own current World Matrix.
  101400. * The mesh World Matrix is then reset.
  101401. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  101402. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101403. * @see http://doc.babylonjs.com/resources/baking_transformations
  101404. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  101405. * @returns the current mesh
  101406. */
  101407. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  101408. /** @hidden */
  101409. get _positions(): Nullable<Vector3[]>;
  101410. /** @hidden */
  101411. _resetPointsArrayCache(): Mesh;
  101412. /** @hidden */
  101413. _generatePointsArray(): boolean;
  101414. /**
  101415. * Returns a new Mesh object generated from the current mesh properties.
  101416. * This method must not get confused with createInstance()
  101417. * @param name is a string, the name given to the new mesh
  101418. * @param newParent can be any Node object (default `null`)
  101419. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  101420. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  101421. * @returns a new mesh
  101422. */
  101423. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  101424. /**
  101425. * Releases resources associated with this mesh.
  101426. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101427. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101428. */
  101429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101430. /** @hidden */
  101431. _disposeInstanceSpecificData(): void;
  101432. /**
  101433. * Modifies the mesh geometry according to a displacement map.
  101434. * 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.
  101435. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101436. * @param url is a string, the URL from the image file is to be downloaded.
  101437. * @param minHeight is the lower limit of the displacement.
  101438. * @param maxHeight is the upper limit of the displacement.
  101439. * @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.
  101440. * @param uvOffset is an optional vector2 used to offset UV.
  101441. * @param uvScale is an optional vector2 used to scale UV.
  101442. * @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.
  101443. * @returns the Mesh.
  101444. */
  101445. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101446. /**
  101447. * Modifies the mesh geometry according to a displacementMap buffer.
  101448. * 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.
  101449. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101450. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  101451. * @param heightMapWidth is the width of the buffer image.
  101452. * @param heightMapHeight is the height of the buffer image.
  101453. * @param minHeight is the lower limit of the displacement.
  101454. * @param maxHeight is the upper limit of the displacement.
  101455. * @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.
  101456. * @param uvOffset is an optional vector2 used to offset UV.
  101457. * @param uvScale is an optional vector2 used to scale UV.
  101458. * @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.
  101459. * @returns the Mesh.
  101460. */
  101461. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101462. /**
  101463. * Modify the mesh to get a flat shading rendering.
  101464. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  101465. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  101466. * @returns current mesh
  101467. */
  101468. convertToFlatShadedMesh(): Mesh;
  101469. /**
  101470. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  101471. * In other words, more vertices, no more indices and a single bigger VBO.
  101472. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  101473. * @returns current mesh
  101474. */
  101475. convertToUnIndexedMesh(): Mesh;
  101476. /**
  101477. * Inverses facet orientations.
  101478. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101479. * @param flipNormals will also inverts the normals
  101480. * @returns current mesh
  101481. */
  101482. flipFaces(flipNormals?: boolean): Mesh;
  101483. /**
  101484. * Increase the number of facets and hence vertices in a mesh
  101485. * Vertex normals are interpolated from existing vertex normals
  101486. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101487. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  101488. */
  101489. increaseVertices(numberPerEdge: number): void;
  101490. /**
  101491. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  101492. * This will undo any application of covertToFlatShadedMesh
  101493. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101494. */
  101495. forceSharedVertices(): void;
  101496. /** @hidden */
  101497. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  101498. /** @hidden */
  101499. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  101500. /**
  101501. * Creates a new InstancedMesh object from the mesh model.
  101502. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  101503. * @param name defines the name of the new instance
  101504. * @returns a new InstancedMesh
  101505. */
  101506. createInstance(name: string): InstancedMesh;
  101507. /**
  101508. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  101509. * After this call, all the mesh instances have the same submeshes than the current mesh.
  101510. * @returns the current mesh
  101511. */
  101512. synchronizeInstances(): Mesh;
  101513. /**
  101514. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  101515. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  101516. * This should be used together with the simplification to avoid disappearing triangles.
  101517. * @param successCallback an optional success callback to be called after the optimization finished.
  101518. * @returns the current mesh
  101519. */
  101520. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  101521. /**
  101522. * Serialize current mesh
  101523. * @param serializationObject defines the object which will receive the serialization data
  101524. */
  101525. serialize(serializationObject: any): void;
  101526. /** @hidden */
  101527. _syncGeometryWithMorphTargetManager(): void;
  101528. /** @hidden */
  101529. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  101530. /**
  101531. * Returns a new Mesh object parsed from the source provided.
  101532. * @param parsedMesh is the source
  101533. * @param scene defines the hosting scene
  101534. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  101535. * @returns a new Mesh
  101536. */
  101537. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  101538. /**
  101539. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  101540. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101541. * @param name defines the name of the mesh to create
  101542. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  101543. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  101544. * @param closePath creates a seam between the first and the last points of each path of the path array
  101545. * @param offset is taken in account only if the `pathArray` is containing a single path
  101546. * @param scene defines the hosting scene
  101547. * @param updatable defines if the mesh must be flagged as updatable
  101548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101549. * @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)
  101550. * @returns a new Mesh
  101551. */
  101552. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101553. /**
  101554. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  101555. * @param name defines the name of the mesh to create
  101556. * @param radius sets the radius size (float) of the polygon (default 0.5)
  101557. * @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
  101558. * @param scene defines the hosting scene
  101559. * @param updatable defines if the mesh must be flagged as updatable
  101560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101561. * @returns a new Mesh
  101562. */
  101563. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101564. /**
  101565. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  101566. * @param name defines the name of the mesh to create
  101567. * @param size sets the size (float) of each box side (default 1)
  101568. * @param scene defines the hosting scene
  101569. * @param updatable defines if the mesh must be flagged as updatable
  101570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101571. * @returns a new Mesh
  101572. */
  101573. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101574. /**
  101575. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  101576. * @param name defines the name of the mesh to create
  101577. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101578. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101579. * @param scene defines the hosting scene
  101580. * @param updatable defines if the mesh must be flagged as updatable
  101581. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101582. * @returns a new Mesh
  101583. */
  101584. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101585. /**
  101586. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  101587. * @param name defines the name of the mesh to create
  101588. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101589. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101590. * @param scene defines the hosting scene
  101591. * @returns a new Mesh
  101592. */
  101593. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  101594. /**
  101595. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  101596. * @param name defines the name of the mesh to create
  101597. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  101598. * @param diameterTop set the top cap diameter (floats, default 1)
  101599. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  101600. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  101601. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  101602. * @param scene defines the hosting scene
  101603. * @param updatable defines if the mesh must be flagged as updatable
  101604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101605. * @returns a new Mesh
  101606. */
  101607. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  101608. /**
  101609. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  101610. * @param name defines the name of the mesh to create
  101611. * @param diameter sets the diameter size (float) of the torus (default 1)
  101612. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  101613. * @param tessellation sets the number of torus sides (postive integer, default 16)
  101614. * @param scene defines the hosting scene
  101615. * @param updatable defines if the mesh must be flagged as updatable
  101616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101617. * @returns a new Mesh
  101618. */
  101619. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101620. /**
  101621. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  101622. * @param name defines the name of the mesh to create
  101623. * @param radius sets the global radius size (float) of the torus knot (default 2)
  101624. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  101625. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  101626. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  101627. * @param p the number of windings on X axis (positive integers, default 2)
  101628. * @param q the number of windings on Y axis (positive integers, default 3)
  101629. * @param scene defines the hosting scene
  101630. * @param updatable defines if the mesh must be flagged as updatable
  101631. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101632. * @returns a new Mesh
  101633. */
  101634. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101635. /**
  101636. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  101637. * @param name defines the name of the mesh to create
  101638. * @param points is an array successive Vector3
  101639. * @param scene defines the hosting scene
  101640. * @param updatable defines if the mesh must be flagged as updatable
  101641. * @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).
  101642. * @returns a new Mesh
  101643. */
  101644. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  101645. /**
  101646. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  101647. * @param name defines the name of the mesh to create
  101648. * @param points is an array successive Vector3
  101649. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  101650. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101651. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  101652. * @param scene defines the hosting scene
  101653. * @param updatable defines if the mesh must be flagged as updatable
  101654. * @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)
  101655. * @returns a new Mesh
  101656. */
  101657. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  101658. /**
  101659. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  101660. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  101661. * 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.
  101662. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101663. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101664. * Remember you can only change the shape positions, not their number when updating a polygon.
  101665. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  101666. * @param name defines the name of the mesh to create
  101667. * @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
  101668. * @param scene defines the hosting scene
  101669. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101670. * @param updatable defines if the mesh must be flagged as updatable
  101671. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101672. * @param earcutInjection can be used to inject your own earcut reference
  101673. * @returns a new Mesh
  101674. */
  101675. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101676. /**
  101677. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  101678. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  101679. * @param name defines the name of the mesh to create
  101680. * @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
  101681. * @param depth defines the height of extrusion
  101682. * @param scene defines the hosting scene
  101683. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101684. * @param updatable defines if the mesh must be flagged as updatable
  101685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101686. * @param earcutInjection can be used to inject your own earcut reference
  101687. * @returns a new Mesh
  101688. */
  101689. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101690. /**
  101691. * Creates an extruded shape mesh.
  101692. * 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
  101693. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101694. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101695. * @param name defines the name of the mesh to create
  101696. * @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
  101697. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101698. * @param scale is the value to scale the shape
  101699. * @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
  101700. * @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
  101701. * @param scene defines the hosting scene
  101702. * @param updatable defines if the mesh must be flagged as updatable
  101703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101704. * @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)
  101705. * @returns a new Mesh
  101706. */
  101707. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101708. /**
  101709. * Creates an custom extruded shape mesh.
  101710. * The custom extrusion is a parametric shape.
  101711. * It has no predefined shape. Its final shape will depend on the input parameters.
  101712. * Please consider using the same method from the MeshBuilder class instead
  101713. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101714. * @param name defines the name of the mesh to create
  101715. * @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
  101716. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101717. * @param scaleFunction is a custom Javascript function called on each path point
  101718. * @param rotationFunction is a custom Javascript function called on each path point
  101719. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101720. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101721. * @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
  101722. * @param scene defines the hosting scene
  101723. * @param updatable defines if the mesh must be flagged as updatable
  101724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101725. * @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)
  101726. * @returns a new Mesh
  101727. */
  101728. 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;
  101729. /**
  101730. * Creates lathe mesh.
  101731. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101732. * Please consider using the same method from the MeshBuilder class instead
  101733. * @param name defines the name of the mesh to create
  101734. * @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
  101735. * @param radius is the radius value of the lathe
  101736. * @param tessellation is the side number of the lathe.
  101737. * @param scene defines the hosting scene
  101738. * @param updatable defines if the mesh must be flagged as updatable
  101739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101740. * @returns a new Mesh
  101741. */
  101742. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101743. /**
  101744. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101745. * @param name defines the name of the mesh to create
  101746. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101747. * @param scene defines the hosting scene
  101748. * @param updatable defines if the mesh must be flagged as updatable
  101749. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101750. * @returns a new Mesh
  101751. */
  101752. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101753. /**
  101754. * Creates a ground mesh.
  101755. * Please consider using the same method from the MeshBuilder class instead
  101756. * @param name defines the name of the mesh to create
  101757. * @param width set the width of the ground
  101758. * @param height set the height of the ground
  101759. * @param subdivisions sets the number of subdivisions per side
  101760. * @param scene defines the hosting scene
  101761. * @param updatable defines if the mesh must be flagged as updatable
  101762. * @returns a new Mesh
  101763. */
  101764. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  101765. /**
  101766. * Creates a tiled ground mesh.
  101767. * Please consider using the same method from the MeshBuilder class instead
  101768. * @param name defines the name of the mesh to create
  101769. * @param xmin set the ground minimum X coordinate
  101770. * @param zmin set the ground minimum Y coordinate
  101771. * @param xmax set the ground maximum X coordinate
  101772. * @param zmax set the ground maximum Z coordinate
  101773. * @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
  101774. * @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
  101775. * @param scene defines the hosting scene
  101776. * @param updatable defines if the mesh must be flagged as updatable
  101777. * @returns a new Mesh
  101778. */
  101779. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  101780. w: number;
  101781. h: number;
  101782. }, precision: {
  101783. w: number;
  101784. h: number;
  101785. }, scene: Scene, updatable?: boolean): Mesh;
  101786. /**
  101787. * Creates a ground mesh from a height map.
  101788. * Please consider using the same method from the MeshBuilder class instead
  101789. * @see http://doc.babylonjs.com/babylon101/height_map
  101790. * @param name defines the name of the mesh to create
  101791. * @param url sets the URL of the height map image resource
  101792. * @param width set the ground width size
  101793. * @param height set the ground height size
  101794. * @param subdivisions sets the number of subdivision per side
  101795. * @param minHeight is the minimum altitude on the ground
  101796. * @param maxHeight is the maximum altitude on the ground
  101797. * @param scene defines the hosting scene
  101798. * @param updatable defines if the mesh must be flagged as updatable
  101799. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101800. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101801. * @returns a new Mesh
  101802. */
  101803. 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;
  101804. /**
  101805. * Creates a tube mesh.
  101806. * The tube is a parametric shape.
  101807. * It has no predefined shape. Its final shape will depend on the input parameters.
  101808. * Please consider using the same method from the MeshBuilder class instead
  101809. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101810. * @param name defines the name of the mesh to create
  101811. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101812. * @param radius sets the tube radius size
  101813. * @param tessellation is the number of sides on the tubular surface
  101814. * @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
  101815. * @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
  101816. * @param scene defines the hosting scene
  101817. * @param updatable defines if the mesh must be flagged as updatable
  101818. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101819. * @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)
  101820. * @returns a new Mesh
  101821. */
  101822. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  101823. (i: number, distance: number): number;
  101824. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101825. /**
  101826. * Creates a polyhedron mesh.
  101827. * Please consider using the same method from the MeshBuilder class instead.
  101828. * * 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
  101829. * * The parameter `size` (positive float, default 1) sets the polygon size
  101830. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101831. * * 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`
  101832. * * 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
  101833. * * 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)`)
  101834. * * 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
  101835. * * 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
  101836. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101837. * * 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
  101838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101839. * @param name defines the name of the mesh to create
  101840. * @param options defines the options used to create the mesh
  101841. * @param scene defines the hosting scene
  101842. * @returns a new Mesh
  101843. */
  101844. static CreatePolyhedron(name: string, options: {
  101845. type?: number;
  101846. size?: number;
  101847. sizeX?: number;
  101848. sizeY?: number;
  101849. sizeZ?: number;
  101850. custom?: any;
  101851. faceUV?: Vector4[];
  101852. faceColors?: Color4[];
  101853. updatable?: boolean;
  101854. sideOrientation?: number;
  101855. }, scene: Scene): Mesh;
  101856. /**
  101857. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101858. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101859. * * 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`)
  101860. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101861. * * 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
  101862. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101863. * * 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
  101864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101865. * @param name defines the name of the mesh
  101866. * @param options defines the options used to create the mesh
  101867. * @param scene defines the hosting scene
  101868. * @returns a new Mesh
  101869. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101870. */
  101871. static CreateIcoSphere(name: string, options: {
  101872. radius?: number;
  101873. flat?: boolean;
  101874. subdivisions?: number;
  101875. sideOrientation?: number;
  101876. updatable?: boolean;
  101877. }, scene: Scene): Mesh;
  101878. /**
  101879. * Creates a decal mesh.
  101880. * Please consider using the same method from the MeshBuilder class instead.
  101881. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101882. * @param name defines the name of the mesh
  101883. * @param sourceMesh defines the mesh receiving the decal
  101884. * @param position sets the position of the decal in world coordinates
  101885. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101886. * @param size sets the decal scaling
  101887. * @param angle sets the angle to rotate the decal
  101888. * @returns a new Mesh
  101889. */
  101890. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  101891. /**
  101892. * Prepare internal position array for software CPU skinning
  101893. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101894. */
  101895. setPositionsForCPUSkinning(): Float32Array;
  101896. /**
  101897. * Prepare internal normal array for software CPU skinning
  101898. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101899. */
  101900. setNormalsForCPUSkinning(): Float32Array;
  101901. /**
  101902. * Updates the vertex buffer by applying transformation from the bones
  101903. * @param skeleton defines the skeleton to apply to current mesh
  101904. * @returns the current mesh
  101905. */
  101906. applySkeleton(skeleton: Skeleton): Mesh;
  101907. /**
  101908. * 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
  101909. * @param meshes defines the list of meshes to scan
  101910. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101911. */
  101912. static MinMax(meshes: AbstractMesh[]): {
  101913. min: Vector3;
  101914. max: Vector3;
  101915. };
  101916. /**
  101917. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101918. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101919. * @returns a vector3
  101920. */
  101921. static Center(meshesOrMinMaxVector: {
  101922. min: Vector3;
  101923. max: Vector3;
  101924. } | AbstractMesh[]): Vector3;
  101925. /**
  101926. * Merge the array of meshes into a single mesh for performance reasons.
  101927. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101928. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101929. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101930. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101931. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101932. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101933. * @returns a new mesh
  101934. */
  101935. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  101936. /** @hidden */
  101937. addInstance(instance: InstancedMesh): void;
  101938. /** @hidden */
  101939. removeInstance(instance: InstancedMesh): void;
  101940. }
  101941. }
  101942. declare module BABYLON {
  101943. /**
  101944. * This is the base class of all the camera used in the application.
  101945. * @see http://doc.babylonjs.com/features/cameras
  101946. */
  101947. export class Camera extends Node {
  101948. /** @hidden */
  101949. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  101950. /**
  101951. * This is the default projection mode used by the cameras.
  101952. * It helps recreating a feeling of perspective and better appreciate depth.
  101953. * This is the best way to simulate real life cameras.
  101954. */
  101955. static readonly PERSPECTIVE_CAMERA: number;
  101956. /**
  101957. * This helps creating camera with an orthographic mode.
  101958. * 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.
  101959. */
  101960. static readonly ORTHOGRAPHIC_CAMERA: number;
  101961. /**
  101962. * This is the default FOV mode for perspective cameras.
  101963. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  101964. */
  101965. static readonly FOVMODE_VERTICAL_FIXED: number;
  101966. /**
  101967. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  101968. */
  101969. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  101970. /**
  101971. * This specifies ther is no need for a camera rig.
  101972. * Basically only one eye is rendered corresponding to the camera.
  101973. */
  101974. static readonly RIG_MODE_NONE: number;
  101975. /**
  101976. * Simulates a camera Rig with one blue eye and one red eye.
  101977. * This can be use with 3d blue and red glasses.
  101978. */
  101979. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  101980. /**
  101981. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  101982. */
  101983. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  101984. /**
  101985. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  101986. */
  101987. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  101988. /**
  101989. * Defines that both eyes of the camera will be rendered over under each other.
  101990. */
  101991. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  101992. /**
  101993. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  101994. */
  101995. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  101996. /**
  101997. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  101998. */
  101999. static readonly RIG_MODE_VR: number;
  102000. /**
  102001. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  102002. */
  102003. static readonly RIG_MODE_WEBVR: number;
  102004. /**
  102005. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  102006. */
  102007. static readonly RIG_MODE_CUSTOM: number;
  102008. /**
  102009. * Defines if by default attaching controls should prevent the default javascript event to continue.
  102010. */
  102011. static ForceAttachControlToAlwaysPreventDefault: boolean;
  102012. /**
  102013. * Define the input manager associated with the camera.
  102014. */
  102015. inputs: CameraInputsManager<Camera>;
  102016. /** @hidden */
  102017. _position: Vector3;
  102018. /**
  102019. * Define the current local position of the camera in the scene
  102020. */
  102021. get position(): Vector3;
  102022. set position(newPosition: Vector3);
  102023. /**
  102024. * The vector the camera should consider as up.
  102025. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  102026. */
  102027. upVector: Vector3;
  102028. /**
  102029. * Define the current limit on the left side for an orthographic camera
  102030. * In scene unit
  102031. */
  102032. orthoLeft: Nullable<number>;
  102033. /**
  102034. * Define the current limit on the right side for an orthographic camera
  102035. * In scene unit
  102036. */
  102037. orthoRight: Nullable<number>;
  102038. /**
  102039. * Define the current limit on the bottom side for an orthographic camera
  102040. * In scene unit
  102041. */
  102042. orthoBottom: Nullable<number>;
  102043. /**
  102044. * Define the current limit on the top side for an orthographic camera
  102045. * In scene unit
  102046. */
  102047. orthoTop: Nullable<number>;
  102048. /**
  102049. * Field Of View is set in Radians. (default is 0.8)
  102050. */
  102051. fov: number;
  102052. /**
  102053. * Define the minimum distance the camera can see from.
  102054. * This is important to note that the depth buffer are not infinite and the closer it starts
  102055. * the more your scene might encounter depth fighting issue.
  102056. */
  102057. minZ: number;
  102058. /**
  102059. * Define the maximum distance the camera can see to.
  102060. * This is important to note that the depth buffer are not infinite and the further it end
  102061. * the more your scene might encounter depth fighting issue.
  102062. */
  102063. maxZ: number;
  102064. /**
  102065. * Define the default inertia of the camera.
  102066. * This helps giving a smooth feeling to the camera movement.
  102067. */
  102068. inertia: number;
  102069. /**
  102070. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  102071. */
  102072. mode: number;
  102073. /**
  102074. * Define whether the camera is intermediate.
  102075. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  102076. */
  102077. isIntermediate: boolean;
  102078. /**
  102079. * Define the viewport of the camera.
  102080. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  102081. */
  102082. viewport: Viewport;
  102083. /**
  102084. * Restricts the camera to viewing objects with the same layerMask.
  102085. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  102086. */
  102087. layerMask: number;
  102088. /**
  102089. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  102090. */
  102091. fovMode: number;
  102092. /**
  102093. * Rig mode of the camera.
  102094. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  102095. * This is normally controlled byt the camera themselves as internal use.
  102096. */
  102097. cameraRigMode: number;
  102098. /**
  102099. * Defines the distance between both "eyes" in case of a RIG
  102100. */
  102101. interaxialDistance: number;
  102102. /**
  102103. * Defines if stereoscopic rendering is done side by side or over under.
  102104. */
  102105. isStereoscopicSideBySide: boolean;
  102106. /**
  102107. * 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
  102108. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  102109. * else in the scene. (Eg. security camera)
  102110. *
  102111. * 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)
  102112. */
  102113. customRenderTargets: RenderTargetTexture[];
  102114. /**
  102115. * When set, the camera will render to this render target instead of the default canvas
  102116. *
  102117. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  102118. */
  102119. outputRenderTarget: Nullable<RenderTargetTexture>;
  102120. /**
  102121. * Observable triggered when the camera view matrix has changed.
  102122. */
  102123. onViewMatrixChangedObservable: Observable<Camera>;
  102124. /**
  102125. * Observable triggered when the camera Projection matrix has changed.
  102126. */
  102127. onProjectionMatrixChangedObservable: Observable<Camera>;
  102128. /**
  102129. * Observable triggered when the inputs have been processed.
  102130. */
  102131. onAfterCheckInputsObservable: Observable<Camera>;
  102132. /**
  102133. * Observable triggered when reset has been called and applied to the camera.
  102134. */
  102135. onRestoreStateObservable: Observable<Camera>;
  102136. /**
  102137. * Is this camera a part of a rig system?
  102138. */
  102139. isRigCamera: boolean;
  102140. /**
  102141. * If isRigCamera set to true this will be set with the parent camera.
  102142. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  102143. */
  102144. rigParent?: Camera;
  102145. /** @hidden */
  102146. _cameraRigParams: any;
  102147. /** @hidden */
  102148. _rigCameras: Camera[];
  102149. /** @hidden */
  102150. _rigPostProcess: Nullable<PostProcess>;
  102151. protected _webvrViewMatrix: Matrix;
  102152. /** @hidden */
  102153. _skipRendering: boolean;
  102154. /** @hidden */
  102155. _projectionMatrix: Matrix;
  102156. /** @hidden */
  102157. _postProcesses: Nullable<PostProcess>[];
  102158. /** @hidden */
  102159. _activeMeshes: SmartArray<AbstractMesh>;
  102160. protected _globalPosition: Vector3;
  102161. /** @hidden */
  102162. _computedViewMatrix: Matrix;
  102163. private _doNotComputeProjectionMatrix;
  102164. private _transformMatrix;
  102165. private _frustumPlanes;
  102166. private _refreshFrustumPlanes;
  102167. private _storedFov;
  102168. private _stateStored;
  102169. /**
  102170. * Instantiates a new camera object.
  102171. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  102172. * @see http://doc.babylonjs.com/features/cameras
  102173. * @param name Defines the name of the camera in the scene
  102174. * @param position Defines the position of the camera
  102175. * @param scene Defines the scene the camera belongs too
  102176. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  102177. */
  102178. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102179. /**
  102180. * Store current camera state (fov, position, etc..)
  102181. * @returns the camera
  102182. */
  102183. storeState(): Camera;
  102184. /**
  102185. * Restores the camera state values if it has been stored. You must call storeState() first
  102186. */
  102187. protected _restoreStateValues(): boolean;
  102188. /**
  102189. * Restored camera state. You must call storeState() first.
  102190. * @returns true if restored and false otherwise
  102191. */
  102192. restoreState(): boolean;
  102193. /**
  102194. * Gets the class name of the camera.
  102195. * @returns the class name
  102196. */
  102197. getClassName(): string;
  102198. /** @hidden */
  102199. readonly _isCamera: boolean;
  102200. /**
  102201. * Gets a string representation of the camera useful for debug purpose.
  102202. * @param fullDetails Defines that a more verboe level of logging is required
  102203. * @returns the string representation
  102204. */
  102205. toString(fullDetails?: boolean): string;
  102206. /**
  102207. * Gets the current world space position of the camera.
  102208. */
  102209. get globalPosition(): Vector3;
  102210. /**
  102211. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  102212. * @returns the active meshe list
  102213. */
  102214. getActiveMeshes(): SmartArray<AbstractMesh>;
  102215. /**
  102216. * Check whether a mesh is part of the current active mesh list of the camera
  102217. * @param mesh Defines the mesh to check
  102218. * @returns true if active, false otherwise
  102219. */
  102220. isActiveMesh(mesh: Mesh): boolean;
  102221. /**
  102222. * Is this camera ready to be used/rendered
  102223. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  102224. * @return true if the camera is ready
  102225. */
  102226. isReady(completeCheck?: boolean): boolean;
  102227. /** @hidden */
  102228. _initCache(): void;
  102229. /** @hidden */
  102230. _updateCache(ignoreParentClass?: boolean): void;
  102231. /** @hidden */
  102232. _isSynchronized(): boolean;
  102233. /** @hidden */
  102234. _isSynchronizedViewMatrix(): boolean;
  102235. /** @hidden */
  102236. _isSynchronizedProjectionMatrix(): boolean;
  102237. /**
  102238. * Attach the input controls to a specific dom element to get the input from.
  102239. * @param element Defines the element the controls should be listened from
  102240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102241. */
  102242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102243. /**
  102244. * Detach the current controls from the specified dom element.
  102245. * @param element Defines the element to stop listening the inputs from
  102246. */
  102247. detachControl(element: HTMLElement): void;
  102248. /**
  102249. * Update the camera state according to the different inputs gathered during the frame.
  102250. */
  102251. update(): void;
  102252. /** @hidden */
  102253. _checkInputs(): void;
  102254. /** @hidden */
  102255. get rigCameras(): Camera[];
  102256. /**
  102257. * Gets the post process used by the rig cameras
  102258. */
  102259. get rigPostProcess(): Nullable<PostProcess>;
  102260. /**
  102261. * Internal, gets the first post proces.
  102262. * @returns the first post process to be run on this camera.
  102263. */
  102264. _getFirstPostProcess(): Nullable<PostProcess>;
  102265. private _cascadePostProcessesToRigCams;
  102266. /**
  102267. * Attach a post process to the camera.
  102268. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102269. * @param postProcess The post process to attach to the camera
  102270. * @param insertAt The position of the post process in case several of them are in use in the scene
  102271. * @returns the position the post process has been inserted at
  102272. */
  102273. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  102274. /**
  102275. * Detach a post process to the camera.
  102276. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102277. * @param postProcess The post process to detach from the camera
  102278. */
  102279. detachPostProcess(postProcess: PostProcess): void;
  102280. /**
  102281. * Gets the current world matrix of the camera
  102282. */
  102283. getWorldMatrix(): Matrix;
  102284. /** @hidden */
  102285. _getViewMatrix(): Matrix;
  102286. /**
  102287. * Gets the current view matrix of the camera.
  102288. * @param force forces the camera to recompute the matrix without looking at the cached state
  102289. * @returns the view matrix
  102290. */
  102291. getViewMatrix(force?: boolean): Matrix;
  102292. /**
  102293. * Freeze the projection matrix.
  102294. * It will prevent the cache check of the camera projection compute and can speed up perf
  102295. * if no parameter of the camera are meant to change
  102296. * @param projection Defines manually a projection if necessary
  102297. */
  102298. freezeProjectionMatrix(projection?: Matrix): void;
  102299. /**
  102300. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  102301. */
  102302. unfreezeProjectionMatrix(): void;
  102303. /**
  102304. * Gets the current projection matrix of the camera.
  102305. * @param force forces the camera to recompute the matrix without looking at the cached state
  102306. * @returns the projection matrix
  102307. */
  102308. getProjectionMatrix(force?: boolean): Matrix;
  102309. /**
  102310. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  102311. * @returns a Matrix
  102312. */
  102313. getTransformationMatrix(): Matrix;
  102314. private _updateFrustumPlanes;
  102315. /**
  102316. * Checks if a cullable object (mesh...) is in the camera frustum
  102317. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  102318. * @param target The object to check
  102319. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  102320. * @returns true if the object is in frustum otherwise false
  102321. */
  102322. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  102323. /**
  102324. * Checks if a cullable object (mesh...) is in the camera frustum
  102325. * Unlike isInFrustum this cheks the full bounding box
  102326. * @param target The object to check
  102327. * @returns true if the object is in frustum otherwise false
  102328. */
  102329. isCompletelyInFrustum(target: ICullable): boolean;
  102330. /**
  102331. * Gets a ray in the forward direction from the camera.
  102332. * @param length Defines the length of the ray to create
  102333. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  102334. * @param origin Defines the start point of the ray which defaults to the camera position
  102335. * @returns the forward ray
  102336. */
  102337. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  102338. /**
  102339. * Releases resources associated with this node.
  102340. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102341. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102342. */
  102343. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102344. /** @hidden */
  102345. _isLeftCamera: boolean;
  102346. /**
  102347. * Gets the left camera of a rig setup in case of Rigged Camera
  102348. */
  102349. get isLeftCamera(): boolean;
  102350. /** @hidden */
  102351. _isRightCamera: boolean;
  102352. /**
  102353. * Gets the right camera of a rig setup in case of Rigged Camera
  102354. */
  102355. get isRightCamera(): boolean;
  102356. /**
  102357. * Gets the left camera of a rig setup in case of Rigged Camera
  102358. */
  102359. get leftCamera(): Nullable<FreeCamera>;
  102360. /**
  102361. * Gets the right camera of a rig setup in case of Rigged Camera
  102362. */
  102363. get rightCamera(): Nullable<FreeCamera>;
  102364. /**
  102365. * Gets the left camera target of a rig setup in case of Rigged Camera
  102366. * @returns the target position
  102367. */
  102368. getLeftTarget(): Nullable<Vector3>;
  102369. /**
  102370. * Gets the right camera target of a rig setup in case of Rigged Camera
  102371. * @returns the target position
  102372. */
  102373. getRightTarget(): Nullable<Vector3>;
  102374. /**
  102375. * @hidden
  102376. */
  102377. setCameraRigMode(mode: number, rigParams: any): void;
  102378. /** @hidden */
  102379. static _setStereoscopicRigMode(camera: Camera): void;
  102380. /** @hidden */
  102381. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  102382. /** @hidden */
  102383. static _setVRRigMode(camera: Camera, rigParams: any): void;
  102384. /** @hidden */
  102385. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  102386. /** @hidden */
  102387. _getVRProjectionMatrix(): Matrix;
  102388. protected _updateCameraRotationMatrix(): void;
  102389. protected _updateWebVRCameraRotationMatrix(): void;
  102390. /**
  102391. * This function MUST be overwritten by the different WebVR cameras available.
  102392. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102393. * @hidden
  102394. */
  102395. _getWebVRProjectionMatrix(): Matrix;
  102396. /**
  102397. * This function MUST be overwritten by the different WebVR cameras available.
  102398. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102399. * @hidden
  102400. */
  102401. _getWebVRViewMatrix(): Matrix;
  102402. /** @hidden */
  102403. setCameraRigParameter(name: string, value: any): void;
  102404. /**
  102405. * needs to be overridden by children so sub has required properties to be copied
  102406. * @hidden
  102407. */
  102408. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  102409. /**
  102410. * May need to be overridden by children
  102411. * @hidden
  102412. */
  102413. _updateRigCameras(): void;
  102414. /** @hidden */
  102415. _setupInputs(): void;
  102416. /**
  102417. * Serialiaze the camera setup to a json represention
  102418. * @returns the JSON representation
  102419. */
  102420. serialize(): any;
  102421. /**
  102422. * Clones the current camera.
  102423. * @param name The cloned camera name
  102424. * @returns the cloned camera
  102425. */
  102426. clone(name: string): Camera;
  102427. /**
  102428. * Gets the direction of the camera relative to a given local axis.
  102429. * @param localAxis Defines the reference axis to provide a relative direction.
  102430. * @return the direction
  102431. */
  102432. getDirection(localAxis: Vector3): Vector3;
  102433. /**
  102434. * Returns the current camera absolute rotation
  102435. */
  102436. get absoluteRotation(): Quaternion;
  102437. /**
  102438. * Gets the direction of the camera relative to a given local axis into a passed vector.
  102439. * @param localAxis Defines the reference axis to provide a relative direction.
  102440. * @param result Defines the vector to store the result in
  102441. */
  102442. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  102443. /**
  102444. * Gets a camera constructor for a given camera type
  102445. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  102446. * @param name The name of the camera the result will be able to instantiate
  102447. * @param scene The scene the result will construct the camera in
  102448. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  102449. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  102450. * @returns a factory method to construc the camera
  102451. */
  102452. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  102453. /**
  102454. * Compute the world matrix of the camera.
  102455. * @returns the camera world matrix
  102456. */
  102457. computeWorldMatrix(): Matrix;
  102458. /**
  102459. * Parse a JSON and creates the camera from the parsed information
  102460. * @param parsedCamera The JSON to parse
  102461. * @param scene The scene to instantiate the camera in
  102462. * @returns the newly constructed camera
  102463. */
  102464. static Parse(parsedCamera: any, scene: Scene): Camera;
  102465. }
  102466. }
  102467. declare module BABYLON {
  102468. /**
  102469. * Class containing static functions to help procedurally build meshes
  102470. */
  102471. export class DiscBuilder {
  102472. /**
  102473. * Creates a plane polygonal mesh. By default, this is a disc
  102474. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  102475. * * 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
  102476. * * 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
  102477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102478. * * 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
  102479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102480. * @param name defines the name of the mesh
  102481. * @param options defines the options used to create the mesh
  102482. * @param scene defines the hosting scene
  102483. * @returns the plane polygonal mesh
  102484. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  102485. */
  102486. static CreateDisc(name: string, options: {
  102487. radius?: number;
  102488. tessellation?: number;
  102489. arc?: number;
  102490. updatable?: boolean;
  102491. sideOrientation?: number;
  102492. frontUVs?: Vector4;
  102493. backUVs?: Vector4;
  102494. }, scene?: Nullable<Scene>): Mesh;
  102495. }
  102496. }
  102497. declare module BABYLON {
  102498. /**
  102499. * Options to be used when creating a FresnelParameters.
  102500. */
  102501. export type IFresnelParametersCreationOptions = {
  102502. /**
  102503. * Define the color used on edges (grazing angle)
  102504. */
  102505. leftColor?: Color3;
  102506. /**
  102507. * Define the color used on center
  102508. */
  102509. rightColor?: Color3;
  102510. /**
  102511. * Define bias applied to computed fresnel term
  102512. */
  102513. bias?: number;
  102514. /**
  102515. * Defined the power exponent applied to fresnel term
  102516. */
  102517. power?: number;
  102518. /**
  102519. * Define if the fresnel effect is enable or not.
  102520. */
  102521. isEnabled?: boolean;
  102522. };
  102523. /**
  102524. * Serialized format for FresnelParameters.
  102525. */
  102526. export type IFresnelParametersSerialized = {
  102527. /**
  102528. * Define the color used on edges (grazing angle) [as an array]
  102529. */
  102530. leftColor: number[];
  102531. /**
  102532. * Define the color used on center [as an array]
  102533. */
  102534. rightColor: number[];
  102535. /**
  102536. * Define bias applied to computed fresnel term
  102537. */
  102538. bias: number;
  102539. /**
  102540. * Defined the power exponent applied to fresnel term
  102541. */
  102542. power?: number;
  102543. /**
  102544. * Define if the fresnel effect is enable or not.
  102545. */
  102546. isEnabled: boolean;
  102547. };
  102548. /**
  102549. * This represents all the required information to add a fresnel effect on a material:
  102550. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102551. */
  102552. export class FresnelParameters {
  102553. private _isEnabled;
  102554. /**
  102555. * Define if the fresnel effect is enable or not.
  102556. */
  102557. get isEnabled(): boolean;
  102558. set isEnabled(value: boolean);
  102559. /**
  102560. * Define the color used on edges (grazing angle)
  102561. */
  102562. leftColor: Color3;
  102563. /**
  102564. * Define the color used on center
  102565. */
  102566. rightColor: Color3;
  102567. /**
  102568. * Define bias applied to computed fresnel term
  102569. */
  102570. bias: number;
  102571. /**
  102572. * Defined the power exponent applied to fresnel term
  102573. */
  102574. power: number;
  102575. /**
  102576. * Creates a new FresnelParameters object.
  102577. *
  102578. * @param options provide your own settings to optionally to override defaults
  102579. */
  102580. constructor(options?: IFresnelParametersCreationOptions);
  102581. /**
  102582. * Clones the current fresnel and its valuues
  102583. * @returns a clone fresnel configuration
  102584. */
  102585. clone(): FresnelParameters;
  102586. /**
  102587. * Determines equality between FresnelParameters objects
  102588. * @param otherFresnelParameters defines the second operand
  102589. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  102590. */
  102591. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  102592. /**
  102593. * Serializes the current fresnel parameters to a JSON representation.
  102594. * @return the JSON serialization
  102595. */
  102596. serialize(): IFresnelParametersSerialized;
  102597. /**
  102598. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  102599. * @param parsedFresnelParameters Define the JSON representation
  102600. * @returns the parsed parameters
  102601. */
  102602. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  102603. }
  102604. }
  102605. declare module BABYLON {
  102606. /**
  102607. * Base class of materials working in push mode in babylon JS
  102608. * @hidden
  102609. */
  102610. export class PushMaterial extends Material {
  102611. protected _activeEffect: Effect;
  102612. protected _normalMatrix: Matrix;
  102613. /**
  102614. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102615. * This means that the material can keep using a previous shader while a new one is being compiled.
  102616. * This is mostly used when shader parallel compilation is supported (true by default)
  102617. */
  102618. allowShaderHotSwapping: boolean;
  102619. constructor(name: string, scene: Scene);
  102620. getEffect(): Effect;
  102621. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102622. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102623. /**
  102624. * Binds the given world matrix to the active effect
  102625. *
  102626. * @param world the matrix to bind
  102627. */
  102628. bindOnlyWorldMatrix(world: Matrix): void;
  102629. /**
  102630. * Binds the given normal matrix to the active effect
  102631. *
  102632. * @param normalMatrix the matrix to bind
  102633. */
  102634. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102635. bind(world: Matrix, mesh?: Mesh): void;
  102636. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102637. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102638. }
  102639. }
  102640. declare module BABYLON {
  102641. /**
  102642. * This groups all the flags used to control the materials channel.
  102643. */
  102644. export class MaterialFlags {
  102645. private static _DiffuseTextureEnabled;
  102646. /**
  102647. * Are diffuse textures enabled in the application.
  102648. */
  102649. static get DiffuseTextureEnabled(): boolean;
  102650. static set DiffuseTextureEnabled(value: boolean);
  102651. private static _AmbientTextureEnabled;
  102652. /**
  102653. * Are ambient textures enabled in the application.
  102654. */
  102655. static get AmbientTextureEnabled(): boolean;
  102656. static set AmbientTextureEnabled(value: boolean);
  102657. private static _OpacityTextureEnabled;
  102658. /**
  102659. * Are opacity textures enabled in the application.
  102660. */
  102661. static get OpacityTextureEnabled(): boolean;
  102662. static set OpacityTextureEnabled(value: boolean);
  102663. private static _ReflectionTextureEnabled;
  102664. /**
  102665. * Are reflection textures enabled in the application.
  102666. */
  102667. static get ReflectionTextureEnabled(): boolean;
  102668. static set ReflectionTextureEnabled(value: boolean);
  102669. private static _EmissiveTextureEnabled;
  102670. /**
  102671. * Are emissive textures enabled in the application.
  102672. */
  102673. static get EmissiveTextureEnabled(): boolean;
  102674. static set EmissiveTextureEnabled(value: boolean);
  102675. private static _SpecularTextureEnabled;
  102676. /**
  102677. * Are specular textures enabled in the application.
  102678. */
  102679. static get SpecularTextureEnabled(): boolean;
  102680. static set SpecularTextureEnabled(value: boolean);
  102681. private static _BumpTextureEnabled;
  102682. /**
  102683. * Are bump textures enabled in the application.
  102684. */
  102685. static get BumpTextureEnabled(): boolean;
  102686. static set BumpTextureEnabled(value: boolean);
  102687. private static _LightmapTextureEnabled;
  102688. /**
  102689. * Are lightmap textures enabled in the application.
  102690. */
  102691. static get LightmapTextureEnabled(): boolean;
  102692. static set LightmapTextureEnabled(value: boolean);
  102693. private static _RefractionTextureEnabled;
  102694. /**
  102695. * Are refraction textures enabled in the application.
  102696. */
  102697. static get RefractionTextureEnabled(): boolean;
  102698. static set RefractionTextureEnabled(value: boolean);
  102699. private static _ColorGradingTextureEnabled;
  102700. /**
  102701. * Are color grading textures enabled in the application.
  102702. */
  102703. static get ColorGradingTextureEnabled(): boolean;
  102704. static set ColorGradingTextureEnabled(value: boolean);
  102705. private static _FresnelEnabled;
  102706. /**
  102707. * Are fresnels enabled in the application.
  102708. */
  102709. static get FresnelEnabled(): boolean;
  102710. static set FresnelEnabled(value: boolean);
  102711. private static _ClearCoatTextureEnabled;
  102712. /**
  102713. * Are clear coat textures enabled in the application.
  102714. */
  102715. static get ClearCoatTextureEnabled(): boolean;
  102716. static set ClearCoatTextureEnabled(value: boolean);
  102717. private static _ClearCoatBumpTextureEnabled;
  102718. /**
  102719. * Are clear coat bump textures enabled in the application.
  102720. */
  102721. static get ClearCoatBumpTextureEnabled(): boolean;
  102722. static set ClearCoatBumpTextureEnabled(value: boolean);
  102723. private static _ClearCoatTintTextureEnabled;
  102724. /**
  102725. * Are clear coat tint textures enabled in the application.
  102726. */
  102727. static get ClearCoatTintTextureEnabled(): boolean;
  102728. static set ClearCoatTintTextureEnabled(value: boolean);
  102729. private static _SheenTextureEnabled;
  102730. /**
  102731. * Are sheen textures enabled in the application.
  102732. */
  102733. static get SheenTextureEnabled(): boolean;
  102734. static set SheenTextureEnabled(value: boolean);
  102735. private static _AnisotropicTextureEnabled;
  102736. /**
  102737. * Are anisotropic textures enabled in the application.
  102738. */
  102739. static get AnisotropicTextureEnabled(): boolean;
  102740. static set AnisotropicTextureEnabled(value: boolean);
  102741. private static _ThicknessTextureEnabled;
  102742. /**
  102743. * Are thickness textures enabled in the application.
  102744. */
  102745. static get ThicknessTextureEnabled(): boolean;
  102746. static set ThicknessTextureEnabled(value: boolean);
  102747. }
  102748. }
  102749. declare module BABYLON {
  102750. /** @hidden */
  102751. export var defaultFragmentDeclaration: {
  102752. name: string;
  102753. shader: string;
  102754. };
  102755. }
  102756. declare module BABYLON {
  102757. /** @hidden */
  102758. export var defaultUboDeclaration: {
  102759. name: string;
  102760. shader: string;
  102761. };
  102762. }
  102763. declare module BABYLON {
  102764. /** @hidden */
  102765. export var lightFragmentDeclaration: {
  102766. name: string;
  102767. shader: string;
  102768. };
  102769. }
  102770. declare module BABYLON {
  102771. /** @hidden */
  102772. export var lightUboDeclaration: {
  102773. name: string;
  102774. shader: string;
  102775. };
  102776. }
  102777. declare module BABYLON {
  102778. /** @hidden */
  102779. export var lightsFragmentFunctions: {
  102780. name: string;
  102781. shader: string;
  102782. };
  102783. }
  102784. declare module BABYLON {
  102785. /** @hidden */
  102786. export var shadowsFragmentFunctions: {
  102787. name: string;
  102788. shader: string;
  102789. };
  102790. }
  102791. declare module BABYLON {
  102792. /** @hidden */
  102793. export var fresnelFunction: {
  102794. name: string;
  102795. shader: string;
  102796. };
  102797. }
  102798. declare module BABYLON {
  102799. /** @hidden */
  102800. export var reflectionFunction: {
  102801. name: string;
  102802. shader: string;
  102803. };
  102804. }
  102805. declare module BABYLON {
  102806. /** @hidden */
  102807. export var bumpFragmentMainFunctions: {
  102808. name: string;
  102809. shader: string;
  102810. };
  102811. }
  102812. declare module BABYLON {
  102813. /** @hidden */
  102814. export var bumpFragmentFunctions: {
  102815. name: string;
  102816. shader: string;
  102817. };
  102818. }
  102819. declare module BABYLON {
  102820. /** @hidden */
  102821. export var logDepthDeclaration: {
  102822. name: string;
  102823. shader: string;
  102824. };
  102825. }
  102826. declare module BABYLON {
  102827. /** @hidden */
  102828. export var bumpFragment: {
  102829. name: string;
  102830. shader: string;
  102831. };
  102832. }
  102833. declare module BABYLON {
  102834. /** @hidden */
  102835. export var depthPrePass: {
  102836. name: string;
  102837. shader: string;
  102838. };
  102839. }
  102840. declare module BABYLON {
  102841. /** @hidden */
  102842. export var lightFragment: {
  102843. name: string;
  102844. shader: string;
  102845. };
  102846. }
  102847. declare module BABYLON {
  102848. /** @hidden */
  102849. export var logDepthFragment: {
  102850. name: string;
  102851. shader: string;
  102852. };
  102853. }
  102854. declare module BABYLON {
  102855. /** @hidden */
  102856. export var defaultPixelShader: {
  102857. name: string;
  102858. shader: string;
  102859. };
  102860. }
  102861. declare module BABYLON {
  102862. /** @hidden */
  102863. export var defaultVertexDeclaration: {
  102864. name: string;
  102865. shader: string;
  102866. };
  102867. }
  102868. declare module BABYLON {
  102869. /** @hidden */
  102870. export var bumpVertexDeclaration: {
  102871. name: string;
  102872. shader: string;
  102873. };
  102874. }
  102875. declare module BABYLON {
  102876. /** @hidden */
  102877. export var bumpVertex: {
  102878. name: string;
  102879. shader: string;
  102880. };
  102881. }
  102882. declare module BABYLON {
  102883. /** @hidden */
  102884. export var fogVertex: {
  102885. name: string;
  102886. shader: string;
  102887. };
  102888. }
  102889. declare module BABYLON {
  102890. /** @hidden */
  102891. export var shadowsVertex: {
  102892. name: string;
  102893. shader: string;
  102894. };
  102895. }
  102896. declare module BABYLON {
  102897. /** @hidden */
  102898. export var pointCloudVertex: {
  102899. name: string;
  102900. shader: string;
  102901. };
  102902. }
  102903. declare module BABYLON {
  102904. /** @hidden */
  102905. export var logDepthVertex: {
  102906. name: string;
  102907. shader: string;
  102908. };
  102909. }
  102910. declare module BABYLON {
  102911. /** @hidden */
  102912. export var defaultVertexShader: {
  102913. name: string;
  102914. shader: string;
  102915. };
  102916. }
  102917. declare module BABYLON {
  102918. /** @hidden */
  102919. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102920. MAINUV1: boolean;
  102921. MAINUV2: boolean;
  102922. DIFFUSE: boolean;
  102923. DIFFUSEDIRECTUV: number;
  102924. AMBIENT: boolean;
  102925. AMBIENTDIRECTUV: number;
  102926. OPACITY: boolean;
  102927. OPACITYDIRECTUV: number;
  102928. OPACITYRGB: boolean;
  102929. REFLECTION: boolean;
  102930. EMISSIVE: boolean;
  102931. EMISSIVEDIRECTUV: number;
  102932. SPECULAR: boolean;
  102933. SPECULARDIRECTUV: number;
  102934. BUMP: boolean;
  102935. BUMPDIRECTUV: number;
  102936. PARALLAX: boolean;
  102937. PARALLAXOCCLUSION: boolean;
  102938. SPECULAROVERALPHA: boolean;
  102939. CLIPPLANE: boolean;
  102940. CLIPPLANE2: boolean;
  102941. CLIPPLANE3: boolean;
  102942. CLIPPLANE4: boolean;
  102943. CLIPPLANE5: boolean;
  102944. CLIPPLANE6: boolean;
  102945. ALPHATEST: boolean;
  102946. DEPTHPREPASS: boolean;
  102947. ALPHAFROMDIFFUSE: boolean;
  102948. POINTSIZE: boolean;
  102949. FOG: boolean;
  102950. SPECULARTERM: boolean;
  102951. DIFFUSEFRESNEL: boolean;
  102952. OPACITYFRESNEL: boolean;
  102953. REFLECTIONFRESNEL: boolean;
  102954. REFRACTIONFRESNEL: boolean;
  102955. EMISSIVEFRESNEL: boolean;
  102956. FRESNEL: boolean;
  102957. NORMAL: boolean;
  102958. UV1: boolean;
  102959. UV2: boolean;
  102960. VERTEXCOLOR: boolean;
  102961. VERTEXALPHA: boolean;
  102962. NUM_BONE_INFLUENCERS: number;
  102963. BonesPerMesh: number;
  102964. BONETEXTURE: boolean;
  102965. INSTANCES: boolean;
  102966. GLOSSINESS: boolean;
  102967. ROUGHNESS: boolean;
  102968. EMISSIVEASILLUMINATION: boolean;
  102969. LINKEMISSIVEWITHDIFFUSE: boolean;
  102970. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102971. LIGHTMAP: boolean;
  102972. LIGHTMAPDIRECTUV: number;
  102973. OBJECTSPACE_NORMALMAP: boolean;
  102974. USELIGHTMAPASSHADOWMAP: boolean;
  102975. REFLECTIONMAP_3D: boolean;
  102976. REFLECTIONMAP_SPHERICAL: boolean;
  102977. REFLECTIONMAP_PLANAR: boolean;
  102978. REFLECTIONMAP_CUBIC: boolean;
  102979. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102980. REFLECTIONMAP_PROJECTION: boolean;
  102981. REFLECTIONMAP_SKYBOX: boolean;
  102982. REFLECTIONMAP_EXPLICIT: boolean;
  102983. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102984. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102985. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102986. INVERTCUBICMAP: boolean;
  102987. LOGARITHMICDEPTH: boolean;
  102988. REFRACTION: boolean;
  102989. REFRACTIONMAP_3D: boolean;
  102990. REFLECTIONOVERALPHA: boolean;
  102991. TWOSIDEDLIGHTING: boolean;
  102992. SHADOWFLOAT: boolean;
  102993. MORPHTARGETS: boolean;
  102994. MORPHTARGETS_NORMAL: boolean;
  102995. MORPHTARGETS_TANGENT: boolean;
  102996. MORPHTARGETS_UV: boolean;
  102997. NUM_MORPH_INFLUENCERS: number;
  102998. NONUNIFORMSCALING: boolean;
  102999. PREMULTIPLYALPHA: boolean;
  103000. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  103001. ALPHABLEND: boolean;
  103002. RGBDLIGHTMAP: boolean;
  103003. RGBDREFLECTION: boolean;
  103004. RGBDREFRACTION: boolean;
  103005. IMAGEPROCESSING: boolean;
  103006. VIGNETTE: boolean;
  103007. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103008. VIGNETTEBLENDMODEOPAQUE: boolean;
  103009. TONEMAPPING: boolean;
  103010. TONEMAPPING_ACES: boolean;
  103011. CONTRAST: boolean;
  103012. COLORCURVES: boolean;
  103013. COLORGRADING: boolean;
  103014. COLORGRADING3D: boolean;
  103015. SAMPLER3DGREENDEPTH: boolean;
  103016. SAMPLER3DBGRMAP: boolean;
  103017. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103018. MULTIVIEW: boolean;
  103019. /**
  103020. * If the reflection texture on this material is in linear color space
  103021. * @hidden
  103022. */
  103023. IS_REFLECTION_LINEAR: boolean;
  103024. /**
  103025. * If the refraction texture on this material is in linear color space
  103026. * @hidden
  103027. */
  103028. IS_REFRACTION_LINEAR: boolean;
  103029. EXPOSURE: boolean;
  103030. constructor();
  103031. setReflectionMode(modeToEnable: string): void;
  103032. }
  103033. /**
  103034. * This is the default material used in Babylon. It is the best trade off between quality
  103035. * and performances.
  103036. * @see http://doc.babylonjs.com/babylon101/materials
  103037. */
  103038. export class StandardMaterial extends PushMaterial {
  103039. private _diffuseTexture;
  103040. /**
  103041. * The basic texture of the material as viewed under a light.
  103042. */
  103043. diffuseTexture: Nullable<BaseTexture>;
  103044. private _ambientTexture;
  103045. /**
  103046. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103047. */
  103048. ambientTexture: Nullable<BaseTexture>;
  103049. private _opacityTexture;
  103050. /**
  103051. * Define the transparency of the material from a texture.
  103052. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103053. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103054. */
  103055. opacityTexture: Nullable<BaseTexture>;
  103056. private _reflectionTexture;
  103057. /**
  103058. * Define the texture used to display the reflection.
  103059. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103060. */
  103061. reflectionTexture: Nullable<BaseTexture>;
  103062. private _emissiveTexture;
  103063. /**
  103064. * Define texture of the material as if self lit.
  103065. * This will be mixed in the final result even in the absence of light.
  103066. */
  103067. emissiveTexture: Nullable<BaseTexture>;
  103068. private _specularTexture;
  103069. /**
  103070. * Define how the color and intensity of the highlight given by the light in the material.
  103071. */
  103072. specularTexture: Nullable<BaseTexture>;
  103073. private _bumpTexture;
  103074. /**
  103075. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103076. * 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.
  103077. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103078. */
  103079. bumpTexture: Nullable<BaseTexture>;
  103080. private _lightmapTexture;
  103081. /**
  103082. * Complex lighting can be computationally expensive to compute at runtime.
  103083. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103084. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103085. */
  103086. lightmapTexture: Nullable<BaseTexture>;
  103087. private _refractionTexture;
  103088. /**
  103089. * Define the texture used to display the refraction.
  103090. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103091. */
  103092. refractionTexture: Nullable<BaseTexture>;
  103093. /**
  103094. * The color of the material lit by the environmental background lighting.
  103095. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103096. */
  103097. ambientColor: Color3;
  103098. /**
  103099. * The basic color of the material as viewed under a light.
  103100. */
  103101. diffuseColor: Color3;
  103102. /**
  103103. * Define how the color and intensity of the highlight given by the light in the material.
  103104. */
  103105. specularColor: Color3;
  103106. /**
  103107. * Define the color of the material as if self lit.
  103108. * This will be mixed in the final result even in the absence of light.
  103109. */
  103110. emissiveColor: Color3;
  103111. /**
  103112. * Defines how sharp are the highlights in the material.
  103113. * The bigger the value the sharper giving a more glossy feeling to the result.
  103114. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103115. */
  103116. specularPower: number;
  103117. private _useAlphaFromDiffuseTexture;
  103118. /**
  103119. * Does the transparency come from the diffuse texture alpha channel.
  103120. */
  103121. useAlphaFromDiffuseTexture: boolean;
  103122. private _useEmissiveAsIllumination;
  103123. /**
  103124. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103125. */
  103126. useEmissiveAsIllumination: boolean;
  103127. private _linkEmissiveWithDiffuse;
  103128. /**
  103129. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103130. * the emissive level when the final color is close to one.
  103131. */
  103132. linkEmissiveWithDiffuse: boolean;
  103133. private _useSpecularOverAlpha;
  103134. /**
  103135. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103136. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103137. */
  103138. useSpecularOverAlpha: boolean;
  103139. private _useReflectionOverAlpha;
  103140. /**
  103141. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103142. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103143. */
  103144. useReflectionOverAlpha: boolean;
  103145. private _disableLighting;
  103146. /**
  103147. * Does lights from the scene impacts this material.
  103148. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103149. */
  103150. disableLighting: boolean;
  103151. private _useObjectSpaceNormalMap;
  103152. /**
  103153. * Allows using an object space normal map (instead of tangent space).
  103154. */
  103155. useObjectSpaceNormalMap: boolean;
  103156. private _useParallax;
  103157. /**
  103158. * Is parallax enabled or not.
  103159. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103160. */
  103161. useParallax: boolean;
  103162. private _useParallaxOcclusion;
  103163. /**
  103164. * Is parallax occlusion enabled or not.
  103165. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103166. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103167. */
  103168. useParallaxOcclusion: boolean;
  103169. /**
  103170. * 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.
  103171. */
  103172. parallaxScaleBias: number;
  103173. private _roughness;
  103174. /**
  103175. * Helps to define how blurry the reflections should appears in the material.
  103176. */
  103177. roughness: number;
  103178. /**
  103179. * In case of refraction, define the value of the index of refraction.
  103180. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103181. */
  103182. indexOfRefraction: number;
  103183. /**
  103184. * Invert the refraction texture alongside the y axis.
  103185. * It can be useful with procedural textures or probe for instance.
  103186. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103187. */
  103188. invertRefractionY: boolean;
  103189. /**
  103190. * Defines the alpha limits in alpha test mode.
  103191. */
  103192. alphaCutOff: number;
  103193. private _useLightmapAsShadowmap;
  103194. /**
  103195. * In case of light mapping, define whether the map contains light or shadow informations.
  103196. */
  103197. useLightmapAsShadowmap: boolean;
  103198. private _diffuseFresnelParameters;
  103199. /**
  103200. * Define the diffuse fresnel parameters of the material.
  103201. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103202. */
  103203. diffuseFresnelParameters: FresnelParameters;
  103204. private _opacityFresnelParameters;
  103205. /**
  103206. * Define the opacity fresnel parameters of the material.
  103207. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103208. */
  103209. opacityFresnelParameters: FresnelParameters;
  103210. private _reflectionFresnelParameters;
  103211. /**
  103212. * Define the reflection fresnel parameters of the material.
  103213. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103214. */
  103215. reflectionFresnelParameters: FresnelParameters;
  103216. private _refractionFresnelParameters;
  103217. /**
  103218. * Define the refraction fresnel parameters of the material.
  103219. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103220. */
  103221. refractionFresnelParameters: FresnelParameters;
  103222. private _emissiveFresnelParameters;
  103223. /**
  103224. * Define the emissive fresnel parameters of the material.
  103225. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103226. */
  103227. emissiveFresnelParameters: FresnelParameters;
  103228. private _useReflectionFresnelFromSpecular;
  103229. /**
  103230. * If true automatically deducts the fresnels values from the material specularity.
  103231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103232. */
  103233. useReflectionFresnelFromSpecular: boolean;
  103234. private _useGlossinessFromSpecularMapAlpha;
  103235. /**
  103236. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103237. */
  103238. useGlossinessFromSpecularMapAlpha: boolean;
  103239. private _maxSimultaneousLights;
  103240. /**
  103241. * Defines the maximum number of lights that can be used in the material
  103242. */
  103243. maxSimultaneousLights: number;
  103244. private _invertNormalMapX;
  103245. /**
  103246. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103247. */
  103248. invertNormalMapX: boolean;
  103249. private _invertNormalMapY;
  103250. /**
  103251. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103252. */
  103253. invertNormalMapY: boolean;
  103254. private _twoSidedLighting;
  103255. /**
  103256. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103257. */
  103258. twoSidedLighting: boolean;
  103259. /**
  103260. * Default configuration related to image processing available in the standard Material.
  103261. */
  103262. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103263. /**
  103264. * Gets the image processing configuration used either in this material.
  103265. */
  103266. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103267. /**
  103268. * Sets the Default image processing configuration used either in the this material.
  103269. *
  103270. * If sets to null, the scene one is in use.
  103271. */
  103272. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103273. /**
  103274. * Keep track of the image processing observer to allow dispose and replace.
  103275. */
  103276. private _imageProcessingObserver;
  103277. /**
  103278. * Attaches a new image processing configuration to the Standard Material.
  103279. * @param configuration
  103280. */
  103281. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103282. /**
  103283. * Gets wether the color curves effect is enabled.
  103284. */
  103285. get cameraColorCurvesEnabled(): boolean;
  103286. /**
  103287. * Sets wether the color curves effect is enabled.
  103288. */
  103289. set cameraColorCurvesEnabled(value: boolean);
  103290. /**
  103291. * Gets wether the color grading effect is enabled.
  103292. */
  103293. get cameraColorGradingEnabled(): boolean;
  103294. /**
  103295. * Gets wether the color grading effect is enabled.
  103296. */
  103297. set cameraColorGradingEnabled(value: boolean);
  103298. /**
  103299. * Gets wether tonemapping is enabled or not.
  103300. */
  103301. get cameraToneMappingEnabled(): boolean;
  103302. /**
  103303. * Sets wether tonemapping is enabled or not
  103304. */
  103305. set cameraToneMappingEnabled(value: boolean);
  103306. /**
  103307. * The camera exposure used on this material.
  103308. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103309. * This corresponds to a photographic exposure.
  103310. */
  103311. get cameraExposure(): number;
  103312. /**
  103313. * The camera exposure used on this material.
  103314. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103315. * This corresponds to a photographic exposure.
  103316. */
  103317. set cameraExposure(value: number);
  103318. /**
  103319. * Gets The camera contrast used on this material.
  103320. */
  103321. get cameraContrast(): number;
  103322. /**
  103323. * Sets The camera contrast used on this material.
  103324. */
  103325. set cameraContrast(value: number);
  103326. /**
  103327. * Gets the Color Grading 2D Lookup Texture.
  103328. */
  103329. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103330. /**
  103331. * Sets the Color Grading 2D Lookup Texture.
  103332. */
  103333. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103334. /**
  103335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103337. * 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;
  103338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103339. */
  103340. get cameraColorCurves(): Nullable<ColorCurves>;
  103341. /**
  103342. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103343. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103344. * 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;
  103345. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103346. */
  103347. set cameraColorCurves(value: Nullable<ColorCurves>);
  103348. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103349. protected _worldViewProjectionMatrix: Matrix;
  103350. protected _globalAmbientColor: Color3;
  103351. protected _useLogarithmicDepth: boolean;
  103352. protected _rebuildInParallel: boolean;
  103353. /**
  103354. * Instantiates a new standard material.
  103355. * This is the default material used in Babylon. It is the best trade off between quality
  103356. * and performances.
  103357. * @see http://doc.babylonjs.com/babylon101/materials
  103358. * @param name Define the name of the material in the scene
  103359. * @param scene Define the scene the material belong to
  103360. */
  103361. constructor(name: string, scene: Scene);
  103362. /**
  103363. * Gets a boolean indicating that current material needs to register RTT
  103364. */
  103365. get hasRenderTargetTextures(): boolean;
  103366. /**
  103367. * Gets the current class name of the material e.g. "StandardMaterial"
  103368. * Mainly use in serialization.
  103369. * @returns the class name
  103370. */
  103371. getClassName(): string;
  103372. /**
  103373. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103374. * You can try switching to logarithmic depth.
  103375. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103376. */
  103377. get useLogarithmicDepth(): boolean;
  103378. set useLogarithmicDepth(value: boolean);
  103379. /**
  103380. * Specifies if the material will require alpha blending
  103381. * @returns a boolean specifying if alpha blending is needed
  103382. */
  103383. needAlphaBlending(): boolean;
  103384. /**
  103385. * Specifies if this material should be rendered in alpha test mode
  103386. * @returns a boolean specifying if an alpha test is needed.
  103387. */
  103388. needAlphaTesting(): boolean;
  103389. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103390. /**
  103391. * Get the texture used for alpha test purpose.
  103392. * @returns the diffuse texture in case of the standard material.
  103393. */
  103394. getAlphaTestTexture(): Nullable<BaseTexture>;
  103395. /**
  103396. * Get if the submesh is ready to be used and all its information available.
  103397. * Child classes can use it to update shaders
  103398. * @param mesh defines the mesh to check
  103399. * @param subMesh defines which submesh to check
  103400. * @param useInstances specifies that instances should be used
  103401. * @returns a boolean indicating that the submesh is ready or not
  103402. */
  103403. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103404. /**
  103405. * Builds the material UBO layouts.
  103406. * Used internally during the effect preparation.
  103407. */
  103408. buildUniformLayout(): void;
  103409. /**
  103410. * Unbinds the material from the mesh
  103411. */
  103412. unbind(): void;
  103413. /**
  103414. * Binds the submesh to this material by preparing the effect and shader to draw
  103415. * @param world defines the world transformation matrix
  103416. * @param mesh defines the mesh containing the submesh
  103417. * @param subMesh defines the submesh to bind the material to
  103418. */
  103419. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103420. /**
  103421. * Get the list of animatables in the material.
  103422. * @returns the list of animatables object used in the material
  103423. */
  103424. getAnimatables(): IAnimatable[];
  103425. /**
  103426. * Gets the active textures from the material
  103427. * @returns an array of textures
  103428. */
  103429. getActiveTextures(): BaseTexture[];
  103430. /**
  103431. * Specifies if the material uses a texture
  103432. * @param texture defines the texture to check against the material
  103433. * @returns a boolean specifying if the material uses the texture
  103434. */
  103435. hasTexture(texture: BaseTexture): boolean;
  103436. /**
  103437. * Disposes the material
  103438. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103439. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103440. */
  103441. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103442. /**
  103443. * Makes a duplicate of the material, and gives it a new name
  103444. * @param name defines the new name for the duplicated material
  103445. * @returns the cloned material
  103446. */
  103447. clone(name: string): StandardMaterial;
  103448. /**
  103449. * Serializes this material in a JSON representation
  103450. * @returns the serialized material object
  103451. */
  103452. serialize(): any;
  103453. /**
  103454. * Creates a standard material from parsed material data
  103455. * @param source defines the JSON representation of the material
  103456. * @param scene defines the hosting scene
  103457. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103458. * @returns a new standard material
  103459. */
  103460. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103461. /**
  103462. * Are diffuse textures enabled in the application.
  103463. */
  103464. static get DiffuseTextureEnabled(): boolean;
  103465. static set DiffuseTextureEnabled(value: boolean);
  103466. /**
  103467. * Are ambient textures enabled in the application.
  103468. */
  103469. static get AmbientTextureEnabled(): boolean;
  103470. static set AmbientTextureEnabled(value: boolean);
  103471. /**
  103472. * Are opacity textures enabled in the application.
  103473. */
  103474. static get OpacityTextureEnabled(): boolean;
  103475. static set OpacityTextureEnabled(value: boolean);
  103476. /**
  103477. * Are reflection textures enabled in the application.
  103478. */
  103479. static get ReflectionTextureEnabled(): boolean;
  103480. static set ReflectionTextureEnabled(value: boolean);
  103481. /**
  103482. * Are emissive textures enabled in the application.
  103483. */
  103484. static get EmissiveTextureEnabled(): boolean;
  103485. static set EmissiveTextureEnabled(value: boolean);
  103486. /**
  103487. * Are specular textures enabled in the application.
  103488. */
  103489. static get SpecularTextureEnabled(): boolean;
  103490. static set SpecularTextureEnabled(value: boolean);
  103491. /**
  103492. * Are bump textures enabled in the application.
  103493. */
  103494. static get BumpTextureEnabled(): boolean;
  103495. static set BumpTextureEnabled(value: boolean);
  103496. /**
  103497. * Are lightmap textures enabled in the application.
  103498. */
  103499. static get LightmapTextureEnabled(): boolean;
  103500. static set LightmapTextureEnabled(value: boolean);
  103501. /**
  103502. * Are refraction textures enabled in the application.
  103503. */
  103504. static get RefractionTextureEnabled(): boolean;
  103505. static set RefractionTextureEnabled(value: boolean);
  103506. /**
  103507. * Are color grading textures enabled in the application.
  103508. */
  103509. static get ColorGradingTextureEnabled(): boolean;
  103510. static set ColorGradingTextureEnabled(value: boolean);
  103511. /**
  103512. * Are fresnels enabled in the application.
  103513. */
  103514. static get FresnelEnabled(): boolean;
  103515. static set FresnelEnabled(value: boolean);
  103516. }
  103517. }
  103518. declare module BABYLON {
  103519. /**
  103520. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  103521. *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.
  103522. * The SPS is also a particle system. It provides some methods to manage the particles.
  103523. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  103524. *
  103525. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  103526. */
  103527. export class SolidParticleSystem implements IDisposable {
  103528. /**
  103529. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  103530. * Example : var p = SPS.particles[i];
  103531. */
  103532. particles: SolidParticle[];
  103533. /**
  103534. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  103535. */
  103536. nbParticles: number;
  103537. /**
  103538. * If the particles must ever face the camera (default false). Useful for planar particles.
  103539. */
  103540. billboard: boolean;
  103541. /**
  103542. * Recompute normals when adding a shape
  103543. */
  103544. recomputeNormals: boolean;
  103545. /**
  103546. * This a counter ofr your own usage. It's not set by any SPS functions.
  103547. */
  103548. counter: number;
  103549. /**
  103550. * The SPS name. This name is also given to the underlying mesh.
  103551. */
  103552. name: string;
  103553. /**
  103554. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  103555. */
  103556. mesh: Mesh;
  103557. /**
  103558. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  103559. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  103560. */
  103561. vars: any;
  103562. /**
  103563. * This array is populated when the SPS is set as 'pickable'.
  103564. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  103565. * Each element of this array is an object `{idx: int, faceId: int}`.
  103566. * `idx` is the picked particle index in the `SPS.particles` array
  103567. * `faceId` is the picked face index counted within this particle.
  103568. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  103569. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  103570. * Use the method SPS.pickedParticle(pickingInfo) instead.
  103571. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103572. */
  103573. pickedParticles: {
  103574. idx: number;
  103575. faceId: number;
  103576. }[];
  103577. /**
  103578. * This array is populated when the SPS is set as 'pickable'
  103579. * Each key of this array is a submesh index.
  103580. * Each element of this array is a second array defined like this :
  103581. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  103582. * Each element of this second array is an object `{idx: int, faceId: int}`.
  103583. * `idx` is the picked particle index in the `SPS.particles` array
  103584. * `faceId` is the picked face index counted within this particle.
  103585. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  103586. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103587. */
  103588. pickedBySubMesh: {
  103589. idx: number;
  103590. faceId: number;
  103591. }[][];
  103592. /**
  103593. * This array is populated when `enableDepthSort` is set to true.
  103594. * Each element of this array is an instance of the class DepthSortedParticle.
  103595. */
  103596. depthSortedParticles: DepthSortedParticle[];
  103597. /**
  103598. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  103599. * @hidden
  103600. */
  103601. _bSphereOnly: boolean;
  103602. /**
  103603. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  103604. * @hidden
  103605. */
  103606. _bSphereRadiusFactor: number;
  103607. private _scene;
  103608. private _positions;
  103609. private _indices;
  103610. private _normals;
  103611. private _colors;
  103612. private _uvs;
  103613. private _indices32;
  103614. private _positions32;
  103615. private _normals32;
  103616. private _fixedNormal32;
  103617. private _colors32;
  103618. private _uvs32;
  103619. private _index;
  103620. private _updatable;
  103621. private _pickable;
  103622. private _isVisibilityBoxLocked;
  103623. private _alwaysVisible;
  103624. private _depthSort;
  103625. private _expandable;
  103626. private _shapeCounter;
  103627. private _copy;
  103628. private _color;
  103629. private _computeParticleColor;
  103630. private _computeParticleTexture;
  103631. private _computeParticleRotation;
  103632. private _computeParticleVertex;
  103633. private _computeBoundingBox;
  103634. private _depthSortParticles;
  103635. private _camera;
  103636. private _mustUnrotateFixedNormals;
  103637. private _particlesIntersect;
  103638. private _needs32Bits;
  103639. private _isNotBuilt;
  103640. private _lastParticleId;
  103641. private _idxOfId;
  103642. private _multimaterialEnabled;
  103643. private _useModelMaterial;
  103644. private _indicesByMaterial;
  103645. private _materialIndexes;
  103646. private _depthSortFunction;
  103647. private _materialSortFunction;
  103648. private _materials;
  103649. private _multimaterial;
  103650. private _materialIndexesById;
  103651. private _defaultMaterial;
  103652. private _autoUpdateSubMeshes;
  103653. private _tmpVertex;
  103654. /**
  103655. * Creates a SPS (Solid Particle System) object.
  103656. * @param name (String) is the SPS name, this will be the underlying mesh name.
  103657. * @param scene (Scene) is the scene in which the SPS is added.
  103658. * @param options defines the options of the sps e.g.
  103659. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  103660. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  103661. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  103662. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  103663. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  103664. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  103665. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  103666. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  103667. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  103668. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  103669. */
  103670. constructor(name: string, scene: Scene, options?: {
  103671. updatable?: boolean;
  103672. isPickable?: boolean;
  103673. enableDepthSort?: boolean;
  103674. particleIntersection?: boolean;
  103675. boundingSphereOnly?: boolean;
  103676. bSphereRadiusFactor?: number;
  103677. expandable?: boolean;
  103678. useModelMaterial?: boolean;
  103679. enableMultiMaterial?: boolean;
  103680. });
  103681. /**
  103682. * Builds the SPS underlying mesh. Returns a standard Mesh.
  103683. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  103684. * @returns the created mesh
  103685. */
  103686. buildMesh(): Mesh;
  103687. /**
  103688. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  103689. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  103690. * Thus the particles generated from `digest()` have their property `position` set yet.
  103691. * @param mesh ( Mesh ) is the mesh to be digested
  103692. * @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
  103693. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  103694. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  103695. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103696. * @returns the current SPS
  103697. */
  103698. digest(mesh: Mesh, options?: {
  103699. facetNb?: number;
  103700. number?: number;
  103701. delta?: number;
  103702. storage?: [];
  103703. }): SolidParticleSystem;
  103704. /**
  103705. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  103706. * @hidden
  103707. */
  103708. private _unrotateFixedNormals;
  103709. /**
  103710. * Resets the temporary working copy particle
  103711. * @hidden
  103712. */
  103713. private _resetCopy;
  103714. /**
  103715. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  103716. * @param p the current index in the positions array to be updated
  103717. * @param ind the current index in the indices array
  103718. * @param shape a Vector3 array, the shape geometry
  103719. * @param positions the positions array to be updated
  103720. * @param meshInd the shape indices array
  103721. * @param indices the indices array to be updated
  103722. * @param meshUV the shape uv array
  103723. * @param uvs the uv array to be updated
  103724. * @param meshCol the shape color array
  103725. * @param colors the color array to be updated
  103726. * @param meshNor the shape normals array
  103727. * @param normals the normals array to be updated
  103728. * @param idx the particle index
  103729. * @param idxInShape the particle index in its shape
  103730. * @param options the addShape() method passed options
  103731. * @model the particle model
  103732. * @hidden
  103733. */
  103734. private _meshBuilder;
  103735. /**
  103736. * Returns a shape Vector3 array from positions float array
  103737. * @param positions float array
  103738. * @returns a vector3 array
  103739. * @hidden
  103740. */
  103741. private _posToShape;
  103742. /**
  103743. * Returns a shapeUV array from a float uvs (array deep copy)
  103744. * @param uvs as a float array
  103745. * @returns a shapeUV array
  103746. * @hidden
  103747. */
  103748. private _uvsToShapeUV;
  103749. /**
  103750. * Adds a new particle object in the particles array
  103751. * @param idx particle index in particles array
  103752. * @param id particle id
  103753. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  103754. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  103755. * @param model particle ModelShape object
  103756. * @param shapeId model shape identifier
  103757. * @param idxInShape index of the particle in the current model
  103758. * @param bInfo model bounding info object
  103759. * @param storage target storage array, if any
  103760. * @hidden
  103761. */
  103762. private _addParticle;
  103763. /**
  103764. * Adds some particles to the SPS from the model shape. Returns the shape id.
  103765. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  103766. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  103767. * @param nb (positive integer) the number of particles to be created from this model
  103768. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  103769. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  103770. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103771. * @returns the number of shapes in the system
  103772. */
  103773. addShape(mesh: Mesh, nb: number, options?: {
  103774. positionFunction?: any;
  103775. vertexFunction?: any;
  103776. storage?: [];
  103777. }): number;
  103778. /**
  103779. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  103780. * @hidden
  103781. */
  103782. private _rebuildParticle;
  103783. /**
  103784. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  103785. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  103786. * @returns the SPS.
  103787. */
  103788. rebuildMesh(reset?: boolean): SolidParticleSystem;
  103789. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  103790. * Returns an array with the removed particles.
  103791. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  103792. * The SPS can't be empty so at least one particle needs to remain in place.
  103793. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  103794. * @param start index of the first particle to remove
  103795. * @param end index of the last particle to remove (included)
  103796. * @returns an array populated with the removed particles
  103797. */
  103798. removeParticles(start: number, end: number): SolidParticle[];
  103799. /**
  103800. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  103801. * @param solidParticleArray an array populated with Solid Particles objects
  103802. * @returns the SPS
  103803. */
  103804. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  103805. /**
  103806. * Creates a new particle and modifies the SPS mesh geometry :
  103807. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  103808. * - calls _addParticle() to populate the particle array
  103809. * factorized code from addShape() and insertParticlesFromArray()
  103810. * @param idx particle index in the particles array
  103811. * @param i particle index in its shape
  103812. * @param modelShape particle ModelShape object
  103813. * @param shape shape vertex array
  103814. * @param meshInd shape indices array
  103815. * @param meshUV shape uv array
  103816. * @param meshCol shape color array
  103817. * @param meshNor shape normals array
  103818. * @param bbInfo shape bounding info
  103819. * @param storage target particle storage
  103820. * @options addShape() passed options
  103821. * @hidden
  103822. */
  103823. private _insertNewParticle;
  103824. /**
  103825. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  103826. * This method calls `updateParticle()` for each particle of the SPS.
  103827. * For an animated SPS, it is usually called within the render loop.
  103828. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  103829. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  103830. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  103831. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  103832. * @returns the SPS.
  103833. */
  103834. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  103835. /**
  103836. * Disposes the SPS.
  103837. */
  103838. dispose(): void;
  103839. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  103840. * idx is the particle index in the SPS
  103841. * faceId is the picked face index counted within this particle.
  103842. * Returns null if the pickInfo can't identify a picked particle.
  103843. * @param pickingInfo (PickingInfo object)
  103844. * @returns {idx: number, faceId: number} or null
  103845. */
  103846. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  103847. idx: number;
  103848. faceId: number;
  103849. }>;
  103850. /**
  103851. * Returns a SolidParticle object from its identifier : particle.id
  103852. * @param id (integer) the particle Id
  103853. * @returns the searched particle or null if not found in the SPS.
  103854. */
  103855. getParticleById(id: number): Nullable<SolidParticle>;
  103856. /**
  103857. * Returns a new array populated with the particles having the passed shapeId.
  103858. * @param shapeId (integer) the shape identifier
  103859. * @returns a new solid particle array
  103860. */
  103861. getParticlesByShapeId(shapeId: number): SolidParticle[];
  103862. /**
  103863. * Populates the passed array "ref" with the particles having the passed shapeId.
  103864. * @param shapeId the shape identifier
  103865. * @returns the SPS
  103866. * @param ref
  103867. */
  103868. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  103869. /**
  103870. * Computes the required SubMeshes according the materials assigned to the particles.
  103871. * @returns the solid particle system.
  103872. * Does nothing if called before the SPS mesh is built.
  103873. */
  103874. computeSubMeshes(): SolidParticleSystem;
  103875. /**
  103876. * Sorts the solid particles by material when MultiMaterial is enabled.
  103877. * Updates the indices32 array.
  103878. * Updates the indicesByMaterial array.
  103879. * Updates the mesh indices array.
  103880. * @returns the SPS
  103881. * @hidden
  103882. */
  103883. private _sortParticlesByMaterial;
  103884. /**
  103885. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  103886. * @hidden
  103887. */
  103888. private _setMaterialIndexesById;
  103889. /**
  103890. * Returns an array with unique values of Materials from the passed array
  103891. * @param array the material array to be checked and filtered
  103892. * @hidden
  103893. */
  103894. private _filterUniqueMaterialId;
  103895. /**
  103896. * Sets a new Standard Material as _defaultMaterial if not already set.
  103897. * @hidden
  103898. */
  103899. private _setDefaultMaterial;
  103900. /**
  103901. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  103902. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103903. * @returns the SPS.
  103904. */
  103905. refreshVisibleSize(): SolidParticleSystem;
  103906. /**
  103907. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  103908. * @param size the size (float) of the visibility box
  103909. * note : this doesn't lock the SPS mesh bounding box.
  103910. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103911. */
  103912. setVisibilityBox(size: number): void;
  103913. /**
  103914. * Gets whether the SPS as always visible or not
  103915. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103916. */
  103917. get isAlwaysVisible(): boolean;
  103918. /**
  103919. * Sets the SPS as always visible or not
  103920. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103921. */
  103922. set isAlwaysVisible(val: boolean);
  103923. /**
  103924. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103925. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103926. */
  103927. set isVisibilityBoxLocked(val: boolean);
  103928. /**
  103929. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103930. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103931. */
  103932. get isVisibilityBoxLocked(): boolean;
  103933. /**
  103934. * Tells to `setParticles()` to compute the particle rotations or not.
  103935. * Default value : true. The SPS is faster when it's set to false.
  103936. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103937. */
  103938. set computeParticleRotation(val: boolean);
  103939. /**
  103940. * Tells to `setParticles()` to compute the particle colors or not.
  103941. * Default value : true. The SPS is faster when it's set to false.
  103942. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103943. */
  103944. set computeParticleColor(val: boolean);
  103945. set computeParticleTexture(val: boolean);
  103946. /**
  103947. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  103948. * Default value : false. The SPS is faster when it's set to false.
  103949. * Note : the particle custom vertex positions aren't stored values.
  103950. */
  103951. set computeParticleVertex(val: boolean);
  103952. /**
  103953. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  103954. */
  103955. set computeBoundingBox(val: boolean);
  103956. /**
  103957. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  103958. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103959. * Default : `true`
  103960. */
  103961. set depthSortParticles(val: boolean);
  103962. /**
  103963. * Gets if `setParticles()` computes the particle rotations or not.
  103964. * Default value : true. The SPS is faster when it's set to false.
  103965. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103966. */
  103967. get computeParticleRotation(): boolean;
  103968. /**
  103969. * Gets if `setParticles()` computes the particle colors or not.
  103970. * Default value : true. The SPS is faster when it's set to false.
  103971. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103972. */
  103973. get computeParticleColor(): boolean;
  103974. /**
  103975. * Gets if `setParticles()` computes the particle textures or not.
  103976. * Default value : true. The SPS is faster when it's set to false.
  103977. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  103978. */
  103979. get computeParticleTexture(): boolean;
  103980. /**
  103981. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  103982. * Default value : false. The SPS is faster when it's set to false.
  103983. * Note : the particle custom vertex positions aren't stored values.
  103984. */
  103985. get computeParticleVertex(): boolean;
  103986. /**
  103987. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  103988. */
  103989. get computeBoundingBox(): boolean;
  103990. /**
  103991. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  103992. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103993. * Default : `true`
  103994. */
  103995. get depthSortParticles(): boolean;
  103996. /**
  103997. * Gets if the SPS is created as expandable at construction time.
  103998. * Default : `false`
  103999. */
  104000. get expandable(): boolean;
  104001. /**
  104002. * Gets if the SPS supports the Multi Materials
  104003. */
  104004. get multimaterialEnabled(): boolean;
  104005. /**
  104006. * Gets if the SPS uses the model materials for its own multimaterial.
  104007. */
  104008. get useModelMaterial(): boolean;
  104009. /**
  104010. * The SPS used material array.
  104011. */
  104012. get materials(): Material[];
  104013. /**
  104014. * Sets the SPS MultiMaterial from the passed materials.
  104015. * Note : the passed array is internally copied and not used then by reference.
  104016. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  104017. */
  104018. setMultiMaterial(materials: Material[]): void;
  104019. /**
  104020. * The SPS computed multimaterial object
  104021. */
  104022. get multimaterial(): MultiMaterial;
  104023. set multimaterial(mm: MultiMaterial);
  104024. /**
  104025. * If the subMeshes must be updated on the next call to setParticles()
  104026. */
  104027. get autoUpdateSubMeshes(): boolean;
  104028. set autoUpdateSubMeshes(val: boolean);
  104029. /**
  104030. * This function does nothing. It may be overwritten to set all the particle first values.
  104031. * The SPS doesn't call this function, you may have to call it by your own.
  104032. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  104033. */
  104034. initParticles(): void;
  104035. /**
  104036. * This function does nothing. It may be overwritten to recycle a particle.
  104037. * The SPS doesn't call this function, you may have to call it by your own.
  104038. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  104039. * @param particle The particle to recycle
  104040. * @returns the recycled particle
  104041. */
  104042. recycleParticle(particle: SolidParticle): SolidParticle;
  104043. /**
  104044. * Updates a particle : this function should be overwritten by the user.
  104045. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  104046. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  104047. * @example : just set a particle position or velocity and recycle conditions
  104048. * @param particle The particle to update
  104049. * @returns the updated particle
  104050. */
  104051. updateParticle(particle: SolidParticle): SolidParticle;
  104052. /**
  104053. * Updates a vertex of a particle : it can be overwritten by the user.
  104054. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  104055. * @param particle the current particle
  104056. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  104057. * @param pt the index of the current vertex in the particle shape
  104058. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  104059. * @example : just set a vertex particle position or color
  104060. * @returns the sps
  104061. */
  104062. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  104063. /**
  104064. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  104065. * This does nothing and may be overwritten by the user.
  104066. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  104067. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  104068. * @param update the boolean update value actually passed to setParticles()
  104069. */
  104070. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  104071. /**
  104072. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  104073. * This will be passed three parameters.
  104074. * This does nothing and may be overwritten by the user.
  104075. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  104076. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  104077. * @param update the boolean update value actually passed to setParticles()
  104078. */
  104079. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  104080. }
  104081. }
  104082. declare module BABYLON {
  104083. /**
  104084. * Represents one particle of a solid particle system.
  104085. */
  104086. export class SolidParticle {
  104087. /**
  104088. * particle global index
  104089. */
  104090. idx: number;
  104091. /**
  104092. * particle identifier
  104093. */
  104094. id: number;
  104095. /**
  104096. * The color of the particle
  104097. */
  104098. color: Nullable<Color4>;
  104099. /**
  104100. * The world space position of the particle.
  104101. */
  104102. position: Vector3;
  104103. /**
  104104. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  104105. */
  104106. rotation: Vector3;
  104107. /**
  104108. * The world space rotation quaternion of the particle.
  104109. */
  104110. rotationQuaternion: Nullable<Quaternion>;
  104111. /**
  104112. * The scaling of the particle.
  104113. */
  104114. scaling: Vector3;
  104115. /**
  104116. * The uvs of the particle.
  104117. */
  104118. uvs: Vector4;
  104119. /**
  104120. * The current speed of the particle.
  104121. */
  104122. velocity: Vector3;
  104123. /**
  104124. * The pivot point in the particle local space.
  104125. */
  104126. pivot: Vector3;
  104127. /**
  104128. * Must the particle be translated from its pivot point in its local space ?
  104129. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  104130. * Default : false
  104131. */
  104132. translateFromPivot: boolean;
  104133. /**
  104134. * Is the particle active or not ?
  104135. */
  104136. alive: boolean;
  104137. /**
  104138. * Is the particle visible or not ?
  104139. */
  104140. isVisible: boolean;
  104141. /**
  104142. * Index of this particle in the global "positions" array (Internal use)
  104143. * @hidden
  104144. */
  104145. _pos: number;
  104146. /**
  104147. * @hidden Index of this particle in the global "indices" array (Internal use)
  104148. */
  104149. _ind: number;
  104150. /**
  104151. * @hidden ModelShape of this particle (Internal use)
  104152. */
  104153. _model: ModelShape;
  104154. /**
  104155. * ModelShape id of this particle
  104156. */
  104157. shapeId: number;
  104158. /**
  104159. * Index of the particle in its shape id
  104160. */
  104161. idxInShape: number;
  104162. /**
  104163. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  104164. */
  104165. _modelBoundingInfo: BoundingInfo;
  104166. /**
  104167. * @hidden Particle BoundingInfo object (Internal use)
  104168. */
  104169. _boundingInfo: BoundingInfo;
  104170. /**
  104171. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  104172. */
  104173. _sps: SolidParticleSystem;
  104174. /**
  104175. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  104176. */
  104177. _stillInvisible: boolean;
  104178. /**
  104179. * @hidden Last computed particle rotation matrix
  104180. */
  104181. _rotationMatrix: number[];
  104182. /**
  104183. * Parent particle Id, if any.
  104184. * Default null.
  104185. */
  104186. parentId: Nullable<number>;
  104187. /**
  104188. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  104189. */
  104190. materialIndex: Nullable<number>;
  104191. /**
  104192. * Custom object or properties.
  104193. */
  104194. props: Nullable<any>;
  104195. /**
  104196. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  104197. * The possible values are :
  104198. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104199. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104200. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104201. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104202. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104203. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  104204. * */
  104205. cullingStrategy: number;
  104206. /**
  104207. * @hidden Internal global position in the SPS.
  104208. */
  104209. _globalPosition: Vector3;
  104210. /**
  104211. * Creates a Solid Particle object.
  104212. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  104213. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  104214. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  104215. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  104216. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  104217. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  104218. * @param shapeId (integer) is the model shape identifier in the SPS.
  104219. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  104220. * @param sps defines the sps it is associated to
  104221. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  104222. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  104223. */
  104224. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  104225. /**
  104226. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  104227. * @param target the particle target
  104228. * @returns the current particle
  104229. */
  104230. copyToRef(target: SolidParticle): SolidParticle;
  104231. /**
  104232. * Legacy support, changed scale to scaling
  104233. */
  104234. get scale(): Vector3;
  104235. /**
  104236. * Legacy support, changed scale to scaling
  104237. */
  104238. set scale(scale: Vector3);
  104239. /**
  104240. * Legacy support, changed quaternion to rotationQuaternion
  104241. */
  104242. get quaternion(): Nullable<Quaternion>;
  104243. /**
  104244. * Legacy support, changed quaternion to rotationQuaternion
  104245. */
  104246. set quaternion(q: Nullable<Quaternion>);
  104247. /**
  104248. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  104249. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  104250. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  104251. * @returns true if it intersects
  104252. */
  104253. intersectsMesh(target: Mesh | SolidParticle): boolean;
  104254. /**
  104255. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  104256. * A particle is in the frustum if its bounding box intersects the frustum
  104257. * @param frustumPlanes defines the frustum to test
  104258. * @returns true if the particle is in the frustum planes
  104259. */
  104260. isInFrustum(frustumPlanes: Plane[]): boolean;
  104261. /**
  104262. * get the rotation matrix of the particle
  104263. * @hidden
  104264. */
  104265. getRotationMatrix(m: Matrix): void;
  104266. }
  104267. /**
  104268. * Represents the shape of the model used by one particle of a solid particle system.
  104269. * SPS internal tool, don't use it manually.
  104270. */
  104271. export class ModelShape {
  104272. /**
  104273. * The shape id
  104274. * @hidden
  104275. */
  104276. shapeID: number;
  104277. /**
  104278. * flat array of model positions (internal use)
  104279. * @hidden
  104280. */
  104281. _shape: Vector3[];
  104282. /**
  104283. * flat array of model UVs (internal use)
  104284. * @hidden
  104285. */
  104286. _shapeUV: number[];
  104287. /**
  104288. * color array of the model
  104289. * @hidden
  104290. */
  104291. _shapeColors: number[];
  104292. /**
  104293. * indices array of the model
  104294. * @hidden
  104295. */
  104296. _indices: number[];
  104297. /**
  104298. * normals array of the model
  104299. * @hidden
  104300. */
  104301. _normals: number[];
  104302. /**
  104303. * length of the shape in the model indices array (internal use)
  104304. * @hidden
  104305. */
  104306. _indicesLength: number;
  104307. /**
  104308. * Custom position function (internal use)
  104309. * @hidden
  104310. */
  104311. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  104312. /**
  104313. * Custom vertex function (internal use)
  104314. * @hidden
  104315. */
  104316. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  104317. /**
  104318. * Model material (internal use)
  104319. * @hidden
  104320. */
  104321. _material: Nullable<Material>;
  104322. /**
  104323. * 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.
  104324. * SPS internal tool, don't use it manually.
  104325. * @hidden
  104326. */
  104327. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  104328. }
  104329. /**
  104330. * Represents a Depth Sorted Particle in the solid particle system.
  104331. * @hidden
  104332. */
  104333. export class DepthSortedParticle {
  104334. /**
  104335. * Particle index
  104336. */
  104337. idx: number;
  104338. /**
  104339. * Index of the particle in the "indices" array
  104340. */
  104341. ind: number;
  104342. /**
  104343. * Length of the particle shape in the "indices" array
  104344. */
  104345. indicesLength: number;
  104346. /**
  104347. * Squared distance from the particle to the camera
  104348. */
  104349. sqDistance: number;
  104350. /**
  104351. * Material index when used with MultiMaterials
  104352. */
  104353. materialIndex: number;
  104354. /**
  104355. * Creates a new sorted particle
  104356. * @param materialIndex
  104357. */
  104358. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  104359. }
  104360. /**
  104361. * Represents a solid particle vertex
  104362. */
  104363. export class SolidParticleVertex {
  104364. /**
  104365. * Vertex position
  104366. */
  104367. position: Vector3;
  104368. /**
  104369. * Vertex color
  104370. */
  104371. color: Color4;
  104372. /**
  104373. * Vertex UV
  104374. */
  104375. uv: Vector2;
  104376. /**
  104377. * Creates a new solid particle vertex
  104378. */
  104379. constructor();
  104380. /** Vertex x coordinate */
  104381. get x(): number;
  104382. set x(val: number);
  104383. /** Vertex y coordinate */
  104384. get y(): number;
  104385. set y(val: number);
  104386. /** Vertex z coordinate */
  104387. get z(): number;
  104388. set z(val: number);
  104389. }
  104390. }
  104391. declare module BABYLON {
  104392. /**
  104393. * @hidden
  104394. */
  104395. export class _MeshCollisionData {
  104396. _checkCollisions: boolean;
  104397. _collisionMask: number;
  104398. _collisionGroup: number;
  104399. _surroundingMeshes: Nullable<AbstractMesh[]>;
  104400. _collider: Nullable<Collider>;
  104401. _oldPositionForCollisions: Vector3;
  104402. _diffPositionForCollisions: Vector3;
  104403. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  104404. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  104405. }
  104406. }
  104407. declare module BABYLON {
  104408. /** @hidden */
  104409. class _FacetDataStorage {
  104410. facetPositions: Vector3[];
  104411. facetNormals: Vector3[];
  104412. facetPartitioning: number[][];
  104413. facetNb: number;
  104414. partitioningSubdivisions: number;
  104415. partitioningBBoxRatio: number;
  104416. facetDataEnabled: boolean;
  104417. facetParameters: any;
  104418. bbSize: Vector3;
  104419. subDiv: {
  104420. max: number;
  104421. X: number;
  104422. Y: number;
  104423. Z: number;
  104424. };
  104425. facetDepthSort: boolean;
  104426. facetDepthSortEnabled: boolean;
  104427. depthSortedIndices: IndicesArray;
  104428. depthSortedFacets: {
  104429. ind: number;
  104430. sqDistance: number;
  104431. }[];
  104432. facetDepthSortFunction: (f1: {
  104433. ind: number;
  104434. sqDistance: number;
  104435. }, f2: {
  104436. ind: number;
  104437. sqDistance: number;
  104438. }) => number;
  104439. facetDepthSortFrom: Vector3;
  104440. facetDepthSortOrigin: Vector3;
  104441. invertedMatrix: Matrix;
  104442. }
  104443. /**
  104444. * @hidden
  104445. **/
  104446. class _InternalAbstractMeshDataInfo {
  104447. _hasVertexAlpha: boolean;
  104448. _useVertexColors: boolean;
  104449. _numBoneInfluencers: number;
  104450. _applyFog: boolean;
  104451. _receiveShadows: boolean;
  104452. _facetData: _FacetDataStorage;
  104453. _visibility: number;
  104454. _skeleton: Nullable<Skeleton>;
  104455. _layerMask: number;
  104456. _computeBonesUsingShaders: boolean;
  104457. _isActive: boolean;
  104458. _onlyForInstances: boolean;
  104459. _isActiveIntermediate: boolean;
  104460. _onlyForInstancesIntermediate: boolean;
  104461. _actAsRegularMesh: boolean;
  104462. }
  104463. /**
  104464. * Class used to store all common mesh properties
  104465. */
  104466. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  104467. /** No occlusion */
  104468. static OCCLUSION_TYPE_NONE: number;
  104469. /** Occlusion set to optimisitic */
  104470. static OCCLUSION_TYPE_OPTIMISTIC: number;
  104471. /** Occlusion set to strict */
  104472. static OCCLUSION_TYPE_STRICT: number;
  104473. /** Use an accurante occlusion algorithm */
  104474. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  104475. /** Use a conservative occlusion algorithm */
  104476. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  104477. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  104478. * Test order :
  104479. * Is the bounding sphere outside the frustum ?
  104480. * If not, are the bounding box vertices outside the frustum ?
  104481. * It not, then the cullable object is in the frustum.
  104482. */
  104483. static readonly CULLINGSTRATEGY_STANDARD: number;
  104484. /** Culling strategy : Bounding Sphere Only.
  104485. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  104486. * It's also less accurate than the standard because some not visible objects can still be selected.
  104487. * Test : is the bounding sphere outside the frustum ?
  104488. * If not, then the cullable object is in the frustum.
  104489. */
  104490. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  104491. /** Culling strategy : Optimistic Inclusion.
  104492. * This in an inclusion test first, then the standard exclusion test.
  104493. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  104494. * 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.
  104495. * Anyway, it's as accurate as the standard strategy.
  104496. * Test :
  104497. * Is the cullable object bounding sphere center in the frustum ?
  104498. * If not, apply the default culling strategy.
  104499. */
  104500. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  104501. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  104502. * This in an inclusion test first, then the bounding sphere only exclusion test.
  104503. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  104504. * 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.
  104505. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  104506. * Test :
  104507. * Is the cullable object bounding sphere center in the frustum ?
  104508. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  104509. */
  104510. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  104511. /**
  104512. * No billboard
  104513. */
  104514. static get BILLBOARDMODE_NONE(): number;
  104515. /** Billboard on X axis */
  104516. static get BILLBOARDMODE_X(): number;
  104517. /** Billboard on Y axis */
  104518. static get BILLBOARDMODE_Y(): number;
  104519. /** Billboard on Z axis */
  104520. static get BILLBOARDMODE_Z(): number;
  104521. /** Billboard on all axes */
  104522. static get BILLBOARDMODE_ALL(): number;
  104523. /** Billboard on using position instead of orientation */
  104524. static get BILLBOARDMODE_USE_POSITION(): number;
  104525. /** @hidden */
  104526. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  104527. /**
  104528. * The culling strategy to use to check whether the mesh must be rendered or not.
  104529. * This value can be changed at any time and will be used on the next render mesh selection.
  104530. * The possible values are :
  104531. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104532. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104533. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104534. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104535. * Please read each static variable documentation to get details about the culling process.
  104536. * */
  104537. cullingStrategy: number;
  104538. /**
  104539. * Gets the number of facets in the mesh
  104540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104541. */
  104542. get facetNb(): number;
  104543. /**
  104544. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  104545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104546. */
  104547. get partitioningSubdivisions(): number;
  104548. set partitioningSubdivisions(nb: number);
  104549. /**
  104550. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  104551. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  104552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104553. */
  104554. get partitioningBBoxRatio(): number;
  104555. set partitioningBBoxRatio(ratio: number);
  104556. /**
  104557. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  104558. * Works only for updatable meshes.
  104559. * Doesn't work with multi-materials
  104560. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104561. */
  104562. get mustDepthSortFacets(): boolean;
  104563. set mustDepthSortFacets(sort: boolean);
  104564. /**
  104565. * The location (Vector3) where the facet depth sort must be computed from.
  104566. * By default, the active camera position.
  104567. * Used only when facet depth sort is enabled
  104568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104569. */
  104570. get facetDepthSortFrom(): Vector3;
  104571. set facetDepthSortFrom(location: Vector3);
  104572. /**
  104573. * gets a boolean indicating if facetData is enabled
  104574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104575. */
  104576. get isFacetDataEnabled(): boolean;
  104577. /** @hidden */
  104578. _updateNonUniformScalingState(value: boolean): boolean;
  104579. /**
  104580. * An event triggered when this mesh collides with another one
  104581. */
  104582. onCollideObservable: Observable<AbstractMesh>;
  104583. /** Set a function to call when this mesh collides with another one */
  104584. set onCollide(callback: () => void);
  104585. /**
  104586. * An event triggered when the collision's position changes
  104587. */
  104588. onCollisionPositionChangeObservable: Observable<Vector3>;
  104589. /** Set a function to call when the collision's position changes */
  104590. set onCollisionPositionChange(callback: () => void);
  104591. /**
  104592. * An event triggered when material is changed
  104593. */
  104594. onMaterialChangedObservable: Observable<AbstractMesh>;
  104595. /**
  104596. * Gets or sets the orientation for POV movement & rotation
  104597. */
  104598. definedFacingForward: boolean;
  104599. /** @hidden */
  104600. _occlusionQuery: Nullable<WebGLQuery>;
  104601. /** @hidden */
  104602. _renderingGroup: Nullable<RenderingGroup>;
  104603. /**
  104604. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104605. */
  104606. get visibility(): number;
  104607. /**
  104608. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104609. */
  104610. set visibility(value: number);
  104611. /** Gets or sets the alpha index used to sort transparent meshes
  104612. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  104613. */
  104614. alphaIndex: number;
  104615. /**
  104616. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  104617. */
  104618. isVisible: boolean;
  104619. /**
  104620. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104621. */
  104622. isPickable: boolean;
  104623. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  104624. showSubMeshesBoundingBox: boolean;
  104625. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  104626. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104627. */
  104628. isBlocker: boolean;
  104629. /**
  104630. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  104631. */
  104632. enablePointerMoveEvents: boolean;
  104633. /**
  104634. * Specifies the rendering group id for this mesh (0 by default)
  104635. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104636. */
  104637. renderingGroupId: number;
  104638. private _material;
  104639. /** Gets or sets current material */
  104640. get material(): Nullable<Material>;
  104641. set material(value: Nullable<Material>);
  104642. /**
  104643. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  104644. * @see http://doc.babylonjs.com/babylon101/shadows
  104645. */
  104646. get receiveShadows(): boolean;
  104647. set receiveShadows(value: boolean);
  104648. /** Defines color to use when rendering outline */
  104649. outlineColor: Color3;
  104650. /** Define width to use when rendering outline */
  104651. outlineWidth: number;
  104652. /** Defines color to use when rendering overlay */
  104653. overlayColor: Color3;
  104654. /** Defines alpha to use when rendering overlay */
  104655. overlayAlpha: number;
  104656. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  104657. get hasVertexAlpha(): boolean;
  104658. set hasVertexAlpha(value: boolean);
  104659. /** 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) */
  104660. get useVertexColors(): boolean;
  104661. set useVertexColors(value: boolean);
  104662. /**
  104663. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  104664. */
  104665. get computeBonesUsingShaders(): boolean;
  104666. set computeBonesUsingShaders(value: boolean);
  104667. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  104668. get numBoneInfluencers(): number;
  104669. set numBoneInfluencers(value: number);
  104670. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  104671. get applyFog(): boolean;
  104672. set applyFog(value: boolean);
  104673. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  104674. useOctreeForRenderingSelection: boolean;
  104675. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  104676. useOctreeForPicking: boolean;
  104677. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  104678. useOctreeForCollisions: boolean;
  104679. /**
  104680. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  104681. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  104682. */
  104683. get layerMask(): number;
  104684. set layerMask(value: number);
  104685. /**
  104686. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  104687. */
  104688. alwaysSelectAsActiveMesh: boolean;
  104689. /**
  104690. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  104691. */
  104692. doNotSyncBoundingInfo: boolean;
  104693. /**
  104694. * Gets or sets the current action manager
  104695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104696. */
  104697. actionManager: Nullable<AbstractActionManager>;
  104698. private _meshCollisionData;
  104699. /**
  104700. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  104701. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104702. */
  104703. ellipsoid: Vector3;
  104704. /**
  104705. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  104706. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104707. */
  104708. ellipsoidOffset: Vector3;
  104709. /**
  104710. * Gets or sets a collision mask used to mask collisions (default is -1).
  104711. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104712. */
  104713. get collisionMask(): number;
  104714. set collisionMask(mask: number);
  104715. /**
  104716. * Gets or sets the current collision group mask (-1 by default).
  104717. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104718. */
  104719. get collisionGroup(): number;
  104720. set collisionGroup(mask: number);
  104721. /**
  104722. * Gets or sets current surrounding meshes (null by default).
  104723. *
  104724. * By default collision detection is tested against every mesh in the scene.
  104725. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  104726. * meshes will be tested for the collision.
  104727. *
  104728. * Note: if set to an empty array no collision will happen when this mesh is moved.
  104729. */
  104730. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  104731. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  104732. /**
  104733. * Defines edge width used when edgesRenderer is enabled
  104734. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104735. */
  104736. edgesWidth: number;
  104737. /**
  104738. * Defines edge color used when edgesRenderer is enabled
  104739. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104740. */
  104741. edgesColor: Color4;
  104742. /** @hidden */
  104743. _edgesRenderer: Nullable<IEdgesRenderer>;
  104744. /** @hidden */
  104745. _masterMesh: Nullable<AbstractMesh>;
  104746. /** @hidden */
  104747. _boundingInfo: Nullable<BoundingInfo>;
  104748. /** @hidden */
  104749. _renderId: number;
  104750. /**
  104751. * Gets or sets the list of subMeshes
  104752. * @see http://doc.babylonjs.com/how_to/multi_materials
  104753. */
  104754. subMeshes: SubMesh[];
  104755. /** @hidden */
  104756. _intersectionsInProgress: AbstractMesh[];
  104757. /** @hidden */
  104758. _unIndexed: boolean;
  104759. /** @hidden */
  104760. _lightSources: Light[];
  104761. /** Gets the list of lights affecting that mesh */
  104762. get lightSources(): Light[];
  104763. /** @hidden */
  104764. get _positions(): Nullable<Vector3[]>;
  104765. /** @hidden */
  104766. _waitingData: {
  104767. lods: Nullable<any>;
  104768. actions: Nullable<any>;
  104769. freezeWorldMatrix: Nullable<boolean>;
  104770. };
  104771. /** @hidden */
  104772. _bonesTransformMatrices: Nullable<Float32Array>;
  104773. /** @hidden */
  104774. _transformMatrixTexture: Nullable<RawTexture>;
  104775. /**
  104776. * Gets or sets a skeleton to apply skining transformations
  104777. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104778. */
  104779. set skeleton(value: Nullable<Skeleton>);
  104780. get skeleton(): Nullable<Skeleton>;
  104781. /**
  104782. * An event triggered when the mesh is rebuilt.
  104783. */
  104784. onRebuildObservable: Observable<AbstractMesh>;
  104785. /**
  104786. * Creates a new AbstractMesh
  104787. * @param name defines the name of the mesh
  104788. * @param scene defines the hosting scene
  104789. */
  104790. constructor(name: string, scene?: Nullable<Scene>);
  104791. /**
  104792. * Returns the string "AbstractMesh"
  104793. * @returns "AbstractMesh"
  104794. */
  104795. getClassName(): string;
  104796. /**
  104797. * Gets a string representation of the current mesh
  104798. * @param fullDetails defines a boolean indicating if full details must be included
  104799. * @returns a string representation of the current mesh
  104800. */
  104801. toString(fullDetails?: boolean): string;
  104802. /**
  104803. * @hidden
  104804. */
  104805. protected _getEffectiveParent(): Nullable<Node>;
  104806. /** @hidden */
  104807. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104808. /** @hidden */
  104809. _rebuild(): void;
  104810. /** @hidden */
  104811. _resyncLightSources(): void;
  104812. /** @hidden */
  104813. _resyncLightSource(light: Light): void;
  104814. /** @hidden */
  104815. _unBindEffect(): void;
  104816. /** @hidden */
  104817. _removeLightSource(light: Light, dispose: boolean): void;
  104818. private _markSubMeshesAsDirty;
  104819. /** @hidden */
  104820. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  104821. /** @hidden */
  104822. _markSubMeshesAsAttributesDirty(): void;
  104823. /** @hidden */
  104824. _markSubMeshesAsMiscDirty(): void;
  104825. /**
  104826. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  104827. */
  104828. get scaling(): Vector3;
  104829. set scaling(newScaling: Vector3);
  104830. /**
  104831. * Returns true if the mesh is blocked. Implemented by child classes
  104832. */
  104833. get isBlocked(): boolean;
  104834. /**
  104835. * Returns the mesh itself by default. Implemented by child classes
  104836. * @param camera defines the camera to use to pick the right LOD level
  104837. * @returns the currentAbstractMesh
  104838. */
  104839. getLOD(camera: Camera): Nullable<AbstractMesh>;
  104840. /**
  104841. * Returns 0 by default. Implemented by child classes
  104842. * @returns an integer
  104843. */
  104844. getTotalVertices(): number;
  104845. /**
  104846. * Returns a positive integer : the total number of indices in this mesh geometry.
  104847. * @returns the numner of indices or zero if the mesh has no geometry.
  104848. */
  104849. getTotalIndices(): number;
  104850. /**
  104851. * Returns null by default. Implemented by child classes
  104852. * @returns null
  104853. */
  104854. getIndices(): Nullable<IndicesArray>;
  104855. /**
  104856. * Returns the array of the requested vertex data kind. Implemented by child classes
  104857. * @param kind defines the vertex data kind to use
  104858. * @returns null
  104859. */
  104860. getVerticesData(kind: string): Nullable<FloatArray>;
  104861. /**
  104862. * Sets the vertex data of the mesh geometry for the requested `kind`.
  104863. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  104864. * Note that a new underlying VertexBuffer object is created each call.
  104865. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  104866. * @param kind defines vertex data kind:
  104867. * * VertexBuffer.PositionKind
  104868. * * VertexBuffer.UVKind
  104869. * * VertexBuffer.UV2Kind
  104870. * * VertexBuffer.UV3Kind
  104871. * * VertexBuffer.UV4Kind
  104872. * * VertexBuffer.UV5Kind
  104873. * * VertexBuffer.UV6Kind
  104874. * * VertexBuffer.ColorKind
  104875. * * VertexBuffer.MatricesIndicesKind
  104876. * * VertexBuffer.MatricesIndicesExtraKind
  104877. * * VertexBuffer.MatricesWeightsKind
  104878. * * VertexBuffer.MatricesWeightsExtraKind
  104879. * @param data defines the data source
  104880. * @param updatable defines if the data must be flagged as updatable (or static)
  104881. * @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
  104882. * @returns the current mesh
  104883. */
  104884. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104885. /**
  104886. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  104887. * If the mesh has no geometry, it is simply returned as it is.
  104888. * @param kind defines vertex data kind:
  104889. * * VertexBuffer.PositionKind
  104890. * * VertexBuffer.UVKind
  104891. * * VertexBuffer.UV2Kind
  104892. * * VertexBuffer.UV3Kind
  104893. * * VertexBuffer.UV4Kind
  104894. * * VertexBuffer.UV5Kind
  104895. * * VertexBuffer.UV6Kind
  104896. * * VertexBuffer.ColorKind
  104897. * * VertexBuffer.MatricesIndicesKind
  104898. * * VertexBuffer.MatricesIndicesExtraKind
  104899. * * VertexBuffer.MatricesWeightsKind
  104900. * * VertexBuffer.MatricesWeightsExtraKind
  104901. * @param data defines the data source
  104902. * @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
  104903. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  104904. * @returns the current mesh
  104905. */
  104906. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104907. /**
  104908. * Sets the mesh indices,
  104909. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  104910. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  104911. * @param totalVertices Defines the total number of vertices
  104912. * @returns the current mesh
  104913. */
  104914. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  104915. /**
  104916. * Gets a boolean indicating if specific vertex data is present
  104917. * @param kind defines the vertex data kind to use
  104918. * @returns true is data kind is present
  104919. */
  104920. isVerticesDataPresent(kind: string): boolean;
  104921. /**
  104922. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  104923. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  104924. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  104925. * @returns a BoundingInfo
  104926. */
  104927. getBoundingInfo(): BoundingInfo;
  104928. /**
  104929. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  104930. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  104931. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  104932. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  104933. * @returns the current mesh
  104934. */
  104935. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  104936. /**
  104937. * Overwrite the current bounding info
  104938. * @param boundingInfo defines the new bounding info
  104939. * @returns the current mesh
  104940. */
  104941. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  104942. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  104943. get useBones(): boolean;
  104944. /** @hidden */
  104945. _preActivate(): void;
  104946. /** @hidden */
  104947. _preActivateForIntermediateRendering(renderId: number): void;
  104948. /** @hidden */
  104949. _activate(renderId: number, intermediateRendering: boolean): boolean;
  104950. /** @hidden */
  104951. _postActivate(): void;
  104952. /** @hidden */
  104953. _freeze(): void;
  104954. /** @hidden */
  104955. _unFreeze(): void;
  104956. /**
  104957. * Gets the current world matrix
  104958. * @returns a Matrix
  104959. */
  104960. getWorldMatrix(): Matrix;
  104961. /** @hidden */
  104962. _getWorldMatrixDeterminant(): number;
  104963. /**
  104964. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  104965. */
  104966. get isAnInstance(): boolean;
  104967. /**
  104968. * Gets a boolean indicating if this mesh has instances
  104969. */
  104970. get hasInstances(): boolean;
  104971. /**
  104972. * Perform relative position change from the point of view of behind the front of the mesh.
  104973. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104974. * Supports definition of mesh facing forward or backward
  104975. * @param amountRight defines the distance on the right axis
  104976. * @param amountUp defines the distance on the up axis
  104977. * @param amountForward defines the distance on the forward axis
  104978. * @returns the current mesh
  104979. */
  104980. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  104981. /**
  104982. * Calculate relative position change from the point of view of behind the front of the mesh.
  104983. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104984. * Supports definition of mesh facing forward or backward
  104985. * @param amountRight defines the distance on the right axis
  104986. * @param amountUp defines the distance on the up axis
  104987. * @param amountForward defines the distance on the forward axis
  104988. * @returns the new displacement vector
  104989. */
  104990. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  104991. /**
  104992. * Perform relative rotation change from the point of view of behind the front of the mesh.
  104993. * Supports definition of mesh facing forward or backward
  104994. * @param flipBack defines the flip
  104995. * @param twirlClockwise defines the twirl
  104996. * @param tiltRight defines the tilt
  104997. * @returns the current mesh
  104998. */
  104999. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  105000. /**
  105001. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  105002. * Supports definition of mesh facing forward or backward.
  105003. * @param flipBack defines the flip
  105004. * @param twirlClockwise defines the twirl
  105005. * @param tiltRight defines the tilt
  105006. * @returns the new rotation vector
  105007. */
  105008. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  105009. /**
  105010. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105011. * This means the mesh underlying bounding box and sphere are recomputed.
  105012. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105013. * @returns the current mesh
  105014. */
  105015. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  105016. /** @hidden */
  105017. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  105018. /** @hidden */
  105019. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  105020. /** @hidden */
  105021. _updateBoundingInfo(): AbstractMesh;
  105022. /** @hidden */
  105023. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  105024. /** @hidden */
  105025. protected _afterComputeWorldMatrix(): void;
  105026. /** @hidden */
  105027. get _effectiveMesh(): AbstractMesh;
  105028. /**
  105029. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105030. * A mesh is in the frustum if its bounding box intersects the frustum
  105031. * @param frustumPlanes defines the frustum to test
  105032. * @returns true if the mesh is in the frustum planes
  105033. */
  105034. isInFrustum(frustumPlanes: Plane[]): boolean;
  105035. /**
  105036. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  105037. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  105038. * @param frustumPlanes defines the frustum to test
  105039. * @returns true if the mesh is completely in the frustum planes
  105040. */
  105041. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105042. /**
  105043. * True if the mesh intersects another mesh or a SolidParticle object
  105044. * @param mesh defines a target mesh or SolidParticle to test
  105045. * @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)
  105046. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  105047. * @returns true if there is an intersection
  105048. */
  105049. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  105050. /**
  105051. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  105052. * @param point defines the point to test
  105053. * @returns true if there is an intersection
  105054. */
  105055. intersectsPoint(point: Vector3): boolean;
  105056. /**
  105057. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  105058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105059. */
  105060. get checkCollisions(): boolean;
  105061. set checkCollisions(collisionEnabled: boolean);
  105062. /**
  105063. * Gets Collider object used to compute collisions (not physics)
  105064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105065. */
  105066. get collider(): Nullable<Collider>;
  105067. /**
  105068. * Move the mesh using collision engine
  105069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105070. * @param displacement defines the requested displacement vector
  105071. * @returns the current mesh
  105072. */
  105073. moveWithCollisions(displacement: Vector3): AbstractMesh;
  105074. private _onCollisionPositionChange;
  105075. /** @hidden */
  105076. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  105077. /** @hidden */
  105078. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  105079. /** @hidden */
  105080. _checkCollision(collider: Collider): AbstractMesh;
  105081. /** @hidden */
  105082. _generatePointsArray(): boolean;
  105083. /**
  105084. * Checks if the passed Ray intersects with the mesh
  105085. * @param ray defines the ray to use
  105086. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  105087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105088. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  105089. * @returns the picking info
  105090. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  105091. */
  105092. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  105093. /**
  105094. * Clones the current mesh
  105095. * @param name defines the mesh name
  105096. * @param newParent defines the new mesh parent
  105097. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  105098. * @returns the new mesh
  105099. */
  105100. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  105101. /**
  105102. * Disposes all the submeshes of the current meshnp
  105103. * @returns the current mesh
  105104. */
  105105. releaseSubMeshes(): AbstractMesh;
  105106. /**
  105107. * Releases resources associated with this abstract mesh.
  105108. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105109. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105110. */
  105111. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105112. /**
  105113. * Adds the passed mesh as a child to the current mesh
  105114. * @param mesh defines the child mesh
  105115. * @returns the current mesh
  105116. */
  105117. addChild(mesh: AbstractMesh): AbstractMesh;
  105118. /**
  105119. * Removes the passed mesh from the current mesh children list
  105120. * @param mesh defines the child mesh
  105121. * @returns the current mesh
  105122. */
  105123. removeChild(mesh: AbstractMesh): AbstractMesh;
  105124. /** @hidden */
  105125. private _initFacetData;
  105126. /**
  105127. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  105128. * This method can be called within the render loop.
  105129. * 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
  105130. * @returns the current mesh
  105131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105132. */
  105133. updateFacetData(): AbstractMesh;
  105134. /**
  105135. * Returns the facetLocalNormals array.
  105136. * The normals are expressed in the mesh local spac
  105137. * @returns an array of Vector3
  105138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105139. */
  105140. getFacetLocalNormals(): Vector3[];
  105141. /**
  105142. * Returns the facetLocalPositions array.
  105143. * The facet positions are expressed in the mesh local space
  105144. * @returns an array of Vector3
  105145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105146. */
  105147. getFacetLocalPositions(): Vector3[];
  105148. /**
  105149. * Returns the facetLocalPartioning array
  105150. * @returns an array of array of numbers
  105151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105152. */
  105153. getFacetLocalPartitioning(): number[][];
  105154. /**
  105155. * Returns the i-th facet position in the world system.
  105156. * This method allocates a new Vector3 per call
  105157. * @param i defines the facet index
  105158. * @returns a new Vector3
  105159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105160. */
  105161. getFacetPosition(i: number): Vector3;
  105162. /**
  105163. * Sets the reference Vector3 with the i-th facet position in the world system
  105164. * @param i defines the facet index
  105165. * @param ref defines the target vector
  105166. * @returns the current mesh
  105167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105168. */
  105169. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  105170. /**
  105171. * Returns the i-th facet normal in the world system.
  105172. * This method allocates a new Vector3 per call
  105173. * @param i defines the facet index
  105174. * @returns a new Vector3
  105175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105176. */
  105177. getFacetNormal(i: number): Vector3;
  105178. /**
  105179. * Sets the reference Vector3 with the i-th facet normal in the world system
  105180. * @param i defines the facet index
  105181. * @param ref defines the target vector
  105182. * @returns the current mesh
  105183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105184. */
  105185. getFacetNormalToRef(i: number, ref: Vector3): this;
  105186. /**
  105187. * 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)
  105188. * @param x defines x coordinate
  105189. * @param y defines y coordinate
  105190. * @param z defines z coordinate
  105191. * @returns the array of facet indexes
  105192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105193. */
  105194. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  105195. /**
  105196. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  105197. * @param projected sets as the (x,y,z) world projection on the facet
  105198. * @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
  105199. * @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
  105200. * @param x defines x coordinate
  105201. * @param y defines y coordinate
  105202. * @param z defines z coordinate
  105203. * @returns the face index if found (or null instead)
  105204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105205. */
  105206. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105207. /**
  105208. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  105209. * @param projected sets as the (x,y,z) local projection on the facet
  105210. * @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
  105211. * @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
  105212. * @param x defines x coordinate
  105213. * @param y defines y coordinate
  105214. * @param z defines z coordinate
  105215. * @returns the face index if found (or null instead)
  105216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105217. */
  105218. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105219. /**
  105220. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  105221. * @returns the parameters
  105222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105223. */
  105224. getFacetDataParameters(): any;
  105225. /**
  105226. * Disables the feature FacetData and frees the related memory
  105227. * @returns the current mesh
  105228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105229. */
  105230. disableFacetData(): AbstractMesh;
  105231. /**
  105232. * Updates the AbstractMesh indices array
  105233. * @param indices defines the data source
  105234. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105235. * @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)
  105236. * @returns the current mesh
  105237. */
  105238. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105239. /**
  105240. * Creates new normals data for the mesh
  105241. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  105242. * @returns the current mesh
  105243. */
  105244. createNormals(updatable: boolean): AbstractMesh;
  105245. /**
  105246. * Align the mesh with a normal
  105247. * @param normal defines the normal to use
  105248. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  105249. * @returns the current mesh
  105250. */
  105251. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  105252. /** @hidden */
  105253. _checkOcclusionQuery(): boolean;
  105254. /**
  105255. * Disables the mesh edge rendering mode
  105256. * @returns the currentAbstractMesh
  105257. */
  105258. disableEdgesRendering(): AbstractMesh;
  105259. /**
  105260. * Enables the edge rendering mode on the mesh.
  105261. * This mode makes the mesh edges visible
  105262. * @param epsilon defines the maximal distance between two angles to detect a face
  105263. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  105264. * @returns the currentAbstractMesh
  105265. * @see https://www.babylonjs-playground.com/#19O9TU#0
  105266. */
  105267. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  105268. }
  105269. }
  105270. declare module BABYLON {
  105271. /**
  105272. * Interface used to define ActionEvent
  105273. */
  105274. export interface IActionEvent {
  105275. /** The mesh or sprite that triggered the action */
  105276. source: any;
  105277. /** The X mouse cursor position at the time of the event */
  105278. pointerX: number;
  105279. /** The Y mouse cursor position at the time of the event */
  105280. pointerY: number;
  105281. /** The mesh that is currently pointed at (can be null) */
  105282. meshUnderPointer: Nullable<AbstractMesh>;
  105283. /** the original (browser) event that triggered the ActionEvent */
  105284. sourceEvent?: any;
  105285. /** additional data for the event */
  105286. additionalData?: any;
  105287. }
  105288. /**
  105289. * ActionEvent is the event being sent when an action is triggered.
  105290. */
  105291. export class ActionEvent implements IActionEvent {
  105292. /** The mesh or sprite that triggered the action */
  105293. source: any;
  105294. /** The X mouse cursor position at the time of the event */
  105295. pointerX: number;
  105296. /** The Y mouse cursor position at the time of the event */
  105297. pointerY: number;
  105298. /** The mesh that is currently pointed at (can be null) */
  105299. meshUnderPointer: Nullable<AbstractMesh>;
  105300. /** the original (browser) event that triggered the ActionEvent */
  105301. sourceEvent?: any;
  105302. /** additional data for the event */
  105303. additionalData?: any;
  105304. /**
  105305. * Creates a new ActionEvent
  105306. * @param source The mesh or sprite that triggered the action
  105307. * @param pointerX The X mouse cursor position at the time of the event
  105308. * @param pointerY The Y mouse cursor position at the time of the event
  105309. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  105310. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  105311. * @param additionalData additional data for the event
  105312. */
  105313. constructor(
  105314. /** The mesh or sprite that triggered the action */
  105315. source: any,
  105316. /** The X mouse cursor position at the time of the event */
  105317. pointerX: number,
  105318. /** The Y mouse cursor position at the time of the event */
  105319. pointerY: number,
  105320. /** The mesh that is currently pointed at (can be null) */
  105321. meshUnderPointer: Nullable<AbstractMesh>,
  105322. /** the original (browser) event that triggered the ActionEvent */
  105323. sourceEvent?: any,
  105324. /** additional data for the event */
  105325. additionalData?: any);
  105326. /**
  105327. * Helper function to auto-create an ActionEvent from a source mesh.
  105328. * @param source The source mesh that triggered the event
  105329. * @param evt The original (browser) event
  105330. * @param additionalData additional data for the event
  105331. * @returns the new ActionEvent
  105332. */
  105333. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  105334. /**
  105335. * Helper function to auto-create an ActionEvent from a source sprite
  105336. * @param source The source sprite that triggered the event
  105337. * @param scene Scene associated with the sprite
  105338. * @param evt The original (browser) event
  105339. * @param additionalData additional data for the event
  105340. * @returns the new ActionEvent
  105341. */
  105342. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  105343. /**
  105344. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  105345. * @param scene the scene where the event occurred
  105346. * @param evt The original (browser) event
  105347. * @returns the new ActionEvent
  105348. */
  105349. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  105350. /**
  105351. * Helper function to auto-create an ActionEvent from a primitive
  105352. * @param prim defines the target primitive
  105353. * @param pointerPos defines the pointer position
  105354. * @param evt The original (browser) event
  105355. * @param additionalData additional data for the event
  105356. * @returns the new ActionEvent
  105357. */
  105358. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  105359. }
  105360. }
  105361. declare module BABYLON {
  105362. /**
  105363. * Abstract class used to decouple action Manager from scene and meshes.
  105364. * Do not instantiate.
  105365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105366. */
  105367. export abstract class AbstractActionManager implements IDisposable {
  105368. /** Gets the list of active triggers */
  105369. static Triggers: {
  105370. [key: string]: number;
  105371. };
  105372. /** Gets the cursor to use when hovering items */
  105373. hoverCursor: string;
  105374. /** Gets the list of actions */
  105375. actions: IAction[];
  105376. /**
  105377. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  105378. */
  105379. isRecursive: boolean;
  105380. /**
  105381. * Releases all associated resources
  105382. */
  105383. abstract dispose(): void;
  105384. /**
  105385. * Does this action manager has pointer triggers
  105386. */
  105387. abstract get hasPointerTriggers(): boolean;
  105388. /**
  105389. * Does this action manager has pick triggers
  105390. */
  105391. abstract get hasPickTriggers(): boolean;
  105392. /**
  105393. * Process a specific trigger
  105394. * @param trigger defines the trigger to process
  105395. * @param evt defines the event details to be processed
  105396. */
  105397. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  105398. /**
  105399. * Does this action manager handles actions of any of the given triggers
  105400. * @param triggers defines the triggers to be tested
  105401. * @return a boolean indicating whether one (or more) of the triggers is handled
  105402. */
  105403. abstract hasSpecificTriggers(triggers: number[]): boolean;
  105404. /**
  105405. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  105406. * speed.
  105407. * @param triggerA defines the trigger to be tested
  105408. * @param triggerB defines the trigger to be tested
  105409. * @return a boolean indicating whether one (or more) of the triggers is handled
  105410. */
  105411. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  105412. /**
  105413. * Does this action manager handles actions of a given trigger
  105414. * @param trigger defines the trigger to be tested
  105415. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  105416. * @return whether the trigger is handled
  105417. */
  105418. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  105419. /**
  105420. * Serialize this manager to a JSON object
  105421. * @param name defines the property name to store this manager
  105422. * @returns a JSON representation of this manager
  105423. */
  105424. abstract serialize(name: string): any;
  105425. /**
  105426. * Registers an action to this action manager
  105427. * @param action defines the action to be registered
  105428. * @return the action amended (prepared) after registration
  105429. */
  105430. abstract registerAction(action: IAction): Nullable<IAction>;
  105431. /**
  105432. * Unregisters an action to this action manager
  105433. * @param action defines the action to be unregistered
  105434. * @return a boolean indicating whether the action has been unregistered
  105435. */
  105436. abstract unregisterAction(action: IAction): Boolean;
  105437. /**
  105438. * Does exist one action manager with at least one trigger
  105439. **/
  105440. static get HasTriggers(): boolean;
  105441. /**
  105442. * Does exist one action manager with at least one pick trigger
  105443. **/
  105444. static get HasPickTriggers(): boolean;
  105445. /**
  105446. * Does exist one action manager that handles actions of a given trigger
  105447. * @param trigger defines the trigger to be tested
  105448. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  105449. **/
  105450. static HasSpecificTrigger(trigger: number): boolean;
  105451. }
  105452. }
  105453. declare module BABYLON {
  105454. /**
  105455. * Defines how a node can be built from a string name.
  105456. */
  105457. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  105458. /**
  105459. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  105460. */
  105461. export class Node implements IBehaviorAware<Node> {
  105462. /** @hidden */
  105463. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  105464. private static _NodeConstructors;
  105465. /**
  105466. * Add a new node constructor
  105467. * @param type defines the type name of the node to construct
  105468. * @param constructorFunc defines the constructor function
  105469. */
  105470. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  105471. /**
  105472. * Returns a node constructor based on type name
  105473. * @param type defines the type name
  105474. * @param name defines the new node name
  105475. * @param scene defines the hosting scene
  105476. * @param options defines optional options to transmit to constructors
  105477. * @returns the new constructor or null
  105478. */
  105479. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  105480. /**
  105481. * Gets or sets the name of the node
  105482. */
  105483. name: string;
  105484. /**
  105485. * Gets or sets the id of the node
  105486. */
  105487. id: string;
  105488. /**
  105489. * Gets or sets the unique id of the node
  105490. */
  105491. uniqueId: number;
  105492. /**
  105493. * Gets or sets a string used to store user defined state for the node
  105494. */
  105495. state: string;
  105496. /**
  105497. * Gets or sets an object used to store user defined information for the node
  105498. */
  105499. metadata: any;
  105500. /**
  105501. * For internal use only. Please do not use.
  105502. */
  105503. reservedDataStore: any;
  105504. /**
  105505. * List of inspectable custom properties (used by the Inspector)
  105506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105507. */
  105508. inspectableCustomProperties: IInspectable[];
  105509. private _doNotSerialize;
  105510. /**
  105511. * Gets or sets a boolean used to define if the node must be serialized
  105512. */
  105513. get doNotSerialize(): boolean;
  105514. set doNotSerialize(value: boolean);
  105515. /** @hidden */
  105516. _isDisposed: boolean;
  105517. /**
  105518. * Gets a list of Animations associated with the node
  105519. */
  105520. animations: Animation[];
  105521. protected _ranges: {
  105522. [name: string]: Nullable<AnimationRange>;
  105523. };
  105524. /**
  105525. * Callback raised when the node is ready to be used
  105526. */
  105527. onReady: Nullable<(node: Node) => void>;
  105528. private _isEnabled;
  105529. private _isParentEnabled;
  105530. private _isReady;
  105531. /** @hidden */
  105532. _currentRenderId: number;
  105533. private _parentUpdateId;
  105534. /** @hidden */
  105535. _childUpdateId: number;
  105536. /** @hidden */
  105537. _waitingParentId: Nullable<string>;
  105538. /** @hidden */
  105539. _scene: Scene;
  105540. /** @hidden */
  105541. _cache: any;
  105542. private _parentNode;
  105543. private _children;
  105544. /** @hidden */
  105545. _worldMatrix: Matrix;
  105546. /** @hidden */
  105547. _worldMatrixDeterminant: number;
  105548. /** @hidden */
  105549. _worldMatrixDeterminantIsDirty: boolean;
  105550. /** @hidden */
  105551. private _sceneRootNodesIndex;
  105552. /**
  105553. * Gets a boolean indicating if the node has been disposed
  105554. * @returns true if the node was disposed
  105555. */
  105556. isDisposed(): boolean;
  105557. /**
  105558. * Gets or sets the parent of the node (without keeping the current position in the scene)
  105559. * @see https://doc.babylonjs.com/how_to/parenting
  105560. */
  105561. set parent(parent: Nullable<Node>);
  105562. get parent(): Nullable<Node>;
  105563. /** @hidden */
  105564. _addToSceneRootNodes(): void;
  105565. /** @hidden */
  105566. _removeFromSceneRootNodes(): void;
  105567. private _animationPropertiesOverride;
  105568. /**
  105569. * Gets or sets the animation properties override
  105570. */
  105571. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105572. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105573. /**
  105574. * Gets a string idenfifying the name of the class
  105575. * @returns "Node" string
  105576. */
  105577. getClassName(): string;
  105578. /** @hidden */
  105579. readonly _isNode: boolean;
  105580. /**
  105581. * An event triggered when the mesh is disposed
  105582. */
  105583. onDisposeObservable: Observable<Node>;
  105584. private _onDisposeObserver;
  105585. /**
  105586. * Sets a callback that will be raised when the node will be disposed
  105587. */
  105588. set onDispose(callback: () => void);
  105589. /**
  105590. * Creates a new Node
  105591. * @param name the name and id to be given to this node
  105592. * @param scene the scene this node will be added to
  105593. */
  105594. constructor(name: string, scene?: Nullable<Scene>);
  105595. /**
  105596. * Gets the scene of the node
  105597. * @returns a scene
  105598. */
  105599. getScene(): Scene;
  105600. /**
  105601. * Gets the engine of the node
  105602. * @returns a Engine
  105603. */
  105604. getEngine(): Engine;
  105605. private _behaviors;
  105606. /**
  105607. * Attach a behavior to the node
  105608. * @see http://doc.babylonjs.com/features/behaviour
  105609. * @param behavior defines the behavior to attach
  105610. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  105611. * @returns the current Node
  105612. */
  105613. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  105614. /**
  105615. * Remove an attached behavior
  105616. * @see http://doc.babylonjs.com/features/behaviour
  105617. * @param behavior defines the behavior to attach
  105618. * @returns the current Node
  105619. */
  105620. removeBehavior(behavior: Behavior<Node>): Node;
  105621. /**
  105622. * Gets the list of attached behaviors
  105623. * @see http://doc.babylonjs.com/features/behaviour
  105624. */
  105625. get behaviors(): Behavior<Node>[];
  105626. /**
  105627. * Gets an attached behavior by name
  105628. * @param name defines the name of the behavior to look for
  105629. * @see http://doc.babylonjs.com/features/behaviour
  105630. * @returns null if behavior was not found else the requested behavior
  105631. */
  105632. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  105633. /**
  105634. * Returns the latest update of the World matrix
  105635. * @returns a Matrix
  105636. */
  105637. getWorldMatrix(): Matrix;
  105638. /** @hidden */
  105639. _getWorldMatrixDeterminant(): number;
  105640. /**
  105641. * Returns directly the latest state of the mesh World matrix.
  105642. * A Matrix is returned.
  105643. */
  105644. get worldMatrixFromCache(): Matrix;
  105645. /** @hidden */
  105646. _initCache(): void;
  105647. /** @hidden */
  105648. updateCache(force?: boolean): void;
  105649. /** @hidden */
  105650. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  105651. /** @hidden */
  105652. _updateCache(ignoreParentClass?: boolean): void;
  105653. /** @hidden */
  105654. _isSynchronized(): boolean;
  105655. /** @hidden */
  105656. _markSyncedWithParent(): void;
  105657. /** @hidden */
  105658. isSynchronizedWithParent(): boolean;
  105659. /** @hidden */
  105660. isSynchronized(): boolean;
  105661. /**
  105662. * Is this node ready to be used/rendered
  105663. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105664. * @return true if the node is ready
  105665. */
  105666. isReady(completeCheck?: boolean): boolean;
  105667. /**
  105668. * Is this node enabled?
  105669. * 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
  105670. * @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
  105671. * @return whether this node (and its parent) is enabled
  105672. */
  105673. isEnabled(checkAncestors?: boolean): boolean;
  105674. /** @hidden */
  105675. protected _syncParentEnabledState(): void;
  105676. /**
  105677. * Set the enabled state of this node
  105678. * @param value defines the new enabled state
  105679. */
  105680. setEnabled(value: boolean): void;
  105681. /**
  105682. * Is this node a descendant of the given node?
  105683. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  105684. * @param ancestor defines the parent node to inspect
  105685. * @returns a boolean indicating if this node is a descendant of the given node
  105686. */
  105687. isDescendantOf(ancestor: Node): boolean;
  105688. /** @hidden */
  105689. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  105690. /**
  105691. * Will return all nodes that have this node as ascendant
  105692. * @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
  105693. * @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
  105694. * @return all children nodes of all types
  105695. */
  105696. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  105697. /**
  105698. * Get all child-meshes of this node
  105699. * @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)
  105700. * @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
  105701. * @returns an array of AbstractMesh
  105702. */
  105703. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  105704. /**
  105705. * Get all direct children of this node
  105706. * @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
  105707. * @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)
  105708. * @returns an array of Node
  105709. */
  105710. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  105711. /** @hidden */
  105712. _setReady(state: boolean): void;
  105713. /**
  105714. * Get an animation by name
  105715. * @param name defines the name of the animation to look for
  105716. * @returns null if not found else the requested animation
  105717. */
  105718. getAnimationByName(name: string): Nullable<Animation>;
  105719. /**
  105720. * Creates an animation range for this node
  105721. * @param name defines the name of the range
  105722. * @param from defines the starting key
  105723. * @param to defines the end key
  105724. */
  105725. createAnimationRange(name: string, from: number, to: number): void;
  105726. /**
  105727. * Delete a specific animation range
  105728. * @param name defines the name of the range to delete
  105729. * @param deleteFrames defines if animation frames from the range must be deleted as well
  105730. */
  105731. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  105732. /**
  105733. * Get an animation range by name
  105734. * @param name defines the name of the animation range to look for
  105735. * @returns null if not found else the requested animation range
  105736. */
  105737. getAnimationRange(name: string): Nullable<AnimationRange>;
  105738. /**
  105739. * Gets the list of all animation ranges defined on this node
  105740. * @returns an array
  105741. */
  105742. getAnimationRanges(): Nullable<AnimationRange>[];
  105743. /**
  105744. * Will start the animation sequence
  105745. * @param name defines the range frames for animation sequence
  105746. * @param loop defines if the animation should loop (false by default)
  105747. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  105748. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  105749. * @returns the object created for this animation. If range does not exist, it will return null
  105750. */
  105751. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  105752. /**
  105753. * Serialize animation ranges into a JSON compatible object
  105754. * @returns serialization object
  105755. */
  105756. serializeAnimationRanges(): any;
  105757. /**
  105758. * Computes the world matrix of the node
  105759. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  105760. * @returns the world matrix
  105761. */
  105762. computeWorldMatrix(force?: boolean): Matrix;
  105763. /**
  105764. * Releases resources associated with this node.
  105765. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105766. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105767. */
  105768. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105769. /**
  105770. * Parse animation range data from a serialization object and store them into a given node
  105771. * @param node defines where to store the animation ranges
  105772. * @param parsedNode defines the serialization object to read data from
  105773. * @param scene defines the hosting scene
  105774. */
  105775. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  105776. /**
  105777. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  105778. * @param includeDescendants Include bounding info from descendants as well (true by default)
  105779. * @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
  105780. * @returns the new bounding vectors
  105781. */
  105782. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  105783. min: Vector3;
  105784. max: Vector3;
  105785. };
  105786. }
  105787. }
  105788. declare module BABYLON {
  105789. /**
  105790. * @hidden
  105791. */
  105792. export class _IAnimationState {
  105793. key: number;
  105794. repeatCount: number;
  105795. workValue?: any;
  105796. loopMode?: number;
  105797. offsetValue?: any;
  105798. highLimitValue?: any;
  105799. }
  105800. /**
  105801. * Class used to store any kind of animation
  105802. */
  105803. export class Animation {
  105804. /**Name of the animation */
  105805. name: string;
  105806. /**Property to animate */
  105807. targetProperty: string;
  105808. /**The frames per second of the animation */
  105809. framePerSecond: number;
  105810. /**The data type of the animation */
  105811. dataType: number;
  105812. /**The loop mode of the animation */
  105813. loopMode?: number | undefined;
  105814. /**Specifies if blending should be enabled */
  105815. enableBlending?: boolean | undefined;
  105816. /**
  105817. * Use matrix interpolation instead of using direct key value when animating matrices
  105818. */
  105819. static AllowMatricesInterpolation: boolean;
  105820. /**
  105821. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  105822. */
  105823. static AllowMatrixDecomposeForInterpolation: boolean;
  105824. /**
  105825. * Stores the key frames of the animation
  105826. */
  105827. private _keys;
  105828. /**
  105829. * Stores the easing function of the animation
  105830. */
  105831. private _easingFunction;
  105832. /**
  105833. * @hidden Internal use only
  105834. */
  105835. _runtimeAnimations: RuntimeAnimation[];
  105836. /**
  105837. * The set of event that will be linked to this animation
  105838. */
  105839. private _events;
  105840. /**
  105841. * Stores an array of target property paths
  105842. */
  105843. targetPropertyPath: string[];
  105844. /**
  105845. * Stores the blending speed of the animation
  105846. */
  105847. blendingSpeed: number;
  105848. /**
  105849. * Stores the animation ranges for the animation
  105850. */
  105851. private _ranges;
  105852. /**
  105853. * @hidden Internal use
  105854. */
  105855. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  105856. /**
  105857. * Sets up an animation
  105858. * @param property The property to animate
  105859. * @param animationType The animation type to apply
  105860. * @param framePerSecond The frames per second of the animation
  105861. * @param easingFunction The easing function used in the animation
  105862. * @returns The created animation
  105863. */
  105864. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  105865. /**
  105866. * Create and start an animation on a node
  105867. * @param name defines the name of the global animation that will be run on all nodes
  105868. * @param node defines the root node where the animation will take place
  105869. * @param targetProperty defines property to animate
  105870. * @param framePerSecond defines the number of frame per second yo use
  105871. * @param totalFrame defines the number of frames in total
  105872. * @param from defines the initial value
  105873. * @param to defines the final value
  105874. * @param loopMode defines which loop mode you want to use (off by default)
  105875. * @param easingFunction defines the easing function to use (linear by default)
  105876. * @param onAnimationEnd defines the callback to call when animation end
  105877. * @returns the animatable created for this animation
  105878. */
  105879. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105880. /**
  105881. * Create and start an animation on a node and its descendants
  105882. * @param name defines the name of the global animation that will be run on all nodes
  105883. * @param node defines the root node where the animation will take place
  105884. * @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
  105885. * @param targetProperty defines property to animate
  105886. * @param framePerSecond defines the number of frame per second to use
  105887. * @param totalFrame defines the number of frames in total
  105888. * @param from defines the initial value
  105889. * @param to defines the final value
  105890. * @param loopMode defines which loop mode you want to use (off by default)
  105891. * @param easingFunction defines the easing function to use (linear by default)
  105892. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  105893. * @returns the list of animatables created for all nodes
  105894. * @example https://www.babylonjs-playground.com/#MH0VLI
  105895. */
  105896. 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[]>;
  105897. /**
  105898. * Creates a new animation, merges it with the existing animations and starts it
  105899. * @param name Name of the animation
  105900. * @param node Node which contains the scene that begins the animations
  105901. * @param targetProperty Specifies which property to animate
  105902. * @param framePerSecond The frames per second of the animation
  105903. * @param totalFrame The total number of frames
  105904. * @param from The frame at the beginning of the animation
  105905. * @param to The frame at the end of the animation
  105906. * @param loopMode Specifies the loop mode of the animation
  105907. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  105908. * @param onAnimationEnd Callback to run once the animation is complete
  105909. * @returns Nullable animation
  105910. */
  105911. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105912. /**
  105913. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  105914. * @param sourceAnimation defines the Animation containing keyframes to convert
  105915. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  105916. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  105917. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  105918. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  105919. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  105920. */
  105921. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  105922. /**
  105923. * Transition property of an host to the target Value
  105924. * @param property The property to transition
  105925. * @param targetValue The target Value of the property
  105926. * @param host The object where the property to animate belongs
  105927. * @param scene Scene used to run the animation
  105928. * @param frameRate Framerate (in frame/s) to use
  105929. * @param transition The transition type we want to use
  105930. * @param duration The duration of the animation, in milliseconds
  105931. * @param onAnimationEnd Callback trigger at the end of the animation
  105932. * @returns Nullable animation
  105933. */
  105934. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  105935. /**
  105936. * Return the array of runtime animations currently using this animation
  105937. */
  105938. get runtimeAnimations(): RuntimeAnimation[];
  105939. /**
  105940. * Specifies if any of the runtime animations are currently running
  105941. */
  105942. get hasRunningRuntimeAnimations(): boolean;
  105943. /**
  105944. * Initializes the animation
  105945. * @param name Name of the animation
  105946. * @param targetProperty Property to animate
  105947. * @param framePerSecond The frames per second of the animation
  105948. * @param dataType The data type of the animation
  105949. * @param loopMode The loop mode of the animation
  105950. * @param enableBlending Specifies if blending should be enabled
  105951. */
  105952. constructor(
  105953. /**Name of the animation */
  105954. name: string,
  105955. /**Property to animate */
  105956. targetProperty: string,
  105957. /**The frames per second of the animation */
  105958. framePerSecond: number,
  105959. /**The data type of the animation */
  105960. dataType: number,
  105961. /**The loop mode of the animation */
  105962. loopMode?: number | undefined,
  105963. /**Specifies if blending should be enabled */
  105964. enableBlending?: boolean | undefined);
  105965. /**
  105966. * Converts the animation to a string
  105967. * @param fullDetails support for multiple levels of logging within scene loading
  105968. * @returns String form of the animation
  105969. */
  105970. toString(fullDetails?: boolean): string;
  105971. /**
  105972. * Add an event to this animation
  105973. * @param event Event to add
  105974. */
  105975. addEvent(event: AnimationEvent): void;
  105976. /**
  105977. * Remove all events found at the given frame
  105978. * @param frame The frame to remove events from
  105979. */
  105980. removeEvents(frame: number): void;
  105981. /**
  105982. * Retrieves all the events from the animation
  105983. * @returns Events from the animation
  105984. */
  105985. getEvents(): AnimationEvent[];
  105986. /**
  105987. * Creates an animation range
  105988. * @param name Name of the animation range
  105989. * @param from Starting frame of the animation range
  105990. * @param to Ending frame of the animation
  105991. */
  105992. createRange(name: string, from: number, to: number): void;
  105993. /**
  105994. * Deletes an animation range by name
  105995. * @param name Name of the animation range to delete
  105996. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  105997. */
  105998. deleteRange(name: string, deleteFrames?: boolean): void;
  105999. /**
  106000. * Gets the animation range by name, or null if not defined
  106001. * @param name Name of the animation range
  106002. * @returns Nullable animation range
  106003. */
  106004. getRange(name: string): Nullable<AnimationRange>;
  106005. /**
  106006. * Gets the key frames from the animation
  106007. * @returns The key frames of the animation
  106008. */
  106009. getKeys(): Array<IAnimationKey>;
  106010. /**
  106011. * Gets the highest frame rate of the animation
  106012. * @returns Highest frame rate of the animation
  106013. */
  106014. getHighestFrame(): number;
  106015. /**
  106016. * Gets the easing function of the animation
  106017. * @returns Easing function of the animation
  106018. */
  106019. getEasingFunction(): IEasingFunction;
  106020. /**
  106021. * Sets the easing function of the animation
  106022. * @param easingFunction A custom mathematical formula for animation
  106023. */
  106024. setEasingFunction(easingFunction: EasingFunction): void;
  106025. /**
  106026. * Interpolates a scalar linearly
  106027. * @param startValue Start value of the animation curve
  106028. * @param endValue End value of the animation curve
  106029. * @param gradient Scalar amount to interpolate
  106030. * @returns Interpolated scalar value
  106031. */
  106032. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  106033. /**
  106034. * Interpolates a scalar cubically
  106035. * @param startValue Start value of the animation curve
  106036. * @param outTangent End tangent of the animation
  106037. * @param endValue End value of the animation curve
  106038. * @param inTangent Start tangent of the animation curve
  106039. * @param gradient Scalar amount to interpolate
  106040. * @returns Interpolated scalar value
  106041. */
  106042. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  106043. /**
  106044. * Interpolates a quaternion using a spherical linear interpolation
  106045. * @param startValue Start value of the animation curve
  106046. * @param endValue End value of the animation curve
  106047. * @param gradient Scalar amount to interpolate
  106048. * @returns Interpolated quaternion value
  106049. */
  106050. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  106051. /**
  106052. * Interpolates a quaternion cubically
  106053. * @param startValue Start value of the animation curve
  106054. * @param outTangent End tangent of the animation curve
  106055. * @param endValue End value of the animation curve
  106056. * @param inTangent Start tangent of the animation curve
  106057. * @param gradient Scalar amount to interpolate
  106058. * @returns Interpolated quaternion value
  106059. */
  106060. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  106061. /**
  106062. * Interpolates a Vector3 linearl
  106063. * @param startValue Start value of the animation curve
  106064. * @param endValue End value of the animation curve
  106065. * @param gradient Scalar amount to interpolate
  106066. * @returns Interpolated scalar value
  106067. */
  106068. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  106069. /**
  106070. * Interpolates a Vector3 cubically
  106071. * @param startValue Start value of the animation curve
  106072. * @param outTangent End tangent of the animation
  106073. * @param endValue End value of the animation curve
  106074. * @param inTangent Start tangent of the animation curve
  106075. * @param gradient Scalar amount to interpolate
  106076. * @returns InterpolatedVector3 value
  106077. */
  106078. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  106079. /**
  106080. * Interpolates a Vector2 linearly
  106081. * @param startValue Start value of the animation curve
  106082. * @param endValue End value of the animation curve
  106083. * @param gradient Scalar amount to interpolate
  106084. * @returns Interpolated Vector2 value
  106085. */
  106086. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  106087. /**
  106088. * Interpolates a Vector2 cubically
  106089. * @param startValue Start value of the animation curve
  106090. * @param outTangent End tangent of the animation
  106091. * @param endValue End value of the animation curve
  106092. * @param inTangent Start tangent of the animation curve
  106093. * @param gradient Scalar amount to interpolate
  106094. * @returns Interpolated Vector2 value
  106095. */
  106096. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  106097. /**
  106098. * Interpolates a size linearly
  106099. * @param startValue Start value of the animation curve
  106100. * @param endValue End value of the animation curve
  106101. * @param gradient Scalar amount to interpolate
  106102. * @returns Interpolated Size value
  106103. */
  106104. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  106105. /**
  106106. * Interpolates a Color3 linearly
  106107. * @param startValue Start value of the animation curve
  106108. * @param endValue End value of the animation curve
  106109. * @param gradient Scalar amount to interpolate
  106110. * @returns Interpolated Color3 value
  106111. */
  106112. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  106113. /**
  106114. * Interpolates a Color4 linearly
  106115. * @param startValue Start value of the animation curve
  106116. * @param endValue End value of the animation curve
  106117. * @param gradient Scalar amount to interpolate
  106118. * @returns Interpolated Color3 value
  106119. */
  106120. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  106121. /**
  106122. * @hidden Internal use only
  106123. */
  106124. _getKeyValue(value: any): any;
  106125. /**
  106126. * @hidden Internal use only
  106127. */
  106128. _interpolate(currentFrame: number, state: _IAnimationState): any;
  106129. /**
  106130. * Defines the function to use to interpolate matrices
  106131. * @param startValue defines the start matrix
  106132. * @param endValue defines the end matrix
  106133. * @param gradient defines the gradient between both matrices
  106134. * @param result defines an optional target matrix where to store the interpolation
  106135. * @returns the interpolated matrix
  106136. */
  106137. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  106138. /**
  106139. * Makes a copy of the animation
  106140. * @returns Cloned animation
  106141. */
  106142. clone(): Animation;
  106143. /**
  106144. * Sets the key frames of the animation
  106145. * @param values The animation key frames to set
  106146. */
  106147. setKeys(values: Array<IAnimationKey>): void;
  106148. /**
  106149. * Serializes the animation to an object
  106150. * @returns Serialized object
  106151. */
  106152. serialize(): any;
  106153. /**
  106154. * Float animation type
  106155. */
  106156. static readonly ANIMATIONTYPE_FLOAT: number;
  106157. /**
  106158. * Vector3 animation type
  106159. */
  106160. static readonly ANIMATIONTYPE_VECTOR3: number;
  106161. /**
  106162. * Quaternion animation type
  106163. */
  106164. static readonly ANIMATIONTYPE_QUATERNION: number;
  106165. /**
  106166. * Matrix animation type
  106167. */
  106168. static readonly ANIMATIONTYPE_MATRIX: number;
  106169. /**
  106170. * Color3 animation type
  106171. */
  106172. static readonly ANIMATIONTYPE_COLOR3: number;
  106173. /**
  106174. * Color3 animation type
  106175. */
  106176. static readonly ANIMATIONTYPE_COLOR4: number;
  106177. /**
  106178. * Vector2 animation type
  106179. */
  106180. static readonly ANIMATIONTYPE_VECTOR2: number;
  106181. /**
  106182. * Size animation type
  106183. */
  106184. static readonly ANIMATIONTYPE_SIZE: number;
  106185. /**
  106186. * Relative Loop Mode
  106187. */
  106188. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  106189. /**
  106190. * Cycle Loop Mode
  106191. */
  106192. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  106193. /**
  106194. * Constant Loop Mode
  106195. */
  106196. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  106197. /** @hidden */
  106198. static _UniversalLerp(left: any, right: any, amount: number): any;
  106199. /**
  106200. * Parses an animation object and creates an animation
  106201. * @param parsedAnimation Parsed animation object
  106202. * @returns Animation object
  106203. */
  106204. static Parse(parsedAnimation: any): Animation;
  106205. /**
  106206. * Appends the serialized animations from the source animations
  106207. * @param source Source containing the animations
  106208. * @param destination Target to store the animations
  106209. */
  106210. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106211. }
  106212. }
  106213. declare module BABYLON {
  106214. /**
  106215. * Interface containing an array of animations
  106216. */
  106217. export interface IAnimatable {
  106218. /**
  106219. * Array of animations
  106220. */
  106221. animations: Nullable<Array<Animation>>;
  106222. }
  106223. }
  106224. declare module BABYLON {
  106225. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  106226. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106227. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106228. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106229. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106230. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106231. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106232. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106233. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106234. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106235. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106236. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106237. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106238. /**
  106239. * Decorator used to define property that can be serialized as reference to a camera
  106240. * @param sourceName defines the name of the property to decorate
  106241. */
  106242. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106243. /**
  106244. * Class used to help serialization objects
  106245. */
  106246. export class SerializationHelper {
  106247. /** @hidden */
  106248. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  106249. /** @hidden */
  106250. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  106251. /** @hidden */
  106252. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  106253. /** @hidden */
  106254. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  106255. /**
  106256. * Appends the serialized animations from the source animations
  106257. * @param source Source containing the animations
  106258. * @param destination Target to store the animations
  106259. */
  106260. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106261. /**
  106262. * Static function used to serialized a specific entity
  106263. * @param entity defines the entity to serialize
  106264. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  106265. * @returns a JSON compatible object representing the serialization of the entity
  106266. */
  106267. static Serialize<T>(entity: T, serializationObject?: any): any;
  106268. /**
  106269. * Creates a new entity from a serialization data object
  106270. * @param creationFunction defines a function used to instanciated the new entity
  106271. * @param source defines the source serialization data
  106272. * @param scene defines the hosting scene
  106273. * @param rootUrl defines the root url for resources
  106274. * @returns a new entity
  106275. */
  106276. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  106277. /**
  106278. * Clones an object
  106279. * @param creationFunction defines the function used to instanciate the new object
  106280. * @param source defines the source object
  106281. * @returns the cloned object
  106282. */
  106283. static Clone<T>(creationFunction: () => T, source: T): T;
  106284. /**
  106285. * Instanciates a new object based on a source one (some data will be shared between both object)
  106286. * @param creationFunction defines the function used to instanciate the new object
  106287. * @param source defines the source object
  106288. * @returns the new object
  106289. */
  106290. static Instanciate<T>(creationFunction: () => T, source: T): T;
  106291. }
  106292. }
  106293. declare module BABYLON {
  106294. /**
  106295. * Base class of all the textures in babylon.
  106296. * It groups all the common properties the materials, post process, lights... might need
  106297. * in order to make a correct use of the texture.
  106298. */
  106299. export class BaseTexture implements IAnimatable {
  106300. /**
  106301. * Default anisotropic filtering level for the application.
  106302. * It is set to 4 as a good tradeoff between perf and quality.
  106303. */
  106304. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  106305. /**
  106306. * Gets or sets the unique id of the texture
  106307. */
  106308. uniqueId: number;
  106309. /**
  106310. * Define the name of the texture.
  106311. */
  106312. name: string;
  106313. /**
  106314. * Gets or sets an object used to store user defined information.
  106315. */
  106316. metadata: any;
  106317. /**
  106318. * For internal use only. Please do not use.
  106319. */
  106320. reservedDataStore: any;
  106321. private _hasAlpha;
  106322. /**
  106323. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  106324. */
  106325. set hasAlpha(value: boolean);
  106326. get hasAlpha(): boolean;
  106327. /**
  106328. * Defines if the alpha value should be determined via the rgb values.
  106329. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  106330. */
  106331. getAlphaFromRGB: boolean;
  106332. /**
  106333. * Intensity or strength of the texture.
  106334. * It is commonly used by materials to fine tune the intensity of the texture
  106335. */
  106336. level: number;
  106337. /**
  106338. * Define the UV chanel to use starting from 0 and defaulting to 0.
  106339. * This is part of the texture as textures usually maps to one uv set.
  106340. */
  106341. coordinatesIndex: number;
  106342. private _coordinatesMode;
  106343. /**
  106344. * How a texture is mapped.
  106345. *
  106346. * | Value | Type | Description |
  106347. * | ----- | ----------------------------------- | ----------- |
  106348. * | 0 | EXPLICIT_MODE | |
  106349. * | 1 | SPHERICAL_MODE | |
  106350. * | 2 | PLANAR_MODE | |
  106351. * | 3 | CUBIC_MODE | |
  106352. * | 4 | PROJECTION_MODE | |
  106353. * | 5 | SKYBOX_MODE | |
  106354. * | 6 | INVCUBIC_MODE | |
  106355. * | 7 | EQUIRECTANGULAR_MODE | |
  106356. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  106357. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  106358. */
  106359. set coordinatesMode(value: number);
  106360. get coordinatesMode(): number;
  106361. /**
  106362. * | Value | Type | Description |
  106363. * | ----- | ------------------ | ----------- |
  106364. * | 0 | CLAMP_ADDRESSMODE | |
  106365. * | 1 | WRAP_ADDRESSMODE | |
  106366. * | 2 | MIRROR_ADDRESSMODE | |
  106367. */
  106368. wrapU: number;
  106369. /**
  106370. * | Value | Type | Description |
  106371. * | ----- | ------------------ | ----------- |
  106372. * | 0 | CLAMP_ADDRESSMODE | |
  106373. * | 1 | WRAP_ADDRESSMODE | |
  106374. * | 2 | MIRROR_ADDRESSMODE | |
  106375. */
  106376. wrapV: number;
  106377. /**
  106378. * | Value | Type | Description |
  106379. * | ----- | ------------------ | ----------- |
  106380. * | 0 | CLAMP_ADDRESSMODE | |
  106381. * | 1 | WRAP_ADDRESSMODE | |
  106382. * | 2 | MIRROR_ADDRESSMODE | |
  106383. */
  106384. wrapR: number;
  106385. /**
  106386. * With compliant hardware and browser (supporting anisotropic filtering)
  106387. * this defines the level of anisotropic filtering in the texture.
  106388. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  106389. */
  106390. anisotropicFilteringLevel: number;
  106391. /**
  106392. * Define if the texture is a cube texture or if false a 2d texture.
  106393. */
  106394. get isCube(): boolean;
  106395. set isCube(value: boolean);
  106396. /**
  106397. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  106398. */
  106399. get is3D(): boolean;
  106400. set is3D(value: boolean);
  106401. /**
  106402. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  106403. */
  106404. get is2DArray(): boolean;
  106405. set is2DArray(value: boolean);
  106406. /**
  106407. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  106408. * HDR texture are usually stored in linear space.
  106409. * This only impacts the PBR and Background materials
  106410. */
  106411. gammaSpace: boolean;
  106412. /**
  106413. * Gets or sets whether or not the texture contains RGBD data.
  106414. */
  106415. get isRGBD(): boolean;
  106416. set isRGBD(value: boolean);
  106417. /**
  106418. * Is Z inverted in the texture (useful in a cube texture).
  106419. */
  106420. invertZ: boolean;
  106421. /**
  106422. * Are mip maps generated for this texture or not.
  106423. */
  106424. get noMipmap(): boolean;
  106425. /**
  106426. * @hidden
  106427. */
  106428. lodLevelInAlpha: boolean;
  106429. /**
  106430. * With prefiltered texture, defined the offset used during the prefiltering steps.
  106431. */
  106432. get lodGenerationOffset(): number;
  106433. set lodGenerationOffset(value: number);
  106434. /**
  106435. * With prefiltered texture, defined the scale used during the prefiltering steps.
  106436. */
  106437. get lodGenerationScale(): number;
  106438. set lodGenerationScale(value: number);
  106439. /**
  106440. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  106441. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  106442. * average roughness values.
  106443. */
  106444. get linearSpecularLOD(): boolean;
  106445. set linearSpecularLOD(value: boolean);
  106446. /**
  106447. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  106448. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  106449. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  106450. */
  106451. get irradianceTexture(): Nullable<BaseTexture>;
  106452. set irradianceTexture(value: Nullable<BaseTexture>);
  106453. /**
  106454. * Define if the texture is a render target.
  106455. */
  106456. isRenderTarget: boolean;
  106457. /**
  106458. * Define the unique id of the texture in the scene.
  106459. */
  106460. get uid(): string;
  106461. /**
  106462. * Return a string representation of the texture.
  106463. * @returns the texture as a string
  106464. */
  106465. toString(): string;
  106466. /**
  106467. * Get the class name of the texture.
  106468. * @returns "BaseTexture"
  106469. */
  106470. getClassName(): string;
  106471. /**
  106472. * Define the list of animation attached to the texture.
  106473. */
  106474. animations: Animation[];
  106475. /**
  106476. * An event triggered when the texture is disposed.
  106477. */
  106478. onDisposeObservable: Observable<BaseTexture>;
  106479. private _onDisposeObserver;
  106480. /**
  106481. * Callback triggered when the texture has been disposed.
  106482. * Kept for back compatibility, you can use the onDisposeObservable instead.
  106483. */
  106484. set onDispose(callback: () => void);
  106485. /**
  106486. * Define the current state of the loading sequence when in delayed load mode.
  106487. */
  106488. delayLoadState: number;
  106489. private _scene;
  106490. private _engine;
  106491. /** @hidden */
  106492. _texture: Nullable<InternalTexture>;
  106493. private _uid;
  106494. /**
  106495. * Define if the texture is preventinga material to render or not.
  106496. * If not and the texture is not ready, the engine will use a default black texture instead.
  106497. */
  106498. get isBlocking(): boolean;
  106499. /**
  106500. * Instantiates a new BaseTexture.
  106501. * Base class of all the textures in babylon.
  106502. * It groups all the common properties the materials, post process, lights... might need
  106503. * in order to make a correct use of the texture.
  106504. * @param sceneOrEngine Define the scene or engine the texture blongs to
  106505. */
  106506. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  106507. /**
  106508. * Get the scene the texture belongs to.
  106509. * @returns the scene or null if undefined
  106510. */
  106511. getScene(): Nullable<Scene>;
  106512. /** @hidden */
  106513. protected _getEngine(): Nullable<ThinEngine>;
  106514. /**
  106515. * Get the texture transform matrix used to offset tile the texture for istance.
  106516. * @returns the transformation matrix
  106517. */
  106518. getTextureMatrix(): Matrix;
  106519. /**
  106520. * Get the texture reflection matrix used to rotate/transform the reflection.
  106521. * @returns the reflection matrix
  106522. */
  106523. getReflectionTextureMatrix(): Matrix;
  106524. /**
  106525. * Get the underlying lower level texture from Babylon.
  106526. * @returns the insternal texture
  106527. */
  106528. getInternalTexture(): Nullable<InternalTexture>;
  106529. /**
  106530. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  106531. * @returns true if ready or not blocking
  106532. */
  106533. isReadyOrNotBlocking(): boolean;
  106534. /**
  106535. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  106536. * @returns true if fully ready
  106537. */
  106538. isReady(): boolean;
  106539. private _cachedSize;
  106540. /**
  106541. * Get the size of the texture.
  106542. * @returns the texture size.
  106543. */
  106544. getSize(): ISize;
  106545. /**
  106546. * Get the base size of the texture.
  106547. * It can be different from the size if the texture has been resized for POT for instance
  106548. * @returns the base size
  106549. */
  106550. getBaseSize(): ISize;
  106551. /**
  106552. * Update the sampling mode of the texture.
  106553. * Default is Trilinear mode.
  106554. *
  106555. * | Value | Type | Description |
  106556. * | ----- | ------------------ | ----------- |
  106557. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  106558. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  106559. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  106560. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  106561. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  106562. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  106563. * | 7 | NEAREST_LINEAR | |
  106564. * | 8 | NEAREST_NEAREST | |
  106565. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  106566. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  106567. * | 11 | LINEAR_LINEAR | |
  106568. * | 12 | LINEAR_NEAREST | |
  106569. *
  106570. * > _mag_: magnification filter (close to the viewer)
  106571. * > _min_: minification filter (far from the viewer)
  106572. * > _mip_: filter used between mip map levels
  106573. *@param samplingMode Define the new sampling mode of the texture
  106574. */
  106575. updateSamplingMode(samplingMode: number): void;
  106576. /**
  106577. * Scales the texture if is `canRescale()`
  106578. * @param ratio the resize factor we want to use to rescale
  106579. */
  106580. scale(ratio: number): void;
  106581. /**
  106582. * Get if the texture can rescale.
  106583. */
  106584. get canRescale(): boolean;
  106585. /** @hidden */
  106586. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  106587. /** @hidden */
  106588. _rebuild(): void;
  106589. /**
  106590. * Triggers the load sequence in delayed load mode.
  106591. */
  106592. delayLoad(): void;
  106593. /**
  106594. * Clones the texture.
  106595. * @returns the cloned texture
  106596. */
  106597. clone(): Nullable<BaseTexture>;
  106598. /**
  106599. * Get the texture underlying type (INT, FLOAT...)
  106600. */
  106601. get textureType(): number;
  106602. /**
  106603. * Get the texture underlying format (RGB, RGBA...)
  106604. */
  106605. get textureFormat(): number;
  106606. /**
  106607. * Indicates that textures need to be re-calculated for all materials
  106608. */
  106609. protected _markAllSubMeshesAsTexturesDirty(): void;
  106610. /**
  106611. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  106612. * This will returns an RGBA array buffer containing either in values (0-255) or
  106613. * float values (0-1) depending of the underlying buffer type.
  106614. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  106615. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  106616. * @param buffer defines a user defined buffer to fill with data (can be null)
  106617. * @returns The Array buffer containing the pixels data.
  106618. */
  106619. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  106620. /**
  106621. * Release and destroy the underlying lower level texture aka internalTexture.
  106622. */
  106623. releaseInternalTexture(): void;
  106624. /** @hidden */
  106625. get _lodTextureHigh(): Nullable<BaseTexture>;
  106626. /** @hidden */
  106627. get _lodTextureMid(): Nullable<BaseTexture>;
  106628. /** @hidden */
  106629. get _lodTextureLow(): Nullable<BaseTexture>;
  106630. /**
  106631. * Dispose the texture and release its associated resources.
  106632. */
  106633. dispose(): void;
  106634. /**
  106635. * Serialize the texture into a JSON representation that can be parsed later on.
  106636. * @returns the JSON representation of the texture
  106637. */
  106638. serialize(): any;
  106639. /**
  106640. * Helper function to be called back once a list of texture contains only ready textures.
  106641. * @param textures Define the list of textures to wait for
  106642. * @param callback Define the callback triggered once the entire list will be ready
  106643. */
  106644. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  106645. private static _isScene;
  106646. }
  106647. }
  106648. declare module BABYLON {
  106649. /**
  106650. * Options to be used when creating an effect.
  106651. */
  106652. export interface IEffectCreationOptions {
  106653. /**
  106654. * Atrributes that will be used in the shader.
  106655. */
  106656. attributes: string[];
  106657. /**
  106658. * Uniform varible names that will be set in the shader.
  106659. */
  106660. uniformsNames: string[];
  106661. /**
  106662. * Uniform buffer variable names that will be set in the shader.
  106663. */
  106664. uniformBuffersNames: string[];
  106665. /**
  106666. * Sampler texture variable names that will be set in the shader.
  106667. */
  106668. samplers: string[];
  106669. /**
  106670. * Define statements that will be set in the shader.
  106671. */
  106672. defines: any;
  106673. /**
  106674. * Possible fallbacks for this effect to improve performance when needed.
  106675. */
  106676. fallbacks: Nullable<IEffectFallbacks>;
  106677. /**
  106678. * Callback that will be called when the shader is compiled.
  106679. */
  106680. onCompiled: Nullable<(effect: Effect) => void>;
  106681. /**
  106682. * Callback that will be called if an error occurs during shader compilation.
  106683. */
  106684. onError: Nullable<(effect: Effect, errors: string) => void>;
  106685. /**
  106686. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106687. */
  106688. indexParameters?: any;
  106689. /**
  106690. * Max number of lights that can be used in the shader.
  106691. */
  106692. maxSimultaneousLights?: number;
  106693. /**
  106694. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  106695. */
  106696. transformFeedbackVaryings?: Nullable<string[]>;
  106697. }
  106698. /**
  106699. * Effect containing vertex and fragment shader that can be executed on an object.
  106700. */
  106701. export class Effect implements IDisposable {
  106702. /**
  106703. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106704. */
  106705. static ShadersRepository: string;
  106706. /**
  106707. * Enable logging of the shader code when a compilation error occurs
  106708. */
  106709. static LogShaderCodeOnCompilationError: boolean;
  106710. /**
  106711. * Name of the effect.
  106712. */
  106713. name: any;
  106714. /**
  106715. * String container all the define statements that should be set on the shader.
  106716. */
  106717. defines: string;
  106718. /**
  106719. * Callback that will be called when the shader is compiled.
  106720. */
  106721. onCompiled: Nullable<(effect: Effect) => void>;
  106722. /**
  106723. * Callback that will be called if an error occurs during shader compilation.
  106724. */
  106725. onError: Nullable<(effect: Effect, errors: string) => void>;
  106726. /**
  106727. * Callback that will be called when effect is bound.
  106728. */
  106729. onBind: Nullable<(effect: Effect) => void>;
  106730. /**
  106731. * Unique ID of the effect.
  106732. */
  106733. uniqueId: number;
  106734. /**
  106735. * Observable that will be called when the shader is compiled.
  106736. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  106737. */
  106738. onCompileObservable: Observable<Effect>;
  106739. /**
  106740. * Observable that will be called if an error occurs during shader compilation.
  106741. */
  106742. onErrorObservable: Observable<Effect>;
  106743. /** @hidden */
  106744. _onBindObservable: Nullable<Observable<Effect>>;
  106745. /**
  106746. * @hidden
  106747. * Specifies if the effect was previously ready
  106748. */
  106749. _wasPreviouslyReady: boolean;
  106750. /**
  106751. * Observable that will be called when effect is bound.
  106752. */
  106753. get onBindObservable(): Observable<Effect>;
  106754. /** @hidden */
  106755. _bonesComputationForcedToCPU: boolean;
  106756. private static _uniqueIdSeed;
  106757. private _engine;
  106758. private _uniformBuffersNames;
  106759. private _uniformBuffersNamesList;
  106760. private _uniformsNames;
  106761. private _samplerList;
  106762. private _samplers;
  106763. private _isReady;
  106764. private _compilationError;
  106765. private _allFallbacksProcessed;
  106766. private _attributesNames;
  106767. private _attributes;
  106768. private _attributeLocationByName;
  106769. private _uniforms;
  106770. /**
  106771. * Key for the effect.
  106772. * @hidden
  106773. */
  106774. _key: string;
  106775. private _indexParameters;
  106776. private _fallbacks;
  106777. private _vertexSourceCode;
  106778. private _fragmentSourceCode;
  106779. private _vertexSourceCodeOverride;
  106780. private _fragmentSourceCodeOverride;
  106781. private _transformFeedbackVaryings;
  106782. /**
  106783. * Compiled shader to webGL program.
  106784. * @hidden
  106785. */
  106786. _pipelineContext: Nullable<IPipelineContext>;
  106787. private _valueCache;
  106788. private static _baseCache;
  106789. /**
  106790. * Instantiates an effect.
  106791. * An effect can be used to create/manage/execute vertex and fragment shaders.
  106792. * @param baseName Name of the effect.
  106793. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  106794. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  106795. * @param samplers List of sampler variables that will be passed to the shader.
  106796. * @param engine Engine to be used to render the effect
  106797. * @param defines Define statements to be added to the shader.
  106798. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  106799. * @param onCompiled Callback that will be called when the shader is compiled.
  106800. * @param onError Callback that will be called if an error occurs during shader compilation.
  106801. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106802. */
  106803. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  106804. private _useFinalCode;
  106805. /**
  106806. * Unique key for this effect
  106807. */
  106808. get key(): string;
  106809. /**
  106810. * If the effect has been compiled and prepared.
  106811. * @returns if the effect is compiled and prepared.
  106812. */
  106813. isReady(): boolean;
  106814. private _isReadyInternal;
  106815. /**
  106816. * The engine the effect was initialized with.
  106817. * @returns the engine.
  106818. */
  106819. getEngine(): Engine;
  106820. /**
  106821. * The pipeline context for this effect
  106822. * @returns the associated pipeline context
  106823. */
  106824. getPipelineContext(): Nullable<IPipelineContext>;
  106825. /**
  106826. * The set of names of attribute variables for the shader.
  106827. * @returns An array of attribute names.
  106828. */
  106829. getAttributesNames(): string[];
  106830. /**
  106831. * Returns the attribute at the given index.
  106832. * @param index The index of the attribute.
  106833. * @returns The location of the attribute.
  106834. */
  106835. getAttributeLocation(index: number): number;
  106836. /**
  106837. * Returns the attribute based on the name of the variable.
  106838. * @param name of the attribute to look up.
  106839. * @returns the attribute location.
  106840. */
  106841. getAttributeLocationByName(name: string): number;
  106842. /**
  106843. * The number of attributes.
  106844. * @returns the numnber of attributes.
  106845. */
  106846. getAttributesCount(): number;
  106847. /**
  106848. * Gets the index of a uniform variable.
  106849. * @param uniformName of the uniform to look up.
  106850. * @returns the index.
  106851. */
  106852. getUniformIndex(uniformName: string): number;
  106853. /**
  106854. * Returns the attribute based on the name of the variable.
  106855. * @param uniformName of the uniform to look up.
  106856. * @returns the location of the uniform.
  106857. */
  106858. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  106859. /**
  106860. * Returns an array of sampler variable names
  106861. * @returns The array of sampler variable names.
  106862. */
  106863. getSamplers(): string[];
  106864. /**
  106865. * Returns an array of uniform variable names
  106866. * @returns The array of uniform variable names.
  106867. */
  106868. getUniformNames(): string[];
  106869. /**
  106870. * Returns an array of uniform buffer variable names
  106871. * @returns The array of uniform buffer variable names.
  106872. */
  106873. getUniformBuffersNames(): string[];
  106874. /**
  106875. * Returns the index parameters used to create the effect
  106876. * @returns The index parameters object
  106877. */
  106878. getIndexParameters(): any;
  106879. /**
  106880. * The error from the last compilation.
  106881. * @returns the error string.
  106882. */
  106883. getCompilationError(): string;
  106884. /**
  106885. * Gets a boolean indicating that all fallbacks were used during compilation
  106886. * @returns true if all fallbacks were used
  106887. */
  106888. allFallbacksProcessed(): boolean;
  106889. /**
  106890. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  106891. * @param func The callback to be used.
  106892. */
  106893. executeWhenCompiled(func: (effect: Effect) => void): void;
  106894. private _checkIsReady;
  106895. private _loadShader;
  106896. /**
  106897. * Gets the vertex shader source code of this effect
  106898. */
  106899. get vertexSourceCode(): string;
  106900. /**
  106901. * Gets the fragment shader source code of this effect
  106902. */
  106903. get fragmentSourceCode(): string;
  106904. /**
  106905. * Recompiles the webGL program
  106906. * @param vertexSourceCode The source code for the vertex shader.
  106907. * @param fragmentSourceCode The source code for the fragment shader.
  106908. * @param onCompiled Callback called when completed.
  106909. * @param onError Callback called on error.
  106910. * @hidden
  106911. */
  106912. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  106913. /**
  106914. * Prepares the effect
  106915. * @hidden
  106916. */
  106917. _prepareEffect(): void;
  106918. private _getShaderCodeAndErrorLine;
  106919. private _processCompilationErrors;
  106920. /**
  106921. * Checks if the effect is supported. (Must be called after compilation)
  106922. */
  106923. get isSupported(): boolean;
  106924. /**
  106925. * Binds a texture to the engine to be used as output of the shader.
  106926. * @param channel Name of the output variable.
  106927. * @param texture Texture to bind.
  106928. * @hidden
  106929. */
  106930. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  106931. /**
  106932. * Sets a texture on the engine to be used in the shader.
  106933. * @param channel Name of the sampler variable.
  106934. * @param texture Texture to set.
  106935. */
  106936. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  106937. /**
  106938. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  106939. * @param channel Name of the sampler variable.
  106940. * @param texture Texture to set.
  106941. */
  106942. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  106943. /**
  106944. * Sets an array of textures on the engine to be used in the shader.
  106945. * @param channel Name of the variable.
  106946. * @param textures Textures to set.
  106947. */
  106948. setTextureArray(channel: string, textures: BaseTexture[]): void;
  106949. /**
  106950. * 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)
  106951. * @param channel Name of the sampler variable.
  106952. * @param postProcess Post process to get the input texture from.
  106953. */
  106954. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  106955. /**
  106956. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  106957. * 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)
  106958. * @param channel Name of the sampler variable.
  106959. * @param postProcess Post process to get the output texture from.
  106960. */
  106961. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  106962. /** @hidden */
  106963. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  106964. /** @hidden */
  106965. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  106966. /** @hidden */
  106967. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  106968. /** @hidden */
  106969. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  106970. /**
  106971. * Binds a buffer to a uniform.
  106972. * @param buffer Buffer to bind.
  106973. * @param name Name of the uniform variable to bind to.
  106974. */
  106975. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  106976. /**
  106977. * Binds block to a uniform.
  106978. * @param blockName Name of the block to bind.
  106979. * @param index Index to bind.
  106980. */
  106981. bindUniformBlock(blockName: string, index: number): void;
  106982. /**
  106983. * Sets an interger value on a uniform variable.
  106984. * @param uniformName Name of the variable.
  106985. * @param value Value to be set.
  106986. * @returns this effect.
  106987. */
  106988. setInt(uniformName: string, value: number): Effect;
  106989. /**
  106990. * Sets an int array on a uniform variable.
  106991. * @param uniformName Name of the variable.
  106992. * @param array array to be set.
  106993. * @returns this effect.
  106994. */
  106995. setIntArray(uniformName: string, array: Int32Array): Effect;
  106996. /**
  106997. * 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)
  106998. * @param uniformName Name of the variable.
  106999. * @param array array to be set.
  107000. * @returns this effect.
  107001. */
  107002. setIntArray2(uniformName: string, array: Int32Array): Effect;
  107003. /**
  107004. * 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)
  107005. * @param uniformName Name of the variable.
  107006. * @param array array to be set.
  107007. * @returns this effect.
  107008. */
  107009. setIntArray3(uniformName: string, array: Int32Array): Effect;
  107010. /**
  107011. * 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)
  107012. * @param uniformName Name of the variable.
  107013. * @param array array to be set.
  107014. * @returns this effect.
  107015. */
  107016. setIntArray4(uniformName: string, array: Int32Array): Effect;
  107017. /**
  107018. * Sets an float array on a uniform variable.
  107019. * @param uniformName Name of the variable.
  107020. * @param array array to be set.
  107021. * @returns this effect.
  107022. */
  107023. setFloatArray(uniformName: string, array: Float32Array): Effect;
  107024. /**
  107025. * 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)
  107026. * @param uniformName Name of the variable.
  107027. * @param array array to be set.
  107028. * @returns this effect.
  107029. */
  107030. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  107031. /**
  107032. * 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)
  107033. * @param uniformName Name of the variable.
  107034. * @param array array to be set.
  107035. * @returns this effect.
  107036. */
  107037. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  107038. /**
  107039. * 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)
  107040. * @param uniformName Name of the variable.
  107041. * @param array array to be set.
  107042. * @returns this effect.
  107043. */
  107044. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  107045. /**
  107046. * Sets an array on a uniform variable.
  107047. * @param uniformName Name of the variable.
  107048. * @param array array to be set.
  107049. * @returns this effect.
  107050. */
  107051. setArray(uniformName: string, array: number[]): Effect;
  107052. /**
  107053. * 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)
  107054. * @param uniformName Name of the variable.
  107055. * @param array array to be set.
  107056. * @returns this effect.
  107057. */
  107058. setArray2(uniformName: string, array: number[]): Effect;
  107059. /**
  107060. * 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)
  107061. * @param uniformName Name of the variable.
  107062. * @param array array to be set.
  107063. * @returns this effect.
  107064. */
  107065. setArray3(uniformName: string, array: number[]): Effect;
  107066. /**
  107067. * 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)
  107068. * @param uniformName Name of the variable.
  107069. * @param array array to be set.
  107070. * @returns this effect.
  107071. */
  107072. setArray4(uniformName: string, array: number[]): Effect;
  107073. /**
  107074. * Sets matrices on a uniform variable.
  107075. * @param uniformName Name of the variable.
  107076. * @param matrices matrices to be set.
  107077. * @returns this effect.
  107078. */
  107079. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  107080. /**
  107081. * Sets matrix on a uniform variable.
  107082. * @param uniformName Name of the variable.
  107083. * @param matrix matrix to be set.
  107084. * @returns this effect.
  107085. */
  107086. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  107087. /**
  107088. * 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)
  107089. * @param uniformName Name of the variable.
  107090. * @param matrix matrix to be set.
  107091. * @returns this effect.
  107092. */
  107093. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  107094. /**
  107095. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  107096. * @param uniformName Name of the variable.
  107097. * @param matrix matrix to be set.
  107098. * @returns this effect.
  107099. */
  107100. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  107101. /**
  107102. * Sets a float on a uniform variable.
  107103. * @param uniformName Name of the variable.
  107104. * @param value value to be set.
  107105. * @returns this effect.
  107106. */
  107107. setFloat(uniformName: string, value: number): Effect;
  107108. /**
  107109. * Sets a boolean on a uniform variable.
  107110. * @param uniformName Name of the variable.
  107111. * @param bool value to be set.
  107112. * @returns this effect.
  107113. */
  107114. setBool(uniformName: string, bool: boolean): Effect;
  107115. /**
  107116. * Sets a Vector2 on a uniform variable.
  107117. * @param uniformName Name of the variable.
  107118. * @param vector2 vector2 to be set.
  107119. * @returns this effect.
  107120. */
  107121. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  107122. /**
  107123. * Sets a float2 on a uniform variable.
  107124. * @param uniformName Name of the variable.
  107125. * @param x First float in float2.
  107126. * @param y Second float in float2.
  107127. * @returns this effect.
  107128. */
  107129. setFloat2(uniformName: string, x: number, y: number): Effect;
  107130. /**
  107131. * Sets a Vector3 on a uniform variable.
  107132. * @param uniformName Name of the variable.
  107133. * @param vector3 Value to be set.
  107134. * @returns this effect.
  107135. */
  107136. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  107137. /**
  107138. * Sets a float3 on a uniform variable.
  107139. * @param uniformName Name of the variable.
  107140. * @param x First float in float3.
  107141. * @param y Second float in float3.
  107142. * @param z Third float in float3.
  107143. * @returns this effect.
  107144. */
  107145. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  107146. /**
  107147. * Sets a Vector4 on a uniform variable.
  107148. * @param uniformName Name of the variable.
  107149. * @param vector4 Value to be set.
  107150. * @returns this effect.
  107151. */
  107152. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  107153. /**
  107154. * Sets a float4 on a uniform variable.
  107155. * @param uniformName Name of the variable.
  107156. * @param x First float in float4.
  107157. * @param y Second float in float4.
  107158. * @param z Third float in float4.
  107159. * @param w Fourth float in float4.
  107160. * @returns this effect.
  107161. */
  107162. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  107163. /**
  107164. * Sets a Color3 on a uniform variable.
  107165. * @param uniformName Name of the variable.
  107166. * @param color3 Value to be set.
  107167. * @returns this effect.
  107168. */
  107169. setColor3(uniformName: string, color3: IColor3Like): Effect;
  107170. /**
  107171. * Sets a Color4 on a uniform variable.
  107172. * @param uniformName Name of the variable.
  107173. * @param color3 Value to be set.
  107174. * @param alpha Alpha value to be set.
  107175. * @returns this effect.
  107176. */
  107177. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  107178. /**
  107179. * Sets a Color4 on a uniform variable
  107180. * @param uniformName defines the name of the variable
  107181. * @param color4 defines the value to be set
  107182. * @returns this effect.
  107183. */
  107184. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  107185. /** Release all associated resources */
  107186. dispose(): void;
  107187. /**
  107188. * This function will add a new shader to the shader store
  107189. * @param name the name of the shader
  107190. * @param pixelShader optional pixel shader content
  107191. * @param vertexShader optional vertex shader content
  107192. */
  107193. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  107194. /**
  107195. * Store of each shader (The can be looked up using effect.key)
  107196. */
  107197. static ShadersStore: {
  107198. [key: string]: string;
  107199. };
  107200. /**
  107201. * Store of each included file for a shader (The can be looked up using effect.key)
  107202. */
  107203. static IncludesShadersStore: {
  107204. [key: string]: string;
  107205. };
  107206. /**
  107207. * Resets the cache of effects.
  107208. */
  107209. static ResetCache(): void;
  107210. }
  107211. }
  107212. declare module BABYLON {
  107213. /**
  107214. * Interface used to describe the capabilities of the engine relatively to the current browser
  107215. */
  107216. export interface EngineCapabilities {
  107217. /** Maximum textures units per fragment shader */
  107218. maxTexturesImageUnits: number;
  107219. /** Maximum texture units per vertex shader */
  107220. maxVertexTextureImageUnits: number;
  107221. /** Maximum textures units in the entire pipeline */
  107222. maxCombinedTexturesImageUnits: number;
  107223. /** Maximum texture size */
  107224. maxTextureSize: number;
  107225. /** Maximum texture samples */
  107226. maxSamples?: number;
  107227. /** Maximum cube texture size */
  107228. maxCubemapTextureSize: number;
  107229. /** Maximum render texture size */
  107230. maxRenderTextureSize: number;
  107231. /** Maximum number of vertex attributes */
  107232. maxVertexAttribs: number;
  107233. /** Maximum number of varyings */
  107234. maxVaryingVectors: number;
  107235. /** Maximum number of uniforms per vertex shader */
  107236. maxVertexUniformVectors: number;
  107237. /** Maximum number of uniforms per fragment shader */
  107238. maxFragmentUniformVectors: number;
  107239. /** Defines if standard derivates (dx/dy) are supported */
  107240. standardDerivatives: boolean;
  107241. /** Defines if s3tc texture compression is supported */
  107242. s3tc?: WEBGL_compressed_texture_s3tc;
  107243. /** Defines if pvrtc texture compression is supported */
  107244. pvrtc: any;
  107245. /** Defines if etc1 texture compression is supported */
  107246. etc1: any;
  107247. /** Defines if etc2 texture compression is supported */
  107248. etc2: any;
  107249. /** Defines if astc texture compression is supported */
  107250. astc: any;
  107251. /** Defines if float textures are supported */
  107252. textureFloat: boolean;
  107253. /** Defines if vertex array objects are supported */
  107254. vertexArrayObject: boolean;
  107255. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  107256. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  107257. /** Gets the maximum level of anisotropy supported */
  107258. maxAnisotropy: number;
  107259. /** Defines if instancing is supported */
  107260. instancedArrays: boolean;
  107261. /** Defines if 32 bits indices are supported */
  107262. uintIndices: boolean;
  107263. /** Defines if high precision shaders are supported */
  107264. highPrecisionShaderSupported: boolean;
  107265. /** Defines if depth reading in the fragment shader is supported */
  107266. fragmentDepthSupported: boolean;
  107267. /** Defines if float texture linear filtering is supported*/
  107268. textureFloatLinearFiltering: boolean;
  107269. /** Defines if rendering to float textures is supported */
  107270. textureFloatRender: boolean;
  107271. /** Defines if half float textures are supported*/
  107272. textureHalfFloat: boolean;
  107273. /** Defines if half float texture linear filtering is supported*/
  107274. textureHalfFloatLinearFiltering: boolean;
  107275. /** Defines if rendering to half float textures is supported */
  107276. textureHalfFloatRender: boolean;
  107277. /** Defines if textureLOD shader command is supported */
  107278. textureLOD: boolean;
  107279. /** Defines if draw buffers extension is supported */
  107280. drawBuffersExtension: boolean;
  107281. /** Defines if depth textures are supported */
  107282. depthTextureExtension: boolean;
  107283. /** Defines if float color buffer are supported */
  107284. colorBufferFloat: boolean;
  107285. /** Gets disjoint timer query extension (null if not supported) */
  107286. timerQuery?: EXT_disjoint_timer_query;
  107287. /** Defines if timestamp can be used with timer query */
  107288. canUseTimestampForTimerQuery: boolean;
  107289. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  107290. multiview?: any;
  107291. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  107292. oculusMultiview?: any;
  107293. /** Function used to let the system compiles shaders in background */
  107294. parallelShaderCompile?: {
  107295. COMPLETION_STATUS_KHR: number;
  107296. };
  107297. /** Max number of texture samples for MSAA */
  107298. maxMSAASamples: number;
  107299. /** Defines if the blend min max extension is supported */
  107300. blendMinMax: boolean;
  107301. }
  107302. }
  107303. declare module BABYLON {
  107304. /**
  107305. * @hidden
  107306. **/
  107307. export class DepthCullingState {
  107308. private _isDepthTestDirty;
  107309. private _isDepthMaskDirty;
  107310. private _isDepthFuncDirty;
  107311. private _isCullFaceDirty;
  107312. private _isCullDirty;
  107313. private _isZOffsetDirty;
  107314. private _isFrontFaceDirty;
  107315. private _depthTest;
  107316. private _depthMask;
  107317. private _depthFunc;
  107318. private _cull;
  107319. private _cullFace;
  107320. private _zOffset;
  107321. private _frontFace;
  107322. /**
  107323. * Initializes the state.
  107324. */
  107325. constructor();
  107326. get isDirty(): boolean;
  107327. get zOffset(): number;
  107328. set zOffset(value: number);
  107329. get cullFace(): Nullable<number>;
  107330. set cullFace(value: Nullable<number>);
  107331. get cull(): Nullable<boolean>;
  107332. set cull(value: Nullable<boolean>);
  107333. get depthFunc(): Nullable<number>;
  107334. set depthFunc(value: Nullable<number>);
  107335. get depthMask(): boolean;
  107336. set depthMask(value: boolean);
  107337. get depthTest(): boolean;
  107338. set depthTest(value: boolean);
  107339. get frontFace(): Nullable<number>;
  107340. set frontFace(value: Nullable<number>);
  107341. reset(): void;
  107342. apply(gl: WebGLRenderingContext): void;
  107343. }
  107344. }
  107345. declare module BABYLON {
  107346. /**
  107347. * @hidden
  107348. **/
  107349. export class StencilState {
  107350. /** 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 */
  107351. static readonly ALWAYS: number;
  107352. /** Passed to stencilOperation to specify that stencil value must be kept */
  107353. static readonly KEEP: number;
  107354. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107355. static readonly REPLACE: number;
  107356. private _isStencilTestDirty;
  107357. private _isStencilMaskDirty;
  107358. private _isStencilFuncDirty;
  107359. private _isStencilOpDirty;
  107360. private _stencilTest;
  107361. private _stencilMask;
  107362. private _stencilFunc;
  107363. private _stencilFuncRef;
  107364. private _stencilFuncMask;
  107365. private _stencilOpStencilFail;
  107366. private _stencilOpDepthFail;
  107367. private _stencilOpStencilDepthPass;
  107368. get isDirty(): boolean;
  107369. get stencilFunc(): number;
  107370. set stencilFunc(value: number);
  107371. get stencilFuncRef(): number;
  107372. set stencilFuncRef(value: number);
  107373. get stencilFuncMask(): number;
  107374. set stencilFuncMask(value: number);
  107375. get stencilOpStencilFail(): number;
  107376. set stencilOpStencilFail(value: number);
  107377. get stencilOpDepthFail(): number;
  107378. set stencilOpDepthFail(value: number);
  107379. get stencilOpStencilDepthPass(): number;
  107380. set stencilOpStencilDepthPass(value: number);
  107381. get stencilMask(): number;
  107382. set stencilMask(value: number);
  107383. get stencilTest(): boolean;
  107384. set stencilTest(value: boolean);
  107385. constructor();
  107386. reset(): void;
  107387. apply(gl: WebGLRenderingContext): void;
  107388. }
  107389. }
  107390. declare module BABYLON {
  107391. /**
  107392. * @hidden
  107393. **/
  107394. export class AlphaState {
  107395. private _isAlphaBlendDirty;
  107396. private _isBlendFunctionParametersDirty;
  107397. private _isBlendEquationParametersDirty;
  107398. private _isBlendConstantsDirty;
  107399. private _alphaBlend;
  107400. private _blendFunctionParameters;
  107401. private _blendEquationParameters;
  107402. private _blendConstants;
  107403. /**
  107404. * Initializes the state.
  107405. */
  107406. constructor();
  107407. get isDirty(): boolean;
  107408. get alphaBlend(): boolean;
  107409. set alphaBlend(value: boolean);
  107410. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  107411. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  107412. setAlphaEquationParameters(rgb: number, alpha: number): void;
  107413. reset(): void;
  107414. apply(gl: WebGLRenderingContext): void;
  107415. }
  107416. }
  107417. declare module BABYLON {
  107418. /** @hidden */
  107419. export class WebGL2ShaderProcessor implements IShaderProcessor {
  107420. attributeProcessor(attribute: string): string;
  107421. varyingProcessor(varying: string, isFragment: boolean): string;
  107422. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  107423. }
  107424. }
  107425. declare module BABYLON {
  107426. /**
  107427. * Interface for attribute information associated with buffer instanciation
  107428. */
  107429. export interface InstancingAttributeInfo {
  107430. /**
  107431. * Name of the GLSL attribute
  107432. * if attribute index is not specified, this is used to retrieve the index from the effect
  107433. */
  107434. attributeName: string;
  107435. /**
  107436. * Index/offset of the attribute in the vertex shader
  107437. * if not specified, this will be computes from the name.
  107438. */
  107439. index?: number;
  107440. /**
  107441. * size of the attribute, 1, 2, 3 or 4
  107442. */
  107443. attributeSize: number;
  107444. /**
  107445. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  107446. */
  107447. offset: number;
  107448. /**
  107449. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  107450. * default to 1
  107451. */
  107452. divisor?: number;
  107453. /**
  107454. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  107455. * default is FLOAT
  107456. */
  107457. attributeType?: number;
  107458. /**
  107459. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  107460. */
  107461. normalized?: boolean;
  107462. }
  107463. }
  107464. declare module BABYLON {
  107465. interface ThinEngine {
  107466. /**
  107467. * Update a video texture
  107468. * @param texture defines the texture to update
  107469. * @param video defines the video element to use
  107470. * @param invertY defines if data must be stored with Y axis inverted
  107471. */
  107472. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  107473. }
  107474. }
  107475. declare module BABYLON {
  107476. /**
  107477. * Settings for finer control over video usage
  107478. */
  107479. export interface VideoTextureSettings {
  107480. /**
  107481. * Applies `autoplay` to video, if specified
  107482. */
  107483. autoPlay?: boolean;
  107484. /**
  107485. * Applies `loop` to video, if specified
  107486. */
  107487. loop?: boolean;
  107488. /**
  107489. * Automatically updates internal texture from video at every frame in the render loop
  107490. */
  107491. autoUpdateTexture: boolean;
  107492. /**
  107493. * Image src displayed during the video loading or until the user interacts with the video.
  107494. */
  107495. poster?: string;
  107496. }
  107497. /**
  107498. * If you want to display a video in your scene, this is the special texture for that.
  107499. * This special texture works similar to other textures, with the exception of a few parameters.
  107500. * @see https://doc.babylonjs.com/how_to/video_texture
  107501. */
  107502. export class VideoTexture extends Texture {
  107503. /**
  107504. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  107505. */
  107506. readonly autoUpdateTexture: boolean;
  107507. /**
  107508. * The video instance used by the texture internally
  107509. */
  107510. readonly video: HTMLVideoElement;
  107511. private _onUserActionRequestedObservable;
  107512. /**
  107513. * Event triggerd when a dom action is required by the user to play the video.
  107514. * This happens due to recent changes in browser policies preventing video to auto start.
  107515. */
  107516. get onUserActionRequestedObservable(): Observable<Texture>;
  107517. private _generateMipMaps;
  107518. private _stillImageCaptured;
  107519. private _displayingPosterTexture;
  107520. private _settings;
  107521. private _createInternalTextureOnEvent;
  107522. private _frameId;
  107523. private _currentSrc;
  107524. /**
  107525. * Creates a video texture.
  107526. * If you want to display a video in your scene, this is the special texture for that.
  107527. * This special texture works similar to other textures, with the exception of a few parameters.
  107528. * @see https://doc.babylonjs.com/how_to/video_texture
  107529. * @param name optional name, will detect from video source, if not defined
  107530. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  107531. * @param scene is obviously the current scene.
  107532. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  107533. * @param invertY is false by default but can be used to invert video on Y axis
  107534. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  107535. * @param settings allows finer control over video usage
  107536. */
  107537. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  107538. private _getName;
  107539. private _getVideo;
  107540. private _createInternalTexture;
  107541. private reset;
  107542. /**
  107543. * @hidden Internal method to initiate `update`.
  107544. */
  107545. _rebuild(): void;
  107546. /**
  107547. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  107548. */
  107549. update(): void;
  107550. /**
  107551. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  107552. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  107553. */
  107554. updateTexture(isVisible: boolean): void;
  107555. protected _updateInternalTexture: () => void;
  107556. /**
  107557. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  107558. * @param url New url.
  107559. */
  107560. updateURL(url: string): void;
  107561. /**
  107562. * Clones the texture.
  107563. * @returns the cloned texture
  107564. */
  107565. clone(): VideoTexture;
  107566. /**
  107567. * Dispose the texture and release its associated resources.
  107568. */
  107569. dispose(): void;
  107570. /**
  107571. * Creates a video texture straight from a stream.
  107572. * @param scene Define the scene the texture should be created in
  107573. * @param stream Define the stream the texture should be created from
  107574. * @returns The created video texture as a promise
  107575. */
  107576. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  107577. /**
  107578. * Creates a video texture straight from your WebCam video feed.
  107579. * @param scene Define the scene the texture should be created in
  107580. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107581. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107582. * @returns The created video texture as a promise
  107583. */
  107584. static CreateFromWebCamAsync(scene: Scene, constraints: {
  107585. minWidth: number;
  107586. maxWidth: number;
  107587. minHeight: number;
  107588. maxHeight: number;
  107589. deviceId: string;
  107590. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  107591. /**
  107592. * Creates a video texture straight from your WebCam video feed.
  107593. * @param scene Define the scene the texture should be created in
  107594. * @param onReady Define a callback to triggered once the texture will be ready
  107595. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107596. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107597. */
  107598. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  107599. minWidth: number;
  107600. maxWidth: number;
  107601. minHeight: number;
  107602. maxHeight: number;
  107603. deviceId: string;
  107604. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  107605. }
  107606. }
  107607. declare module BABYLON {
  107608. /**
  107609. * Defines the interface used by objects working like Scene
  107610. * @hidden
  107611. */
  107612. export interface ISceneLike {
  107613. _addPendingData(data: any): void;
  107614. _removePendingData(data: any): void;
  107615. offlineProvider: IOfflineProvider;
  107616. }
  107617. /** Interface defining initialization parameters for Engine class */
  107618. export interface EngineOptions extends WebGLContextAttributes {
  107619. /**
  107620. * Defines if the engine should no exceed a specified device ratio
  107621. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  107622. */
  107623. limitDeviceRatio?: number;
  107624. /**
  107625. * Defines if webvr should be enabled automatically
  107626. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107627. */
  107628. autoEnableWebVR?: boolean;
  107629. /**
  107630. * Defines if webgl2 should be turned off even if supported
  107631. * @see http://doc.babylonjs.com/features/webgl2
  107632. */
  107633. disableWebGL2Support?: boolean;
  107634. /**
  107635. * Defines if webaudio should be initialized as well
  107636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107637. */
  107638. audioEngine?: boolean;
  107639. /**
  107640. * Defines if animations should run using a deterministic lock step
  107641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107642. */
  107643. deterministicLockstep?: boolean;
  107644. /** Defines the maximum steps to use with deterministic lock step mode */
  107645. lockstepMaxSteps?: number;
  107646. /** Defines the seconds between each deterministic lock step */
  107647. timeStep?: number;
  107648. /**
  107649. * Defines that engine should ignore context lost events
  107650. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  107651. */
  107652. doNotHandleContextLost?: boolean;
  107653. /**
  107654. * Defines that engine should ignore modifying touch action attribute and style
  107655. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  107656. */
  107657. doNotHandleTouchAction?: boolean;
  107658. /**
  107659. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  107660. */
  107661. useHighPrecisionFloats?: boolean;
  107662. }
  107663. /**
  107664. * The base engine class (root of all engines)
  107665. */
  107666. export class ThinEngine {
  107667. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  107668. static ExceptionList: ({
  107669. key: string;
  107670. capture: string;
  107671. captureConstraint: number;
  107672. targets: string[];
  107673. } | {
  107674. key: string;
  107675. capture: null;
  107676. captureConstraint: null;
  107677. targets: string[];
  107678. })[];
  107679. /** @hidden */
  107680. static _TextureLoaders: IInternalTextureLoader[];
  107681. /**
  107682. * Returns the current npm package of the sdk
  107683. */
  107684. static get NpmPackage(): string;
  107685. /**
  107686. * Returns the current version of the framework
  107687. */
  107688. static get Version(): string;
  107689. /**
  107690. * Returns a string describing the current engine
  107691. */
  107692. get description(): string;
  107693. /**
  107694. * Gets or sets the epsilon value used by collision engine
  107695. */
  107696. static CollisionsEpsilon: number;
  107697. /**
  107698. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  107699. */
  107700. static get ShadersRepository(): string;
  107701. static set ShadersRepository(value: string);
  107702. /** @hidden */
  107703. _shaderProcessor: IShaderProcessor;
  107704. /**
  107705. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  107706. */
  107707. forcePOTTextures: boolean;
  107708. /**
  107709. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  107710. */
  107711. isFullscreen: boolean;
  107712. /**
  107713. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  107714. */
  107715. cullBackFaces: boolean;
  107716. /**
  107717. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  107718. */
  107719. renderEvenInBackground: boolean;
  107720. /**
  107721. * Gets or sets a boolean indicating that cache can be kept between frames
  107722. */
  107723. preventCacheWipeBetweenFrames: boolean;
  107724. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  107725. validateShaderPrograms: boolean;
  107726. /**
  107727. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  107728. * This can provide greater z depth for distant objects.
  107729. */
  107730. useReverseDepthBuffer: boolean;
  107731. /**
  107732. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  107733. */
  107734. disableUniformBuffers: boolean;
  107735. /** @hidden */
  107736. _uniformBuffers: UniformBuffer[];
  107737. /**
  107738. * Gets a boolean indicating that the engine supports uniform buffers
  107739. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  107740. */
  107741. get supportsUniformBuffers(): boolean;
  107742. /** @hidden */
  107743. _gl: WebGLRenderingContext;
  107744. /** @hidden */
  107745. _webGLVersion: number;
  107746. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  107747. protected _windowIsBackground: boolean;
  107748. protected _creationOptions: EngineOptions;
  107749. protected _highPrecisionShadersAllowed: boolean;
  107750. /** @hidden */
  107751. get _shouldUseHighPrecisionShader(): boolean;
  107752. /**
  107753. * Gets a boolean indicating that only power of 2 textures are supported
  107754. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  107755. */
  107756. get needPOTTextures(): boolean;
  107757. /** @hidden */
  107758. _badOS: boolean;
  107759. /** @hidden */
  107760. _badDesktopOS: boolean;
  107761. private _hardwareScalingLevel;
  107762. /** @hidden */
  107763. _caps: EngineCapabilities;
  107764. private _isStencilEnable;
  107765. private _glVersion;
  107766. private _glRenderer;
  107767. private _glVendor;
  107768. /** @hidden */
  107769. _videoTextureSupported: boolean;
  107770. protected _renderingQueueLaunched: boolean;
  107771. protected _activeRenderLoops: (() => void)[];
  107772. /**
  107773. * Observable signaled when a context lost event is raised
  107774. */
  107775. onContextLostObservable: Observable<ThinEngine>;
  107776. /**
  107777. * Observable signaled when a context restored event is raised
  107778. */
  107779. onContextRestoredObservable: Observable<ThinEngine>;
  107780. private _onContextLost;
  107781. private _onContextRestored;
  107782. protected _contextWasLost: boolean;
  107783. /** @hidden */
  107784. _doNotHandleContextLost: boolean;
  107785. /**
  107786. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  107787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  107788. */
  107789. get doNotHandleContextLost(): boolean;
  107790. set doNotHandleContextLost(value: boolean);
  107791. /**
  107792. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  107793. */
  107794. disableVertexArrayObjects: boolean;
  107795. /** @hidden */
  107796. protected _colorWrite: boolean;
  107797. /** @hidden */
  107798. protected _colorWriteChanged: boolean;
  107799. /** @hidden */
  107800. protected _depthCullingState: DepthCullingState;
  107801. /** @hidden */
  107802. protected _stencilState: StencilState;
  107803. /** @hidden */
  107804. _alphaState: AlphaState;
  107805. /** @hidden */
  107806. _alphaMode: number;
  107807. /** @hidden */
  107808. _alphaEquation: number;
  107809. /** @hidden */
  107810. _internalTexturesCache: InternalTexture[];
  107811. /** @hidden */
  107812. protected _activeChannel: number;
  107813. private _currentTextureChannel;
  107814. /** @hidden */
  107815. protected _boundTexturesCache: {
  107816. [key: string]: Nullable<InternalTexture>;
  107817. };
  107818. /** @hidden */
  107819. protected _currentEffect: Nullable<Effect>;
  107820. /** @hidden */
  107821. protected _currentProgram: Nullable<WebGLProgram>;
  107822. private _compiledEffects;
  107823. private _vertexAttribArraysEnabled;
  107824. /** @hidden */
  107825. protected _cachedViewport: Nullable<IViewportLike>;
  107826. private _cachedVertexArrayObject;
  107827. /** @hidden */
  107828. protected _cachedVertexBuffers: any;
  107829. /** @hidden */
  107830. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  107831. /** @hidden */
  107832. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  107833. /** @hidden */
  107834. _currentRenderTarget: Nullable<InternalTexture>;
  107835. private _uintIndicesCurrentlySet;
  107836. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  107837. /** @hidden */
  107838. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  107839. /** @hidden */
  107840. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  107841. private _currentBufferPointers;
  107842. private _currentInstanceLocations;
  107843. private _currentInstanceBuffers;
  107844. private _textureUnits;
  107845. /** @hidden */
  107846. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107847. /** @hidden */
  107848. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107849. /** @hidden */
  107850. _boundRenderFunction: any;
  107851. private _vaoRecordInProgress;
  107852. private _mustWipeVertexAttributes;
  107853. private _emptyTexture;
  107854. private _emptyCubeTexture;
  107855. private _emptyTexture3D;
  107856. private _emptyTexture2DArray;
  107857. /** @hidden */
  107858. _frameHandler: number;
  107859. private _nextFreeTextureSlots;
  107860. private _maxSimultaneousTextures;
  107861. private _activeRequests;
  107862. /** @hidden */
  107863. _transformTextureUrl: Nullable<(url: string) => string>;
  107864. protected get _supportsHardwareTextureRescaling(): boolean;
  107865. private _framebufferDimensionsObject;
  107866. /**
  107867. * sets the object from which width and height will be taken from when getting render width and height
  107868. * Will fallback to the gl object
  107869. * @param dimensions the framebuffer width and height that will be used.
  107870. */
  107871. set framebufferDimensionsObject(dimensions: Nullable<{
  107872. framebufferWidth: number;
  107873. framebufferHeight: number;
  107874. }>);
  107875. /**
  107876. * Gets the current viewport
  107877. */
  107878. get currentViewport(): Nullable<IViewportLike>;
  107879. /**
  107880. * Gets the default empty texture
  107881. */
  107882. get emptyTexture(): InternalTexture;
  107883. /**
  107884. * Gets the default empty 3D texture
  107885. */
  107886. get emptyTexture3D(): InternalTexture;
  107887. /**
  107888. * Gets the default empty 2D array texture
  107889. */
  107890. get emptyTexture2DArray(): InternalTexture;
  107891. /**
  107892. * Gets the default empty cube texture
  107893. */
  107894. get emptyCubeTexture(): InternalTexture;
  107895. /**
  107896. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  107897. */
  107898. readonly premultipliedAlpha: boolean;
  107899. /**
  107900. * Observable event triggered before each texture is initialized
  107901. */
  107902. onBeforeTextureInitObservable: Observable<Texture>;
  107903. /**
  107904. * Creates a new engine
  107905. * @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
  107906. * @param antialias defines enable antialiasing (default: false)
  107907. * @param options defines further options to be sent to the getContext() function
  107908. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107909. */
  107910. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107911. private _rebuildInternalTextures;
  107912. private _rebuildEffects;
  107913. /**
  107914. * Gets a boolean indicating if all created effects are ready
  107915. * @returns true if all effects are ready
  107916. */
  107917. areAllEffectsReady(): boolean;
  107918. protected _rebuildBuffers(): void;
  107919. protected _initGLContext(): void;
  107920. /**
  107921. * Gets version of the current webGL context
  107922. */
  107923. get webGLVersion(): number;
  107924. /**
  107925. * Gets a string idenfifying the name of the class
  107926. * @returns "Engine" string
  107927. */
  107928. getClassName(): string;
  107929. /**
  107930. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  107931. */
  107932. get isStencilEnable(): boolean;
  107933. /** @hidden */
  107934. _prepareWorkingCanvas(): void;
  107935. /**
  107936. * Reset the texture cache to empty state
  107937. */
  107938. resetTextureCache(): void;
  107939. /**
  107940. * Gets an object containing information about the current webGL context
  107941. * @returns an object containing the vender, the renderer and the version of the current webGL context
  107942. */
  107943. getGlInfo(): {
  107944. vendor: string;
  107945. renderer: string;
  107946. version: string;
  107947. };
  107948. /**
  107949. * Defines the hardware scaling level.
  107950. * By default the hardware scaling level is computed from the window device ratio.
  107951. * 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.
  107952. * @param level defines the level to use
  107953. */
  107954. setHardwareScalingLevel(level: number): void;
  107955. /**
  107956. * Gets the current hardware scaling level.
  107957. * By default the hardware scaling level is computed from the window device ratio.
  107958. * 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.
  107959. * @returns a number indicating the current hardware scaling level
  107960. */
  107961. getHardwareScalingLevel(): number;
  107962. /**
  107963. * Gets the list of loaded textures
  107964. * @returns an array containing all loaded textures
  107965. */
  107966. getLoadedTexturesCache(): InternalTexture[];
  107967. /**
  107968. * Gets the object containing all engine capabilities
  107969. * @returns the EngineCapabilities object
  107970. */
  107971. getCaps(): EngineCapabilities;
  107972. /**
  107973. * stop executing a render loop function and remove it from the execution array
  107974. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  107975. */
  107976. stopRenderLoop(renderFunction?: () => void): void;
  107977. /** @hidden */
  107978. _renderLoop(): void;
  107979. /**
  107980. * Gets the HTML canvas attached with the current webGL context
  107981. * @returns a HTML canvas
  107982. */
  107983. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  107984. /**
  107985. * Gets host window
  107986. * @returns the host window object
  107987. */
  107988. getHostWindow(): Nullable<Window>;
  107989. /**
  107990. * Gets the current render width
  107991. * @param useScreen defines if screen size must be used (or the current render target if any)
  107992. * @returns a number defining the current render width
  107993. */
  107994. getRenderWidth(useScreen?: boolean): number;
  107995. /**
  107996. * Gets the current render height
  107997. * @param useScreen defines if screen size must be used (or the current render target if any)
  107998. * @returns a number defining the current render height
  107999. */
  108000. getRenderHeight(useScreen?: boolean): number;
  108001. /**
  108002. * Can be used to override the current requestAnimationFrame requester.
  108003. * @hidden
  108004. */
  108005. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  108006. /**
  108007. * Register and execute a render loop. The engine can have more than one render function
  108008. * @param renderFunction defines the function to continuously execute
  108009. */
  108010. runRenderLoop(renderFunction: () => void): void;
  108011. /**
  108012. * Clear the current render buffer or the current render target (if any is set up)
  108013. * @param color defines the color to use
  108014. * @param backBuffer defines if the back buffer must be cleared
  108015. * @param depth defines if the depth buffer must be cleared
  108016. * @param stencil defines if the stencil buffer must be cleared
  108017. */
  108018. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108019. private _viewportCached;
  108020. /** @hidden */
  108021. _viewport(x: number, y: number, width: number, height: number): void;
  108022. /**
  108023. * Set the WebGL's viewport
  108024. * @param viewport defines the viewport element to be used
  108025. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  108026. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  108027. */
  108028. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108029. /**
  108030. * Begin a new frame
  108031. */
  108032. beginFrame(): void;
  108033. /**
  108034. * Enf the current frame
  108035. */
  108036. endFrame(): void;
  108037. /**
  108038. * Resize the view according to the canvas' size
  108039. */
  108040. resize(): void;
  108041. /**
  108042. * Force a specific size of the canvas
  108043. * @param width defines the new canvas' width
  108044. * @param height defines the new canvas' height
  108045. */
  108046. setSize(width: number, height: number): void;
  108047. /**
  108048. * Binds the frame buffer to the specified texture.
  108049. * @param texture The texture to render to or null for the default canvas
  108050. * @param faceIndex The face of the texture to render to in case of cube texture
  108051. * @param requiredWidth The width of the target to render to
  108052. * @param requiredHeight The height of the target to render to
  108053. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  108054. * @param lodLevel defines the lod level to bind to the frame buffer
  108055. * @param layer defines the 2d array index to bind to frame buffer to
  108056. */
  108057. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  108058. /** @hidden */
  108059. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  108060. /**
  108061. * Unbind the current render target texture from the webGL context
  108062. * @param texture defines the render target texture to unbind
  108063. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108064. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108065. */
  108066. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108067. /**
  108068. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  108069. */
  108070. flushFramebuffer(): void;
  108071. /**
  108072. * Unbind the current render target and bind the default framebuffer
  108073. */
  108074. restoreDefaultFramebuffer(): void;
  108075. /** @hidden */
  108076. protected _resetVertexBufferBinding(): void;
  108077. /**
  108078. * Creates a vertex buffer
  108079. * @param data the data for the vertex buffer
  108080. * @returns the new WebGL static buffer
  108081. */
  108082. createVertexBuffer(data: DataArray): DataBuffer;
  108083. private _createVertexBuffer;
  108084. /**
  108085. * Creates a dynamic vertex buffer
  108086. * @param data the data for the dynamic vertex buffer
  108087. * @returns the new WebGL dynamic buffer
  108088. */
  108089. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  108090. protected _resetIndexBufferBinding(): void;
  108091. /**
  108092. * Creates a new index buffer
  108093. * @param indices defines the content of the index buffer
  108094. * @param updatable defines if the index buffer must be updatable
  108095. * @returns a new webGL buffer
  108096. */
  108097. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  108098. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  108099. /**
  108100. * Bind a webGL buffer to the webGL context
  108101. * @param buffer defines the buffer to bind
  108102. */
  108103. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  108104. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  108105. private bindBuffer;
  108106. /**
  108107. * update the bound buffer with the given data
  108108. * @param data defines the data to update
  108109. */
  108110. updateArrayBuffer(data: Float32Array): void;
  108111. private _vertexAttribPointer;
  108112. /** @hidden */
  108113. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  108114. private _bindVertexBuffersAttributes;
  108115. /**
  108116. * Records a vertex array object
  108117. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  108118. * @param vertexBuffers defines the list of vertex buffers to store
  108119. * @param indexBuffer defines the index buffer to store
  108120. * @param effect defines the effect to store
  108121. * @returns the new vertex array object
  108122. */
  108123. recordVertexArrayObject(vertexBuffers: {
  108124. [key: string]: VertexBuffer;
  108125. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  108126. /**
  108127. * Bind a specific vertex array object
  108128. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  108129. * @param vertexArrayObject defines the vertex array object to bind
  108130. * @param indexBuffer defines the index buffer to bind
  108131. */
  108132. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  108133. /**
  108134. * Bind webGl buffers directly to the webGL context
  108135. * @param vertexBuffer defines the vertex buffer to bind
  108136. * @param indexBuffer defines the index buffer to bind
  108137. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  108138. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  108139. * @param effect defines the effect associated with the vertex buffer
  108140. */
  108141. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  108142. private _unbindVertexArrayObject;
  108143. /**
  108144. * Bind a list of vertex buffers to the webGL context
  108145. * @param vertexBuffers defines the list of vertex buffers to bind
  108146. * @param indexBuffer defines the index buffer to bind
  108147. * @param effect defines the effect associated with the vertex buffers
  108148. */
  108149. bindBuffers(vertexBuffers: {
  108150. [key: string]: Nullable<VertexBuffer>;
  108151. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  108152. /**
  108153. * Unbind all instance attributes
  108154. */
  108155. unbindInstanceAttributes(): void;
  108156. /**
  108157. * Release and free the memory of a vertex array object
  108158. * @param vao defines the vertex array object to delete
  108159. */
  108160. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  108161. /** @hidden */
  108162. _releaseBuffer(buffer: DataBuffer): boolean;
  108163. protected _deleteBuffer(buffer: DataBuffer): void;
  108164. /**
  108165. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  108166. * @param instancesBuffer defines the webGL buffer to update and bind
  108167. * @param data defines the data to store in the buffer
  108168. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  108169. */
  108170. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  108171. /**
  108172. * Bind the content of a webGL buffer used with instantiation
  108173. * @param instancesBuffer defines the webGL buffer to bind
  108174. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  108175. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  108176. */
  108177. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  108178. /**
  108179. * Disable the instance attribute corresponding to the name in parameter
  108180. * @param name defines the name of the attribute to disable
  108181. */
  108182. disableInstanceAttributeByName(name: string): void;
  108183. /**
  108184. * Disable the instance attribute corresponding to the location in parameter
  108185. * @param attributeLocation defines the attribute location of the attribute to disable
  108186. */
  108187. disableInstanceAttribute(attributeLocation: number): void;
  108188. /**
  108189. * Disable the attribute corresponding to the location in parameter
  108190. * @param attributeLocation defines the attribute location of the attribute to disable
  108191. */
  108192. disableAttributeByIndex(attributeLocation: number): void;
  108193. /**
  108194. * Send a draw order
  108195. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108196. * @param indexStart defines the starting index
  108197. * @param indexCount defines the number of index to draw
  108198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108199. */
  108200. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108201. /**
  108202. * Draw a list of points
  108203. * @param verticesStart defines the index of first vertex to draw
  108204. * @param verticesCount defines the count of vertices to draw
  108205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108206. */
  108207. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108208. /**
  108209. * Draw a list of unindexed primitives
  108210. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108211. * @param verticesStart defines the index of first vertex to draw
  108212. * @param verticesCount defines the count of vertices to draw
  108213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108214. */
  108215. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108216. /**
  108217. * Draw a list of indexed primitives
  108218. * @param fillMode defines the primitive to use
  108219. * @param indexStart defines the starting index
  108220. * @param indexCount defines the number of index to draw
  108221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108222. */
  108223. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108224. /**
  108225. * Draw a list of unindexed primitives
  108226. * @param fillMode defines the primitive to use
  108227. * @param verticesStart defines the index of first vertex to draw
  108228. * @param verticesCount defines the count of vertices to draw
  108229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108230. */
  108231. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108232. private _drawMode;
  108233. /** @hidden */
  108234. protected _reportDrawCall(): void;
  108235. /** @hidden */
  108236. _releaseEffect(effect: Effect): void;
  108237. /** @hidden */
  108238. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108239. /**
  108240. * Create a new effect (used to store vertex/fragment shaders)
  108241. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  108242. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  108243. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  108244. * @param samplers defines an array of string used to represent textures
  108245. * @param defines defines the string containing the defines to use to compile the shaders
  108246. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108247. * @param onCompiled defines a function to call when the effect creation is successful
  108248. * @param onError defines a function to call when the effect creation has failed
  108249. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  108250. * @returns the new Effect
  108251. */
  108252. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  108253. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  108254. private _compileShader;
  108255. private _compileRawShader;
  108256. /** @hidden */
  108257. _getShaderSource(shader: WebGLShader): Nullable<string>;
  108258. /**
  108259. * Directly creates a webGL program
  108260. * @param pipelineContext defines the pipeline context to attach to
  108261. * @param vertexCode defines the vertex shader code to use
  108262. * @param fragmentCode defines the fragment shader code to use
  108263. * @param context defines the webGL context to use (if not set, the current one will be used)
  108264. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108265. * @returns the new webGL program
  108266. */
  108267. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108268. /**
  108269. * Creates a webGL program
  108270. * @param pipelineContext defines the pipeline context to attach to
  108271. * @param vertexCode defines the vertex shader code to use
  108272. * @param fragmentCode defines the fragment shader code to use
  108273. * @param defines defines the string containing the defines to use to compile the shaders
  108274. * @param context defines the webGL context to use (if not set, the current one will be used)
  108275. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108276. * @returns the new webGL program
  108277. */
  108278. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108279. /**
  108280. * Creates a new pipeline context
  108281. * @returns the new pipeline
  108282. */
  108283. createPipelineContext(): IPipelineContext;
  108284. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108285. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  108286. /** @hidden */
  108287. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  108288. /** @hidden */
  108289. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  108290. /** @hidden */
  108291. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  108292. /**
  108293. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  108294. * @param pipelineContext defines the pipeline context to use
  108295. * @param uniformsNames defines the list of uniform names
  108296. * @returns an array of webGL uniform locations
  108297. */
  108298. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108299. /**
  108300. * Gets the lsit of active attributes for a given webGL program
  108301. * @param pipelineContext defines the pipeline context to use
  108302. * @param attributesNames defines the list of attribute names to get
  108303. * @returns an array of indices indicating the offset of each attribute
  108304. */
  108305. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108306. /**
  108307. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  108308. * @param effect defines the effect to activate
  108309. */
  108310. enableEffect(effect: Nullable<Effect>): void;
  108311. /**
  108312. * Set the value of an uniform to a number (int)
  108313. * @param uniform defines the webGL uniform location where to store the value
  108314. * @param value defines the int number to store
  108315. */
  108316. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108317. /**
  108318. * Set the value of an uniform to an array of int32
  108319. * @param uniform defines the webGL uniform location where to store the value
  108320. * @param array defines the array of int32 to store
  108321. */
  108322. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108323. /**
  108324. * Set the value of an uniform to an array of int32 (stored as vec2)
  108325. * @param uniform defines the webGL uniform location where to store the value
  108326. * @param array defines the array of int32 to store
  108327. */
  108328. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108329. /**
  108330. * Set the value of an uniform to an array of int32 (stored as vec3)
  108331. * @param uniform defines the webGL uniform location where to store the value
  108332. * @param array defines the array of int32 to store
  108333. */
  108334. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108335. /**
  108336. * Set the value of an uniform to an array of int32 (stored as vec4)
  108337. * @param uniform defines the webGL uniform location where to store the value
  108338. * @param array defines the array of int32 to store
  108339. */
  108340. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108341. /**
  108342. * Set the value of an uniform to an array of number
  108343. * @param uniform defines the webGL uniform location where to store the value
  108344. * @param array defines the array of number to store
  108345. */
  108346. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108347. /**
  108348. * Set the value of an uniform to an array of number (stored as vec2)
  108349. * @param uniform defines the webGL uniform location where to store the value
  108350. * @param array defines the array of number to store
  108351. */
  108352. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108353. /**
  108354. * Set the value of an uniform to an array of number (stored as vec3)
  108355. * @param uniform defines the webGL uniform location where to store the value
  108356. * @param array defines the array of number to store
  108357. */
  108358. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108359. /**
  108360. * Set the value of an uniform to an array of number (stored as vec4)
  108361. * @param uniform defines the webGL uniform location where to store the value
  108362. * @param array defines the array of number to store
  108363. */
  108364. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108365. /**
  108366. * Set the value of an uniform to an array of float32 (stored as matrices)
  108367. * @param uniform defines the webGL uniform location where to store the value
  108368. * @param matrices defines the array of float32 to store
  108369. */
  108370. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  108371. /**
  108372. * Set the value of an uniform to a matrix (3x3)
  108373. * @param uniform defines the webGL uniform location where to store the value
  108374. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  108375. */
  108376. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108377. /**
  108378. * Set the value of an uniform to a matrix (2x2)
  108379. * @param uniform defines the webGL uniform location where to store the value
  108380. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  108381. */
  108382. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108383. /**
  108384. * Set the value of an uniform to a number (float)
  108385. * @param uniform defines the webGL uniform location where to store the value
  108386. * @param value defines the float number to store
  108387. */
  108388. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108389. /**
  108390. * Set the value of an uniform to a vec2
  108391. * @param uniform defines the webGL uniform location where to store the value
  108392. * @param x defines the 1st component of the value
  108393. * @param y defines the 2nd component of the value
  108394. */
  108395. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  108396. /**
  108397. * Set the value of an uniform to a vec3
  108398. * @param uniform defines the webGL uniform location where to store the value
  108399. * @param x defines the 1st component of the value
  108400. * @param y defines the 2nd component of the value
  108401. * @param z defines the 3rd component of the value
  108402. */
  108403. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  108404. /**
  108405. * Set the value of an uniform to a vec4
  108406. * @param uniform defines the webGL uniform location where to store the value
  108407. * @param x defines the 1st component of the value
  108408. * @param y defines the 2nd component of the value
  108409. * @param z defines the 3rd component of the value
  108410. * @param w defines the 4th component of the value
  108411. */
  108412. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  108413. /**
  108414. * Apply all cached states (depth, culling, stencil and alpha)
  108415. */
  108416. applyStates(): void;
  108417. /**
  108418. * Enable or disable color writing
  108419. * @param enable defines the state to set
  108420. */
  108421. setColorWrite(enable: boolean): void;
  108422. /**
  108423. * Gets a boolean indicating if color writing is enabled
  108424. * @returns the current color writing state
  108425. */
  108426. getColorWrite(): boolean;
  108427. /**
  108428. * Gets the depth culling state manager
  108429. */
  108430. get depthCullingState(): DepthCullingState;
  108431. /**
  108432. * Gets the alpha state manager
  108433. */
  108434. get alphaState(): AlphaState;
  108435. /**
  108436. * Gets the stencil state manager
  108437. */
  108438. get stencilState(): StencilState;
  108439. /**
  108440. * Clears the list of texture accessible through engine.
  108441. * This can help preventing texture load conflict due to name collision.
  108442. */
  108443. clearInternalTexturesCache(): void;
  108444. /**
  108445. * Force the entire cache to be cleared
  108446. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  108447. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  108448. */
  108449. wipeCaches(bruteForce?: boolean): void;
  108450. /** @hidden */
  108451. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  108452. min: number;
  108453. mag: number;
  108454. };
  108455. /** @hidden */
  108456. _createTexture(): WebGLTexture;
  108457. /**
  108458. * Usually called from Texture.ts.
  108459. * Passed information to create a WebGLTexture
  108460. * @param url defines a value which contains one of the following:
  108461. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  108462. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  108463. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  108464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  108465. * @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)
  108466. * @param scene needed for loading to the correct scene
  108467. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  108468. * @param onLoad optional callback to be called upon successful completion
  108469. * @param onError optional callback to be called upon failure
  108470. * @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
  108471. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  108472. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  108473. * @param forcedExtension defines the extension to use to pick the right loader
  108474. * @param mimeType defines an optional mime type
  108475. * @returns a InternalTexture for assignment back into BABYLON.Texture
  108476. */
  108477. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  108478. /**
  108479. * Loads an image as an HTMLImageElement.
  108480. * @param input url string, ArrayBuffer, or Blob to load
  108481. * @param onLoad callback called when the image successfully loads
  108482. * @param onError callback called when the image fails to load
  108483. * @param offlineProvider offline provider for caching
  108484. * @param mimeType optional mime type
  108485. * @returns the HTMLImageElement of the loaded image
  108486. * @hidden
  108487. */
  108488. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108489. /**
  108490. * @hidden
  108491. */
  108492. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108493. private _unpackFlipYCached;
  108494. /**
  108495. * In case you are sharing the context with other applications, it might
  108496. * be interested to not cache the unpack flip y state to ensure a consistent
  108497. * value would be set.
  108498. */
  108499. enableUnpackFlipYCached: boolean;
  108500. /** @hidden */
  108501. _unpackFlipY(value: boolean): void;
  108502. /** @hidden */
  108503. _getUnpackAlignement(): number;
  108504. private _getTextureTarget;
  108505. /**
  108506. * Update the sampling mode of a given texture
  108507. * @param samplingMode defines the required sampling mode
  108508. * @param texture defines the texture to update
  108509. * @param generateMipMaps defines whether to generate mipmaps for the texture
  108510. */
  108511. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  108512. /**
  108513. * Update the sampling mode of a given texture
  108514. * @param texture defines the texture to update
  108515. * @param wrapU defines the texture wrap mode of the u coordinates
  108516. * @param wrapV defines the texture wrap mode of the v coordinates
  108517. * @param wrapR defines the texture wrap mode of the r coordinates
  108518. */
  108519. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  108520. /** @hidden */
  108521. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  108522. width: number;
  108523. height: number;
  108524. layers?: number;
  108525. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  108526. /** @hidden */
  108527. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108528. /** @hidden */
  108529. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  108530. /**
  108531. * Update a portion of an internal texture
  108532. * @param texture defines the texture to update
  108533. * @param imageData defines the data to store into the texture
  108534. * @param xOffset defines the x coordinates of the update rectangle
  108535. * @param yOffset defines the y coordinates of the update rectangle
  108536. * @param width defines the width of the update rectangle
  108537. * @param height defines the height of the update rectangle
  108538. * @param faceIndex defines the face index if texture is a cube (0 by default)
  108539. * @param lod defines the lod level to update (0 by default)
  108540. */
  108541. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  108542. /** @hidden */
  108543. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108544. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  108545. private _prepareWebGLTexture;
  108546. /** @hidden */
  108547. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  108548. private _getDepthStencilBuffer;
  108549. /** @hidden */
  108550. _releaseFramebufferObjects(texture: InternalTexture): void;
  108551. /** @hidden */
  108552. _releaseTexture(texture: InternalTexture): void;
  108553. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  108554. protected _setProgram(program: WebGLProgram): void;
  108555. protected _boundUniforms: {
  108556. [key: number]: WebGLUniformLocation;
  108557. };
  108558. /**
  108559. * Binds an effect to the webGL context
  108560. * @param effect defines the effect to bind
  108561. */
  108562. bindSamplers(effect: Effect): void;
  108563. private _activateCurrentTexture;
  108564. /** @hidden */
  108565. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  108566. /** @hidden */
  108567. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  108568. /**
  108569. * Unbind all textures from the webGL context
  108570. */
  108571. unbindAllTextures(): void;
  108572. /**
  108573. * Sets a texture to the according uniform.
  108574. * @param channel The texture channel
  108575. * @param uniform The uniform to set
  108576. * @param texture The texture to apply
  108577. */
  108578. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  108579. private _bindSamplerUniformToChannel;
  108580. private _getTextureWrapMode;
  108581. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  108582. /**
  108583. * Sets an array of texture to the webGL context
  108584. * @param channel defines the channel where the texture array must be set
  108585. * @param uniform defines the associated uniform location
  108586. * @param textures defines the array of textures to bind
  108587. */
  108588. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  108589. /** @hidden */
  108590. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  108591. private _setTextureParameterFloat;
  108592. private _setTextureParameterInteger;
  108593. /**
  108594. * Unbind all vertex attributes from the webGL context
  108595. */
  108596. unbindAllAttributes(): void;
  108597. /**
  108598. * 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
  108599. */
  108600. releaseEffects(): void;
  108601. /**
  108602. * Dispose and release all associated resources
  108603. */
  108604. dispose(): void;
  108605. /**
  108606. * Attach a new callback raised when context lost event is fired
  108607. * @param callback defines the callback to call
  108608. */
  108609. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108610. /**
  108611. * Attach a new callback raised when context restored event is fired
  108612. * @param callback defines the callback to call
  108613. */
  108614. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108615. /**
  108616. * Get the current error code of the webGL context
  108617. * @returns the error code
  108618. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108619. */
  108620. getError(): number;
  108621. private _canRenderToFloatFramebuffer;
  108622. private _canRenderToHalfFloatFramebuffer;
  108623. private _canRenderToFramebuffer;
  108624. /** @hidden */
  108625. _getWebGLTextureType(type: number): number;
  108626. /** @hidden */
  108627. _getInternalFormat(format: number): number;
  108628. /** @hidden */
  108629. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  108630. /** @hidden */
  108631. _getRGBAMultiSampleBufferFormat(type: number): number;
  108632. /** @hidden */
  108633. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  108634. /**
  108635. * Loads a file from a url
  108636. * @param url url to load
  108637. * @param onSuccess callback called when the file successfully loads
  108638. * @param onProgress callback called while file is loading (if the server supports this mode)
  108639. * @param offlineProvider defines the offline provider for caching
  108640. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108641. * @param onError callback called when the file fails to load
  108642. * @returns a file request object
  108643. * @hidden
  108644. */
  108645. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  108646. /**
  108647. * Reads pixels from the current frame buffer. Please note that this function can be slow
  108648. * @param x defines the x coordinate of the rectangle where pixels must be read
  108649. * @param y defines the y coordinate of the rectangle where pixels must be read
  108650. * @param width defines the width of the rectangle where pixels must be read
  108651. * @param height defines the height of the rectangle where pixels must be read
  108652. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  108653. * @returns a Uint8Array containing RGBA colors
  108654. */
  108655. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  108656. private static _isSupported;
  108657. /**
  108658. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  108659. * @returns true if the engine can be created
  108660. * @ignorenaming
  108661. */
  108662. static isSupported(): boolean;
  108663. /**
  108664. * Find the next highest power of two.
  108665. * @param x Number to start search from.
  108666. * @return Next highest power of two.
  108667. */
  108668. static CeilingPOT(x: number): number;
  108669. /**
  108670. * Find the next lowest power of two.
  108671. * @param x Number to start search from.
  108672. * @return Next lowest power of two.
  108673. */
  108674. static FloorPOT(x: number): number;
  108675. /**
  108676. * Find the nearest power of two.
  108677. * @param x Number to start search from.
  108678. * @return Next nearest power of two.
  108679. */
  108680. static NearestPOT(x: number): number;
  108681. /**
  108682. * Get the closest exponent of two
  108683. * @param value defines the value to approximate
  108684. * @param max defines the maximum value to return
  108685. * @param mode defines how to define the closest value
  108686. * @returns closest exponent of two of the given value
  108687. */
  108688. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  108689. /**
  108690. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  108691. * @param func - the function to be called
  108692. * @param requester - the object that will request the next frame. Falls back to window.
  108693. * @returns frame number
  108694. */
  108695. static QueueNewFrame(func: () => void, requester?: any): number;
  108696. /**
  108697. * Gets host document
  108698. * @returns the host document object
  108699. */
  108700. getHostDocument(): Nullable<Document>;
  108701. }
  108702. }
  108703. declare module BABYLON {
  108704. /**
  108705. * Class representing spherical harmonics coefficients to the 3rd degree
  108706. */
  108707. export class SphericalHarmonics {
  108708. /**
  108709. * Defines whether or not the harmonics have been prescaled for rendering.
  108710. */
  108711. preScaled: boolean;
  108712. /**
  108713. * The l0,0 coefficients of the spherical harmonics
  108714. */
  108715. l00: Vector3;
  108716. /**
  108717. * The l1,-1 coefficients of the spherical harmonics
  108718. */
  108719. l1_1: Vector3;
  108720. /**
  108721. * The l1,0 coefficients of the spherical harmonics
  108722. */
  108723. l10: Vector3;
  108724. /**
  108725. * The l1,1 coefficients of the spherical harmonics
  108726. */
  108727. l11: Vector3;
  108728. /**
  108729. * The l2,-2 coefficients of the spherical harmonics
  108730. */
  108731. l2_2: Vector3;
  108732. /**
  108733. * The l2,-1 coefficients of the spherical harmonics
  108734. */
  108735. l2_1: Vector3;
  108736. /**
  108737. * The l2,0 coefficients of the spherical harmonics
  108738. */
  108739. l20: Vector3;
  108740. /**
  108741. * The l2,1 coefficients of the spherical harmonics
  108742. */
  108743. l21: Vector3;
  108744. /**
  108745. * The l2,2 coefficients of the spherical harmonics
  108746. */
  108747. l22: Vector3;
  108748. /**
  108749. * Adds a light to the spherical harmonics
  108750. * @param direction the direction of the light
  108751. * @param color the color of the light
  108752. * @param deltaSolidAngle the delta solid angle of the light
  108753. */
  108754. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  108755. /**
  108756. * Scales the spherical harmonics by the given amount
  108757. * @param scale the amount to scale
  108758. */
  108759. scaleInPlace(scale: number): void;
  108760. /**
  108761. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  108762. *
  108763. * ```
  108764. * E_lm = A_l * L_lm
  108765. * ```
  108766. *
  108767. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  108768. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  108769. * the scaling factors are given in equation 9.
  108770. */
  108771. convertIncidentRadianceToIrradiance(): void;
  108772. /**
  108773. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  108774. *
  108775. * ```
  108776. * L = (1/pi) * E * rho
  108777. * ```
  108778. *
  108779. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  108780. */
  108781. convertIrradianceToLambertianRadiance(): void;
  108782. /**
  108783. * Integrates the reconstruction coefficients directly in to the SH preventing further
  108784. * required operations at run time.
  108785. *
  108786. * This is simply done by scaling back the SH with Ylm constants parameter.
  108787. * The trigonometric part being applied by the shader at run time.
  108788. */
  108789. preScaleForRendering(): void;
  108790. /**
  108791. * Constructs a spherical harmonics from an array.
  108792. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  108793. * @returns the spherical harmonics
  108794. */
  108795. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  108796. /**
  108797. * Gets the spherical harmonics from polynomial
  108798. * @param polynomial the spherical polynomial
  108799. * @returns the spherical harmonics
  108800. */
  108801. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  108802. }
  108803. /**
  108804. * Class representing spherical polynomial coefficients to the 3rd degree
  108805. */
  108806. export class SphericalPolynomial {
  108807. private _harmonics;
  108808. /**
  108809. * The spherical harmonics used to create the polynomials.
  108810. */
  108811. get preScaledHarmonics(): SphericalHarmonics;
  108812. /**
  108813. * The x coefficients of the spherical polynomial
  108814. */
  108815. x: Vector3;
  108816. /**
  108817. * The y coefficients of the spherical polynomial
  108818. */
  108819. y: Vector3;
  108820. /**
  108821. * The z coefficients of the spherical polynomial
  108822. */
  108823. z: Vector3;
  108824. /**
  108825. * The xx coefficients of the spherical polynomial
  108826. */
  108827. xx: Vector3;
  108828. /**
  108829. * The yy coefficients of the spherical polynomial
  108830. */
  108831. yy: Vector3;
  108832. /**
  108833. * The zz coefficients of the spherical polynomial
  108834. */
  108835. zz: Vector3;
  108836. /**
  108837. * The xy coefficients of the spherical polynomial
  108838. */
  108839. xy: Vector3;
  108840. /**
  108841. * The yz coefficients of the spherical polynomial
  108842. */
  108843. yz: Vector3;
  108844. /**
  108845. * The zx coefficients of the spherical polynomial
  108846. */
  108847. zx: Vector3;
  108848. /**
  108849. * Adds an ambient color to the spherical polynomial
  108850. * @param color the color to add
  108851. */
  108852. addAmbient(color: Color3): void;
  108853. /**
  108854. * Scales the spherical polynomial by the given amount
  108855. * @param scale the amount to scale
  108856. */
  108857. scaleInPlace(scale: number): void;
  108858. /**
  108859. * Gets the spherical polynomial from harmonics
  108860. * @param harmonics the spherical harmonics
  108861. * @returns the spherical polynomial
  108862. */
  108863. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  108864. /**
  108865. * Constructs a spherical polynomial from an array.
  108866. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  108867. * @returns the spherical polynomial
  108868. */
  108869. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  108870. }
  108871. }
  108872. declare module BABYLON {
  108873. /**
  108874. * Defines the source of the internal texture
  108875. */
  108876. export enum InternalTextureSource {
  108877. /**
  108878. * The source of the texture data is unknown
  108879. */
  108880. Unknown = 0,
  108881. /**
  108882. * Texture data comes from an URL
  108883. */
  108884. Url = 1,
  108885. /**
  108886. * Texture data is only used for temporary storage
  108887. */
  108888. Temp = 2,
  108889. /**
  108890. * Texture data comes from raw data (ArrayBuffer)
  108891. */
  108892. Raw = 3,
  108893. /**
  108894. * Texture content is dynamic (video or dynamic texture)
  108895. */
  108896. Dynamic = 4,
  108897. /**
  108898. * Texture content is generated by rendering to it
  108899. */
  108900. RenderTarget = 5,
  108901. /**
  108902. * Texture content is part of a multi render target process
  108903. */
  108904. MultiRenderTarget = 6,
  108905. /**
  108906. * Texture data comes from a cube data file
  108907. */
  108908. Cube = 7,
  108909. /**
  108910. * Texture data comes from a raw cube data
  108911. */
  108912. CubeRaw = 8,
  108913. /**
  108914. * Texture data come from a prefiltered cube data file
  108915. */
  108916. CubePrefiltered = 9,
  108917. /**
  108918. * Texture content is raw 3D data
  108919. */
  108920. Raw3D = 10,
  108921. /**
  108922. * Texture content is raw 2D array data
  108923. */
  108924. Raw2DArray = 11,
  108925. /**
  108926. * Texture content is a depth texture
  108927. */
  108928. Depth = 12,
  108929. /**
  108930. * Texture data comes from a raw cube data encoded with RGBD
  108931. */
  108932. CubeRawRGBD = 13
  108933. }
  108934. /**
  108935. * Class used to store data associated with WebGL texture data for the engine
  108936. * This class should not be used directly
  108937. */
  108938. export class InternalTexture {
  108939. /** @hidden */
  108940. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  108941. /**
  108942. * Defines if the texture is ready
  108943. */
  108944. isReady: boolean;
  108945. /**
  108946. * Defines if the texture is a cube texture
  108947. */
  108948. isCube: boolean;
  108949. /**
  108950. * Defines if the texture contains 3D data
  108951. */
  108952. is3D: boolean;
  108953. /**
  108954. * Defines if the texture contains 2D array data
  108955. */
  108956. is2DArray: boolean;
  108957. /**
  108958. * Defines if the texture contains multiview data
  108959. */
  108960. isMultiview: boolean;
  108961. /**
  108962. * Gets the URL used to load this texture
  108963. */
  108964. url: string;
  108965. /**
  108966. * Gets the sampling mode of the texture
  108967. */
  108968. samplingMode: number;
  108969. /**
  108970. * Gets a boolean indicating if the texture needs mipmaps generation
  108971. */
  108972. generateMipMaps: boolean;
  108973. /**
  108974. * Gets the number of samples used by the texture (WebGL2+ only)
  108975. */
  108976. samples: number;
  108977. /**
  108978. * Gets the type of the texture (int, float...)
  108979. */
  108980. type: number;
  108981. /**
  108982. * Gets the format of the texture (RGB, RGBA...)
  108983. */
  108984. format: number;
  108985. /**
  108986. * Observable called when the texture is loaded
  108987. */
  108988. onLoadedObservable: Observable<InternalTexture>;
  108989. /**
  108990. * Gets the width of the texture
  108991. */
  108992. width: number;
  108993. /**
  108994. * Gets the height of the texture
  108995. */
  108996. height: number;
  108997. /**
  108998. * Gets the depth of the texture
  108999. */
  109000. depth: number;
  109001. /**
  109002. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  109003. */
  109004. baseWidth: number;
  109005. /**
  109006. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  109007. */
  109008. baseHeight: number;
  109009. /**
  109010. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  109011. */
  109012. baseDepth: number;
  109013. /**
  109014. * Gets a boolean indicating if the texture is inverted on Y axis
  109015. */
  109016. invertY: boolean;
  109017. /** @hidden */
  109018. _invertVScale: boolean;
  109019. /** @hidden */
  109020. _associatedChannel: number;
  109021. /** @hidden */
  109022. _source: InternalTextureSource;
  109023. /** @hidden */
  109024. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109025. /** @hidden */
  109026. _bufferView: Nullable<ArrayBufferView>;
  109027. /** @hidden */
  109028. _bufferViewArray: Nullable<ArrayBufferView[]>;
  109029. /** @hidden */
  109030. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  109031. /** @hidden */
  109032. _size: number;
  109033. /** @hidden */
  109034. _extension: string;
  109035. /** @hidden */
  109036. _files: Nullable<string[]>;
  109037. /** @hidden */
  109038. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  109039. /** @hidden */
  109040. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  109041. /** @hidden */
  109042. _framebuffer: Nullable<WebGLFramebuffer>;
  109043. /** @hidden */
  109044. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  109045. /** @hidden */
  109046. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  109047. /** @hidden */
  109048. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  109049. /** @hidden */
  109050. _attachments: Nullable<number[]>;
  109051. /** @hidden */
  109052. _cachedCoordinatesMode: Nullable<number>;
  109053. /** @hidden */
  109054. _cachedWrapU: Nullable<number>;
  109055. /** @hidden */
  109056. _cachedWrapV: Nullable<number>;
  109057. /** @hidden */
  109058. _cachedWrapR: Nullable<number>;
  109059. /** @hidden */
  109060. _cachedAnisotropicFilteringLevel: Nullable<number>;
  109061. /** @hidden */
  109062. _isDisabled: boolean;
  109063. /** @hidden */
  109064. _compression: Nullable<string>;
  109065. /** @hidden */
  109066. _generateStencilBuffer: boolean;
  109067. /** @hidden */
  109068. _generateDepthBuffer: boolean;
  109069. /** @hidden */
  109070. _comparisonFunction: number;
  109071. /** @hidden */
  109072. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  109073. /** @hidden */
  109074. _lodGenerationScale: number;
  109075. /** @hidden */
  109076. _lodGenerationOffset: number;
  109077. /** @hidden */
  109078. _depthStencilTexture: Nullable<InternalTexture>;
  109079. /** @hidden */
  109080. _colorTextureArray: Nullable<WebGLTexture>;
  109081. /** @hidden */
  109082. _depthStencilTextureArray: Nullable<WebGLTexture>;
  109083. /** @hidden */
  109084. _lodTextureHigh: Nullable<BaseTexture>;
  109085. /** @hidden */
  109086. _lodTextureMid: Nullable<BaseTexture>;
  109087. /** @hidden */
  109088. _lodTextureLow: Nullable<BaseTexture>;
  109089. /** @hidden */
  109090. _isRGBD: boolean;
  109091. /** @hidden */
  109092. _linearSpecularLOD: boolean;
  109093. /** @hidden */
  109094. _irradianceTexture: Nullable<BaseTexture>;
  109095. /** @hidden */
  109096. _webGLTexture: Nullable<WebGLTexture>;
  109097. /** @hidden */
  109098. _references: number;
  109099. private _engine;
  109100. /**
  109101. * Gets the Engine the texture belongs to.
  109102. * @returns The babylon engine
  109103. */
  109104. getEngine(): ThinEngine;
  109105. /**
  109106. * Gets the data source type of the texture
  109107. */
  109108. get source(): InternalTextureSource;
  109109. /**
  109110. * Creates a new InternalTexture
  109111. * @param engine defines the engine to use
  109112. * @param source defines the type of data that will be used
  109113. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109114. */
  109115. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  109116. /**
  109117. * Increments the number of references (ie. the number of Texture that point to it)
  109118. */
  109119. incrementReferences(): void;
  109120. /**
  109121. * Change the size of the texture (not the size of the content)
  109122. * @param width defines the new width
  109123. * @param height defines the new height
  109124. * @param depth defines the new depth (1 by default)
  109125. */
  109126. updateSize(width: int, height: int, depth?: int): void;
  109127. /** @hidden */
  109128. _rebuild(): void;
  109129. /** @hidden */
  109130. _swapAndDie(target: InternalTexture): void;
  109131. /**
  109132. * Dispose the current allocated resources
  109133. */
  109134. dispose(): void;
  109135. }
  109136. }
  109137. declare module BABYLON {
  109138. /**
  109139. * Class used to work with sound analyzer using fast fourier transform (FFT)
  109140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109141. */
  109142. export class Analyser {
  109143. /**
  109144. * Gets or sets the smoothing
  109145. * @ignorenaming
  109146. */
  109147. SMOOTHING: number;
  109148. /**
  109149. * Gets or sets the FFT table size
  109150. * @ignorenaming
  109151. */
  109152. FFT_SIZE: number;
  109153. /**
  109154. * Gets or sets the bar graph amplitude
  109155. * @ignorenaming
  109156. */
  109157. BARGRAPHAMPLITUDE: number;
  109158. /**
  109159. * Gets or sets the position of the debug canvas
  109160. * @ignorenaming
  109161. */
  109162. DEBUGCANVASPOS: {
  109163. x: number;
  109164. y: number;
  109165. };
  109166. /**
  109167. * Gets or sets the debug canvas size
  109168. * @ignorenaming
  109169. */
  109170. DEBUGCANVASSIZE: {
  109171. width: number;
  109172. height: number;
  109173. };
  109174. private _byteFreqs;
  109175. private _byteTime;
  109176. private _floatFreqs;
  109177. private _webAudioAnalyser;
  109178. private _debugCanvas;
  109179. private _debugCanvasContext;
  109180. private _scene;
  109181. private _registerFunc;
  109182. private _audioEngine;
  109183. /**
  109184. * Creates a new analyser
  109185. * @param scene defines hosting scene
  109186. */
  109187. constructor(scene: Scene);
  109188. /**
  109189. * Get the number of data values you will have to play with for the visualization
  109190. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  109191. * @returns a number
  109192. */
  109193. getFrequencyBinCount(): number;
  109194. /**
  109195. * Gets the current frequency data as a byte array
  109196. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109197. * @returns a Uint8Array
  109198. */
  109199. getByteFrequencyData(): Uint8Array;
  109200. /**
  109201. * Gets the current waveform as a byte array
  109202. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  109203. * @returns a Uint8Array
  109204. */
  109205. getByteTimeDomainData(): Uint8Array;
  109206. /**
  109207. * Gets the current frequency data as a float array
  109208. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109209. * @returns a Float32Array
  109210. */
  109211. getFloatFrequencyData(): Float32Array;
  109212. /**
  109213. * Renders the debug canvas
  109214. */
  109215. drawDebugCanvas(): void;
  109216. /**
  109217. * Stops rendering the debug canvas and removes it
  109218. */
  109219. stopDebugCanvas(): void;
  109220. /**
  109221. * Connects two audio nodes
  109222. * @param inputAudioNode defines first node to connect
  109223. * @param outputAudioNode defines second node to connect
  109224. */
  109225. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  109226. /**
  109227. * Releases all associated resources
  109228. */
  109229. dispose(): void;
  109230. }
  109231. }
  109232. declare module BABYLON {
  109233. /**
  109234. * This represents an audio engine and it is responsible
  109235. * to play, synchronize and analyse sounds throughout the application.
  109236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109237. */
  109238. export interface IAudioEngine extends IDisposable {
  109239. /**
  109240. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109241. */
  109242. readonly canUseWebAudio: boolean;
  109243. /**
  109244. * Gets the current AudioContext if available.
  109245. */
  109246. readonly audioContext: Nullable<AudioContext>;
  109247. /**
  109248. * The master gain node defines the global audio volume of your audio engine.
  109249. */
  109250. readonly masterGain: GainNode;
  109251. /**
  109252. * Gets whether or not mp3 are supported by your browser.
  109253. */
  109254. readonly isMP3supported: boolean;
  109255. /**
  109256. * Gets whether or not ogg are supported by your browser.
  109257. */
  109258. readonly isOGGsupported: boolean;
  109259. /**
  109260. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109261. * @ignoreNaming
  109262. */
  109263. WarnedWebAudioUnsupported: boolean;
  109264. /**
  109265. * Defines if the audio engine relies on a custom unlocked button.
  109266. * In this case, the embedded button will not be displayed.
  109267. */
  109268. useCustomUnlockedButton: boolean;
  109269. /**
  109270. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  109271. */
  109272. readonly unlocked: boolean;
  109273. /**
  109274. * Event raised when audio has been unlocked on the browser.
  109275. */
  109276. onAudioUnlockedObservable: Observable<AudioEngine>;
  109277. /**
  109278. * Event raised when audio has been locked on the browser.
  109279. */
  109280. onAudioLockedObservable: Observable<AudioEngine>;
  109281. /**
  109282. * Flags the audio engine in Locked state.
  109283. * This happens due to new browser policies preventing audio to autoplay.
  109284. */
  109285. lock(): void;
  109286. /**
  109287. * Unlocks the audio engine once a user action has been done on the dom.
  109288. * This is helpful to resume play once browser policies have been satisfied.
  109289. */
  109290. unlock(): void;
  109291. /**
  109292. * Gets the global volume sets on the master gain.
  109293. * @returns the global volume if set or -1 otherwise
  109294. */
  109295. getGlobalVolume(): number;
  109296. /**
  109297. * Sets the global volume of your experience (sets on the master gain).
  109298. * @param newVolume Defines the new global volume of the application
  109299. */
  109300. setGlobalVolume(newVolume: number): void;
  109301. /**
  109302. * Connect the audio engine to an audio analyser allowing some amazing
  109303. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109305. * @param analyser The analyser to connect to the engine
  109306. */
  109307. connectToAnalyser(analyser: Analyser): void;
  109308. }
  109309. /**
  109310. * This represents the default audio engine used in babylon.
  109311. * It is responsible to play, synchronize and analyse sounds throughout the application.
  109312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109313. */
  109314. export class AudioEngine implements IAudioEngine {
  109315. private _audioContext;
  109316. private _audioContextInitialized;
  109317. private _muteButton;
  109318. private _hostElement;
  109319. /**
  109320. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109321. */
  109322. canUseWebAudio: boolean;
  109323. /**
  109324. * The master gain node defines the global audio volume of your audio engine.
  109325. */
  109326. masterGain: GainNode;
  109327. /**
  109328. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109329. * @ignoreNaming
  109330. */
  109331. WarnedWebAudioUnsupported: boolean;
  109332. /**
  109333. * Gets whether or not mp3 are supported by your browser.
  109334. */
  109335. isMP3supported: boolean;
  109336. /**
  109337. * Gets whether or not ogg are supported by your browser.
  109338. */
  109339. isOGGsupported: boolean;
  109340. /**
  109341. * Gets whether audio has been unlocked on the device.
  109342. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  109343. * a user interaction has happened.
  109344. */
  109345. unlocked: boolean;
  109346. /**
  109347. * Defines if the audio engine relies on a custom unlocked button.
  109348. * In this case, the embedded button will not be displayed.
  109349. */
  109350. useCustomUnlockedButton: boolean;
  109351. /**
  109352. * Event raised when audio has been unlocked on the browser.
  109353. */
  109354. onAudioUnlockedObservable: Observable<AudioEngine>;
  109355. /**
  109356. * Event raised when audio has been locked on the browser.
  109357. */
  109358. onAudioLockedObservable: Observable<AudioEngine>;
  109359. /**
  109360. * Gets the current AudioContext if available.
  109361. */
  109362. get audioContext(): Nullable<AudioContext>;
  109363. private _connectedAnalyser;
  109364. /**
  109365. * Instantiates a new audio engine.
  109366. *
  109367. * There should be only one per page as some browsers restrict the number
  109368. * of audio contexts you can create.
  109369. * @param hostElement defines the host element where to display the mute icon if necessary
  109370. */
  109371. constructor(hostElement?: Nullable<HTMLElement>);
  109372. /**
  109373. * Flags the audio engine in Locked state.
  109374. * This happens due to new browser policies preventing audio to autoplay.
  109375. */
  109376. lock(): void;
  109377. /**
  109378. * Unlocks the audio engine once a user action has been done on the dom.
  109379. * This is helpful to resume play once browser policies have been satisfied.
  109380. */
  109381. unlock(): void;
  109382. private _resumeAudioContext;
  109383. private _initializeAudioContext;
  109384. private _tryToRun;
  109385. private _triggerRunningState;
  109386. private _triggerSuspendedState;
  109387. private _displayMuteButton;
  109388. private _moveButtonToTopLeft;
  109389. private _onResize;
  109390. private _hideMuteButton;
  109391. /**
  109392. * Destroy and release the resources associated with the audio ccontext.
  109393. */
  109394. dispose(): void;
  109395. /**
  109396. * Gets the global volume sets on the master gain.
  109397. * @returns the global volume if set or -1 otherwise
  109398. */
  109399. getGlobalVolume(): number;
  109400. /**
  109401. * Sets the global volume of your experience (sets on the master gain).
  109402. * @param newVolume Defines the new global volume of the application
  109403. */
  109404. setGlobalVolume(newVolume: number): void;
  109405. /**
  109406. * Connect the audio engine to an audio analyser allowing some amazing
  109407. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109409. * @param analyser The analyser to connect to the engine
  109410. */
  109411. connectToAnalyser(analyser: Analyser): void;
  109412. }
  109413. }
  109414. declare module BABYLON {
  109415. /**
  109416. * Interface used to present a loading screen while loading a scene
  109417. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109418. */
  109419. export interface ILoadingScreen {
  109420. /**
  109421. * Function called to display the loading screen
  109422. */
  109423. displayLoadingUI: () => void;
  109424. /**
  109425. * Function called to hide the loading screen
  109426. */
  109427. hideLoadingUI: () => void;
  109428. /**
  109429. * Gets or sets the color to use for the background
  109430. */
  109431. loadingUIBackgroundColor: string;
  109432. /**
  109433. * Gets or sets the text to display while loading
  109434. */
  109435. loadingUIText: string;
  109436. }
  109437. /**
  109438. * Class used for the default loading screen
  109439. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109440. */
  109441. export class DefaultLoadingScreen implements ILoadingScreen {
  109442. private _renderingCanvas;
  109443. private _loadingText;
  109444. private _loadingDivBackgroundColor;
  109445. private _loadingDiv;
  109446. private _loadingTextDiv;
  109447. /** Gets or sets the logo url to use for the default loading screen */
  109448. static DefaultLogoUrl: string;
  109449. /** Gets or sets the spinner url to use for the default loading screen */
  109450. static DefaultSpinnerUrl: string;
  109451. /**
  109452. * Creates a new default loading screen
  109453. * @param _renderingCanvas defines the canvas used to render the scene
  109454. * @param _loadingText defines the default text to display
  109455. * @param _loadingDivBackgroundColor defines the default background color
  109456. */
  109457. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  109458. /**
  109459. * Function called to display the loading screen
  109460. */
  109461. displayLoadingUI(): void;
  109462. /**
  109463. * Function called to hide the loading screen
  109464. */
  109465. hideLoadingUI(): void;
  109466. /**
  109467. * Gets or sets the text to display while loading
  109468. */
  109469. set loadingUIText(text: string);
  109470. get loadingUIText(): string;
  109471. /**
  109472. * Gets or sets the color to use for the background
  109473. */
  109474. get loadingUIBackgroundColor(): string;
  109475. set loadingUIBackgroundColor(color: string);
  109476. private _resizeLoadingUI;
  109477. }
  109478. }
  109479. declare module BABYLON {
  109480. /**
  109481. * Interface for any object that can request an animation frame
  109482. */
  109483. export interface ICustomAnimationFrameRequester {
  109484. /**
  109485. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  109486. */
  109487. renderFunction?: Function;
  109488. /**
  109489. * Called to request the next frame to render to
  109490. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  109491. */
  109492. requestAnimationFrame: Function;
  109493. /**
  109494. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  109495. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  109496. */
  109497. requestID?: number;
  109498. }
  109499. }
  109500. declare module BABYLON {
  109501. /**
  109502. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  109503. */
  109504. export class PerformanceMonitor {
  109505. private _enabled;
  109506. private _rollingFrameTime;
  109507. private _lastFrameTimeMs;
  109508. /**
  109509. * constructor
  109510. * @param frameSampleSize The number of samples required to saturate the sliding window
  109511. */
  109512. constructor(frameSampleSize?: number);
  109513. /**
  109514. * Samples current frame
  109515. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  109516. */
  109517. sampleFrame(timeMs?: number): void;
  109518. /**
  109519. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109520. */
  109521. get averageFrameTime(): number;
  109522. /**
  109523. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109524. */
  109525. get averageFrameTimeVariance(): number;
  109526. /**
  109527. * Returns the frame time of the most recent frame
  109528. */
  109529. get instantaneousFrameTime(): number;
  109530. /**
  109531. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  109532. */
  109533. get averageFPS(): number;
  109534. /**
  109535. * Returns the average framerate in frames per second using the most recent frame time
  109536. */
  109537. get instantaneousFPS(): number;
  109538. /**
  109539. * Returns true if enough samples have been taken to completely fill the sliding window
  109540. */
  109541. get isSaturated(): boolean;
  109542. /**
  109543. * Enables contributions to the sliding window sample set
  109544. */
  109545. enable(): void;
  109546. /**
  109547. * Disables contributions to the sliding window sample set
  109548. * Samples will not be interpolated over the disabled period
  109549. */
  109550. disable(): void;
  109551. /**
  109552. * Returns true if sampling is enabled
  109553. */
  109554. get isEnabled(): boolean;
  109555. /**
  109556. * Resets performance monitor
  109557. */
  109558. reset(): void;
  109559. }
  109560. /**
  109561. * RollingAverage
  109562. *
  109563. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  109564. */
  109565. export class RollingAverage {
  109566. /**
  109567. * Current average
  109568. */
  109569. average: number;
  109570. /**
  109571. * Current variance
  109572. */
  109573. variance: number;
  109574. protected _samples: Array<number>;
  109575. protected _sampleCount: number;
  109576. protected _pos: number;
  109577. protected _m2: number;
  109578. /**
  109579. * constructor
  109580. * @param length The number of samples required to saturate the sliding window
  109581. */
  109582. constructor(length: number);
  109583. /**
  109584. * Adds a sample to the sample set
  109585. * @param v The sample value
  109586. */
  109587. add(v: number): void;
  109588. /**
  109589. * Returns previously added values or null if outside of history or outside the sliding window domain
  109590. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  109591. * @return Value previously recorded with add() or null if outside of range
  109592. */
  109593. history(i: number): number;
  109594. /**
  109595. * Returns true if enough samples have been taken to completely fill the sliding window
  109596. * @return true if sample-set saturated
  109597. */
  109598. isSaturated(): boolean;
  109599. /**
  109600. * Resets the rolling average (equivalent to 0 samples taken so far)
  109601. */
  109602. reset(): void;
  109603. /**
  109604. * Wraps a value around the sample range boundaries
  109605. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  109606. * @return Wrapped position in sample range
  109607. */
  109608. protected _wrapPosition(i: number): number;
  109609. }
  109610. }
  109611. declare module BABYLON {
  109612. /**
  109613. * This class is used to track a performance counter which is number based.
  109614. * The user has access to many properties which give statistics of different nature.
  109615. *
  109616. * The implementer can track two kinds of Performance Counter: time and count.
  109617. * 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.
  109618. * 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.
  109619. */
  109620. export class PerfCounter {
  109621. /**
  109622. * Gets or sets a global boolean to turn on and off all the counters
  109623. */
  109624. static Enabled: boolean;
  109625. /**
  109626. * Returns the smallest value ever
  109627. */
  109628. get min(): number;
  109629. /**
  109630. * Returns the biggest value ever
  109631. */
  109632. get max(): number;
  109633. /**
  109634. * Returns the average value since the performance counter is running
  109635. */
  109636. get average(): number;
  109637. /**
  109638. * Returns the average value of the last second the counter was monitored
  109639. */
  109640. get lastSecAverage(): number;
  109641. /**
  109642. * Returns the current value
  109643. */
  109644. get current(): number;
  109645. /**
  109646. * Gets the accumulated total
  109647. */
  109648. get total(): number;
  109649. /**
  109650. * Gets the total value count
  109651. */
  109652. get count(): number;
  109653. /**
  109654. * Creates a new counter
  109655. */
  109656. constructor();
  109657. /**
  109658. * Call this method to start monitoring a new frame.
  109659. * 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.
  109660. */
  109661. fetchNewFrame(): void;
  109662. /**
  109663. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  109664. * @param newCount the count value to add to the monitored count
  109665. * @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.
  109666. */
  109667. addCount(newCount: number, fetchResult: boolean): void;
  109668. /**
  109669. * Start monitoring this performance counter
  109670. */
  109671. beginMonitoring(): void;
  109672. /**
  109673. * Compute the time lapsed since the previous beginMonitoring() call.
  109674. * @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
  109675. */
  109676. endMonitoring(newFrame?: boolean): void;
  109677. private _fetchResult;
  109678. private _startMonitoringTime;
  109679. private _min;
  109680. private _max;
  109681. private _average;
  109682. private _current;
  109683. private _totalValueCount;
  109684. private _totalAccumulated;
  109685. private _lastSecAverage;
  109686. private _lastSecAccumulated;
  109687. private _lastSecTime;
  109688. private _lastSecValueCount;
  109689. }
  109690. }
  109691. declare module BABYLON {
  109692. interface ThinEngine {
  109693. /**
  109694. * Sets alpha constants used by some alpha blending modes
  109695. * @param r defines the red component
  109696. * @param g defines the green component
  109697. * @param b defines the blue component
  109698. * @param a defines the alpha component
  109699. */
  109700. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109701. /**
  109702. * Sets the current alpha mode
  109703. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  109704. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109706. */
  109707. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109708. /**
  109709. * Gets the current alpha mode
  109710. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109711. * @returns the current alpha mode
  109712. */
  109713. getAlphaMode(): number;
  109714. /**
  109715. * Sets the current alpha equation
  109716. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  109717. */
  109718. setAlphaEquation(equation: number): void;
  109719. /**
  109720. * Gets the current alpha equation.
  109721. * @returns the current alpha equation
  109722. */
  109723. getAlphaEquation(): number;
  109724. }
  109725. }
  109726. declare module BABYLON {
  109727. interface ThinEngine {
  109728. /** @hidden */
  109729. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  109730. }
  109731. }
  109732. declare module BABYLON {
  109733. /**
  109734. * Defines the interface used by display changed events
  109735. */
  109736. export interface IDisplayChangedEventArgs {
  109737. /** Gets the vrDisplay object (if any) */
  109738. vrDisplay: Nullable<any>;
  109739. /** Gets a boolean indicating if webVR is supported */
  109740. vrSupported: boolean;
  109741. }
  109742. /**
  109743. * Defines the interface used by objects containing a viewport (like a camera)
  109744. */
  109745. interface IViewportOwnerLike {
  109746. /**
  109747. * Gets or sets the viewport
  109748. */
  109749. viewport: IViewportLike;
  109750. }
  109751. /**
  109752. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  109753. */
  109754. export class Engine extends ThinEngine {
  109755. /** Defines that alpha blending is disabled */
  109756. static readonly ALPHA_DISABLE: number;
  109757. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  109758. static readonly ALPHA_ADD: number;
  109759. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  109760. static readonly ALPHA_COMBINE: number;
  109761. /** Defines that alpha blending to DEST - SRC * DEST */
  109762. static readonly ALPHA_SUBTRACT: number;
  109763. /** Defines that alpha blending to SRC * DEST */
  109764. static readonly ALPHA_MULTIPLY: number;
  109765. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  109766. static readonly ALPHA_MAXIMIZED: number;
  109767. /** Defines that alpha blending to SRC + DEST */
  109768. static readonly ALPHA_ONEONE: number;
  109769. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  109770. static readonly ALPHA_PREMULTIPLIED: number;
  109771. /**
  109772. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  109773. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  109774. */
  109775. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  109776. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  109777. static readonly ALPHA_INTERPOLATE: number;
  109778. /**
  109779. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  109780. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  109781. */
  109782. static readonly ALPHA_SCREENMODE: number;
  109783. /** Defines that the ressource is not delayed*/
  109784. static readonly DELAYLOADSTATE_NONE: number;
  109785. /** Defines that the ressource was successfully delay loaded */
  109786. static readonly DELAYLOADSTATE_LOADED: number;
  109787. /** Defines that the ressource is currently delay loading */
  109788. static readonly DELAYLOADSTATE_LOADING: number;
  109789. /** Defines that the ressource is delayed and has not started loading */
  109790. static readonly DELAYLOADSTATE_NOTLOADED: number;
  109791. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  109792. static readonly NEVER: number;
  109793. /** 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 */
  109794. static readonly ALWAYS: number;
  109795. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  109796. static readonly LESS: number;
  109797. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  109798. static readonly EQUAL: number;
  109799. /** 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 */
  109800. static readonly LEQUAL: number;
  109801. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  109802. static readonly GREATER: number;
  109803. /** 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 */
  109804. static readonly GEQUAL: number;
  109805. /** 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 */
  109806. static readonly NOTEQUAL: number;
  109807. /** Passed to stencilOperation to specify that stencil value must be kept */
  109808. static readonly KEEP: number;
  109809. /** Passed to stencilOperation to specify that stencil value must be replaced */
  109810. static readonly REPLACE: number;
  109811. /** Passed to stencilOperation to specify that stencil value must be incremented */
  109812. static readonly INCR: number;
  109813. /** Passed to stencilOperation to specify that stencil value must be decremented */
  109814. static readonly DECR: number;
  109815. /** Passed to stencilOperation to specify that stencil value must be inverted */
  109816. static readonly INVERT: number;
  109817. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  109818. static readonly INCR_WRAP: number;
  109819. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  109820. static readonly DECR_WRAP: number;
  109821. /** Texture is not repeating outside of 0..1 UVs */
  109822. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  109823. /** Texture is repeating outside of 0..1 UVs */
  109824. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  109825. /** Texture is repeating and mirrored */
  109826. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  109827. /** ALPHA */
  109828. static readonly TEXTUREFORMAT_ALPHA: number;
  109829. /** LUMINANCE */
  109830. static readonly TEXTUREFORMAT_LUMINANCE: number;
  109831. /** LUMINANCE_ALPHA */
  109832. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  109833. /** RGB */
  109834. static readonly TEXTUREFORMAT_RGB: number;
  109835. /** RGBA */
  109836. static readonly TEXTUREFORMAT_RGBA: number;
  109837. /** RED */
  109838. static readonly TEXTUREFORMAT_RED: number;
  109839. /** RED (2nd reference) */
  109840. static readonly TEXTUREFORMAT_R: number;
  109841. /** RG */
  109842. static readonly TEXTUREFORMAT_RG: number;
  109843. /** RED_INTEGER */
  109844. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  109845. /** RED_INTEGER (2nd reference) */
  109846. static readonly TEXTUREFORMAT_R_INTEGER: number;
  109847. /** RG_INTEGER */
  109848. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  109849. /** RGB_INTEGER */
  109850. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  109851. /** RGBA_INTEGER */
  109852. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  109853. /** UNSIGNED_BYTE */
  109854. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  109855. /** UNSIGNED_BYTE (2nd reference) */
  109856. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  109857. /** FLOAT */
  109858. static readonly TEXTURETYPE_FLOAT: number;
  109859. /** HALF_FLOAT */
  109860. static readonly TEXTURETYPE_HALF_FLOAT: number;
  109861. /** BYTE */
  109862. static readonly TEXTURETYPE_BYTE: number;
  109863. /** SHORT */
  109864. static readonly TEXTURETYPE_SHORT: number;
  109865. /** UNSIGNED_SHORT */
  109866. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  109867. /** INT */
  109868. static readonly TEXTURETYPE_INT: number;
  109869. /** UNSIGNED_INT */
  109870. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  109871. /** UNSIGNED_SHORT_4_4_4_4 */
  109872. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  109873. /** UNSIGNED_SHORT_5_5_5_1 */
  109874. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  109875. /** UNSIGNED_SHORT_5_6_5 */
  109876. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  109877. /** UNSIGNED_INT_2_10_10_10_REV */
  109878. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  109879. /** UNSIGNED_INT_24_8 */
  109880. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  109881. /** UNSIGNED_INT_10F_11F_11F_REV */
  109882. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  109883. /** UNSIGNED_INT_5_9_9_9_REV */
  109884. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  109885. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  109886. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109887. /** nearest is mag = nearest and min = nearest and mip = linear */
  109888. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  109889. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109890. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  109891. /** Trilinear is mag = linear and min = linear and mip = linear */
  109892. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  109893. /** nearest is mag = nearest and min = nearest and mip = linear */
  109894. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  109895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109896. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  109897. /** Trilinear is mag = linear and min = linear and mip = linear */
  109898. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  109899. /** mag = nearest and min = nearest and mip = nearest */
  109900. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  109901. /** mag = nearest and min = linear and mip = nearest */
  109902. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  109903. /** mag = nearest and min = linear and mip = linear */
  109904. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  109905. /** mag = nearest and min = linear and mip = none */
  109906. static readonly TEXTURE_NEAREST_LINEAR: number;
  109907. /** mag = nearest and min = nearest and mip = none */
  109908. static readonly TEXTURE_NEAREST_NEAREST: number;
  109909. /** mag = linear and min = nearest and mip = nearest */
  109910. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  109911. /** mag = linear and min = nearest and mip = linear */
  109912. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  109913. /** mag = linear and min = linear and mip = none */
  109914. static readonly TEXTURE_LINEAR_LINEAR: number;
  109915. /** mag = linear and min = nearest and mip = none */
  109916. static readonly TEXTURE_LINEAR_NEAREST: number;
  109917. /** Explicit coordinates mode */
  109918. static readonly TEXTURE_EXPLICIT_MODE: number;
  109919. /** Spherical coordinates mode */
  109920. static readonly TEXTURE_SPHERICAL_MODE: number;
  109921. /** Planar coordinates mode */
  109922. static readonly TEXTURE_PLANAR_MODE: number;
  109923. /** Cubic coordinates mode */
  109924. static readonly TEXTURE_CUBIC_MODE: number;
  109925. /** Projection coordinates mode */
  109926. static readonly TEXTURE_PROJECTION_MODE: number;
  109927. /** Skybox coordinates mode */
  109928. static readonly TEXTURE_SKYBOX_MODE: number;
  109929. /** Inverse Cubic coordinates mode */
  109930. static readonly TEXTURE_INVCUBIC_MODE: number;
  109931. /** Equirectangular coordinates mode */
  109932. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  109933. /** Equirectangular Fixed coordinates mode */
  109934. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  109935. /** Equirectangular Fixed Mirrored coordinates mode */
  109936. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109937. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  109938. static readonly SCALEMODE_FLOOR: number;
  109939. /** Defines that texture rescaling will look for the nearest power of 2 size */
  109940. static readonly SCALEMODE_NEAREST: number;
  109941. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  109942. static readonly SCALEMODE_CEILING: number;
  109943. /**
  109944. * Returns the current npm package of the sdk
  109945. */
  109946. static get NpmPackage(): string;
  109947. /**
  109948. * Returns the current version of the framework
  109949. */
  109950. static get Version(): string;
  109951. /** Gets the list of created engines */
  109952. static get Instances(): Engine[];
  109953. /**
  109954. * Gets the latest created engine
  109955. */
  109956. static get LastCreatedEngine(): Nullable<Engine>;
  109957. /**
  109958. * Gets the latest created scene
  109959. */
  109960. static get LastCreatedScene(): Nullable<Scene>;
  109961. /**
  109962. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  109963. * @param flag defines which part of the materials must be marked as dirty
  109964. * @param predicate defines a predicate used to filter which materials should be affected
  109965. */
  109966. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109967. /**
  109968. * Method called to create the default loading screen.
  109969. * This can be overriden in your own app.
  109970. * @param canvas The rendering canvas element
  109971. * @returns The loading screen
  109972. */
  109973. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  109974. /**
  109975. * Method called to create the default rescale post process on each engine.
  109976. */
  109977. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  109978. /**
  109979. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  109980. **/
  109981. enableOfflineSupport: boolean;
  109982. /**
  109983. * 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)
  109984. **/
  109985. disableManifestCheck: boolean;
  109986. /**
  109987. * Gets the list of created scenes
  109988. */
  109989. scenes: Scene[];
  109990. /**
  109991. * Event raised when a new scene is created
  109992. */
  109993. onNewSceneAddedObservable: Observable<Scene>;
  109994. /**
  109995. * Gets the list of created postprocesses
  109996. */
  109997. postProcesses: PostProcess[];
  109998. /**
  109999. * Gets a boolean indicating if the pointer is currently locked
  110000. */
  110001. isPointerLock: boolean;
  110002. /**
  110003. * Observable event triggered each time the rendering canvas is resized
  110004. */
  110005. onResizeObservable: Observable<Engine>;
  110006. /**
  110007. * Observable event triggered each time the canvas loses focus
  110008. */
  110009. onCanvasBlurObservable: Observable<Engine>;
  110010. /**
  110011. * Observable event triggered each time the canvas gains focus
  110012. */
  110013. onCanvasFocusObservable: Observable<Engine>;
  110014. /**
  110015. * Observable event triggered each time the canvas receives pointerout event
  110016. */
  110017. onCanvasPointerOutObservable: Observable<PointerEvent>;
  110018. /**
  110019. * Observable raised when the engine begins a new frame
  110020. */
  110021. onBeginFrameObservable: Observable<Engine>;
  110022. /**
  110023. * If set, will be used to request the next animation frame for the render loop
  110024. */
  110025. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  110026. /**
  110027. * Observable raised when the engine ends the current frame
  110028. */
  110029. onEndFrameObservable: Observable<Engine>;
  110030. /**
  110031. * Observable raised when the engine is about to compile a shader
  110032. */
  110033. onBeforeShaderCompilationObservable: Observable<Engine>;
  110034. /**
  110035. * Observable raised when the engine has jsut compiled a shader
  110036. */
  110037. onAfterShaderCompilationObservable: Observable<Engine>;
  110038. /**
  110039. * Gets the audio engine
  110040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110041. * @ignorenaming
  110042. */
  110043. static audioEngine: IAudioEngine;
  110044. /**
  110045. * Default AudioEngine factory responsible of creating the Audio Engine.
  110046. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  110047. */
  110048. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  110049. /**
  110050. * Default offline support factory responsible of creating a tool used to store data locally.
  110051. * By default, this will create a Database object if the workload has been embedded.
  110052. */
  110053. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  110054. private _loadingScreen;
  110055. private _pointerLockRequested;
  110056. private _rescalePostProcess;
  110057. private _deterministicLockstep;
  110058. private _lockstepMaxSteps;
  110059. private _timeStep;
  110060. protected get _supportsHardwareTextureRescaling(): boolean;
  110061. private _fps;
  110062. private _deltaTime;
  110063. /** @hidden */
  110064. _drawCalls: PerfCounter;
  110065. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  110066. canvasTabIndex: number;
  110067. /**
  110068. * Turn this value on if you want to pause FPS computation when in background
  110069. */
  110070. disablePerformanceMonitorInBackground: boolean;
  110071. private _performanceMonitor;
  110072. /**
  110073. * Gets the performance monitor attached to this engine
  110074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110075. */
  110076. get performanceMonitor(): PerformanceMonitor;
  110077. private _onFocus;
  110078. private _onBlur;
  110079. private _onCanvasPointerOut;
  110080. private _onCanvasBlur;
  110081. private _onCanvasFocus;
  110082. private _onFullscreenChange;
  110083. private _onPointerLockChange;
  110084. /**
  110085. * Gets the HTML element used to attach event listeners
  110086. * @returns a HTML element
  110087. */
  110088. getInputElement(): Nullable<HTMLElement>;
  110089. /**
  110090. * Creates a new engine
  110091. * @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
  110092. * @param antialias defines enable antialiasing (default: false)
  110093. * @param options defines further options to be sent to the getContext() function
  110094. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  110095. */
  110096. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  110097. /**
  110098. * Gets current aspect ratio
  110099. * @param viewportOwner defines the camera to use to get the aspect ratio
  110100. * @param useScreen defines if screen size must be used (or the current render target if any)
  110101. * @returns a number defining the aspect ratio
  110102. */
  110103. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  110104. /**
  110105. * Gets current screen aspect ratio
  110106. * @returns a number defining the aspect ratio
  110107. */
  110108. getScreenAspectRatio(): number;
  110109. /**
  110110. * Gets the client rect of the HTML canvas attached with the current webGL context
  110111. * @returns a client rectanglee
  110112. */
  110113. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  110114. /**
  110115. * Gets the client rect of the HTML element used for events
  110116. * @returns a client rectanglee
  110117. */
  110118. getInputElementClientRect(): Nullable<ClientRect>;
  110119. /**
  110120. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110122. * @returns true if engine is in deterministic lock step mode
  110123. */
  110124. isDeterministicLockStep(): boolean;
  110125. /**
  110126. * Gets the max steps when engine is running in deterministic lock step
  110127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110128. * @returns the max steps
  110129. */
  110130. getLockstepMaxSteps(): number;
  110131. /**
  110132. * Returns the time in ms between steps when using deterministic lock step.
  110133. * @returns time step in (ms)
  110134. */
  110135. getTimeStep(): number;
  110136. /**
  110137. * Force the mipmap generation for the given render target texture
  110138. * @param texture defines the render target texture to use
  110139. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  110140. */
  110141. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  110142. /** States */
  110143. /**
  110144. * Set various states to the webGL context
  110145. * @param culling defines backface culling state
  110146. * @param zOffset defines the value to apply to zOffset (0 by default)
  110147. * @param force defines if states must be applied even if cache is up to date
  110148. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110149. */
  110150. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110151. /**
  110152. * Set the z offset to apply to current rendering
  110153. * @param value defines the offset to apply
  110154. */
  110155. setZOffset(value: number): void;
  110156. /**
  110157. * Gets the current value of the zOffset
  110158. * @returns the current zOffset state
  110159. */
  110160. getZOffset(): number;
  110161. /**
  110162. * Enable or disable depth buffering
  110163. * @param enable defines the state to set
  110164. */
  110165. setDepthBuffer(enable: boolean): void;
  110166. /**
  110167. * Gets a boolean indicating if depth writing is enabled
  110168. * @returns the current depth writing state
  110169. */
  110170. getDepthWrite(): boolean;
  110171. /**
  110172. * Enable or disable depth writing
  110173. * @param enable defines the state to set
  110174. */
  110175. setDepthWrite(enable: boolean): void;
  110176. /**
  110177. * Gets a boolean indicating if stencil buffer is enabled
  110178. * @returns the current stencil buffer state
  110179. */
  110180. getStencilBuffer(): boolean;
  110181. /**
  110182. * Enable or disable the stencil buffer
  110183. * @param enable defines if the stencil buffer must be enabled or disabled
  110184. */
  110185. setStencilBuffer(enable: boolean): void;
  110186. /**
  110187. * Gets the current stencil mask
  110188. * @returns a number defining the new stencil mask to use
  110189. */
  110190. getStencilMask(): number;
  110191. /**
  110192. * Sets the current stencil mask
  110193. * @param mask defines the new stencil mask to use
  110194. */
  110195. setStencilMask(mask: number): void;
  110196. /**
  110197. * Gets the current stencil function
  110198. * @returns a number defining the stencil function to use
  110199. */
  110200. getStencilFunction(): number;
  110201. /**
  110202. * Gets the current stencil reference value
  110203. * @returns a number defining the stencil reference value to use
  110204. */
  110205. getStencilFunctionReference(): number;
  110206. /**
  110207. * Gets the current stencil mask
  110208. * @returns a number defining the stencil mask to use
  110209. */
  110210. getStencilFunctionMask(): number;
  110211. /**
  110212. * Sets the current stencil function
  110213. * @param stencilFunc defines the new stencil function to use
  110214. */
  110215. setStencilFunction(stencilFunc: number): void;
  110216. /**
  110217. * Sets the current stencil reference
  110218. * @param reference defines the new stencil reference to use
  110219. */
  110220. setStencilFunctionReference(reference: number): void;
  110221. /**
  110222. * Sets the current stencil mask
  110223. * @param mask defines the new stencil mask to use
  110224. */
  110225. setStencilFunctionMask(mask: number): void;
  110226. /**
  110227. * Gets the current stencil operation when stencil fails
  110228. * @returns a number defining stencil operation to use when stencil fails
  110229. */
  110230. getStencilOperationFail(): number;
  110231. /**
  110232. * Gets the current stencil operation when depth fails
  110233. * @returns a number defining stencil operation to use when depth fails
  110234. */
  110235. getStencilOperationDepthFail(): number;
  110236. /**
  110237. * Gets the current stencil operation when stencil passes
  110238. * @returns a number defining stencil operation to use when stencil passes
  110239. */
  110240. getStencilOperationPass(): number;
  110241. /**
  110242. * Sets the stencil operation to use when stencil fails
  110243. * @param operation defines the stencil operation to use when stencil fails
  110244. */
  110245. setStencilOperationFail(operation: number): void;
  110246. /**
  110247. * Sets the stencil operation to use when depth fails
  110248. * @param operation defines the stencil operation to use when depth fails
  110249. */
  110250. setStencilOperationDepthFail(operation: number): void;
  110251. /**
  110252. * Sets the stencil operation to use when stencil passes
  110253. * @param operation defines the stencil operation to use when stencil passes
  110254. */
  110255. setStencilOperationPass(operation: number): void;
  110256. /**
  110257. * Sets a boolean indicating if the dithering state is enabled or disabled
  110258. * @param value defines the dithering state
  110259. */
  110260. setDitheringState(value: boolean): void;
  110261. /**
  110262. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  110263. * @param value defines the rasterizer state
  110264. */
  110265. setRasterizerState(value: boolean): void;
  110266. /**
  110267. * Gets the current depth function
  110268. * @returns a number defining the depth function
  110269. */
  110270. getDepthFunction(): Nullable<number>;
  110271. /**
  110272. * Sets the current depth function
  110273. * @param depthFunc defines the function to use
  110274. */
  110275. setDepthFunction(depthFunc: number): void;
  110276. /**
  110277. * Sets the current depth function to GREATER
  110278. */
  110279. setDepthFunctionToGreater(): void;
  110280. /**
  110281. * Sets the current depth function to GEQUAL
  110282. */
  110283. setDepthFunctionToGreaterOrEqual(): void;
  110284. /**
  110285. * Sets the current depth function to LESS
  110286. */
  110287. setDepthFunctionToLess(): void;
  110288. /**
  110289. * Sets the current depth function to LEQUAL
  110290. */
  110291. setDepthFunctionToLessOrEqual(): void;
  110292. private _cachedStencilBuffer;
  110293. private _cachedStencilFunction;
  110294. private _cachedStencilMask;
  110295. private _cachedStencilOperationPass;
  110296. private _cachedStencilOperationFail;
  110297. private _cachedStencilOperationDepthFail;
  110298. private _cachedStencilReference;
  110299. /**
  110300. * Caches the the state of the stencil buffer
  110301. */
  110302. cacheStencilState(): void;
  110303. /**
  110304. * Restores the state of the stencil buffer
  110305. */
  110306. restoreStencilState(): void;
  110307. /**
  110308. * Directly set the WebGL Viewport
  110309. * @param x defines the x coordinate of the viewport (in screen space)
  110310. * @param y defines the y coordinate of the viewport (in screen space)
  110311. * @param width defines the width of the viewport (in screen space)
  110312. * @param height defines the height of the viewport (in screen space)
  110313. * @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
  110314. */
  110315. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  110316. /**
  110317. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  110318. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110319. * @param y defines the y-coordinate of the corner of the clear rectangle
  110320. * @param width defines the width of the clear rectangle
  110321. * @param height defines the height of the clear rectangle
  110322. * @param clearColor defines the clear color
  110323. */
  110324. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  110325. /**
  110326. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  110327. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110328. * @param y defines the y-coordinate of the corner of the clear rectangle
  110329. * @param width defines the width of the clear rectangle
  110330. * @param height defines the height of the clear rectangle
  110331. */
  110332. enableScissor(x: number, y: number, width: number, height: number): void;
  110333. /**
  110334. * Disable previously set scissor test rectangle
  110335. */
  110336. disableScissor(): void;
  110337. protected _reportDrawCall(): void;
  110338. /**
  110339. * Initializes a webVR display and starts listening to display change events
  110340. * The onVRDisplayChangedObservable will be notified upon these changes
  110341. * @returns The onVRDisplayChangedObservable
  110342. */
  110343. initWebVR(): Observable<IDisplayChangedEventArgs>;
  110344. /** @hidden */
  110345. _prepareVRComponent(): void;
  110346. /** @hidden */
  110347. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  110348. /** @hidden */
  110349. _submitVRFrame(): void;
  110350. /**
  110351. * Call this function to leave webVR mode
  110352. * Will do nothing if webVR is not supported or if there is no webVR device
  110353. * @see http://doc.babylonjs.com/how_to/webvr_camera
  110354. */
  110355. disableVR(): void;
  110356. /**
  110357. * Gets a boolean indicating that the system is in VR mode and is presenting
  110358. * @returns true if VR mode is engaged
  110359. */
  110360. isVRPresenting(): boolean;
  110361. /** @hidden */
  110362. _requestVRFrame(): void;
  110363. /** @hidden */
  110364. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110365. /**
  110366. * Gets the source code of the vertex shader associated with a specific webGL program
  110367. * @param program defines the program to use
  110368. * @returns a string containing the source code of the vertex shader associated with the program
  110369. */
  110370. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  110371. /**
  110372. * Gets the source code of the fragment shader associated with a specific webGL program
  110373. * @param program defines the program to use
  110374. * @returns a string containing the source code of the fragment shader associated with the program
  110375. */
  110376. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  110377. /**
  110378. * Sets a depth stencil texture from a render target to the according uniform.
  110379. * @param channel The texture channel
  110380. * @param uniform The uniform to set
  110381. * @param texture The render target texture containing the depth stencil texture to apply
  110382. */
  110383. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  110384. /**
  110385. * Sets a texture to the webGL context from a postprocess
  110386. * @param channel defines the channel to use
  110387. * @param postProcess defines the source postprocess
  110388. */
  110389. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  110390. /**
  110391. * Binds the output of the passed in post process to the texture channel specified
  110392. * @param channel The channel the texture should be bound to
  110393. * @param postProcess The post process which's output should be bound
  110394. */
  110395. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  110396. protected _rebuildBuffers(): void;
  110397. /** @hidden */
  110398. _renderFrame(): void;
  110399. _renderLoop(): void;
  110400. /** @hidden */
  110401. _renderViews(): boolean;
  110402. /**
  110403. * Toggle full screen mode
  110404. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110405. */
  110406. switchFullscreen(requestPointerLock: boolean): void;
  110407. /**
  110408. * Enters full screen mode
  110409. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110410. */
  110411. enterFullscreen(requestPointerLock: boolean): void;
  110412. /**
  110413. * Exits full screen mode
  110414. */
  110415. exitFullscreen(): void;
  110416. /**
  110417. * Enters Pointerlock mode
  110418. */
  110419. enterPointerlock(): void;
  110420. /**
  110421. * Exits Pointerlock mode
  110422. */
  110423. exitPointerlock(): void;
  110424. /**
  110425. * Begin a new frame
  110426. */
  110427. beginFrame(): void;
  110428. /**
  110429. * Enf the current frame
  110430. */
  110431. endFrame(): void;
  110432. resize(): void;
  110433. /**
  110434. * Force a specific size of the canvas
  110435. * @param width defines the new canvas' width
  110436. * @param height defines the new canvas' height
  110437. */
  110438. setSize(width: number, height: number): void;
  110439. /**
  110440. * Updates a dynamic vertex buffer.
  110441. * @param vertexBuffer the vertex buffer to update
  110442. * @param data the data used to update the vertex buffer
  110443. * @param byteOffset the byte offset of the data
  110444. * @param byteLength the byte length of the data
  110445. */
  110446. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110447. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110448. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110449. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110450. _releaseTexture(texture: InternalTexture): void;
  110451. /**
  110452. * @hidden
  110453. * Rescales a texture
  110454. * @param source input texutre
  110455. * @param destination destination texture
  110456. * @param scene scene to use to render the resize
  110457. * @param internalFormat format to use when resizing
  110458. * @param onComplete callback to be called when resize has completed
  110459. */
  110460. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  110461. /**
  110462. * Gets the current framerate
  110463. * @returns a number representing the framerate
  110464. */
  110465. getFps(): number;
  110466. /**
  110467. * Gets the time spent between current and previous frame
  110468. * @returns a number representing the delta time in ms
  110469. */
  110470. getDeltaTime(): number;
  110471. private _measureFps;
  110472. /** @hidden */
  110473. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  110474. /**
  110475. * Update a dynamic index buffer
  110476. * @param indexBuffer defines the target index buffer
  110477. * @param indices defines the data to update
  110478. * @param offset defines the offset in the target index buffer where update should start
  110479. */
  110480. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110481. /**
  110482. * Updates the sample count of a render target texture
  110483. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110484. * @param texture defines the texture to update
  110485. * @param samples defines the sample count to set
  110486. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110487. */
  110488. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  110489. /**
  110490. * Updates a depth texture Comparison Mode and Function.
  110491. * If the comparison Function is equal to 0, the mode will be set to none.
  110492. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  110493. * @param texture The texture to set the comparison function for
  110494. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  110495. */
  110496. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  110497. /**
  110498. * Creates a webGL buffer to use with instanciation
  110499. * @param capacity defines the size of the buffer
  110500. * @returns the webGL buffer
  110501. */
  110502. createInstancesBuffer(capacity: number): DataBuffer;
  110503. /**
  110504. * Delete a webGL buffer used with instanciation
  110505. * @param buffer defines the webGL buffer to delete
  110506. */
  110507. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  110508. private _clientWaitAsync;
  110509. /** @hidden */
  110510. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  110511. dispose(): void;
  110512. private _disableTouchAction;
  110513. /**
  110514. * Display the loading screen
  110515. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110516. */
  110517. displayLoadingUI(): void;
  110518. /**
  110519. * Hide the loading screen
  110520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110521. */
  110522. hideLoadingUI(): void;
  110523. /**
  110524. * Gets the current loading screen object
  110525. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110526. */
  110527. get loadingScreen(): ILoadingScreen;
  110528. /**
  110529. * Sets the current loading screen object
  110530. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110531. */
  110532. set loadingScreen(loadingScreen: ILoadingScreen);
  110533. /**
  110534. * Sets the current loading screen text
  110535. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110536. */
  110537. set loadingUIText(text: string);
  110538. /**
  110539. * Sets the current loading screen background color
  110540. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110541. */
  110542. set loadingUIBackgroundColor(color: string);
  110543. /** Pointerlock and fullscreen */
  110544. /**
  110545. * Ask the browser to promote the current element to pointerlock mode
  110546. * @param element defines the DOM element to promote
  110547. */
  110548. static _RequestPointerlock(element: HTMLElement): void;
  110549. /**
  110550. * Asks the browser to exit pointerlock mode
  110551. */
  110552. static _ExitPointerlock(): void;
  110553. /**
  110554. * Ask the browser to promote the current element to fullscreen rendering mode
  110555. * @param element defines the DOM element to promote
  110556. */
  110557. static _RequestFullscreen(element: HTMLElement): void;
  110558. /**
  110559. * Asks the browser to exit fullscreen mode
  110560. */
  110561. static _ExitFullscreen(): void;
  110562. }
  110563. }
  110564. declare module BABYLON {
  110565. /**
  110566. * The engine store class is responsible to hold all the instances of Engine and Scene created
  110567. * during the life time of the application.
  110568. */
  110569. export class EngineStore {
  110570. /** Gets the list of created engines */
  110571. static Instances: Engine[];
  110572. /** @hidden */
  110573. static _LastCreatedScene: Nullable<Scene>;
  110574. /**
  110575. * Gets the latest created engine
  110576. */
  110577. static get LastCreatedEngine(): Nullable<Engine>;
  110578. /**
  110579. * Gets the latest created scene
  110580. */
  110581. static get LastCreatedScene(): Nullable<Scene>;
  110582. /**
  110583. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110584. * @ignorenaming
  110585. */
  110586. static UseFallbackTexture: boolean;
  110587. /**
  110588. * Texture content used if a texture cannot loaded
  110589. * @ignorenaming
  110590. */
  110591. static FallbackTexture: string;
  110592. }
  110593. }
  110594. declare module BABYLON {
  110595. /**
  110596. * Helper class that provides a small promise polyfill
  110597. */
  110598. export class PromisePolyfill {
  110599. /**
  110600. * Static function used to check if the polyfill is required
  110601. * If this is the case then the function will inject the polyfill to window.Promise
  110602. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  110603. */
  110604. static Apply(force?: boolean): void;
  110605. }
  110606. }
  110607. declare module BABYLON {
  110608. /**
  110609. * Interface for screenshot methods with describe argument called `size` as object with options
  110610. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  110611. */
  110612. export interface IScreenshotSize {
  110613. /**
  110614. * number in pixels for canvas height
  110615. */
  110616. height?: number;
  110617. /**
  110618. * multiplier allowing render at a higher or lower resolution
  110619. * If value is defined then height and width will be ignored and taken from camera
  110620. */
  110621. precision?: number;
  110622. /**
  110623. * number in pixels for canvas width
  110624. */
  110625. width?: number;
  110626. }
  110627. }
  110628. declare module BABYLON {
  110629. interface IColor4Like {
  110630. r: float;
  110631. g: float;
  110632. b: float;
  110633. a: float;
  110634. }
  110635. /**
  110636. * Class containing a set of static utilities functions
  110637. */
  110638. export class Tools {
  110639. /**
  110640. * Gets or sets the base URL to use to load assets
  110641. */
  110642. static get BaseUrl(): string;
  110643. static set BaseUrl(value: string);
  110644. /**
  110645. * Enable/Disable Custom HTTP Request Headers globally.
  110646. * default = false
  110647. * @see CustomRequestHeaders
  110648. */
  110649. static UseCustomRequestHeaders: boolean;
  110650. /**
  110651. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  110652. * i.e. when loading files, where the server/service expects an Authorization header
  110653. */
  110654. static CustomRequestHeaders: {
  110655. [key: string]: string;
  110656. };
  110657. /**
  110658. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  110659. */
  110660. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  110661. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  110662. /**
  110663. * Default behaviour for cors in the application.
  110664. * It can be a string if the expected behavior is identical in the entire app.
  110665. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  110666. */
  110667. static get CorsBehavior(): string | ((url: string | string[]) => string);
  110668. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  110669. /**
  110670. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110671. * @ignorenaming
  110672. */
  110673. static get UseFallbackTexture(): boolean;
  110674. static set UseFallbackTexture(value: boolean);
  110675. /**
  110676. * Use this object to register external classes like custom textures or material
  110677. * to allow the laoders to instantiate them
  110678. */
  110679. static get RegisteredExternalClasses(): {
  110680. [key: string]: Object;
  110681. };
  110682. static set RegisteredExternalClasses(classes: {
  110683. [key: string]: Object;
  110684. });
  110685. /**
  110686. * Texture content used if a texture cannot loaded
  110687. * @ignorenaming
  110688. */
  110689. static get fallbackTexture(): string;
  110690. static set fallbackTexture(value: string);
  110691. /**
  110692. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  110693. * @param u defines the coordinate on X axis
  110694. * @param v defines the coordinate on Y axis
  110695. * @param width defines the width of the source data
  110696. * @param height defines the height of the source data
  110697. * @param pixels defines the source byte array
  110698. * @param color defines the output color
  110699. */
  110700. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  110701. /**
  110702. * Interpolates between a and b via alpha
  110703. * @param a The lower value (returned when alpha = 0)
  110704. * @param b The upper value (returned when alpha = 1)
  110705. * @param alpha The interpolation-factor
  110706. * @return The mixed value
  110707. */
  110708. static Mix(a: number, b: number, alpha: number): number;
  110709. /**
  110710. * Tries to instantiate a new object from a given class name
  110711. * @param className defines the class name to instantiate
  110712. * @returns the new object or null if the system was not able to do the instantiation
  110713. */
  110714. static Instantiate(className: string): any;
  110715. /**
  110716. * Provides a slice function that will work even on IE
  110717. * @param data defines the array to slice
  110718. * @param start defines the start of the data (optional)
  110719. * @param end defines the end of the data (optional)
  110720. * @returns the new sliced array
  110721. */
  110722. static Slice<T>(data: T, start?: number, end?: number): T;
  110723. /**
  110724. * Polyfill for setImmediate
  110725. * @param action defines the action to execute after the current execution block
  110726. */
  110727. static SetImmediate(action: () => void): void;
  110728. /**
  110729. * Function indicating if a number is an exponent of 2
  110730. * @param value defines the value to test
  110731. * @returns true if the value is an exponent of 2
  110732. */
  110733. static IsExponentOfTwo(value: number): boolean;
  110734. private static _tmpFloatArray;
  110735. /**
  110736. * Returns the nearest 32-bit single precision float representation of a Number
  110737. * @param value A Number. If the parameter is of a different type, it will get converted
  110738. * to a number or to NaN if it cannot be converted
  110739. * @returns number
  110740. */
  110741. static FloatRound(value: number): number;
  110742. /**
  110743. * Extracts the filename from a path
  110744. * @param path defines the path to use
  110745. * @returns the filename
  110746. */
  110747. static GetFilename(path: string): string;
  110748. /**
  110749. * Extracts the "folder" part of a path (everything before the filename).
  110750. * @param uri The URI to extract the info from
  110751. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  110752. * @returns The "folder" part of the path
  110753. */
  110754. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  110755. /**
  110756. * Extracts text content from a DOM element hierarchy
  110757. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  110758. */
  110759. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  110760. /**
  110761. * Convert an angle in radians to degrees
  110762. * @param angle defines the angle to convert
  110763. * @returns the angle in degrees
  110764. */
  110765. static ToDegrees(angle: number): number;
  110766. /**
  110767. * Convert an angle in degrees to radians
  110768. * @param angle defines the angle to convert
  110769. * @returns the angle in radians
  110770. */
  110771. static ToRadians(angle: number): number;
  110772. /**
  110773. * Returns an array if obj is not an array
  110774. * @param obj defines the object to evaluate as an array
  110775. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  110776. * @returns either obj directly if obj is an array or a new array containing obj
  110777. */
  110778. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  110779. /**
  110780. * Gets the pointer prefix to use
  110781. * @returns "pointer" if touch is enabled. Else returns "mouse"
  110782. */
  110783. static GetPointerPrefix(): string;
  110784. /**
  110785. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110786. * @param url define the url we are trying
  110787. * @param element define the dom element where to configure the cors policy
  110788. */
  110789. static SetCorsBehavior(url: string | string[], element: {
  110790. crossOrigin: string | null;
  110791. }): void;
  110792. /**
  110793. * Removes unwanted characters from an url
  110794. * @param url defines the url to clean
  110795. * @returns the cleaned url
  110796. */
  110797. static CleanUrl(url: string): string;
  110798. /**
  110799. * Gets or sets a function used to pre-process url before using them to load assets
  110800. */
  110801. static get PreprocessUrl(): (url: string) => string;
  110802. static set PreprocessUrl(processor: (url: string) => string);
  110803. /**
  110804. * Loads an image as an HTMLImageElement.
  110805. * @param input url string, ArrayBuffer, or Blob to load
  110806. * @param onLoad callback called when the image successfully loads
  110807. * @param onError callback called when the image fails to load
  110808. * @param offlineProvider offline provider for caching
  110809. * @param mimeType optional mime type
  110810. * @returns the HTMLImageElement of the loaded image
  110811. */
  110812. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  110813. /**
  110814. * Loads a file from a url
  110815. * @param url url string, ArrayBuffer, or Blob to load
  110816. * @param onSuccess callback called when the file successfully loads
  110817. * @param onProgress callback called while file is loading (if the server supports this mode)
  110818. * @param offlineProvider defines the offline provider for caching
  110819. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110820. * @param onError callback called when the file fails to load
  110821. * @returns a file request object
  110822. */
  110823. 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;
  110824. /**
  110825. * Loads a file from a url
  110826. * @param url the file url to load
  110827. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110828. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  110829. */
  110830. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  110831. /**
  110832. * Load a script (identified by an url). When the url returns, the
  110833. * content of this file is added into a new script element, attached to the DOM (body element)
  110834. * @param scriptUrl defines the url of the script to laod
  110835. * @param onSuccess defines the callback called when the script is loaded
  110836. * @param onError defines the callback to call if an error occurs
  110837. * @param scriptId defines the id of the script element
  110838. */
  110839. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  110840. /**
  110841. * Load an asynchronous script (identified by an url). When the url returns, the
  110842. * content of this file is added into a new script element, attached to the DOM (body element)
  110843. * @param scriptUrl defines the url of the script to laod
  110844. * @param scriptId defines the id of the script element
  110845. * @returns a promise request object
  110846. */
  110847. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  110848. /**
  110849. * Loads a file from a blob
  110850. * @param fileToLoad defines the blob to use
  110851. * @param callback defines the callback to call when data is loaded
  110852. * @param progressCallback defines the callback to call during loading process
  110853. * @returns a file request object
  110854. */
  110855. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  110856. /**
  110857. * Reads a file from a File object
  110858. * @param file defines the file to load
  110859. * @param onSuccess defines the callback to call when data is loaded
  110860. * @param onProgress defines the callback to call during loading process
  110861. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110862. * @param onError defines the callback to call when an error occurs
  110863. * @returns a file request object
  110864. */
  110865. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110866. /**
  110867. * Creates a data url from a given string content
  110868. * @param content defines the content to convert
  110869. * @returns the new data url link
  110870. */
  110871. static FileAsURL(content: string): string;
  110872. /**
  110873. * Format the given number to a specific decimal format
  110874. * @param value defines the number to format
  110875. * @param decimals defines the number of decimals to use
  110876. * @returns the formatted string
  110877. */
  110878. static Format(value: number, decimals?: number): string;
  110879. /**
  110880. * Tries to copy an object by duplicating every property
  110881. * @param source defines the source object
  110882. * @param destination defines the target object
  110883. * @param doNotCopyList defines a list of properties to avoid
  110884. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  110885. */
  110886. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  110887. /**
  110888. * Gets a boolean indicating if the given object has no own property
  110889. * @param obj defines the object to test
  110890. * @returns true if object has no own property
  110891. */
  110892. static IsEmpty(obj: any): boolean;
  110893. /**
  110894. * Function used to register events at window level
  110895. * @param windowElement defines the Window object to use
  110896. * @param events defines the events to register
  110897. */
  110898. static RegisterTopRootEvents(windowElement: Window, events: {
  110899. name: string;
  110900. handler: Nullable<(e: FocusEvent) => any>;
  110901. }[]): void;
  110902. /**
  110903. * Function used to unregister events from window level
  110904. * @param windowElement defines the Window object to use
  110905. * @param events defines the events to unregister
  110906. */
  110907. static UnregisterTopRootEvents(windowElement: Window, events: {
  110908. name: string;
  110909. handler: Nullable<(e: FocusEvent) => any>;
  110910. }[]): void;
  110911. /**
  110912. * @ignore
  110913. */
  110914. static _ScreenshotCanvas: HTMLCanvasElement;
  110915. /**
  110916. * Dumps the current bound framebuffer
  110917. * @param width defines the rendering width
  110918. * @param height defines the rendering height
  110919. * @param engine defines the hosting engine
  110920. * @param successCallback defines the callback triggered once the data are available
  110921. * @param mimeType defines the mime type of the result
  110922. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  110923. */
  110924. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110925. /**
  110926. * Converts the canvas data to blob.
  110927. * This acts as a polyfill for browsers not supporting the to blob function.
  110928. * @param canvas Defines the canvas to extract the data from
  110929. * @param successCallback Defines the callback triggered once the data are available
  110930. * @param mimeType Defines the mime type of the result
  110931. */
  110932. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  110933. /**
  110934. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  110935. * @param successCallback defines the callback triggered once the data are available
  110936. * @param mimeType defines the mime type of the result
  110937. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  110938. */
  110939. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110940. /**
  110941. * Downloads a blob in the browser
  110942. * @param blob defines the blob to download
  110943. * @param fileName defines the name of the downloaded file
  110944. */
  110945. static Download(blob: Blob, fileName: string): void;
  110946. /**
  110947. * Captures a screenshot of the current rendering
  110948. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110949. * @param engine defines the rendering engine
  110950. * @param camera defines the source camera
  110951. * @param size This parameter can be set to a single number or to an object with the
  110952. * following (optional) properties: precision, width, height. If a single number is passed,
  110953. * it will be used for both width and height. If an object is passed, the screenshot size
  110954. * will be derived from the parameters. The precision property is a multiplier allowing
  110955. * rendering at a higher or lower resolution
  110956. * @param successCallback defines the callback receives a single parameter which contains the
  110957. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110958. * src parameter of an <img> to display it
  110959. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110960. * Check your browser for supported MIME types
  110961. */
  110962. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  110963. /**
  110964. * Captures a screenshot of the current rendering
  110965. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110966. * @param engine defines the rendering engine
  110967. * @param camera defines the source camera
  110968. * @param size This parameter can be set to a single number or to an object with the
  110969. * following (optional) properties: precision, width, height. If a single number is passed,
  110970. * it will be used for both width and height. If an object is passed, the screenshot size
  110971. * will be derived from the parameters. The precision property is a multiplier allowing
  110972. * rendering at a higher or lower resolution
  110973. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110974. * Check your browser for supported MIME types
  110975. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110976. * to the src parameter of an <img> to display it
  110977. */
  110978. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  110979. /**
  110980. * Generates an image screenshot from the specified camera.
  110981. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110982. * @param engine The engine to use for rendering
  110983. * @param camera The camera to use for rendering
  110984. * @param size This parameter can be set to a single number or to an object with the
  110985. * following (optional) properties: precision, width, height. If a single number is passed,
  110986. * it will be used for both width and height. If an object is passed, the screenshot size
  110987. * will be derived from the parameters. The precision property is a multiplier allowing
  110988. * rendering at a higher or lower resolution
  110989. * @param successCallback The callback receives a single parameter which contains the
  110990. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110991. * src parameter of an <img> to display it
  110992. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110993. * Check your browser for supported MIME types
  110994. * @param samples Texture samples (default: 1)
  110995. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110996. * @param fileName A name for for the downloaded file.
  110997. */
  110998. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110999. /**
  111000. * Generates an image screenshot from the specified camera.
  111001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111002. * @param engine The engine to use for rendering
  111003. * @param camera The camera to use for rendering
  111004. * @param size This parameter can be set to a single number or to an object with the
  111005. * following (optional) properties: precision, width, height. If a single number is passed,
  111006. * it will be used for both width and height. If an object is passed, the screenshot size
  111007. * will be derived from the parameters. The precision property is a multiplier allowing
  111008. * rendering at a higher or lower resolution
  111009. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111010. * Check your browser for supported MIME types
  111011. * @param samples Texture samples (default: 1)
  111012. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111013. * @param fileName A name for for the downloaded file.
  111014. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  111015. * to the src parameter of an <img> to display it
  111016. */
  111017. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  111018. /**
  111019. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111020. * Be aware Math.random() could cause collisions, but:
  111021. * "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"
  111022. * @returns a pseudo random id
  111023. */
  111024. static RandomId(): string;
  111025. /**
  111026. * Test if the given uri is a base64 string
  111027. * @param uri The uri to test
  111028. * @return True if the uri is a base64 string or false otherwise
  111029. */
  111030. static IsBase64(uri: string): boolean;
  111031. /**
  111032. * Decode the given base64 uri.
  111033. * @param uri The uri to decode
  111034. * @return The decoded base64 data.
  111035. */
  111036. static DecodeBase64(uri: string): ArrayBuffer;
  111037. /**
  111038. * Gets the absolute url.
  111039. * @param url the input url
  111040. * @return the absolute url
  111041. */
  111042. static GetAbsoluteUrl(url: string): string;
  111043. /**
  111044. * No log
  111045. */
  111046. static readonly NoneLogLevel: number;
  111047. /**
  111048. * Only message logs
  111049. */
  111050. static readonly MessageLogLevel: number;
  111051. /**
  111052. * Only warning logs
  111053. */
  111054. static readonly WarningLogLevel: number;
  111055. /**
  111056. * Only error logs
  111057. */
  111058. static readonly ErrorLogLevel: number;
  111059. /**
  111060. * All logs
  111061. */
  111062. static readonly AllLogLevel: number;
  111063. /**
  111064. * Gets a value indicating the number of loading errors
  111065. * @ignorenaming
  111066. */
  111067. static get errorsCount(): number;
  111068. /**
  111069. * Callback called when a new log is added
  111070. */
  111071. static OnNewCacheEntry: (entry: string) => void;
  111072. /**
  111073. * Log a message to the console
  111074. * @param message defines the message to log
  111075. */
  111076. static Log(message: string): void;
  111077. /**
  111078. * Write a warning message to the console
  111079. * @param message defines the message to log
  111080. */
  111081. static Warn(message: string): void;
  111082. /**
  111083. * Write an error message to the console
  111084. * @param message defines the message to log
  111085. */
  111086. static Error(message: string): void;
  111087. /**
  111088. * Gets current log cache (list of logs)
  111089. */
  111090. static get LogCache(): string;
  111091. /**
  111092. * Clears the log cache
  111093. */
  111094. static ClearLogCache(): void;
  111095. /**
  111096. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  111097. */
  111098. static set LogLevels(level: number);
  111099. /**
  111100. * Checks if the window object exists
  111101. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  111102. */
  111103. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  111104. /**
  111105. * No performance log
  111106. */
  111107. static readonly PerformanceNoneLogLevel: number;
  111108. /**
  111109. * Use user marks to log performance
  111110. */
  111111. static readonly PerformanceUserMarkLogLevel: number;
  111112. /**
  111113. * Log performance to the console
  111114. */
  111115. static readonly PerformanceConsoleLogLevel: number;
  111116. private static _performance;
  111117. /**
  111118. * Sets the current performance log level
  111119. */
  111120. static set PerformanceLogLevel(level: number);
  111121. private static _StartPerformanceCounterDisabled;
  111122. private static _EndPerformanceCounterDisabled;
  111123. private static _StartUserMark;
  111124. private static _EndUserMark;
  111125. private static _StartPerformanceConsole;
  111126. private static _EndPerformanceConsole;
  111127. /**
  111128. * Starts a performance counter
  111129. */
  111130. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  111131. /**
  111132. * Ends a specific performance coutner
  111133. */
  111134. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  111135. /**
  111136. * Gets either window.performance.now() if supported or Date.now() else
  111137. */
  111138. static get Now(): number;
  111139. /**
  111140. * This method will return the name of the class used to create the instance of the given object.
  111141. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  111142. * @param object the object to get the class name from
  111143. * @param isType defines if the object is actually a type
  111144. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  111145. */
  111146. static GetClassName(object: any, isType?: boolean): string;
  111147. /**
  111148. * Gets the first element of an array satisfying a given predicate
  111149. * @param array defines the array to browse
  111150. * @param predicate defines the predicate to use
  111151. * @returns null if not found or the element
  111152. */
  111153. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  111154. /**
  111155. * This method will return the name of the full name of the class, including its owning module (if any).
  111156. * 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).
  111157. * @param object the object to get the class name from
  111158. * @param isType defines if the object is actually a type
  111159. * @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.
  111160. * @ignorenaming
  111161. */
  111162. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  111163. /**
  111164. * Returns a promise that resolves after the given amount of time.
  111165. * @param delay Number of milliseconds to delay
  111166. * @returns Promise that resolves after the given amount of time
  111167. */
  111168. static DelayAsync(delay: number): Promise<void>;
  111169. /**
  111170. * Utility function to detect if the current user agent is Safari
  111171. * @returns whether or not the current user agent is safari
  111172. */
  111173. static IsSafari(): boolean;
  111174. }
  111175. /**
  111176. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  111177. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  111178. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  111179. * @param name The name of the class, case should be preserved
  111180. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  111181. */
  111182. export function className(name: string, module?: string): (target: Object) => void;
  111183. /**
  111184. * An implementation of a loop for asynchronous functions.
  111185. */
  111186. export class AsyncLoop {
  111187. /**
  111188. * Defines the number of iterations for the loop
  111189. */
  111190. iterations: number;
  111191. /**
  111192. * Defines the current index of the loop.
  111193. */
  111194. index: number;
  111195. private _done;
  111196. private _fn;
  111197. private _successCallback;
  111198. /**
  111199. * Constructor.
  111200. * @param iterations the number of iterations.
  111201. * @param func the function to run each iteration
  111202. * @param successCallback the callback that will be called upon succesful execution
  111203. * @param offset starting offset.
  111204. */
  111205. constructor(
  111206. /**
  111207. * Defines the number of iterations for the loop
  111208. */
  111209. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  111210. /**
  111211. * Execute the next iteration. Must be called after the last iteration was finished.
  111212. */
  111213. executeNext(): void;
  111214. /**
  111215. * Break the loop and run the success callback.
  111216. */
  111217. breakLoop(): void;
  111218. /**
  111219. * Create and run an async loop.
  111220. * @param iterations the number of iterations.
  111221. * @param fn the function to run each iteration
  111222. * @param successCallback the callback that will be called upon succesful execution
  111223. * @param offset starting offset.
  111224. * @returns the created async loop object
  111225. */
  111226. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  111227. /**
  111228. * A for-loop that will run a given number of iterations synchronous and the rest async.
  111229. * @param iterations total number of iterations
  111230. * @param syncedIterations number of synchronous iterations in each async iteration.
  111231. * @param fn the function to call each iteration.
  111232. * @param callback a success call back that will be called when iterating stops.
  111233. * @param breakFunction a break condition (optional)
  111234. * @param timeout timeout settings for the setTimeout function. default - 0.
  111235. * @returns the created async loop object
  111236. */
  111237. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  111238. }
  111239. }
  111240. declare module BABYLON {
  111241. /**
  111242. * This class implement a typical dictionary using a string as key and the generic type T as value.
  111243. * The underlying implementation relies on an associative array to ensure the best performances.
  111244. * The value can be anything including 'null' but except 'undefined'
  111245. */
  111246. export class StringDictionary<T> {
  111247. /**
  111248. * This will clear this dictionary and copy the content from the 'source' one.
  111249. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  111250. * @param source the dictionary to take the content from and copy to this dictionary
  111251. */
  111252. copyFrom(source: StringDictionary<T>): void;
  111253. /**
  111254. * Get a value based from its key
  111255. * @param key the given key to get the matching value from
  111256. * @return the value if found, otherwise undefined is returned
  111257. */
  111258. get(key: string): T | undefined;
  111259. /**
  111260. * Get a value from its key or add it if it doesn't exist.
  111261. * This method will ensure you that a given key/data will be present in the dictionary.
  111262. * @param key the given key to get the matching value from
  111263. * @param factory the factory that will create the value if the key is not present in the dictionary.
  111264. * The factory will only be invoked if there's no data for the given key.
  111265. * @return the value corresponding to the key.
  111266. */
  111267. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  111268. /**
  111269. * Get a value from its key if present in the dictionary otherwise add it
  111270. * @param key the key to get the value from
  111271. * @param val if there's no such key/value pair in the dictionary add it with this value
  111272. * @return the value corresponding to the key
  111273. */
  111274. getOrAdd(key: string, val: T): T;
  111275. /**
  111276. * Check if there's a given key in the dictionary
  111277. * @param key the key to check for
  111278. * @return true if the key is present, false otherwise
  111279. */
  111280. contains(key: string): boolean;
  111281. /**
  111282. * Add a new key and its corresponding value
  111283. * @param key the key to add
  111284. * @param value the value corresponding to the key
  111285. * @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
  111286. */
  111287. add(key: string, value: T): boolean;
  111288. /**
  111289. * Update a specific value associated to a key
  111290. * @param key defines the key to use
  111291. * @param value defines the value to store
  111292. * @returns true if the value was updated (or false if the key was not found)
  111293. */
  111294. set(key: string, value: T): boolean;
  111295. /**
  111296. * Get the element of the given key and remove it from the dictionary
  111297. * @param key defines the key to search
  111298. * @returns the value associated with the key or null if not found
  111299. */
  111300. getAndRemove(key: string): Nullable<T>;
  111301. /**
  111302. * Remove a key/value from the dictionary.
  111303. * @param key the key to remove
  111304. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  111305. */
  111306. remove(key: string): boolean;
  111307. /**
  111308. * Clear the whole content of the dictionary
  111309. */
  111310. clear(): void;
  111311. /**
  111312. * Gets the current count
  111313. */
  111314. get count(): number;
  111315. /**
  111316. * Execute a callback on each key/val of the dictionary.
  111317. * Note that you can remove any element in this dictionary in the callback implementation
  111318. * @param callback the callback to execute on a given key/value pair
  111319. */
  111320. forEach(callback: (key: string, val: T) => void): void;
  111321. /**
  111322. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  111323. * If the callback returns null or undefined the method will iterate to the next key/value pair
  111324. * Note that you can remove any element in this dictionary in the callback implementation
  111325. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  111326. * @returns the first item
  111327. */
  111328. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  111329. private _count;
  111330. private _data;
  111331. }
  111332. }
  111333. declare module BABYLON {
  111334. /** @hidden */
  111335. export interface ICollisionCoordinator {
  111336. createCollider(): Collider;
  111337. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111338. init(scene: Scene): void;
  111339. }
  111340. /** @hidden */
  111341. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  111342. private _scene;
  111343. private _scaledPosition;
  111344. private _scaledVelocity;
  111345. private _finalPosition;
  111346. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111347. createCollider(): Collider;
  111348. init(scene: Scene): void;
  111349. private _collideWithWorld;
  111350. }
  111351. }
  111352. declare module BABYLON {
  111353. /**
  111354. * Class used to manage all inputs for the scene.
  111355. */
  111356. export class InputManager {
  111357. /** The distance in pixel that you have to move to prevent some events */
  111358. static DragMovementThreshold: number;
  111359. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  111360. static LongPressDelay: number;
  111361. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  111362. static DoubleClickDelay: number;
  111363. /** If you need to check double click without raising a single click at first click, enable this flag */
  111364. static ExclusiveDoubleClickMode: boolean;
  111365. private _wheelEventName;
  111366. private _onPointerMove;
  111367. private _onPointerDown;
  111368. private _onPointerUp;
  111369. private _initClickEvent;
  111370. private _initActionManager;
  111371. private _delayedSimpleClick;
  111372. private _delayedSimpleClickTimeout;
  111373. private _previousDelayedSimpleClickTimeout;
  111374. private _meshPickProceed;
  111375. private _previousButtonPressed;
  111376. private _currentPickResult;
  111377. private _previousPickResult;
  111378. private _totalPointersPressed;
  111379. private _doubleClickOccured;
  111380. private _pointerOverMesh;
  111381. private _pickedDownMesh;
  111382. private _pickedUpMesh;
  111383. private _pointerX;
  111384. private _pointerY;
  111385. private _unTranslatedPointerX;
  111386. private _unTranslatedPointerY;
  111387. private _startingPointerPosition;
  111388. private _previousStartingPointerPosition;
  111389. private _startingPointerTime;
  111390. private _previousStartingPointerTime;
  111391. private _pointerCaptures;
  111392. private _onKeyDown;
  111393. private _onKeyUp;
  111394. private _onCanvasFocusObserver;
  111395. private _onCanvasBlurObserver;
  111396. private _scene;
  111397. /**
  111398. * Creates a new InputManager
  111399. * @param scene defines the hosting scene
  111400. */
  111401. constructor(scene: Scene);
  111402. /**
  111403. * Gets the mesh that is currently under the pointer
  111404. */
  111405. get meshUnderPointer(): Nullable<AbstractMesh>;
  111406. /**
  111407. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  111408. */
  111409. get unTranslatedPointer(): Vector2;
  111410. /**
  111411. * Gets or sets the current on-screen X position of the pointer
  111412. */
  111413. get pointerX(): number;
  111414. set pointerX(value: number);
  111415. /**
  111416. * Gets or sets the current on-screen Y position of the pointer
  111417. */
  111418. get pointerY(): number;
  111419. set pointerY(value: number);
  111420. private _updatePointerPosition;
  111421. private _processPointerMove;
  111422. private _setRayOnPointerInfo;
  111423. private _checkPrePointerObservable;
  111424. /**
  111425. * Use this method to simulate a pointer move on a mesh
  111426. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111427. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111428. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111429. */
  111430. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111431. /**
  111432. * Use this method to simulate a pointer down on a mesh
  111433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111436. */
  111437. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111438. private _processPointerDown;
  111439. /** @hidden */
  111440. _isPointerSwiping(): boolean;
  111441. /**
  111442. * Use this method to simulate a pointer up on a mesh
  111443. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111444. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111445. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111446. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  111447. */
  111448. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  111449. private _processPointerUp;
  111450. /**
  111451. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  111452. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  111453. * @returns true if the pointer was captured
  111454. */
  111455. isPointerCaptured(pointerId?: number): boolean;
  111456. /**
  111457. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  111458. * @param attachUp defines if you want to attach events to pointerup
  111459. * @param attachDown defines if you want to attach events to pointerdown
  111460. * @param attachMove defines if you want to attach events to pointermove
  111461. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  111462. */
  111463. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  111464. /**
  111465. * Detaches all event handlers
  111466. */
  111467. detachControl(): void;
  111468. /**
  111469. * Force the value of meshUnderPointer
  111470. * @param mesh defines the mesh to use
  111471. */
  111472. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111473. /**
  111474. * Gets the mesh under the pointer
  111475. * @returns a Mesh or null if no mesh is under the pointer
  111476. */
  111477. getPointerOverMesh(): Nullable<AbstractMesh>;
  111478. }
  111479. }
  111480. declare module BABYLON {
  111481. /**
  111482. * Helper class used to generate session unique ID
  111483. */
  111484. export class UniqueIdGenerator {
  111485. private static _UniqueIdCounter;
  111486. /**
  111487. * Gets an unique (relatively to the current scene) Id
  111488. */
  111489. static get UniqueId(): number;
  111490. }
  111491. }
  111492. declare module BABYLON {
  111493. /**
  111494. * This class defines the direct association between an animation and a target
  111495. */
  111496. export class TargetedAnimation {
  111497. /**
  111498. * Animation to perform
  111499. */
  111500. animation: Animation;
  111501. /**
  111502. * Target to animate
  111503. */
  111504. target: any;
  111505. /**
  111506. * Serialize the object
  111507. * @returns the JSON object representing the current entity
  111508. */
  111509. serialize(): any;
  111510. }
  111511. /**
  111512. * Use this class to create coordinated animations on multiple targets
  111513. */
  111514. export class AnimationGroup implements IDisposable {
  111515. /** The name of the animation group */
  111516. name: string;
  111517. private _scene;
  111518. private _targetedAnimations;
  111519. private _animatables;
  111520. private _from;
  111521. private _to;
  111522. private _isStarted;
  111523. private _isPaused;
  111524. private _speedRatio;
  111525. private _loopAnimation;
  111526. private _isAdditive;
  111527. /**
  111528. * Gets or sets the unique id of the node
  111529. */
  111530. uniqueId: number;
  111531. /**
  111532. * This observable will notify when one animation have ended
  111533. */
  111534. onAnimationEndObservable: Observable<TargetedAnimation>;
  111535. /**
  111536. * Observer raised when one animation loops
  111537. */
  111538. onAnimationLoopObservable: Observable<TargetedAnimation>;
  111539. /**
  111540. * Observer raised when all animations have looped
  111541. */
  111542. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  111543. /**
  111544. * This observable will notify when all animations have ended.
  111545. */
  111546. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  111547. /**
  111548. * This observable will notify when all animations have paused.
  111549. */
  111550. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  111551. /**
  111552. * This observable will notify when all animations are playing.
  111553. */
  111554. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  111555. /**
  111556. * Gets the first frame
  111557. */
  111558. get from(): number;
  111559. /**
  111560. * Gets the last frame
  111561. */
  111562. get to(): number;
  111563. /**
  111564. * Define if the animations are started
  111565. */
  111566. get isStarted(): boolean;
  111567. /**
  111568. * Gets a value indicating that the current group is playing
  111569. */
  111570. get isPlaying(): boolean;
  111571. /**
  111572. * Gets or sets the speed ratio to use for all animations
  111573. */
  111574. get speedRatio(): number;
  111575. /**
  111576. * Gets or sets the speed ratio to use for all animations
  111577. */
  111578. set speedRatio(value: number);
  111579. /**
  111580. * Gets or sets if all animations should loop or not
  111581. */
  111582. get loopAnimation(): boolean;
  111583. set loopAnimation(value: boolean);
  111584. /**
  111585. * Gets or sets if all animations should be evaluated additively
  111586. */
  111587. get isAdditive(): boolean;
  111588. set isAdditive(value: boolean);
  111589. /**
  111590. * Gets the targeted animations for this animation group
  111591. */
  111592. get targetedAnimations(): Array<TargetedAnimation>;
  111593. /**
  111594. * returning the list of animatables controlled by this animation group.
  111595. */
  111596. get animatables(): Array<Animatable>;
  111597. /**
  111598. * Instantiates a new Animation Group.
  111599. * This helps managing several animations at once.
  111600. * @see http://doc.babylonjs.com/how_to/group
  111601. * @param name Defines the name of the group
  111602. * @param scene Defines the scene the group belongs to
  111603. */
  111604. constructor(
  111605. /** The name of the animation group */
  111606. name: string, scene?: Nullable<Scene>);
  111607. /**
  111608. * Add an animation (with its target) in the group
  111609. * @param animation defines the animation we want to add
  111610. * @param target defines the target of the animation
  111611. * @returns the TargetedAnimation object
  111612. */
  111613. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  111614. /**
  111615. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  111616. * It can add constant keys at begin or end
  111617. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  111618. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  111619. * @returns the animation group
  111620. */
  111621. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  111622. private _animationLoopCount;
  111623. private _animationLoopFlags;
  111624. private _processLoop;
  111625. /**
  111626. * Start all animations on given targets
  111627. * @param loop defines if animations must loop
  111628. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  111629. * @param from defines the from key (optional)
  111630. * @param to defines the to key (optional)
  111631. * @param isAdditive defines the additive state for the resulting animatables (optional)
  111632. * @returns the current animation group
  111633. */
  111634. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  111635. /**
  111636. * Pause all animations
  111637. * @returns the animation group
  111638. */
  111639. pause(): AnimationGroup;
  111640. /**
  111641. * Play all animations to initial state
  111642. * This function will start() the animations if they were not started or will restart() them if they were paused
  111643. * @param loop defines if animations must loop
  111644. * @returns the animation group
  111645. */
  111646. play(loop?: boolean): AnimationGroup;
  111647. /**
  111648. * Reset all animations to initial state
  111649. * @returns the animation group
  111650. */
  111651. reset(): AnimationGroup;
  111652. /**
  111653. * Restart animations from key 0
  111654. * @returns the animation group
  111655. */
  111656. restart(): AnimationGroup;
  111657. /**
  111658. * Stop all animations
  111659. * @returns the animation group
  111660. */
  111661. stop(): AnimationGroup;
  111662. /**
  111663. * Set animation weight for all animatables
  111664. * @param weight defines the weight to use
  111665. * @return the animationGroup
  111666. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111667. */
  111668. setWeightForAllAnimatables(weight: number): AnimationGroup;
  111669. /**
  111670. * Synchronize and normalize all animatables with a source animatable
  111671. * @param root defines the root animatable to synchronize with
  111672. * @return the animationGroup
  111673. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111674. */
  111675. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  111676. /**
  111677. * Goes to a specific frame in this animation group
  111678. * @param frame the frame number to go to
  111679. * @return the animationGroup
  111680. */
  111681. goToFrame(frame: number): AnimationGroup;
  111682. /**
  111683. * Dispose all associated resources
  111684. */
  111685. dispose(): void;
  111686. private _checkAnimationGroupEnded;
  111687. /**
  111688. * Clone the current animation group and returns a copy
  111689. * @param newName defines the name of the new group
  111690. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  111691. * @returns the new aniamtion group
  111692. */
  111693. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  111694. /**
  111695. * Serializes the animationGroup to an object
  111696. * @returns Serialized object
  111697. */
  111698. serialize(): any;
  111699. /**
  111700. * Returns a new AnimationGroup object parsed from the source provided.
  111701. * @param parsedAnimationGroup defines the source
  111702. * @param scene defines the scene that will receive the animationGroup
  111703. * @returns a new AnimationGroup
  111704. */
  111705. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  111706. /**
  111707. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111708. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  111709. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111710. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  111711. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  111712. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  111713. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  111714. */
  111715. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  111716. /**
  111717. * Returns the string "AnimationGroup"
  111718. * @returns "AnimationGroup"
  111719. */
  111720. getClassName(): string;
  111721. /**
  111722. * Creates a detailled string about the object
  111723. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  111724. * @returns a string representing the object
  111725. */
  111726. toString(fullDetails?: boolean): string;
  111727. }
  111728. }
  111729. declare module BABYLON {
  111730. /**
  111731. * Define an interface for all classes that will hold resources
  111732. */
  111733. export interface IDisposable {
  111734. /**
  111735. * Releases all held resources
  111736. */
  111737. dispose(): void;
  111738. }
  111739. /** Interface defining initialization parameters for Scene class */
  111740. export interface SceneOptions {
  111741. /**
  111742. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  111743. * It will improve performance when the number of geometries becomes important.
  111744. */
  111745. useGeometryUniqueIdsMap?: boolean;
  111746. /**
  111747. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  111748. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111749. */
  111750. useMaterialMeshMap?: boolean;
  111751. /**
  111752. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  111753. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111754. */
  111755. useClonedMeshMap?: boolean;
  111756. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  111757. virtual?: boolean;
  111758. }
  111759. /**
  111760. * Represents a scene to be rendered by the engine.
  111761. * @see http://doc.babylonjs.com/features/scene
  111762. */
  111763. export class Scene extends AbstractScene implements IAnimatable {
  111764. /** The fog is deactivated */
  111765. static readonly FOGMODE_NONE: number;
  111766. /** The fog density is following an exponential function */
  111767. static readonly FOGMODE_EXP: number;
  111768. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  111769. static readonly FOGMODE_EXP2: number;
  111770. /** The fog density is following a linear function. */
  111771. static readonly FOGMODE_LINEAR: number;
  111772. /**
  111773. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  111774. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111775. */
  111776. static MinDeltaTime: number;
  111777. /**
  111778. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  111779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111780. */
  111781. static MaxDeltaTime: number;
  111782. /**
  111783. * Factory used to create the default material.
  111784. * @param name The name of the material to create
  111785. * @param scene The scene to create the material for
  111786. * @returns The default material
  111787. */
  111788. static DefaultMaterialFactory(scene: Scene): Material;
  111789. /**
  111790. * Factory used to create the a collision coordinator.
  111791. * @returns The collision coordinator
  111792. */
  111793. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  111794. /** @hidden */
  111795. _inputManager: InputManager;
  111796. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  111797. cameraToUseForPointers: Nullable<Camera>;
  111798. /** @hidden */
  111799. readonly _isScene: boolean;
  111800. /** @hidden */
  111801. _blockEntityCollection: boolean;
  111802. /**
  111803. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  111804. */
  111805. autoClear: boolean;
  111806. /**
  111807. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  111808. */
  111809. autoClearDepthAndStencil: boolean;
  111810. /**
  111811. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  111812. */
  111813. clearColor: Color4;
  111814. /**
  111815. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  111816. */
  111817. ambientColor: Color3;
  111818. /**
  111819. * This is use to store the default BRDF lookup for PBR materials in your scene.
  111820. * It should only be one of the following (if not the default embedded one):
  111821. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111822. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  111823. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111824. * The material properties need to be setup according to the type of texture in use.
  111825. */
  111826. environmentBRDFTexture: BaseTexture;
  111827. /** @hidden */
  111828. protected _environmentTexture: Nullable<BaseTexture>;
  111829. /**
  111830. * Texture used in all pbr material as the reflection texture.
  111831. * As in the majority of the scene they are the same (exception for multi room and so on),
  111832. * this is easier to reference from here than from all the materials.
  111833. */
  111834. get environmentTexture(): Nullable<BaseTexture>;
  111835. /**
  111836. * Texture used in all pbr material as the reflection texture.
  111837. * As in the majority of the scene they are the same (exception for multi room and so on),
  111838. * this is easier to set here than in all the materials.
  111839. */
  111840. set environmentTexture(value: Nullable<BaseTexture>);
  111841. /** @hidden */
  111842. protected _environmentIntensity: number;
  111843. /**
  111844. * Intensity of the environment in all pbr material.
  111845. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111846. * As in the majority of the scene they are the same (exception for multi room and so on),
  111847. * this is easier to reference from here than from all the materials.
  111848. */
  111849. get environmentIntensity(): number;
  111850. /**
  111851. * Intensity of the environment in all pbr material.
  111852. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111853. * As in the majority of the scene they are the same (exception for multi room and so on),
  111854. * this is easier to set here than in all the materials.
  111855. */
  111856. set environmentIntensity(value: number);
  111857. /** @hidden */
  111858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111859. /**
  111860. * Default image processing configuration used either in the rendering
  111861. * Forward main pass or through the imageProcessingPostProcess if present.
  111862. * As in the majority of the scene they are the same (exception for multi camera),
  111863. * this is easier to reference from here than from all the materials and post process.
  111864. *
  111865. * No setter as we it is a shared configuration, you can set the values instead.
  111866. */
  111867. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111868. private _forceWireframe;
  111869. /**
  111870. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  111871. */
  111872. set forceWireframe(value: boolean);
  111873. get forceWireframe(): boolean;
  111874. private _skipFrustumClipping;
  111875. /**
  111876. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  111877. */
  111878. set skipFrustumClipping(value: boolean);
  111879. get skipFrustumClipping(): boolean;
  111880. private _forcePointsCloud;
  111881. /**
  111882. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  111883. */
  111884. set forcePointsCloud(value: boolean);
  111885. get forcePointsCloud(): boolean;
  111886. /**
  111887. * Gets or sets the active clipplane 1
  111888. */
  111889. clipPlane: Nullable<Plane>;
  111890. /**
  111891. * Gets or sets the active clipplane 2
  111892. */
  111893. clipPlane2: Nullable<Plane>;
  111894. /**
  111895. * Gets or sets the active clipplane 3
  111896. */
  111897. clipPlane3: Nullable<Plane>;
  111898. /**
  111899. * Gets or sets the active clipplane 4
  111900. */
  111901. clipPlane4: Nullable<Plane>;
  111902. /**
  111903. * Gets or sets the active clipplane 5
  111904. */
  111905. clipPlane5: Nullable<Plane>;
  111906. /**
  111907. * Gets or sets the active clipplane 6
  111908. */
  111909. clipPlane6: Nullable<Plane>;
  111910. /**
  111911. * Gets or sets a boolean indicating if animations are enabled
  111912. */
  111913. animationsEnabled: boolean;
  111914. private _animationPropertiesOverride;
  111915. /**
  111916. * Gets or sets the animation properties override
  111917. */
  111918. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111919. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111920. /**
  111921. * Gets or sets a boolean indicating if a constant deltatime has to be used
  111922. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  111923. */
  111924. useConstantAnimationDeltaTime: boolean;
  111925. /**
  111926. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  111927. * Please note that it requires to run a ray cast through the scene on every frame
  111928. */
  111929. constantlyUpdateMeshUnderPointer: boolean;
  111930. /**
  111931. * Defines the HTML cursor to use when hovering over interactive elements
  111932. */
  111933. hoverCursor: string;
  111934. /**
  111935. * Defines the HTML default cursor to use (empty by default)
  111936. */
  111937. defaultCursor: string;
  111938. /**
  111939. * Defines whether cursors are handled by the scene.
  111940. */
  111941. doNotHandleCursors: boolean;
  111942. /**
  111943. * This is used to call preventDefault() on pointer down
  111944. * in order to block unwanted artifacts like system double clicks
  111945. */
  111946. preventDefaultOnPointerDown: boolean;
  111947. /**
  111948. * This is used to call preventDefault() on pointer up
  111949. * in order to block unwanted artifacts like system double clicks
  111950. */
  111951. preventDefaultOnPointerUp: boolean;
  111952. /**
  111953. * Gets or sets user defined metadata
  111954. */
  111955. metadata: any;
  111956. /**
  111957. * For internal use only. Please do not use.
  111958. */
  111959. reservedDataStore: any;
  111960. /**
  111961. * Gets the name of the plugin used to load this scene (null by default)
  111962. */
  111963. loadingPluginName: string;
  111964. /**
  111965. * Use this array to add regular expressions used to disable offline support for specific urls
  111966. */
  111967. disableOfflineSupportExceptionRules: RegExp[];
  111968. /**
  111969. * An event triggered when the scene is disposed.
  111970. */
  111971. onDisposeObservable: Observable<Scene>;
  111972. private _onDisposeObserver;
  111973. /** Sets a function to be executed when this scene is disposed. */
  111974. set onDispose(callback: () => void);
  111975. /**
  111976. * An event triggered before rendering the scene (right after animations and physics)
  111977. */
  111978. onBeforeRenderObservable: Observable<Scene>;
  111979. private _onBeforeRenderObserver;
  111980. /** Sets a function to be executed before rendering this scene */
  111981. set beforeRender(callback: Nullable<() => void>);
  111982. /**
  111983. * An event triggered after rendering the scene
  111984. */
  111985. onAfterRenderObservable: Observable<Scene>;
  111986. /**
  111987. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  111988. */
  111989. onAfterRenderCameraObservable: Observable<Camera>;
  111990. private _onAfterRenderObserver;
  111991. /** Sets a function to be executed after rendering this scene */
  111992. set afterRender(callback: Nullable<() => void>);
  111993. /**
  111994. * An event triggered before animating the scene
  111995. */
  111996. onBeforeAnimationsObservable: Observable<Scene>;
  111997. /**
  111998. * An event triggered after animations processing
  111999. */
  112000. onAfterAnimationsObservable: Observable<Scene>;
  112001. /**
  112002. * An event triggered before draw calls are ready to be sent
  112003. */
  112004. onBeforeDrawPhaseObservable: Observable<Scene>;
  112005. /**
  112006. * An event triggered after draw calls have been sent
  112007. */
  112008. onAfterDrawPhaseObservable: Observable<Scene>;
  112009. /**
  112010. * An event triggered when the scene is ready
  112011. */
  112012. onReadyObservable: Observable<Scene>;
  112013. /**
  112014. * An event triggered before rendering a camera
  112015. */
  112016. onBeforeCameraRenderObservable: Observable<Camera>;
  112017. private _onBeforeCameraRenderObserver;
  112018. /** Sets a function to be executed before rendering a camera*/
  112019. set beforeCameraRender(callback: () => void);
  112020. /**
  112021. * An event triggered after rendering a camera
  112022. */
  112023. onAfterCameraRenderObservable: Observable<Camera>;
  112024. private _onAfterCameraRenderObserver;
  112025. /** Sets a function to be executed after rendering a camera*/
  112026. set afterCameraRender(callback: () => void);
  112027. /**
  112028. * An event triggered when active meshes evaluation is about to start
  112029. */
  112030. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  112031. /**
  112032. * An event triggered when active meshes evaluation is done
  112033. */
  112034. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  112035. /**
  112036. * An event triggered when particles rendering is about to start
  112037. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  112038. */
  112039. onBeforeParticlesRenderingObservable: Observable<Scene>;
  112040. /**
  112041. * An event triggered when particles rendering is done
  112042. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  112043. */
  112044. onAfterParticlesRenderingObservable: Observable<Scene>;
  112045. /**
  112046. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  112047. */
  112048. onDataLoadedObservable: Observable<Scene>;
  112049. /**
  112050. * An event triggered when a camera is created
  112051. */
  112052. onNewCameraAddedObservable: Observable<Camera>;
  112053. /**
  112054. * An event triggered when a camera is removed
  112055. */
  112056. onCameraRemovedObservable: Observable<Camera>;
  112057. /**
  112058. * An event triggered when a light is created
  112059. */
  112060. onNewLightAddedObservable: Observable<Light>;
  112061. /**
  112062. * An event triggered when a light is removed
  112063. */
  112064. onLightRemovedObservable: Observable<Light>;
  112065. /**
  112066. * An event triggered when a geometry is created
  112067. */
  112068. onNewGeometryAddedObservable: Observable<Geometry>;
  112069. /**
  112070. * An event triggered when a geometry is removed
  112071. */
  112072. onGeometryRemovedObservable: Observable<Geometry>;
  112073. /**
  112074. * An event triggered when a transform node is created
  112075. */
  112076. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  112077. /**
  112078. * An event triggered when a transform node is removed
  112079. */
  112080. onTransformNodeRemovedObservable: Observable<TransformNode>;
  112081. /**
  112082. * An event triggered when a mesh is created
  112083. */
  112084. onNewMeshAddedObservable: Observable<AbstractMesh>;
  112085. /**
  112086. * An event triggered when a mesh is removed
  112087. */
  112088. onMeshRemovedObservable: Observable<AbstractMesh>;
  112089. /**
  112090. * An event triggered when a skeleton is created
  112091. */
  112092. onNewSkeletonAddedObservable: Observable<Skeleton>;
  112093. /**
  112094. * An event triggered when a skeleton is removed
  112095. */
  112096. onSkeletonRemovedObservable: Observable<Skeleton>;
  112097. /**
  112098. * An event triggered when a material is created
  112099. */
  112100. onNewMaterialAddedObservable: Observable<Material>;
  112101. /**
  112102. * An event triggered when a material is removed
  112103. */
  112104. onMaterialRemovedObservable: Observable<Material>;
  112105. /**
  112106. * An event triggered when a texture is created
  112107. */
  112108. onNewTextureAddedObservable: Observable<BaseTexture>;
  112109. /**
  112110. * An event triggered when a texture is removed
  112111. */
  112112. onTextureRemovedObservable: Observable<BaseTexture>;
  112113. /**
  112114. * An event triggered when render targets are about to be rendered
  112115. * Can happen multiple times per frame.
  112116. */
  112117. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  112118. /**
  112119. * An event triggered when render targets were rendered.
  112120. * Can happen multiple times per frame.
  112121. */
  112122. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  112123. /**
  112124. * An event triggered before calculating deterministic simulation step
  112125. */
  112126. onBeforeStepObservable: Observable<Scene>;
  112127. /**
  112128. * An event triggered after calculating deterministic simulation step
  112129. */
  112130. onAfterStepObservable: Observable<Scene>;
  112131. /**
  112132. * An event triggered when the activeCamera property is updated
  112133. */
  112134. onActiveCameraChanged: Observable<Scene>;
  112135. /**
  112136. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  112137. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112138. * 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)
  112139. */
  112140. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112141. /**
  112142. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  112143. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112144. * 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)
  112145. */
  112146. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112147. /**
  112148. * This Observable will when a mesh has been imported into the scene.
  112149. */
  112150. onMeshImportedObservable: Observable<AbstractMesh>;
  112151. /**
  112152. * This Observable will when an animation file has been imported into the scene.
  112153. */
  112154. onAnimationFileImportedObservable: Observable<Scene>;
  112155. /**
  112156. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  112157. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  112158. */
  112159. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  112160. /** @hidden */
  112161. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  112162. /**
  112163. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  112164. */
  112165. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  112166. /**
  112167. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  112168. */
  112169. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  112170. /**
  112171. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  112172. */
  112173. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  112174. /** Callback called when a pointer move is detected */
  112175. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112176. /** Callback called when a pointer down is detected */
  112177. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112178. /** Callback called when a pointer up is detected */
  112179. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  112180. /** Callback called when a pointer pick is detected */
  112181. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  112182. /**
  112183. * 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).
  112184. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  112185. */
  112186. onPrePointerObservable: Observable<PointerInfoPre>;
  112187. /**
  112188. * Observable event triggered each time an input event is received from the rendering canvas
  112189. */
  112190. onPointerObservable: Observable<PointerInfo>;
  112191. /**
  112192. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  112193. */
  112194. get unTranslatedPointer(): Vector2;
  112195. /**
  112196. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  112197. */
  112198. static get DragMovementThreshold(): number;
  112199. static set DragMovementThreshold(value: number);
  112200. /**
  112201. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  112202. */
  112203. static get LongPressDelay(): number;
  112204. static set LongPressDelay(value: number);
  112205. /**
  112206. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  112207. */
  112208. static get DoubleClickDelay(): number;
  112209. static set DoubleClickDelay(value: number);
  112210. /** If you need to check double click without raising a single click at first click, enable this flag */
  112211. static get ExclusiveDoubleClickMode(): boolean;
  112212. static set ExclusiveDoubleClickMode(value: boolean);
  112213. /** @hidden */
  112214. _mirroredCameraPosition: Nullable<Vector3>;
  112215. /**
  112216. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  112217. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  112218. */
  112219. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  112220. /**
  112221. * Observable event triggered each time an keyboard event is received from the hosting window
  112222. */
  112223. onKeyboardObservable: Observable<KeyboardInfo>;
  112224. private _useRightHandedSystem;
  112225. /**
  112226. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  112227. */
  112228. set useRightHandedSystem(value: boolean);
  112229. get useRightHandedSystem(): boolean;
  112230. private _timeAccumulator;
  112231. private _currentStepId;
  112232. private _currentInternalStep;
  112233. /**
  112234. * Sets the step Id used by deterministic lock step
  112235. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112236. * @param newStepId defines the step Id
  112237. */
  112238. setStepId(newStepId: number): void;
  112239. /**
  112240. * Gets the step Id used by deterministic lock step
  112241. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112242. * @returns the step Id
  112243. */
  112244. getStepId(): number;
  112245. /**
  112246. * Gets the internal step used by deterministic lock step
  112247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112248. * @returns the internal step
  112249. */
  112250. getInternalStep(): number;
  112251. private _fogEnabled;
  112252. /**
  112253. * Gets or sets a boolean indicating if fog is enabled on this scene
  112254. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112255. * (Default is true)
  112256. */
  112257. set fogEnabled(value: boolean);
  112258. get fogEnabled(): boolean;
  112259. private _fogMode;
  112260. /**
  112261. * Gets or sets the fog mode to use
  112262. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112263. * | mode | value |
  112264. * | --- | --- |
  112265. * | FOGMODE_NONE | 0 |
  112266. * | FOGMODE_EXP | 1 |
  112267. * | FOGMODE_EXP2 | 2 |
  112268. * | FOGMODE_LINEAR | 3 |
  112269. */
  112270. set fogMode(value: number);
  112271. get fogMode(): number;
  112272. /**
  112273. * Gets or sets the fog color to use
  112274. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112275. * (Default is Color3(0.2, 0.2, 0.3))
  112276. */
  112277. fogColor: Color3;
  112278. /**
  112279. * Gets or sets the fog density to use
  112280. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112281. * (Default is 0.1)
  112282. */
  112283. fogDensity: number;
  112284. /**
  112285. * Gets or sets the fog start distance to use
  112286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112287. * (Default is 0)
  112288. */
  112289. fogStart: number;
  112290. /**
  112291. * Gets or sets the fog end distance to use
  112292. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112293. * (Default is 1000)
  112294. */
  112295. fogEnd: number;
  112296. private _shadowsEnabled;
  112297. /**
  112298. * Gets or sets a boolean indicating if shadows are enabled on this scene
  112299. */
  112300. set shadowsEnabled(value: boolean);
  112301. get shadowsEnabled(): boolean;
  112302. private _lightsEnabled;
  112303. /**
  112304. * Gets or sets a boolean indicating if lights are enabled on this scene
  112305. */
  112306. set lightsEnabled(value: boolean);
  112307. get lightsEnabled(): boolean;
  112308. /** All of the active cameras added to this scene. */
  112309. activeCameras: Camera[];
  112310. /** @hidden */
  112311. _activeCamera: Nullable<Camera>;
  112312. /** Gets or sets the current active camera */
  112313. get activeCamera(): Nullable<Camera>;
  112314. set activeCamera(value: Nullable<Camera>);
  112315. private _defaultMaterial;
  112316. /** The default material used on meshes when no material is affected */
  112317. get defaultMaterial(): Material;
  112318. /** The default material used on meshes when no material is affected */
  112319. set defaultMaterial(value: Material);
  112320. private _texturesEnabled;
  112321. /**
  112322. * Gets or sets a boolean indicating if textures are enabled on this scene
  112323. */
  112324. set texturesEnabled(value: boolean);
  112325. get texturesEnabled(): boolean;
  112326. /**
  112327. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  112328. */
  112329. physicsEnabled: boolean;
  112330. /**
  112331. * Gets or sets a boolean indicating if particles are enabled on this scene
  112332. */
  112333. particlesEnabled: boolean;
  112334. /**
  112335. * Gets or sets a boolean indicating if sprites are enabled on this scene
  112336. */
  112337. spritesEnabled: boolean;
  112338. private _skeletonsEnabled;
  112339. /**
  112340. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  112341. */
  112342. set skeletonsEnabled(value: boolean);
  112343. get skeletonsEnabled(): boolean;
  112344. /**
  112345. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  112346. */
  112347. lensFlaresEnabled: boolean;
  112348. /**
  112349. * Gets or sets a boolean indicating if collisions are enabled on this scene
  112350. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112351. */
  112352. collisionsEnabled: boolean;
  112353. private _collisionCoordinator;
  112354. /** @hidden */
  112355. get collisionCoordinator(): ICollisionCoordinator;
  112356. /**
  112357. * Defines the gravity applied to this scene (used only for collisions)
  112358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112359. */
  112360. gravity: Vector3;
  112361. /**
  112362. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  112363. */
  112364. postProcessesEnabled: boolean;
  112365. /**
  112366. * The list of postprocesses added to the scene
  112367. */
  112368. postProcesses: PostProcess[];
  112369. /**
  112370. * Gets the current postprocess manager
  112371. */
  112372. postProcessManager: PostProcessManager;
  112373. /**
  112374. * Gets or sets a boolean indicating if render targets are enabled on this scene
  112375. */
  112376. renderTargetsEnabled: boolean;
  112377. /**
  112378. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  112379. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  112380. */
  112381. dumpNextRenderTargets: boolean;
  112382. /**
  112383. * The list of user defined render targets added to the scene
  112384. */
  112385. customRenderTargets: RenderTargetTexture[];
  112386. /**
  112387. * Defines if texture loading must be delayed
  112388. * If true, textures will only be loaded when they need to be rendered
  112389. */
  112390. useDelayedTextureLoading: boolean;
  112391. /**
  112392. * Gets the list of meshes imported to the scene through SceneLoader
  112393. */
  112394. importedMeshesFiles: String[];
  112395. /**
  112396. * Gets or sets a boolean indicating if probes are enabled on this scene
  112397. */
  112398. probesEnabled: boolean;
  112399. /**
  112400. * Gets or sets the current offline provider to use to store scene data
  112401. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  112402. */
  112403. offlineProvider: IOfflineProvider;
  112404. /**
  112405. * Gets or sets the action manager associated with the scene
  112406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112407. */
  112408. actionManager: AbstractActionManager;
  112409. private _meshesForIntersections;
  112410. /**
  112411. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  112412. */
  112413. proceduralTexturesEnabled: boolean;
  112414. private _engine;
  112415. private _totalVertices;
  112416. /** @hidden */
  112417. _activeIndices: PerfCounter;
  112418. /** @hidden */
  112419. _activeParticles: PerfCounter;
  112420. /** @hidden */
  112421. _activeBones: PerfCounter;
  112422. private _animationRatio;
  112423. /** @hidden */
  112424. _animationTimeLast: number;
  112425. /** @hidden */
  112426. _animationTime: number;
  112427. /**
  112428. * Gets or sets a general scale for animation speed
  112429. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  112430. */
  112431. animationTimeScale: number;
  112432. /** @hidden */
  112433. _cachedMaterial: Nullable<Material>;
  112434. /** @hidden */
  112435. _cachedEffect: Nullable<Effect>;
  112436. /** @hidden */
  112437. _cachedVisibility: Nullable<number>;
  112438. private _renderId;
  112439. private _frameId;
  112440. private _executeWhenReadyTimeoutId;
  112441. private _intermediateRendering;
  112442. private _viewUpdateFlag;
  112443. private _projectionUpdateFlag;
  112444. /** @hidden */
  112445. _toBeDisposed: Nullable<IDisposable>[];
  112446. private _activeRequests;
  112447. /** @hidden */
  112448. _pendingData: any[];
  112449. private _isDisposed;
  112450. /**
  112451. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  112452. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  112453. */
  112454. dispatchAllSubMeshesOfActiveMeshes: boolean;
  112455. private _activeMeshes;
  112456. private _processedMaterials;
  112457. private _renderTargets;
  112458. /** @hidden */
  112459. _activeParticleSystems: SmartArray<IParticleSystem>;
  112460. private _activeSkeletons;
  112461. private _softwareSkinnedMeshes;
  112462. private _renderingManager;
  112463. /** @hidden */
  112464. _activeAnimatables: Animatable[];
  112465. private _transformMatrix;
  112466. private _sceneUbo;
  112467. /** @hidden */
  112468. _viewMatrix: Matrix;
  112469. private _projectionMatrix;
  112470. /** @hidden */
  112471. _forcedViewPosition: Nullable<Vector3>;
  112472. /** @hidden */
  112473. _frustumPlanes: Plane[];
  112474. /**
  112475. * Gets the list of frustum planes (built from the active camera)
  112476. */
  112477. get frustumPlanes(): Plane[];
  112478. /**
  112479. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  112480. * This is useful if there are more lights that the maximum simulteanous authorized
  112481. */
  112482. requireLightSorting: boolean;
  112483. /** @hidden */
  112484. readonly useMaterialMeshMap: boolean;
  112485. /** @hidden */
  112486. readonly useClonedMeshMap: boolean;
  112487. private _externalData;
  112488. private _uid;
  112489. /**
  112490. * @hidden
  112491. * Backing store of defined scene components.
  112492. */
  112493. _components: ISceneComponent[];
  112494. /**
  112495. * @hidden
  112496. * Backing store of defined scene components.
  112497. */
  112498. _serializableComponents: ISceneSerializableComponent[];
  112499. /**
  112500. * List of components to register on the next registration step.
  112501. */
  112502. private _transientComponents;
  112503. /**
  112504. * Registers the transient components if needed.
  112505. */
  112506. private _registerTransientComponents;
  112507. /**
  112508. * @hidden
  112509. * Add a component to the scene.
  112510. * Note that the ccomponent could be registered on th next frame if this is called after
  112511. * the register component stage.
  112512. * @param component Defines the component to add to the scene
  112513. */
  112514. _addComponent(component: ISceneComponent): void;
  112515. /**
  112516. * @hidden
  112517. * Gets a component from the scene.
  112518. * @param name defines the name of the component to retrieve
  112519. * @returns the component or null if not present
  112520. */
  112521. _getComponent(name: string): Nullable<ISceneComponent>;
  112522. /**
  112523. * @hidden
  112524. * Defines the actions happening before camera updates.
  112525. */
  112526. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  112527. /**
  112528. * @hidden
  112529. * Defines the actions happening before clear the canvas.
  112530. */
  112531. _beforeClearStage: Stage<SimpleStageAction>;
  112532. /**
  112533. * @hidden
  112534. * Defines the actions when collecting render targets for the frame.
  112535. */
  112536. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112537. /**
  112538. * @hidden
  112539. * Defines the actions happening for one camera in the frame.
  112540. */
  112541. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112542. /**
  112543. * @hidden
  112544. * Defines the actions happening during the per mesh ready checks.
  112545. */
  112546. _isReadyForMeshStage: Stage<MeshStageAction>;
  112547. /**
  112548. * @hidden
  112549. * Defines the actions happening before evaluate active mesh checks.
  112550. */
  112551. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  112552. /**
  112553. * @hidden
  112554. * Defines the actions happening during the evaluate sub mesh checks.
  112555. */
  112556. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  112557. /**
  112558. * @hidden
  112559. * Defines the actions happening during the active mesh stage.
  112560. */
  112561. _activeMeshStage: Stage<ActiveMeshStageAction>;
  112562. /**
  112563. * @hidden
  112564. * Defines the actions happening during the per camera render target step.
  112565. */
  112566. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  112567. /**
  112568. * @hidden
  112569. * Defines the actions happening just before the active camera is drawing.
  112570. */
  112571. _beforeCameraDrawStage: Stage<CameraStageAction>;
  112572. /**
  112573. * @hidden
  112574. * Defines the actions happening just before a render target is drawing.
  112575. */
  112576. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112577. /**
  112578. * @hidden
  112579. * Defines the actions happening just before a rendering group is drawing.
  112580. */
  112581. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112582. /**
  112583. * @hidden
  112584. * Defines the actions happening just before a mesh is drawing.
  112585. */
  112586. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112587. /**
  112588. * @hidden
  112589. * Defines the actions happening just after a mesh has been drawn.
  112590. */
  112591. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112592. /**
  112593. * @hidden
  112594. * Defines the actions happening just after a rendering group has been drawn.
  112595. */
  112596. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112597. /**
  112598. * @hidden
  112599. * Defines the actions happening just after the active camera has been drawn.
  112600. */
  112601. _afterCameraDrawStage: Stage<CameraStageAction>;
  112602. /**
  112603. * @hidden
  112604. * Defines the actions happening just after a render target has been drawn.
  112605. */
  112606. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112607. /**
  112608. * @hidden
  112609. * Defines the actions happening just after rendering all cameras and computing intersections.
  112610. */
  112611. _afterRenderStage: Stage<SimpleStageAction>;
  112612. /**
  112613. * @hidden
  112614. * Defines the actions happening when a pointer move event happens.
  112615. */
  112616. _pointerMoveStage: Stage<PointerMoveStageAction>;
  112617. /**
  112618. * @hidden
  112619. * Defines the actions happening when a pointer down event happens.
  112620. */
  112621. _pointerDownStage: Stage<PointerUpDownStageAction>;
  112622. /**
  112623. * @hidden
  112624. * Defines the actions happening when a pointer up event happens.
  112625. */
  112626. _pointerUpStage: Stage<PointerUpDownStageAction>;
  112627. /**
  112628. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  112629. */
  112630. private geometriesByUniqueId;
  112631. /**
  112632. * Creates a new Scene
  112633. * @param engine defines the engine to use to render this scene
  112634. * @param options defines the scene options
  112635. */
  112636. constructor(engine: Engine, options?: SceneOptions);
  112637. /**
  112638. * Gets a string idenfifying the name of the class
  112639. * @returns "Scene" string
  112640. */
  112641. getClassName(): string;
  112642. private _defaultMeshCandidates;
  112643. /**
  112644. * @hidden
  112645. */
  112646. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112647. private _defaultSubMeshCandidates;
  112648. /**
  112649. * @hidden
  112650. */
  112651. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112652. /**
  112653. * Sets the default candidate providers for the scene.
  112654. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  112655. * and getCollidingSubMeshCandidates to their default function
  112656. */
  112657. setDefaultCandidateProviders(): void;
  112658. /**
  112659. * Gets the mesh that is currently under the pointer
  112660. */
  112661. get meshUnderPointer(): Nullable<AbstractMesh>;
  112662. /**
  112663. * Gets or sets the current on-screen X position of the pointer
  112664. */
  112665. get pointerX(): number;
  112666. set pointerX(value: number);
  112667. /**
  112668. * Gets or sets the current on-screen Y position of the pointer
  112669. */
  112670. get pointerY(): number;
  112671. set pointerY(value: number);
  112672. /**
  112673. * Gets the cached material (ie. the latest rendered one)
  112674. * @returns the cached material
  112675. */
  112676. getCachedMaterial(): Nullable<Material>;
  112677. /**
  112678. * Gets the cached effect (ie. the latest rendered one)
  112679. * @returns the cached effect
  112680. */
  112681. getCachedEffect(): Nullable<Effect>;
  112682. /**
  112683. * Gets the cached visibility state (ie. the latest rendered one)
  112684. * @returns the cached visibility state
  112685. */
  112686. getCachedVisibility(): Nullable<number>;
  112687. /**
  112688. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  112689. * @param material defines the current material
  112690. * @param effect defines the current effect
  112691. * @param visibility defines the current visibility state
  112692. * @returns true if one parameter is not cached
  112693. */
  112694. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  112695. /**
  112696. * Gets the engine associated with the scene
  112697. * @returns an Engine
  112698. */
  112699. getEngine(): Engine;
  112700. /**
  112701. * Gets the total number of vertices rendered per frame
  112702. * @returns the total number of vertices rendered per frame
  112703. */
  112704. getTotalVertices(): number;
  112705. /**
  112706. * Gets the performance counter for total vertices
  112707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112708. */
  112709. get totalVerticesPerfCounter(): PerfCounter;
  112710. /**
  112711. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  112712. * @returns the total number of active indices rendered per frame
  112713. */
  112714. getActiveIndices(): number;
  112715. /**
  112716. * Gets the performance counter for active indices
  112717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112718. */
  112719. get totalActiveIndicesPerfCounter(): PerfCounter;
  112720. /**
  112721. * Gets the total number of active particles rendered per frame
  112722. * @returns the total number of active particles rendered per frame
  112723. */
  112724. getActiveParticles(): number;
  112725. /**
  112726. * Gets the performance counter for active particles
  112727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112728. */
  112729. get activeParticlesPerfCounter(): PerfCounter;
  112730. /**
  112731. * Gets the total number of active bones rendered per frame
  112732. * @returns the total number of active bones rendered per frame
  112733. */
  112734. getActiveBones(): number;
  112735. /**
  112736. * Gets the performance counter for active bones
  112737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112738. */
  112739. get activeBonesPerfCounter(): PerfCounter;
  112740. /**
  112741. * Gets the array of active meshes
  112742. * @returns an array of AbstractMesh
  112743. */
  112744. getActiveMeshes(): SmartArray<AbstractMesh>;
  112745. /**
  112746. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  112747. * @returns a number
  112748. */
  112749. getAnimationRatio(): number;
  112750. /**
  112751. * Gets an unique Id for the current render phase
  112752. * @returns a number
  112753. */
  112754. getRenderId(): number;
  112755. /**
  112756. * Gets an unique Id for the current frame
  112757. * @returns a number
  112758. */
  112759. getFrameId(): number;
  112760. /** Call this function if you want to manually increment the render Id*/
  112761. incrementRenderId(): void;
  112762. private _createUbo;
  112763. /**
  112764. * Use this method to simulate a pointer move on a mesh
  112765. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112766. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112767. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112768. * @returns the current scene
  112769. */
  112770. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112771. /**
  112772. * Use this method to simulate a pointer down on a mesh
  112773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112776. * @returns the current scene
  112777. */
  112778. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112779. /**
  112780. * Use this method to simulate a pointer up on a mesh
  112781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112784. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  112785. * @returns the current scene
  112786. */
  112787. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  112788. /**
  112789. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  112790. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  112791. * @returns true if the pointer was captured
  112792. */
  112793. isPointerCaptured(pointerId?: number): boolean;
  112794. /**
  112795. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  112796. * @param attachUp defines if you want to attach events to pointerup
  112797. * @param attachDown defines if you want to attach events to pointerdown
  112798. * @param attachMove defines if you want to attach events to pointermove
  112799. */
  112800. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  112801. /** Detaches all event handlers*/
  112802. detachControl(): void;
  112803. /**
  112804. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  112805. * Delay loaded resources are not taking in account
  112806. * @return true if all required resources are ready
  112807. */
  112808. isReady(): boolean;
  112809. /** Resets all cached information relative to material (including effect and visibility) */
  112810. resetCachedMaterial(): void;
  112811. /**
  112812. * Registers a function to be called before every frame render
  112813. * @param func defines the function to register
  112814. */
  112815. registerBeforeRender(func: () => void): void;
  112816. /**
  112817. * Unregisters a function called before every frame render
  112818. * @param func defines the function to unregister
  112819. */
  112820. unregisterBeforeRender(func: () => void): void;
  112821. /**
  112822. * Registers a function to be called after every frame render
  112823. * @param func defines the function to register
  112824. */
  112825. registerAfterRender(func: () => void): void;
  112826. /**
  112827. * Unregisters a function called after every frame render
  112828. * @param func defines the function to unregister
  112829. */
  112830. unregisterAfterRender(func: () => void): void;
  112831. private _executeOnceBeforeRender;
  112832. /**
  112833. * The provided function will run before render once and will be disposed afterwards.
  112834. * A timeout delay can be provided so that the function will be executed in N ms.
  112835. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  112836. * @param func The function to be executed.
  112837. * @param timeout optional delay in ms
  112838. */
  112839. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  112840. /** @hidden */
  112841. _addPendingData(data: any): void;
  112842. /** @hidden */
  112843. _removePendingData(data: any): void;
  112844. /**
  112845. * Returns the number of items waiting to be loaded
  112846. * @returns the number of items waiting to be loaded
  112847. */
  112848. getWaitingItemsCount(): number;
  112849. /**
  112850. * Returns a boolean indicating if the scene is still loading data
  112851. */
  112852. get isLoading(): boolean;
  112853. /**
  112854. * Registers a function to be executed when the scene is ready
  112855. * @param {Function} func - the function to be executed
  112856. */
  112857. executeWhenReady(func: () => void): void;
  112858. /**
  112859. * Returns a promise that resolves when the scene is ready
  112860. * @returns A promise that resolves when the scene is ready
  112861. */
  112862. whenReadyAsync(): Promise<void>;
  112863. /** @hidden */
  112864. _checkIsReady(): void;
  112865. /**
  112866. * Gets all animatable attached to the scene
  112867. */
  112868. get animatables(): Animatable[];
  112869. /**
  112870. * Resets the last animation time frame.
  112871. * Useful to override when animations start running when loading a scene for the first time.
  112872. */
  112873. resetLastAnimationTimeFrame(): void;
  112874. /**
  112875. * Gets the current view matrix
  112876. * @returns a Matrix
  112877. */
  112878. getViewMatrix(): Matrix;
  112879. /**
  112880. * Gets the current projection matrix
  112881. * @returns a Matrix
  112882. */
  112883. getProjectionMatrix(): Matrix;
  112884. /**
  112885. * Gets the current transform matrix
  112886. * @returns a Matrix made of View * Projection
  112887. */
  112888. getTransformMatrix(): Matrix;
  112889. /**
  112890. * Sets the current transform matrix
  112891. * @param viewL defines the View matrix to use
  112892. * @param projectionL defines the Projection matrix to use
  112893. * @param viewR defines the right View matrix to use (if provided)
  112894. * @param projectionR defines the right Projection matrix to use (if provided)
  112895. */
  112896. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  112897. /**
  112898. * Gets the uniform buffer used to store scene data
  112899. * @returns a UniformBuffer
  112900. */
  112901. getSceneUniformBuffer(): UniformBuffer;
  112902. /**
  112903. * Gets an unique (relatively to the current scene) Id
  112904. * @returns an unique number for the scene
  112905. */
  112906. getUniqueId(): number;
  112907. /**
  112908. * Add a mesh to the list of scene's meshes
  112909. * @param newMesh defines the mesh to add
  112910. * @param recursive if all child meshes should also be added to the scene
  112911. */
  112912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  112913. /**
  112914. * Remove a mesh for the list of scene's meshes
  112915. * @param toRemove defines the mesh to remove
  112916. * @param recursive if all child meshes should also be removed from the scene
  112917. * @returns the index where the mesh was in the mesh list
  112918. */
  112919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  112920. /**
  112921. * Add a transform node to the list of scene's transform nodes
  112922. * @param newTransformNode defines the transform node to add
  112923. */
  112924. addTransformNode(newTransformNode: TransformNode): void;
  112925. /**
  112926. * Remove a transform node for the list of scene's transform nodes
  112927. * @param toRemove defines the transform node to remove
  112928. * @returns the index where the transform node was in the transform node list
  112929. */
  112930. removeTransformNode(toRemove: TransformNode): number;
  112931. /**
  112932. * Remove a skeleton for the list of scene's skeletons
  112933. * @param toRemove defines the skeleton to remove
  112934. * @returns the index where the skeleton was in the skeleton list
  112935. */
  112936. removeSkeleton(toRemove: Skeleton): number;
  112937. /**
  112938. * Remove a morph target for the list of scene's morph targets
  112939. * @param toRemove defines the morph target to remove
  112940. * @returns the index where the morph target was in the morph target list
  112941. */
  112942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  112943. /**
  112944. * Remove a light for the list of scene's lights
  112945. * @param toRemove defines the light to remove
  112946. * @returns the index where the light was in the light list
  112947. */
  112948. removeLight(toRemove: Light): number;
  112949. /**
  112950. * Remove a camera for the list of scene's cameras
  112951. * @param toRemove defines the camera to remove
  112952. * @returns the index where the camera was in the camera list
  112953. */
  112954. removeCamera(toRemove: Camera): number;
  112955. /**
  112956. * Remove a particle system for the list of scene's particle systems
  112957. * @param toRemove defines the particle system to remove
  112958. * @returns the index where the particle system was in the particle system list
  112959. */
  112960. removeParticleSystem(toRemove: IParticleSystem): number;
  112961. /**
  112962. * Remove a animation for the list of scene's animations
  112963. * @param toRemove defines the animation to remove
  112964. * @returns the index where the animation was in the animation list
  112965. */
  112966. removeAnimation(toRemove: Animation): number;
  112967. /**
  112968. * Will stop the animation of the given target
  112969. * @param target - the target
  112970. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  112971. * @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)
  112972. */
  112973. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  112974. /**
  112975. * Removes the given animation group from this scene.
  112976. * @param toRemove The animation group to remove
  112977. * @returns The index of the removed animation group
  112978. */
  112979. removeAnimationGroup(toRemove: AnimationGroup): number;
  112980. /**
  112981. * Removes the given multi-material from this scene.
  112982. * @param toRemove The multi-material to remove
  112983. * @returns The index of the removed multi-material
  112984. */
  112985. removeMultiMaterial(toRemove: MultiMaterial): number;
  112986. /**
  112987. * Removes the given material from this scene.
  112988. * @param toRemove The material to remove
  112989. * @returns The index of the removed material
  112990. */
  112991. removeMaterial(toRemove: Material): number;
  112992. /**
  112993. * Removes the given action manager from this scene.
  112994. * @param toRemove The action manager to remove
  112995. * @returns The index of the removed action manager
  112996. */
  112997. removeActionManager(toRemove: AbstractActionManager): number;
  112998. /**
  112999. * Removes the given texture from this scene.
  113000. * @param toRemove The texture to remove
  113001. * @returns The index of the removed texture
  113002. */
  113003. removeTexture(toRemove: BaseTexture): number;
  113004. /**
  113005. * Adds the given light to this scene
  113006. * @param newLight The light to add
  113007. */
  113008. addLight(newLight: Light): void;
  113009. /**
  113010. * Sorts the list list based on light priorities
  113011. */
  113012. sortLightsByPriority(): void;
  113013. /**
  113014. * Adds the given camera to this scene
  113015. * @param newCamera The camera to add
  113016. */
  113017. addCamera(newCamera: Camera): void;
  113018. /**
  113019. * Adds the given skeleton to this scene
  113020. * @param newSkeleton The skeleton to add
  113021. */
  113022. addSkeleton(newSkeleton: Skeleton): void;
  113023. /**
  113024. * Adds the given particle system to this scene
  113025. * @param newParticleSystem The particle system to add
  113026. */
  113027. addParticleSystem(newParticleSystem: IParticleSystem): void;
  113028. /**
  113029. * Adds the given animation to this scene
  113030. * @param newAnimation The animation to add
  113031. */
  113032. addAnimation(newAnimation: Animation): void;
  113033. /**
  113034. * Adds the given animation group to this scene.
  113035. * @param newAnimationGroup The animation group to add
  113036. */
  113037. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  113038. /**
  113039. * Adds the given multi-material to this scene
  113040. * @param newMultiMaterial The multi-material to add
  113041. */
  113042. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  113043. /**
  113044. * Adds the given material to this scene
  113045. * @param newMaterial The material to add
  113046. */
  113047. addMaterial(newMaterial: Material): void;
  113048. /**
  113049. * Adds the given morph target to this scene
  113050. * @param newMorphTargetManager The morph target to add
  113051. */
  113052. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  113053. /**
  113054. * Adds the given geometry to this scene
  113055. * @param newGeometry The geometry to add
  113056. */
  113057. addGeometry(newGeometry: Geometry): void;
  113058. /**
  113059. * Adds the given action manager to this scene
  113060. * @param newActionManager The action manager to add
  113061. */
  113062. addActionManager(newActionManager: AbstractActionManager): void;
  113063. /**
  113064. * Adds the given texture to this scene.
  113065. * @param newTexture The texture to add
  113066. */
  113067. addTexture(newTexture: BaseTexture): void;
  113068. /**
  113069. * Switch active camera
  113070. * @param newCamera defines the new active camera
  113071. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  113072. */
  113073. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  113074. /**
  113075. * sets the active camera of the scene using its ID
  113076. * @param id defines the camera's ID
  113077. * @return the new active camera or null if none found.
  113078. */
  113079. setActiveCameraByID(id: string): Nullable<Camera>;
  113080. /**
  113081. * sets the active camera of the scene using its name
  113082. * @param name defines the camera's name
  113083. * @returns the new active camera or null if none found.
  113084. */
  113085. setActiveCameraByName(name: string): Nullable<Camera>;
  113086. /**
  113087. * get an animation group using its name
  113088. * @param name defines the material's name
  113089. * @return the animation group or null if none found.
  113090. */
  113091. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  113092. /**
  113093. * Get a material using its unique id
  113094. * @param uniqueId defines the material's unique id
  113095. * @return the material or null if none found.
  113096. */
  113097. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  113098. /**
  113099. * get a material using its id
  113100. * @param id defines the material's ID
  113101. * @return the material or null if none found.
  113102. */
  113103. getMaterialByID(id: string): Nullable<Material>;
  113104. /**
  113105. * Gets a the last added material using a given id
  113106. * @param id defines the material's ID
  113107. * @return the last material with the given id or null if none found.
  113108. */
  113109. getLastMaterialByID(id: string): Nullable<Material>;
  113110. /**
  113111. * Gets a material using its name
  113112. * @param name defines the material's name
  113113. * @return the material or null if none found.
  113114. */
  113115. getMaterialByName(name: string): Nullable<Material>;
  113116. /**
  113117. * Get a texture using its unique id
  113118. * @param uniqueId defines the texture's unique id
  113119. * @return the texture or null if none found.
  113120. */
  113121. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  113122. /**
  113123. * Gets a camera using its id
  113124. * @param id defines the id to look for
  113125. * @returns the camera or null if not found
  113126. */
  113127. getCameraByID(id: string): Nullable<Camera>;
  113128. /**
  113129. * Gets a camera using its unique id
  113130. * @param uniqueId defines the unique id to look for
  113131. * @returns the camera or null if not found
  113132. */
  113133. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  113134. /**
  113135. * Gets a camera using its name
  113136. * @param name defines the camera's name
  113137. * @return the camera or null if none found.
  113138. */
  113139. getCameraByName(name: string): Nullable<Camera>;
  113140. /**
  113141. * Gets a bone using its id
  113142. * @param id defines the bone's id
  113143. * @return the bone or null if not found
  113144. */
  113145. getBoneByID(id: string): Nullable<Bone>;
  113146. /**
  113147. * Gets a bone using its id
  113148. * @param name defines the bone's name
  113149. * @return the bone or null if not found
  113150. */
  113151. getBoneByName(name: string): Nullable<Bone>;
  113152. /**
  113153. * Gets a light node using its name
  113154. * @param name defines the the light's name
  113155. * @return the light or null if none found.
  113156. */
  113157. getLightByName(name: string): Nullable<Light>;
  113158. /**
  113159. * Gets a light node using its id
  113160. * @param id defines the light's id
  113161. * @return the light or null if none found.
  113162. */
  113163. getLightByID(id: string): Nullable<Light>;
  113164. /**
  113165. * Gets a light node using its scene-generated unique ID
  113166. * @param uniqueId defines the light's unique id
  113167. * @return the light or null if none found.
  113168. */
  113169. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  113170. /**
  113171. * Gets a particle system by id
  113172. * @param id defines the particle system id
  113173. * @return the corresponding system or null if none found
  113174. */
  113175. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  113176. /**
  113177. * Gets a geometry using its ID
  113178. * @param id defines the geometry's id
  113179. * @return the geometry or null if none found.
  113180. */
  113181. getGeometryByID(id: string): Nullable<Geometry>;
  113182. private _getGeometryByUniqueID;
  113183. /**
  113184. * Add a new geometry to this scene
  113185. * @param geometry defines the geometry to be added to the scene.
  113186. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  113187. * @return a boolean defining if the geometry was added or not
  113188. */
  113189. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  113190. /**
  113191. * Removes an existing geometry
  113192. * @param geometry defines the geometry to be removed from the scene
  113193. * @return a boolean defining if the geometry was removed or not
  113194. */
  113195. removeGeometry(geometry: Geometry): boolean;
  113196. /**
  113197. * Gets the list of geometries attached to the scene
  113198. * @returns an array of Geometry
  113199. */
  113200. getGeometries(): Geometry[];
  113201. /**
  113202. * Gets the first added mesh found of a given ID
  113203. * @param id defines the id to search for
  113204. * @return the mesh found or null if not found at all
  113205. */
  113206. getMeshByID(id: string): Nullable<AbstractMesh>;
  113207. /**
  113208. * Gets a list of meshes using their id
  113209. * @param id defines the id to search for
  113210. * @returns a list of meshes
  113211. */
  113212. getMeshesByID(id: string): Array<AbstractMesh>;
  113213. /**
  113214. * Gets the first added transform node found of a given ID
  113215. * @param id defines the id to search for
  113216. * @return the found transform node or null if not found at all.
  113217. */
  113218. getTransformNodeByID(id: string): Nullable<TransformNode>;
  113219. /**
  113220. * Gets a transform node with its auto-generated unique id
  113221. * @param uniqueId efines the unique id to search for
  113222. * @return the found transform node or null if not found at all.
  113223. */
  113224. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  113225. /**
  113226. * Gets a list of transform nodes using their id
  113227. * @param id defines the id to search for
  113228. * @returns a list of transform nodes
  113229. */
  113230. getTransformNodesByID(id: string): Array<TransformNode>;
  113231. /**
  113232. * Gets a mesh with its auto-generated unique id
  113233. * @param uniqueId defines the unique id to search for
  113234. * @return the found mesh or null if not found at all.
  113235. */
  113236. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  113237. /**
  113238. * Gets a the last added mesh using a given id
  113239. * @param id defines the id to search for
  113240. * @return the found mesh or null if not found at all.
  113241. */
  113242. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  113243. /**
  113244. * Gets a the last added node (Mesh, Camera, Light) using a given id
  113245. * @param id defines the id to search for
  113246. * @return the found node or null if not found at all
  113247. */
  113248. getLastEntryByID(id: string): Nullable<Node>;
  113249. /**
  113250. * Gets a node (Mesh, Camera, Light) using a given id
  113251. * @param id defines the id to search for
  113252. * @return the found node or null if not found at all
  113253. */
  113254. getNodeByID(id: string): Nullable<Node>;
  113255. /**
  113256. * Gets a node (Mesh, Camera, Light) using a given name
  113257. * @param name defines the name to search for
  113258. * @return the found node or null if not found at all.
  113259. */
  113260. getNodeByName(name: string): Nullable<Node>;
  113261. /**
  113262. * Gets a mesh using a given name
  113263. * @param name defines the name to search for
  113264. * @return the found mesh or null if not found at all.
  113265. */
  113266. getMeshByName(name: string): Nullable<AbstractMesh>;
  113267. /**
  113268. * Gets a transform node using a given name
  113269. * @param name defines the name to search for
  113270. * @return the found transform node or null if not found at all.
  113271. */
  113272. getTransformNodeByName(name: string): Nullable<TransformNode>;
  113273. /**
  113274. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  113275. * @param id defines the id to search for
  113276. * @return the found skeleton or null if not found at all.
  113277. */
  113278. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  113279. /**
  113280. * Gets a skeleton using a given auto generated unique id
  113281. * @param uniqueId defines the unique id to search for
  113282. * @return the found skeleton or null if not found at all.
  113283. */
  113284. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  113285. /**
  113286. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  113287. * @param id defines the id to search for
  113288. * @return the found skeleton or null if not found at all.
  113289. */
  113290. getSkeletonById(id: string): Nullable<Skeleton>;
  113291. /**
  113292. * Gets a skeleton using a given name
  113293. * @param name defines the name to search for
  113294. * @return the found skeleton or null if not found at all.
  113295. */
  113296. getSkeletonByName(name: string): Nullable<Skeleton>;
  113297. /**
  113298. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  113299. * @param id defines the id to search for
  113300. * @return the found morph target manager or null if not found at all.
  113301. */
  113302. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  113303. /**
  113304. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  113305. * @param id defines the id to search for
  113306. * @return the found morph target or null if not found at all.
  113307. */
  113308. getMorphTargetById(id: string): Nullable<MorphTarget>;
  113309. /**
  113310. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  113311. * @param name defines the name to search for
  113312. * @return the found morph target or null if not found at all.
  113313. */
  113314. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  113315. /**
  113316. * Gets a boolean indicating if the given mesh is active
  113317. * @param mesh defines the mesh to look for
  113318. * @returns true if the mesh is in the active list
  113319. */
  113320. isActiveMesh(mesh: AbstractMesh): boolean;
  113321. /**
  113322. * Return a unique id as a string which can serve as an identifier for the scene
  113323. */
  113324. get uid(): string;
  113325. /**
  113326. * Add an externaly attached data from its key.
  113327. * This method call will fail and return false, if such key already exists.
  113328. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  113329. * @param key the unique key that identifies the data
  113330. * @param data the data object to associate to the key for this Engine instance
  113331. * @return true if no such key were already present and the data was added successfully, false otherwise
  113332. */
  113333. addExternalData<T>(key: string, data: T): boolean;
  113334. /**
  113335. * Get an externaly attached data from its key
  113336. * @param key the unique key that identifies the data
  113337. * @return the associated data, if present (can be null), or undefined if not present
  113338. */
  113339. getExternalData<T>(key: string): Nullable<T>;
  113340. /**
  113341. * Get an externaly attached data from its key, create it using a factory if it's not already present
  113342. * @param key the unique key that identifies the data
  113343. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  113344. * @return the associated data, can be null if the factory returned null.
  113345. */
  113346. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  113347. /**
  113348. * Remove an externaly attached data from the Engine instance
  113349. * @param key the unique key that identifies the data
  113350. * @return true if the data was successfully removed, false if it doesn't exist
  113351. */
  113352. removeExternalData(key: string): boolean;
  113353. private _evaluateSubMesh;
  113354. /**
  113355. * Clear the processed materials smart array preventing retention point in material dispose.
  113356. */
  113357. freeProcessedMaterials(): void;
  113358. private _preventFreeActiveMeshesAndRenderingGroups;
  113359. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  113360. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  113361. * when disposing several meshes in a row or a hierarchy of meshes.
  113362. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  113363. */
  113364. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  113365. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  113366. /**
  113367. * Clear the active meshes smart array preventing retention point in mesh dispose.
  113368. */
  113369. freeActiveMeshes(): void;
  113370. /**
  113371. * Clear the info related to rendering groups preventing retention points during dispose.
  113372. */
  113373. freeRenderingGroups(): void;
  113374. /** @hidden */
  113375. _isInIntermediateRendering(): boolean;
  113376. /**
  113377. * Lambda returning the list of potentially active meshes.
  113378. */
  113379. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  113380. /**
  113381. * Lambda returning the list of potentially active sub meshes.
  113382. */
  113383. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  113384. /**
  113385. * Lambda returning the list of potentially intersecting sub meshes.
  113386. */
  113387. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  113388. /**
  113389. * Lambda returning the list of potentially colliding sub meshes.
  113390. */
  113391. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  113392. private _activeMeshesFrozen;
  113393. private _skipEvaluateActiveMeshesCompletely;
  113394. /**
  113395. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  113396. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  113397. * @returns the current scene
  113398. */
  113399. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  113400. /**
  113401. * Use this function to restart evaluating active meshes on every frame
  113402. * @returns the current scene
  113403. */
  113404. unfreezeActiveMeshes(): Scene;
  113405. private _evaluateActiveMeshes;
  113406. private _activeMesh;
  113407. /**
  113408. * Update the transform matrix to update from the current active camera
  113409. * @param force defines a boolean used to force the update even if cache is up to date
  113410. */
  113411. updateTransformMatrix(force?: boolean): void;
  113412. private _bindFrameBuffer;
  113413. /** @hidden */
  113414. _allowPostProcessClearColor: boolean;
  113415. /** @hidden */
  113416. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  113417. private _processSubCameras;
  113418. private _checkIntersections;
  113419. /** @hidden */
  113420. _advancePhysicsEngineStep(step: number): void;
  113421. /**
  113422. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  113423. */
  113424. getDeterministicFrameTime: () => number;
  113425. /** @hidden */
  113426. _animate(): void;
  113427. /** Execute all animations (for a frame) */
  113428. animate(): void;
  113429. /**
  113430. * Render the scene
  113431. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  113432. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  113433. */
  113434. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  113435. /**
  113436. * Freeze all materials
  113437. * A frozen material will not be updatable but should be faster to render
  113438. */
  113439. freezeMaterials(): void;
  113440. /**
  113441. * Unfreeze all materials
  113442. * A frozen material will not be updatable but should be faster to render
  113443. */
  113444. unfreezeMaterials(): void;
  113445. /**
  113446. * Releases all held ressources
  113447. */
  113448. dispose(): void;
  113449. /**
  113450. * Gets if the scene is already disposed
  113451. */
  113452. get isDisposed(): boolean;
  113453. /**
  113454. * Call this function to reduce memory footprint of the scene.
  113455. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  113456. */
  113457. clearCachedVertexData(): void;
  113458. /**
  113459. * This function will remove the local cached buffer data from texture.
  113460. * It will save memory but will prevent the texture from being rebuilt
  113461. */
  113462. cleanCachedTextureBuffer(): void;
  113463. /**
  113464. * Get the world extend vectors with an optional filter
  113465. *
  113466. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  113467. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  113468. */
  113469. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  113470. min: Vector3;
  113471. max: Vector3;
  113472. };
  113473. /**
  113474. * Creates a ray that can be used to pick in the scene
  113475. * @param x defines the x coordinate of the origin (on-screen)
  113476. * @param y defines the y coordinate of the origin (on-screen)
  113477. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113478. * @param camera defines the camera to use for the picking
  113479. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113480. * @returns a Ray
  113481. */
  113482. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  113483. /**
  113484. * Creates a ray that can be used to pick in the scene
  113485. * @param x defines the x coordinate of the origin (on-screen)
  113486. * @param y defines the y coordinate of the origin (on-screen)
  113487. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113488. * @param result defines the ray where to store the picking ray
  113489. * @param camera defines the camera to use for the picking
  113490. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113491. * @returns the current scene
  113492. */
  113493. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  113494. /**
  113495. * Creates a ray that can be used to pick in the scene
  113496. * @param x defines the x coordinate of the origin (on-screen)
  113497. * @param y defines the y coordinate of the origin (on-screen)
  113498. * @param camera defines the camera to use for the picking
  113499. * @returns a Ray
  113500. */
  113501. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  113502. /**
  113503. * Creates a ray that can be used to pick in the scene
  113504. * @param x defines the x coordinate of the origin (on-screen)
  113505. * @param y defines the y coordinate of the origin (on-screen)
  113506. * @param result defines the ray where to store the picking ray
  113507. * @param camera defines the camera to use for the picking
  113508. * @returns the current scene
  113509. */
  113510. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  113511. /** Launch a ray to try to pick a mesh in the scene
  113512. * @param x position on screen
  113513. * @param y position on screen
  113514. * @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
  113515. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113516. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113517. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113518. * @returns a PickingInfo
  113519. */
  113520. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113521. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  113522. * @param x position on screen
  113523. * @param y position on screen
  113524. * @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
  113525. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113526. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113527. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  113528. */
  113529. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  113530. /** Use the given ray to pick a mesh in the scene
  113531. * @param ray The ray to use to pick meshes
  113532. * @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
  113533. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113534. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113535. * @returns a PickingInfo
  113536. */
  113537. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113538. /**
  113539. * Launch a ray to try to pick a mesh in the scene
  113540. * @param x X position on screen
  113541. * @param y Y position on screen
  113542. * @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
  113543. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113544. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113545. * @returns an array of PickingInfo
  113546. */
  113547. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113548. /**
  113549. * Launch a ray to try to pick a mesh in the scene
  113550. * @param ray Ray to use
  113551. * @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
  113552. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113553. * @returns an array of PickingInfo
  113554. */
  113555. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113556. /**
  113557. * Force the value of meshUnderPointer
  113558. * @param mesh defines the mesh to use
  113559. */
  113560. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  113561. /**
  113562. * Gets the mesh under the pointer
  113563. * @returns a Mesh or null if no mesh is under the pointer
  113564. */
  113565. getPointerOverMesh(): Nullable<AbstractMesh>;
  113566. /** @hidden */
  113567. _rebuildGeometries(): void;
  113568. /** @hidden */
  113569. _rebuildTextures(): void;
  113570. private _getByTags;
  113571. /**
  113572. * Get a list of meshes by tags
  113573. * @param tagsQuery defines the tags query to use
  113574. * @param forEach defines a predicate used to filter results
  113575. * @returns an array of Mesh
  113576. */
  113577. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  113578. /**
  113579. * Get a list of cameras by tags
  113580. * @param tagsQuery defines the tags query to use
  113581. * @param forEach defines a predicate used to filter results
  113582. * @returns an array of Camera
  113583. */
  113584. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  113585. /**
  113586. * Get a list of lights by tags
  113587. * @param tagsQuery defines the tags query to use
  113588. * @param forEach defines a predicate used to filter results
  113589. * @returns an array of Light
  113590. */
  113591. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  113592. /**
  113593. * Get a list of materials by tags
  113594. * @param tagsQuery defines the tags query to use
  113595. * @param forEach defines a predicate used to filter results
  113596. * @returns an array of Material
  113597. */
  113598. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  113599. /**
  113600. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113601. * This allowed control for front to back rendering or reversly depending of the special needs.
  113602. *
  113603. * @param renderingGroupId The rendering group id corresponding to its index
  113604. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113605. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113606. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113607. */
  113608. 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;
  113609. /**
  113610. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113611. *
  113612. * @param renderingGroupId The rendering group id corresponding to its index
  113613. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113614. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113615. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113616. */
  113617. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113618. /**
  113619. * Gets the current auto clear configuration for one rendering group of the rendering
  113620. * manager.
  113621. * @param index the rendering group index to get the information for
  113622. * @returns The auto clear setup for the requested rendering group
  113623. */
  113624. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113625. private _blockMaterialDirtyMechanism;
  113626. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  113627. get blockMaterialDirtyMechanism(): boolean;
  113628. set blockMaterialDirtyMechanism(value: boolean);
  113629. /**
  113630. * Will flag all materials as dirty to trigger new shader compilation
  113631. * @param flag defines the flag used to specify which material part must be marked as dirty
  113632. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  113633. */
  113634. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113635. /** @hidden */
  113636. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  113637. /** @hidden */
  113638. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113639. /** @hidden */
  113640. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  113641. /** @hidden */
  113642. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  113643. /** @hidden */
  113644. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  113645. /** @hidden */
  113646. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113647. }
  113648. }
  113649. declare module BABYLON {
  113650. /**
  113651. * Set of assets to keep when moving a scene into an asset container.
  113652. */
  113653. export class KeepAssets extends AbstractScene {
  113654. }
  113655. /**
  113656. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  113657. */
  113658. export class InstantiatedEntries {
  113659. /**
  113660. * List of new root nodes (eg. nodes with no parent)
  113661. */
  113662. rootNodes: TransformNode[];
  113663. /**
  113664. * List of new skeletons
  113665. */
  113666. skeletons: Skeleton[];
  113667. /**
  113668. * List of new animation groups
  113669. */
  113670. animationGroups: AnimationGroup[];
  113671. }
  113672. /**
  113673. * Container with a set of assets that can be added or removed from a scene.
  113674. */
  113675. export class AssetContainer extends AbstractScene {
  113676. private _wasAddedToScene;
  113677. /**
  113678. * The scene the AssetContainer belongs to.
  113679. */
  113680. scene: Scene;
  113681. /**
  113682. * Instantiates an AssetContainer.
  113683. * @param scene The scene the AssetContainer belongs to.
  113684. */
  113685. constructor(scene: Scene);
  113686. /**
  113687. * Instantiate or clone all meshes and add the new ones to the scene.
  113688. * Skeletons and animation groups will all be cloned
  113689. * @param nameFunction defines an optional function used to get new names for clones
  113690. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  113691. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  113692. */
  113693. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  113694. /**
  113695. * Adds all the assets from the container to the scene.
  113696. */
  113697. addAllToScene(): void;
  113698. /**
  113699. * Removes all the assets in the container from the scene
  113700. */
  113701. removeAllFromScene(): void;
  113702. /**
  113703. * Disposes all the assets in the container
  113704. */
  113705. dispose(): void;
  113706. private _moveAssets;
  113707. /**
  113708. * Removes all the assets contained in the scene and adds them to the container.
  113709. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  113710. */
  113711. moveAllFromScene(keepAssets?: KeepAssets): void;
  113712. /**
  113713. * 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.
  113714. * @returns the root mesh
  113715. */
  113716. createRootMesh(): Mesh;
  113717. /**
  113718. * Merge animations (direct and animation groups) from this asset container into a scene
  113719. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113720. * @param animatables set of animatables to retarget to a node from the scene
  113721. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  113722. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  113723. */
  113724. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  113725. }
  113726. }
  113727. declare module BABYLON {
  113728. /**
  113729. * Defines how the parser contract is defined.
  113730. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  113731. */
  113732. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  113733. /**
  113734. * Defines how the individual parser contract is defined.
  113735. * These parser can parse an individual asset
  113736. */
  113737. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  113738. /**
  113739. * Base class of the scene acting as a container for the different elements composing a scene.
  113740. * This class is dynamically extended by the different components of the scene increasing
  113741. * flexibility and reducing coupling
  113742. */
  113743. export abstract class AbstractScene {
  113744. /**
  113745. * Stores the list of available parsers in the application.
  113746. */
  113747. private static _BabylonFileParsers;
  113748. /**
  113749. * Stores the list of available individual parsers in the application.
  113750. */
  113751. private static _IndividualBabylonFileParsers;
  113752. /**
  113753. * Adds a parser in the list of available ones
  113754. * @param name Defines the name of the parser
  113755. * @param parser Defines the parser to add
  113756. */
  113757. static AddParser(name: string, parser: BabylonFileParser): void;
  113758. /**
  113759. * Gets a general parser from the list of avaialble ones
  113760. * @param name Defines the name of the parser
  113761. * @returns the requested parser or null
  113762. */
  113763. static GetParser(name: string): Nullable<BabylonFileParser>;
  113764. /**
  113765. * Adds n individual parser in the list of available ones
  113766. * @param name Defines the name of the parser
  113767. * @param parser Defines the parser to add
  113768. */
  113769. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  113770. /**
  113771. * Gets an individual parser from the list of avaialble ones
  113772. * @param name Defines the name of the parser
  113773. * @returns the requested parser or null
  113774. */
  113775. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  113776. /**
  113777. * Parser json data and populate both a scene and its associated container object
  113778. * @param jsonData Defines the data to parse
  113779. * @param scene Defines the scene to parse the data for
  113780. * @param container Defines the container attached to the parsing sequence
  113781. * @param rootUrl Defines the root url of the data
  113782. */
  113783. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  113784. /**
  113785. * Gets the list of root nodes (ie. nodes with no parent)
  113786. */
  113787. rootNodes: Node[];
  113788. /** All of the cameras added to this scene
  113789. * @see http://doc.babylonjs.com/babylon101/cameras
  113790. */
  113791. cameras: Camera[];
  113792. /**
  113793. * All of the lights added to this scene
  113794. * @see http://doc.babylonjs.com/babylon101/lights
  113795. */
  113796. lights: Light[];
  113797. /**
  113798. * All of the (abstract) meshes added to this scene
  113799. */
  113800. meshes: AbstractMesh[];
  113801. /**
  113802. * The list of skeletons added to the scene
  113803. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  113804. */
  113805. skeletons: Skeleton[];
  113806. /**
  113807. * All of the particle systems added to this scene
  113808. * @see http://doc.babylonjs.com/babylon101/particles
  113809. */
  113810. particleSystems: IParticleSystem[];
  113811. /**
  113812. * Gets a list of Animations associated with the scene
  113813. */
  113814. animations: Animation[];
  113815. /**
  113816. * All of the animation groups added to this scene
  113817. * @see http://doc.babylonjs.com/how_to/group
  113818. */
  113819. animationGroups: AnimationGroup[];
  113820. /**
  113821. * All of the multi-materials added to this scene
  113822. * @see http://doc.babylonjs.com/how_to/multi_materials
  113823. */
  113824. multiMaterials: MultiMaterial[];
  113825. /**
  113826. * All of the materials added to this scene
  113827. * In the context of a Scene, it is not supposed to be modified manually.
  113828. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  113829. * Note also that the order of the Material within the array is not significant and might change.
  113830. * @see http://doc.babylonjs.com/babylon101/materials
  113831. */
  113832. materials: Material[];
  113833. /**
  113834. * The list of morph target managers added to the scene
  113835. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113836. */
  113837. morphTargetManagers: MorphTargetManager[];
  113838. /**
  113839. * The list of geometries used in the scene.
  113840. */
  113841. geometries: Geometry[];
  113842. /**
  113843. * All of the tranform nodes added to this scene
  113844. * In the context of a Scene, it is not supposed to be modified manually.
  113845. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  113846. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  113847. * @see http://doc.babylonjs.com/how_to/transformnode
  113848. */
  113849. transformNodes: TransformNode[];
  113850. /**
  113851. * ActionManagers available on the scene.
  113852. */
  113853. actionManagers: AbstractActionManager[];
  113854. /**
  113855. * Textures to keep.
  113856. */
  113857. textures: BaseTexture[];
  113858. /**
  113859. * Environment texture for the scene
  113860. */
  113861. environmentTexture: Nullable<BaseTexture>;
  113862. /**
  113863. * @returns all meshes, lights, cameras, transformNodes and bones
  113864. */
  113865. getNodes(): Array<Node>;
  113866. }
  113867. }
  113868. declare module BABYLON {
  113869. /**
  113870. * Interface used to define options for Sound class
  113871. */
  113872. export interface ISoundOptions {
  113873. /**
  113874. * Does the sound autoplay once loaded.
  113875. */
  113876. autoplay?: boolean;
  113877. /**
  113878. * Does the sound loop after it finishes playing once.
  113879. */
  113880. loop?: boolean;
  113881. /**
  113882. * Sound's volume
  113883. */
  113884. volume?: number;
  113885. /**
  113886. * Is it a spatial sound?
  113887. */
  113888. spatialSound?: boolean;
  113889. /**
  113890. * Maximum distance to hear that sound
  113891. */
  113892. maxDistance?: number;
  113893. /**
  113894. * Uses user defined attenuation function
  113895. */
  113896. useCustomAttenuation?: boolean;
  113897. /**
  113898. * Define the roll off factor of spatial sounds.
  113899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113900. */
  113901. rolloffFactor?: number;
  113902. /**
  113903. * Define the reference distance the sound should be heard perfectly.
  113904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113905. */
  113906. refDistance?: number;
  113907. /**
  113908. * Define the distance attenuation model the sound will follow.
  113909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113910. */
  113911. distanceModel?: string;
  113912. /**
  113913. * Defines the playback speed (1 by default)
  113914. */
  113915. playbackRate?: number;
  113916. /**
  113917. * Defines if the sound is from a streaming source
  113918. */
  113919. streaming?: boolean;
  113920. /**
  113921. * Defines an optional length (in seconds) inside the sound file
  113922. */
  113923. length?: number;
  113924. /**
  113925. * Defines an optional offset (in seconds) inside the sound file
  113926. */
  113927. offset?: number;
  113928. /**
  113929. * If true, URLs will not be required to state the audio file codec to use.
  113930. */
  113931. skipCodecCheck?: boolean;
  113932. }
  113933. /**
  113934. * Defines a sound that can be played in the application.
  113935. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  113936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113937. */
  113938. export class Sound {
  113939. /**
  113940. * The name of the sound in the scene.
  113941. */
  113942. name: string;
  113943. /**
  113944. * Does the sound autoplay once loaded.
  113945. */
  113946. autoplay: boolean;
  113947. /**
  113948. * Does the sound loop after it finishes playing once.
  113949. */
  113950. loop: boolean;
  113951. /**
  113952. * Does the sound use a custom attenuation curve to simulate the falloff
  113953. * happening when the source gets further away from the camera.
  113954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113955. */
  113956. useCustomAttenuation: boolean;
  113957. /**
  113958. * The sound track id this sound belongs to.
  113959. */
  113960. soundTrackId: number;
  113961. /**
  113962. * Is this sound currently played.
  113963. */
  113964. isPlaying: boolean;
  113965. /**
  113966. * Is this sound currently paused.
  113967. */
  113968. isPaused: boolean;
  113969. /**
  113970. * Does this sound enables spatial sound.
  113971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113972. */
  113973. spatialSound: boolean;
  113974. /**
  113975. * Define the reference distance the sound should be heard perfectly.
  113976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113977. */
  113978. refDistance: number;
  113979. /**
  113980. * Define the roll off factor of spatial sounds.
  113981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113982. */
  113983. rolloffFactor: number;
  113984. /**
  113985. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  113986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113987. */
  113988. maxDistance: number;
  113989. /**
  113990. * Define the distance attenuation model the sound will follow.
  113991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113992. */
  113993. distanceModel: string;
  113994. /**
  113995. * @hidden
  113996. * Back Compat
  113997. **/
  113998. onended: () => any;
  113999. /**
  114000. * Observable event when the current playing sound finishes.
  114001. */
  114002. onEndedObservable: Observable<Sound>;
  114003. private _panningModel;
  114004. private _playbackRate;
  114005. private _streaming;
  114006. private _startTime;
  114007. private _startOffset;
  114008. private _position;
  114009. /** @hidden */
  114010. _positionInEmitterSpace: boolean;
  114011. private _localDirection;
  114012. private _volume;
  114013. private _isReadyToPlay;
  114014. private _isDirectional;
  114015. private _readyToPlayCallback;
  114016. private _audioBuffer;
  114017. private _soundSource;
  114018. private _streamingSource;
  114019. private _soundPanner;
  114020. private _soundGain;
  114021. private _inputAudioNode;
  114022. private _outputAudioNode;
  114023. private _coneInnerAngle;
  114024. private _coneOuterAngle;
  114025. private _coneOuterGain;
  114026. private _scene;
  114027. private _connectedTransformNode;
  114028. private _customAttenuationFunction;
  114029. private _registerFunc;
  114030. private _isOutputConnected;
  114031. private _htmlAudioElement;
  114032. private _urlType;
  114033. private _length?;
  114034. private _offset?;
  114035. /** @hidden */
  114036. static _SceneComponentInitialization: (scene: Scene) => void;
  114037. /**
  114038. * Create a sound and attach it to a scene
  114039. * @param name Name of your sound
  114040. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  114041. * @param scene defines the scene the sound belongs to
  114042. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  114043. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  114044. */
  114045. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  114046. /**
  114047. * Release the sound and its associated resources
  114048. */
  114049. dispose(): void;
  114050. /**
  114051. * Gets if the sounds is ready to be played or not.
  114052. * @returns true if ready, otherwise false
  114053. */
  114054. isReady(): boolean;
  114055. private _soundLoaded;
  114056. /**
  114057. * Sets the data of the sound from an audiobuffer
  114058. * @param audioBuffer The audioBuffer containing the data
  114059. */
  114060. setAudioBuffer(audioBuffer: AudioBuffer): void;
  114061. /**
  114062. * Updates the current sounds options such as maxdistance, loop...
  114063. * @param options A JSON object containing values named as the object properties
  114064. */
  114065. updateOptions(options: ISoundOptions): void;
  114066. private _createSpatialParameters;
  114067. private _updateSpatialParameters;
  114068. /**
  114069. * Switch the panning model to HRTF:
  114070. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  114071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114072. */
  114073. switchPanningModelToHRTF(): void;
  114074. /**
  114075. * Switch the panning model to Equal Power:
  114076. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114078. */
  114079. switchPanningModelToEqualPower(): void;
  114080. private _switchPanningModel;
  114081. /**
  114082. * Connect this sound to a sound track audio node like gain...
  114083. * @param soundTrackAudioNode the sound track audio node to connect to
  114084. */
  114085. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  114086. /**
  114087. * Transform this sound into a directional source
  114088. * @param coneInnerAngle Size of the inner cone in degree
  114089. * @param coneOuterAngle Size of the outer cone in degree
  114090. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  114091. */
  114092. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  114093. /**
  114094. * Gets or sets the inner angle for the directional cone.
  114095. */
  114096. get directionalConeInnerAngle(): number;
  114097. /**
  114098. * Gets or sets the inner angle for the directional cone.
  114099. */
  114100. set directionalConeInnerAngle(value: number);
  114101. /**
  114102. * Gets or sets the outer angle for the directional cone.
  114103. */
  114104. get directionalConeOuterAngle(): number;
  114105. /**
  114106. * Gets or sets the outer angle for the directional cone.
  114107. */
  114108. set directionalConeOuterAngle(value: number);
  114109. /**
  114110. * Sets the position of the emitter if spatial sound is enabled
  114111. * @param newPosition Defines the new posisiton
  114112. */
  114113. setPosition(newPosition: Vector3): void;
  114114. /**
  114115. * Sets the local direction of the emitter if spatial sound is enabled
  114116. * @param newLocalDirection Defines the new local direction
  114117. */
  114118. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  114119. private _updateDirection;
  114120. /** @hidden */
  114121. updateDistanceFromListener(): void;
  114122. /**
  114123. * Sets a new custom attenuation function for the sound.
  114124. * @param callback Defines the function used for the attenuation
  114125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  114126. */
  114127. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  114128. /**
  114129. * Play the sound
  114130. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  114131. * @param offset (optional) Start the sound at a specific time in seconds
  114132. * @param length (optional) Sound duration (in seconds)
  114133. */
  114134. play(time?: number, offset?: number, length?: number): void;
  114135. private _onended;
  114136. /**
  114137. * Stop the sound
  114138. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  114139. */
  114140. stop(time?: number): void;
  114141. /**
  114142. * Put the sound in pause
  114143. */
  114144. pause(): void;
  114145. /**
  114146. * Sets a dedicated volume for this sounds
  114147. * @param newVolume Define the new volume of the sound
  114148. * @param time Define time for gradual change to new volume
  114149. */
  114150. setVolume(newVolume: number, time?: number): void;
  114151. /**
  114152. * Set the sound play back rate
  114153. * @param newPlaybackRate Define the playback rate the sound should be played at
  114154. */
  114155. setPlaybackRate(newPlaybackRate: number): void;
  114156. /**
  114157. * Gets the volume of the sound.
  114158. * @returns the volume of the sound
  114159. */
  114160. getVolume(): number;
  114161. /**
  114162. * Attach the sound to a dedicated mesh
  114163. * @param transformNode The transform node to connect the sound with
  114164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114165. */
  114166. attachToMesh(transformNode: TransformNode): void;
  114167. /**
  114168. * Detach the sound from the previously attached mesh
  114169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114170. */
  114171. detachFromMesh(): void;
  114172. private _onRegisterAfterWorldMatrixUpdate;
  114173. /**
  114174. * Clone the current sound in the scene.
  114175. * @returns the new sound clone
  114176. */
  114177. clone(): Nullable<Sound>;
  114178. /**
  114179. * Gets the current underlying audio buffer containing the data
  114180. * @returns the audio buffer
  114181. */
  114182. getAudioBuffer(): Nullable<AudioBuffer>;
  114183. /**
  114184. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  114185. * @returns the source node
  114186. */
  114187. getSoundSource(): Nullable<AudioBufferSourceNode>;
  114188. /**
  114189. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  114190. * @returns the gain node
  114191. */
  114192. getSoundGain(): Nullable<GainNode>;
  114193. /**
  114194. * Serializes the Sound in a JSON representation
  114195. * @returns the JSON representation of the sound
  114196. */
  114197. serialize(): any;
  114198. /**
  114199. * Parse a JSON representation of a sound to innstantiate in a given scene
  114200. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  114201. * @param scene Define the scene the new parsed sound should be created in
  114202. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  114203. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  114204. * @returns the newly parsed sound
  114205. */
  114206. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  114207. }
  114208. }
  114209. declare module BABYLON {
  114210. /**
  114211. * This defines an action helpful to play a defined sound on a triggered action.
  114212. */
  114213. export class PlaySoundAction extends Action {
  114214. private _sound;
  114215. /**
  114216. * Instantiate the action
  114217. * @param triggerOptions defines the trigger options
  114218. * @param sound defines the sound to play
  114219. * @param condition defines the trigger related conditions
  114220. */
  114221. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114222. /** @hidden */
  114223. _prepare(): void;
  114224. /**
  114225. * Execute the action and play the sound.
  114226. */
  114227. execute(): void;
  114228. /**
  114229. * Serializes the actions and its related information.
  114230. * @param parent defines the object to serialize in
  114231. * @returns the serialized object
  114232. */
  114233. serialize(parent: any): any;
  114234. }
  114235. /**
  114236. * This defines an action helpful to stop a defined sound on a triggered action.
  114237. */
  114238. export class StopSoundAction extends Action {
  114239. private _sound;
  114240. /**
  114241. * Instantiate the action
  114242. * @param triggerOptions defines the trigger options
  114243. * @param sound defines the sound to stop
  114244. * @param condition defines the trigger related conditions
  114245. */
  114246. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114247. /** @hidden */
  114248. _prepare(): void;
  114249. /**
  114250. * Execute the action and stop the sound.
  114251. */
  114252. execute(): void;
  114253. /**
  114254. * Serializes the actions and its related information.
  114255. * @param parent defines the object to serialize in
  114256. * @returns the serialized object
  114257. */
  114258. serialize(parent: any): any;
  114259. }
  114260. }
  114261. declare module BABYLON {
  114262. /**
  114263. * This defines an action responsible to change the value of a property
  114264. * by interpolating between its current value and the newly set one once triggered.
  114265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  114266. */
  114267. export class InterpolateValueAction extends Action {
  114268. /**
  114269. * Defines the path of the property where the value should be interpolated
  114270. */
  114271. propertyPath: string;
  114272. /**
  114273. * Defines the target value at the end of the interpolation.
  114274. */
  114275. value: any;
  114276. /**
  114277. * Defines the time it will take for the property to interpolate to the value.
  114278. */
  114279. duration: number;
  114280. /**
  114281. * Defines if the other scene animations should be stopped when the action has been triggered
  114282. */
  114283. stopOtherAnimations?: boolean;
  114284. /**
  114285. * Defines a callback raised once the interpolation animation has been done.
  114286. */
  114287. onInterpolationDone?: () => void;
  114288. /**
  114289. * Observable triggered once the interpolation animation has been done.
  114290. */
  114291. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  114292. private _target;
  114293. private _effectiveTarget;
  114294. private _property;
  114295. /**
  114296. * Instantiate the action
  114297. * @param triggerOptions defines the trigger options
  114298. * @param target defines the object containing the value to interpolate
  114299. * @param propertyPath defines the path to the property in the target object
  114300. * @param value defines the target value at the end of the interpolation
  114301. * @param duration deines the time it will take for the property to interpolate to the value.
  114302. * @param condition defines the trigger related conditions
  114303. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  114304. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  114305. */
  114306. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  114307. /** @hidden */
  114308. _prepare(): void;
  114309. /**
  114310. * Execute the action starts the value interpolation.
  114311. */
  114312. execute(): void;
  114313. /**
  114314. * Serializes the actions and its related information.
  114315. * @param parent defines the object to serialize in
  114316. * @returns the serialized object
  114317. */
  114318. serialize(parent: any): any;
  114319. }
  114320. }
  114321. declare module BABYLON {
  114322. /**
  114323. * Options allowed during the creation of a sound track.
  114324. */
  114325. export interface ISoundTrackOptions {
  114326. /**
  114327. * The volume the sound track should take during creation
  114328. */
  114329. volume?: number;
  114330. /**
  114331. * Define if the sound track is the main sound track of the scene
  114332. */
  114333. mainTrack?: boolean;
  114334. }
  114335. /**
  114336. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  114337. * It will be also used in a future release to apply effects on a specific track.
  114338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114339. */
  114340. export class SoundTrack {
  114341. /**
  114342. * The unique identifier of the sound track in the scene.
  114343. */
  114344. id: number;
  114345. /**
  114346. * The list of sounds included in the sound track.
  114347. */
  114348. soundCollection: Array<Sound>;
  114349. private _outputAudioNode;
  114350. private _scene;
  114351. private _connectedAnalyser;
  114352. private _options;
  114353. private _isInitialized;
  114354. /**
  114355. * Creates a new sound track.
  114356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114357. * @param scene Define the scene the sound track belongs to
  114358. * @param options
  114359. */
  114360. constructor(scene: Scene, options?: ISoundTrackOptions);
  114361. private _initializeSoundTrackAudioGraph;
  114362. /**
  114363. * Release the sound track and its associated resources
  114364. */
  114365. dispose(): void;
  114366. /**
  114367. * Adds a sound to this sound track
  114368. * @param sound define the cound to add
  114369. * @ignoreNaming
  114370. */
  114371. AddSound(sound: Sound): void;
  114372. /**
  114373. * Removes a sound to this sound track
  114374. * @param sound define the cound to remove
  114375. * @ignoreNaming
  114376. */
  114377. RemoveSound(sound: Sound): void;
  114378. /**
  114379. * Set a global volume for the full sound track.
  114380. * @param newVolume Define the new volume of the sound track
  114381. */
  114382. setVolume(newVolume: number): void;
  114383. /**
  114384. * Switch the panning model to HRTF:
  114385. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  114386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114387. */
  114388. switchPanningModelToHRTF(): void;
  114389. /**
  114390. * Switch the panning model to Equal Power:
  114391. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114393. */
  114394. switchPanningModelToEqualPower(): void;
  114395. /**
  114396. * Connect the sound track to an audio analyser allowing some amazing
  114397. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114399. * @param analyser The analyser to connect to the engine
  114400. */
  114401. connectToAnalyser(analyser: Analyser): void;
  114402. }
  114403. }
  114404. declare module BABYLON {
  114405. interface AbstractScene {
  114406. /**
  114407. * The list of sounds used in the scene.
  114408. */
  114409. sounds: Nullable<Array<Sound>>;
  114410. }
  114411. interface Scene {
  114412. /**
  114413. * @hidden
  114414. * Backing field
  114415. */
  114416. _mainSoundTrack: SoundTrack;
  114417. /**
  114418. * The main sound track played by the scene.
  114419. * It cotains your primary collection of sounds.
  114420. */
  114421. mainSoundTrack: SoundTrack;
  114422. /**
  114423. * The list of sound tracks added to the scene
  114424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114425. */
  114426. soundTracks: Nullable<Array<SoundTrack>>;
  114427. /**
  114428. * Gets a sound using a given name
  114429. * @param name defines the name to search for
  114430. * @return the found sound or null if not found at all.
  114431. */
  114432. getSoundByName(name: string): Nullable<Sound>;
  114433. /**
  114434. * Gets or sets if audio support is enabled
  114435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114436. */
  114437. audioEnabled: boolean;
  114438. /**
  114439. * Gets or sets if audio will be output to headphones
  114440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114441. */
  114442. headphone: boolean;
  114443. /**
  114444. * Gets or sets custom audio listener position provider
  114445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114446. */
  114447. audioListenerPositionProvider: Nullable<() => Vector3>;
  114448. /**
  114449. * Gets or sets a refresh rate when using 3D audio positioning
  114450. */
  114451. audioPositioningRefreshRate: number;
  114452. }
  114453. /**
  114454. * Defines the sound scene component responsible to manage any sounds
  114455. * in a given scene.
  114456. */
  114457. export class AudioSceneComponent implements ISceneSerializableComponent {
  114458. /**
  114459. * The component name helpfull to identify the component in the list of scene components.
  114460. */
  114461. readonly name: string;
  114462. /**
  114463. * The scene the component belongs to.
  114464. */
  114465. scene: Scene;
  114466. private _audioEnabled;
  114467. /**
  114468. * Gets whether audio is enabled or not.
  114469. * Please use related enable/disable method to switch state.
  114470. */
  114471. get audioEnabled(): boolean;
  114472. private _headphone;
  114473. /**
  114474. * Gets whether audio is outputing to headphone or not.
  114475. * Please use the according Switch methods to change output.
  114476. */
  114477. get headphone(): boolean;
  114478. /**
  114479. * Gets or sets a refresh rate when using 3D audio positioning
  114480. */
  114481. audioPositioningRefreshRate: number;
  114482. private _audioListenerPositionProvider;
  114483. /**
  114484. * Gets the current audio listener position provider
  114485. */
  114486. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  114487. /**
  114488. * Sets a custom listener position for all sounds in the scene
  114489. * By default, this is the position of the first active camera
  114490. */
  114491. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  114492. /**
  114493. * Creates a new instance of the component for the given scene
  114494. * @param scene Defines the scene to register the component in
  114495. */
  114496. constructor(scene: Scene);
  114497. /**
  114498. * Registers the component in a given scene
  114499. */
  114500. register(): void;
  114501. /**
  114502. * Rebuilds the elements related to this component in case of
  114503. * context lost for instance.
  114504. */
  114505. rebuild(): void;
  114506. /**
  114507. * Serializes the component data to the specified json object
  114508. * @param serializationObject The object to serialize to
  114509. */
  114510. serialize(serializationObject: any): void;
  114511. /**
  114512. * Adds all the elements from the container to the scene
  114513. * @param container the container holding the elements
  114514. */
  114515. addFromContainer(container: AbstractScene): void;
  114516. /**
  114517. * Removes all the elements in the container from the scene
  114518. * @param container contains the elements to remove
  114519. * @param dispose if the removed element should be disposed (default: false)
  114520. */
  114521. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114522. /**
  114523. * Disposes the component and the associated ressources.
  114524. */
  114525. dispose(): void;
  114526. /**
  114527. * Disables audio in the associated scene.
  114528. */
  114529. disableAudio(): void;
  114530. /**
  114531. * Enables audio in the associated scene.
  114532. */
  114533. enableAudio(): void;
  114534. /**
  114535. * Switch audio to headphone output.
  114536. */
  114537. switchAudioModeForHeadphones(): void;
  114538. /**
  114539. * Switch audio to normal speakers.
  114540. */
  114541. switchAudioModeForNormalSpeakers(): void;
  114542. private _cachedCameraDirection;
  114543. private _cachedCameraPosition;
  114544. private _lastCheck;
  114545. private _afterRender;
  114546. }
  114547. }
  114548. declare module BABYLON {
  114549. /**
  114550. * Wraps one or more Sound objects and selects one with random weight for playback.
  114551. */
  114552. export class WeightedSound {
  114553. /** When true a Sound will be selected and played when the current playing Sound completes. */
  114554. loop: boolean;
  114555. private _coneInnerAngle;
  114556. private _coneOuterAngle;
  114557. private _volume;
  114558. /** A Sound is currently playing. */
  114559. isPlaying: boolean;
  114560. /** A Sound is currently paused. */
  114561. isPaused: boolean;
  114562. private _sounds;
  114563. private _weights;
  114564. private _currentIndex?;
  114565. /**
  114566. * Creates a new WeightedSound from the list of sounds given.
  114567. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  114568. * @param sounds Array of Sounds that will be selected from.
  114569. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  114570. */
  114571. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  114572. /**
  114573. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  114574. */
  114575. get directionalConeInnerAngle(): number;
  114576. /**
  114577. * The size of cone in degress for a directional sound in which there will be no attenuation.
  114578. */
  114579. set directionalConeInnerAngle(value: number);
  114580. /**
  114581. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114582. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114583. */
  114584. get directionalConeOuterAngle(): number;
  114585. /**
  114586. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114587. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114588. */
  114589. set directionalConeOuterAngle(value: number);
  114590. /**
  114591. * Playback volume.
  114592. */
  114593. get volume(): number;
  114594. /**
  114595. * Playback volume.
  114596. */
  114597. set volume(value: number);
  114598. private _onended;
  114599. /**
  114600. * Suspend playback
  114601. */
  114602. pause(): void;
  114603. /**
  114604. * Stop playback
  114605. */
  114606. stop(): void;
  114607. /**
  114608. * Start playback.
  114609. * @param startOffset Position the clip head at a specific time in seconds.
  114610. */
  114611. play(startOffset?: number): void;
  114612. }
  114613. }
  114614. declare module BABYLON {
  114615. /**
  114616. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  114617. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114618. */
  114619. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  114620. /**
  114621. * Gets the name of the behavior.
  114622. */
  114623. get name(): string;
  114624. /**
  114625. * The easing function used by animations
  114626. */
  114627. static EasingFunction: BackEase;
  114628. /**
  114629. * The easing mode used by animations
  114630. */
  114631. static EasingMode: number;
  114632. /**
  114633. * The duration of the animation, in milliseconds
  114634. */
  114635. transitionDuration: number;
  114636. /**
  114637. * Length of the distance animated by the transition when lower radius is reached
  114638. */
  114639. lowerRadiusTransitionRange: number;
  114640. /**
  114641. * Length of the distance animated by the transition when upper radius is reached
  114642. */
  114643. upperRadiusTransitionRange: number;
  114644. private _autoTransitionRange;
  114645. /**
  114646. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114647. */
  114648. get autoTransitionRange(): boolean;
  114649. /**
  114650. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114651. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  114652. */
  114653. set autoTransitionRange(value: boolean);
  114654. private _attachedCamera;
  114655. private _onAfterCheckInputsObserver;
  114656. private _onMeshTargetChangedObserver;
  114657. /**
  114658. * Initializes the behavior.
  114659. */
  114660. init(): void;
  114661. /**
  114662. * Attaches the behavior to its arc rotate camera.
  114663. * @param camera Defines the camera to attach the behavior to
  114664. */
  114665. attach(camera: ArcRotateCamera): void;
  114666. /**
  114667. * Detaches the behavior from its current arc rotate camera.
  114668. */
  114669. detach(): void;
  114670. private _radiusIsAnimating;
  114671. private _radiusBounceTransition;
  114672. private _animatables;
  114673. private _cachedWheelPrecision;
  114674. /**
  114675. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  114676. * @param radiusLimit The limit to check against.
  114677. * @return Bool to indicate if at limit.
  114678. */
  114679. private _isRadiusAtLimit;
  114680. /**
  114681. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  114682. * @param radiusDelta The delta by which to animate to. Can be negative.
  114683. */
  114684. private _applyBoundRadiusAnimation;
  114685. /**
  114686. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  114687. */
  114688. protected _clearAnimationLocks(): void;
  114689. /**
  114690. * Stops and removes all animations that have been applied to the camera
  114691. */
  114692. stopAllAnimations(): void;
  114693. }
  114694. }
  114695. declare module BABYLON {
  114696. /**
  114697. * 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.
  114698. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114699. */
  114700. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  114701. /**
  114702. * Gets the name of the behavior.
  114703. */
  114704. get name(): string;
  114705. private _mode;
  114706. private _radiusScale;
  114707. private _positionScale;
  114708. private _defaultElevation;
  114709. private _elevationReturnTime;
  114710. private _elevationReturnWaitTime;
  114711. private _zoomStopsAnimation;
  114712. private _framingTime;
  114713. /**
  114714. * The easing function used by animations
  114715. */
  114716. static EasingFunction: ExponentialEase;
  114717. /**
  114718. * The easing mode used by animations
  114719. */
  114720. static EasingMode: number;
  114721. /**
  114722. * Sets the current mode used by the behavior
  114723. */
  114724. set mode(mode: number);
  114725. /**
  114726. * Gets current mode used by the behavior.
  114727. */
  114728. get mode(): number;
  114729. /**
  114730. * Sets the scale applied to the radius (1 by default)
  114731. */
  114732. set radiusScale(radius: number);
  114733. /**
  114734. * Gets the scale applied to the radius
  114735. */
  114736. get radiusScale(): number;
  114737. /**
  114738. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114739. */
  114740. set positionScale(scale: number);
  114741. /**
  114742. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114743. */
  114744. get positionScale(): number;
  114745. /**
  114746. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114747. * behaviour is triggered, in radians.
  114748. */
  114749. set defaultElevation(elevation: number);
  114750. /**
  114751. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114752. * behaviour is triggered, in radians.
  114753. */
  114754. get defaultElevation(): number;
  114755. /**
  114756. * Sets the time (in milliseconds) taken to return to the default beta position.
  114757. * Negative value indicates camera should not return to default.
  114758. */
  114759. set elevationReturnTime(speed: number);
  114760. /**
  114761. * Gets the time (in milliseconds) taken to return to the default beta position.
  114762. * Negative value indicates camera should not return to default.
  114763. */
  114764. get elevationReturnTime(): number;
  114765. /**
  114766. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114767. */
  114768. set elevationReturnWaitTime(time: number);
  114769. /**
  114770. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114771. */
  114772. get elevationReturnWaitTime(): number;
  114773. /**
  114774. * Sets the flag that indicates if user zooming should stop animation.
  114775. */
  114776. set zoomStopsAnimation(flag: boolean);
  114777. /**
  114778. * Gets the flag that indicates if user zooming should stop animation.
  114779. */
  114780. get zoomStopsAnimation(): boolean;
  114781. /**
  114782. * Sets the transition time when framing the mesh, in milliseconds
  114783. */
  114784. set framingTime(time: number);
  114785. /**
  114786. * Gets the transition time when framing the mesh, in milliseconds
  114787. */
  114788. get framingTime(): number;
  114789. /**
  114790. * Define if the behavior should automatically change the configured
  114791. * camera limits and sensibilities.
  114792. */
  114793. autoCorrectCameraLimitsAndSensibility: boolean;
  114794. private _onPrePointerObservableObserver;
  114795. private _onAfterCheckInputsObserver;
  114796. private _onMeshTargetChangedObserver;
  114797. private _attachedCamera;
  114798. private _isPointerDown;
  114799. private _lastInteractionTime;
  114800. /**
  114801. * Initializes the behavior.
  114802. */
  114803. init(): void;
  114804. /**
  114805. * Attaches the behavior to its arc rotate camera.
  114806. * @param camera Defines the camera to attach the behavior to
  114807. */
  114808. attach(camera: ArcRotateCamera): void;
  114809. /**
  114810. * Detaches the behavior from its current arc rotate camera.
  114811. */
  114812. detach(): void;
  114813. private _animatables;
  114814. private _betaIsAnimating;
  114815. private _betaTransition;
  114816. private _radiusTransition;
  114817. private _vectorTransition;
  114818. /**
  114819. * Targets the given mesh and updates zoom level accordingly.
  114820. * @param mesh The mesh to target.
  114821. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114822. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114823. */
  114824. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114825. /**
  114826. * Targets the given mesh with its children and updates zoom level accordingly.
  114827. * @param mesh The mesh to target.
  114828. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114829. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114830. */
  114831. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114832. /**
  114833. * Targets the given meshes with their children and updates zoom level accordingly.
  114834. * @param meshes The mesh to target.
  114835. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114836. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114837. */
  114838. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114839. /**
  114840. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  114841. * @param minimumWorld Determines the smaller position of the bounding box extend
  114842. * @param maximumWorld Determines the bigger position of the bounding box extend
  114843. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114844. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114845. */
  114846. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114847. /**
  114848. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  114849. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  114850. * frustum width.
  114851. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  114852. * to fully enclose the mesh in the viewing frustum.
  114853. */
  114854. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  114855. /**
  114856. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  114857. * is automatically returned to its default position (expected to be above ground plane).
  114858. */
  114859. private _maintainCameraAboveGround;
  114860. /**
  114861. * Returns the frustum slope based on the canvas ratio and camera FOV
  114862. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  114863. */
  114864. private _getFrustumSlope;
  114865. /**
  114866. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  114867. */
  114868. private _clearAnimationLocks;
  114869. /**
  114870. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114871. */
  114872. private _applyUserInteraction;
  114873. /**
  114874. * Stops and removes all animations that have been applied to the camera
  114875. */
  114876. stopAllAnimations(): void;
  114877. /**
  114878. * Gets a value indicating if the user is moving the camera
  114879. */
  114880. get isUserIsMoving(): boolean;
  114881. /**
  114882. * The camera can move all the way towards the mesh.
  114883. */
  114884. static IgnoreBoundsSizeMode: number;
  114885. /**
  114886. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  114887. */
  114888. static FitFrustumSidesMode: number;
  114889. }
  114890. }
  114891. declare module BABYLON {
  114892. /**
  114893. * Base class for Camera Pointer Inputs.
  114894. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  114895. * for example usage.
  114896. */
  114897. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  114898. /**
  114899. * Defines the camera the input is attached to.
  114900. */
  114901. abstract camera: Camera;
  114902. /**
  114903. * Whether keyboard modifier keys are pressed at time of last mouse event.
  114904. */
  114905. protected _altKey: boolean;
  114906. protected _ctrlKey: boolean;
  114907. protected _metaKey: boolean;
  114908. protected _shiftKey: boolean;
  114909. /**
  114910. * Which mouse buttons were pressed at time of last mouse event.
  114911. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  114912. */
  114913. protected _buttonsPressed: number;
  114914. /**
  114915. * Defines the buttons associated with the input to handle camera move.
  114916. */
  114917. buttons: number[];
  114918. /**
  114919. * Attach the input controls to a specific dom element to get the input from.
  114920. * @param element Defines the element the controls should be listened from
  114921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114922. */
  114923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114924. /**
  114925. * Detach the current controls from the specified dom element.
  114926. * @param element Defines the element to stop listening the inputs from
  114927. */
  114928. detachControl(element: Nullable<HTMLElement>): void;
  114929. /**
  114930. * Gets the class name of the current input.
  114931. * @returns the class name
  114932. */
  114933. getClassName(): string;
  114934. /**
  114935. * Get the friendly name associated with the input class.
  114936. * @returns the input friendly name
  114937. */
  114938. getSimpleName(): string;
  114939. /**
  114940. * Called on pointer POINTERDOUBLETAP event.
  114941. * Override this method to provide functionality on POINTERDOUBLETAP event.
  114942. */
  114943. protected onDoubleTap(type: string): void;
  114944. /**
  114945. * Called on pointer POINTERMOVE event if only a single touch is active.
  114946. * Override this method to provide functionality.
  114947. */
  114948. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114949. /**
  114950. * Called on pointer POINTERMOVE event if multiple touches are active.
  114951. * Override this method to provide functionality.
  114952. */
  114953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114954. /**
  114955. * Called on JS contextmenu event.
  114956. * Override this method to provide functionality.
  114957. */
  114958. protected onContextMenu(evt: PointerEvent): void;
  114959. /**
  114960. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114961. * press.
  114962. * Override this method to provide functionality.
  114963. */
  114964. protected onButtonDown(evt: PointerEvent): void;
  114965. /**
  114966. * Called each time a new POINTERUP event occurs. Ie, for each button
  114967. * release.
  114968. * Override this method to provide functionality.
  114969. */
  114970. protected onButtonUp(evt: PointerEvent): void;
  114971. /**
  114972. * Called when window becomes inactive.
  114973. * Override this method to provide functionality.
  114974. */
  114975. protected onLostFocus(): void;
  114976. private _pointerInput;
  114977. private _observer;
  114978. private _onLostFocus;
  114979. private pointA;
  114980. private pointB;
  114981. }
  114982. }
  114983. declare module BABYLON {
  114984. /**
  114985. * Manage the pointers inputs to control an arc rotate camera.
  114986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114987. */
  114988. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  114989. /**
  114990. * Defines the camera the input is attached to.
  114991. */
  114992. camera: ArcRotateCamera;
  114993. /**
  114994. * Gets the class name of the current input.
  114995. * @returns the class name
  114996. */
  114997. getClassName(): string;
  114998. /**
  114999. * Defines the buttons associated with the input to handle camera move.
  115000. */
  115001. buttons: number[];
  115002. /**
  115003. * Defines the pointer angular sensibility along the X axis or how fast is
  115004. * the camera rotating.
  115005. */
  115006. angularSensibilityX: number;
  115007. /**
  115008. * Defines the pointer angular sensibility along the Y axis or how fast is
  115009. * the camera rotating.
  115010. */
  115011. angularSensibilityY: number;
  115012. /**
  115013. * Defines the pointer pinch precision or how fast is the camera zooming.
  115014. */
  115015. pinchPrecision: number;
  115016. /**
  115017. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  115018. * from 0.
  115019. * It defines the percentage of current camera.radius to use as delta when
  115020. * pinch zoom is used.
  115021. */
  115022. pinchDeltaPercentage: number;
  115023. /**
  115024. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  115025. * that any object in the plane at the camera's target point will scale
  115026. * perfectly with finger motion.
  115027. * Overrides pinchDeltaPercentage and pinchPrecision.
  115028. */
  115029. useNaturalPinchZoom: boolean;
  115030. /**
  115031. * Defines the pointer panning sensibility or how fast is the camera moving.
  115032. */
  115033. panningSensibility: number;
  115034. /**
  115035. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  115036. */
  115037. multiTouchPanning: boolean;
  115038. /**
  115039. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  115040. * zoom (pinch) through multitouch.
  115041. */
  115042. multiTouchPanAndZoom: boolean;
  115043. /**
  115044. * Revers pinch action direction.
  115045. */
  115046. pinchInwards: boolean;
  115047. private _isPanClick;
  115048. private _twoFingerActivityCount;
  115049. private _isPinching;
  115050. /**
  115051. * Called on pointer POINTERMOVE event if only a single touch is active.
  115052. */
  115053. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  115054. /**
  115055. * Called on pointer POINTERDOUBLETAP event.
  115056. */
  115057. protected onDoubleTap(type: string): void;
  115058. /**
  115059. * Called on pointer POINTERMOVE event if multiple touches are active.
  115060. */
  115061. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  115062. /**
  115063. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  115064. * press.
  115065. */
  115066. protected onButtonDown(evt: PointerEvent): void;
  115067. /**
  115068. * Called each time a new POINTERUP event occurs. Ie, for each button
  115069. * release.
  115070. */
  115071. protected onButtonUp(evt: PointerEvent): void;
  115072. /**
  115073. * Called when window becomes inactive.
  115074. */
  115075. protected onLostFocus(): void;
  115076. }
  115077. }
  115078. declare module BABYLON {
  115079. /**
  115080. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  115081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115082. */
  115083. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  115084. /**
  115085. * Defines the camera the input is attached to.
  115086. */
  115087. camera: ArcRotateCamera;
  115088. /**
  115089. * Defines the list of key codes associated with the up action (increase alpha)
  115090. */
  115091. keysUp: number[];
  115092. /**
  115093. * Defines the list of key codes associated with the down action (decrease alpha)
  115094. */
  115095. keysDown: number[];
  115096. /**
  115097. * Defines the list of key codes associated with the left action (increase beta)
  115098. */
  115099. keysLeft: number[];
  115100. /**
  115101. * Defines the list of key codes associated with the right action (decrease beta)
  115102. */
  115103. keysRight: number[];
  115104. /**
  115105. * Defines the list of key codes associated with the reset action.
  115106. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  115107. */
  115108. keysReset: number[];
  115109. /**
  115110. * Defines the panning sensibility of the inputs.
  115111. * (How fast is the camera panning)
  115112. */
  115113. panningSensibility: number;
  115114. /**
  115115. * Defines the zooming sensibility of the inputs.
  115116. * (How fast is the camera zooming)
  115117. */
  115118. zoomingSensibility: number;
  115119. /**
  115120. * Defines whether maintaining the alt key down switch the movement mode from
  115121. * orientation to zoom.
  115122. */
  115123. useAltToZoom: boolean;
  115124. /**
  115125. * Rotation speed of the camera
  115126. */
  115127. angularSpeed: number;
  115128. private _keys;
  115129. private _ctrlPressed;
  115130. private _altPressed;
  115131. private _onCanvasBlurObserver;
  115132. private _onKeyboardObserver;
  115133. private _engine;
  115134. private _scene;
  115135. /**
  115136. * Attach the input controls to a specific dom element to get the input from.
  115137. * @param element Defines the element the controls should be listened from
  115138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115139. */
  115140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115141. /**
  115142. * Detach the current controls from the specified dom element.
  115143. * @param element Defines the element to stop listening the inputs from
  115144. */
  115145. detachControl(element: Nullable<HTMLElement>): void;
  115146. /**
  115147. * Update the current camera state depending on the inputs that have been used this frame.
  115148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115149. */
  115150. checkInputs(): void;
  115151. /**
  115152. * Gets the class name of the current intput.
  115153. * @returns the class name
  115154. */
  115155. getClassName(): string;
  115156. /**
  115157. * Get the friendly name associated with the input class.
  115158. * @returns the input friendly name
  115159. */
  115160. getSimpleName(): string;
  115161. }
  115162. }
  115163. declare module BABYLON {
  115164. /**
  115165. * Manage the mouse wheel inputs to control an arc rotate camera.
  115166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115167. */
  115168. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  115169. /**
  115170. * Defines the camera the input is attached to.
  115171. */
  115172. camera: ArcRotateCamera;
  115173. /**
  115174. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115175. */
  115176. wheelPrecision: number;
  115177. /**
  115178. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  115179. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  115180. */
  115181. wheelDeltaPercentage: number;
  115182. private _wheel;
  115183. private _observer;
  115184. private computeDeltaFromMouseWheelLegacyEvent;
  115185. /**
  115186. * Attach the input controls to a specific dom element to get the input from.
  115187. * @param element Defines the element the controls should be listened from
  115188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115189. */
  115190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115191. /**
  115192. * Detach the current controls from the specified dom element.
  115193. * @param element Defines the element to stop listening the inputs from
  115194. */
  115195. detachControl(element: Nullable<HTMLElement>): void;
  115196. /**
  115197. * Gets the class name of the current intput.
  115198. * @returns the class name
  115199. */
  115200. getClassName(): string;
  115201. /**
  115202. * Get the friendly name associated with the input class.
  115203. * @returns the input friendly name
  115204. */
  115205. getSimpleName(): string;
  115206. }
  115207. }
  115208. declare module BABYLON {
  115209. /**
  115210. * Default Inputs manager for the ArcRotateCamera.
  115211. * It groups all the default supported inputs for ease of use.
  115212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115213. */
  115214. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  115215. /**
  115216. * Instantiates a new ArcRotateCameraInputsManager.
  115217. * @param camera Defines the camera the inputs belong to
  115218. */
  115219. constructor(camera: ArcRotateCamera);
  115220. /**
  115221. * Add mouse wheel input support to the input manager.
  115222. * @returns the current input manager
  115223. */
  115224. addMouseWheel(): ArcRotateCameraInputsManager;
  115225. /**
  115226. * Add pointers input support to the input manager.
  115227. * @returns the current input manager
  115228. */
  115229. addPointers(): ArcRotateCameraInputsManager;
  115230. /**
  115231. * Add keyboard input support to the input manager.
  115232. * @returns the current input manager
  115233. */
  115234. addKeyboard(): ArcRotateCameraInputsManager;
  115235. }
  115236. }
  115237. declare module BABYLON {
  115238. /**
  115239. * This represents an orbital type of camera.
  115240. *
  115241. * 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.
  115242. * 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.
  115243. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  115244. */
  115245. export class ArcRotateCamera extends TargetCamera {
  115246. /**
  115247. * Defines the rotation angle of the camera along the longitudinal axis.
  115248. */
  115249. alpha: number;
  115250. /**
  115251. * Defines the rotation angle of the camera along the latitudinal axis.
  115252. */
  115253. beta: number;
  115254. /**
  115255. * Defines the radius of the camera from it s target point.
  115256. */
  115257. radius: number;
  115258. protected _target: Vector3;
  115259. protected _targetHost: Nullable<AbstractMesh>;
  115260. /**
  115261. * Defines the target point of the camera.
  115262. * The camera looks towards it form the radius distance.
  115263. */
  115264. get target(): Vector3;
  115265. set target(value: Vector3);
  115266. /**
  115267. * Define the current local position of the camera in the scene
  115268. */
  115269. get position(): Vector3;
  115270. set position(newPosition: Vector3);
  115271. protected _upVector: Vector3;
  115272. protected _upToYMatrix: Matrix;
  115273. protected _YToUpMatrix: Matrix;
  115274. /**
  115275. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  115276. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  115277. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  115278. */
  115279. set upVector(vec: Vector3);
  115280. get upVector(): Vector3;
  115281. /**
  115282. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  115283. */
  115284. setMatUp(): void;
  115285. /**
  115286. * Current inertia value on the longitudinal axis.
  115287. * The bigger this number the longer it will take for the camera to stop.
  115288. */
  115289. inertialAlphaOffset: number;
  115290. /**
  115291. * Current inertia value on the latitudinal axis.
  115292. * The bigger this number the longer it will take for the camera to stop.
  115293. */
  115294. inertialBetaOffset: number;
  115295. /**
  115296. * Current inertia value on the radius axis.
  115297. * The bigger this number the longer it will take for the camera to stop.
  115298. */
  115299. inertialRadiusOffset: number;
  115300. /**
  115301. * Minimum allowed angle on the longitudinal axis.
  115302. * This can help limiting how the Camera is able to move in the scene.
  115303. */
  115304. lowerAlphaLimit: Nullable<number>;
  115305. /**
  115306. * Maximum allowed angle on the longitudinal axis.
  115307. * This can help limiting how the Camera is able to move in the scene.
  115308. */
  115309. upperAlphaLimit: Nullable<number>;
  115310. /**
  115311. * Minimum allowed angle on the latitudinal axis.
  115312. * This can help limiting how the Camera is able to move in the scene.
  115313. */
  115314. lowerBetaLimit: number;
  115315. /**
  115316. * Maximum allowed angle on the latitudinal axis.
  115317. * This can help limiting how the Camera is able to move in the scene.
  115318. */
  115319. upperBetaLimit: number;
  115320. /**
  115321. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  115322. * This can help limiting how the Camera is able to move in the scene.
  115323. */
  115324. lowerRadiusLimit: Nullable<number>;
  115325. /**
  115326. * Maximum allowed distance of the camera to the target (The camera can not get further).
  115327. * This can help limiting how the Camera is able to move in the scene.
  115328. */
  115329. upperRadiusLimit: Nullable<number>;
  115330. /**
  115331. * Defines the current inertia value used during panning of the camera along the X axis.
  115332. */
  115333. inertialPanningX: number;
  115334. /**
  115335. * Defines the current inertia value used during panning of the camera along the Y axis.
  115336. */
  115337. inertialPanningY: number;
  115338. /**
  115339. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  115340. * Basically if your fingers moves away from more than this distance you will be considered
  115341. * in pinch mode.
  115342. */
  115343. pinchToPanMaxDistance: number;
  115344. /**
  115345. * Defines the maximum distance the camera can pan.
  115346. * This could help keeping the cammera always in your scene.
  115347. */
  115348. panningDistanceLimit: Nullable<number>;
  115349. /**
  115350. * Defines the target of the camera before paning.
  115351. */
  115352. panningOriginTarget: Vector3;
  115353. /**
  115354. * Defines the value of the inertia used during panning.
  115355. * 0 would mean stop inertia and one would mean no decelleration at all.
  115356. */
  115357. panningInertia: number;
  115358. /**
  115359. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  115360. */
  115361. get angularSensibilityX(): number;
  115362. set angularSensibilityX(value: number);
  115363. /**
  115364. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  115365. */
  115366. get angularSensibilityY(): number;
  115367. set angularSensibilityY(value: number);
  115368. /**
  115369. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  115370. */
  115371. get pinchPrecision(): number;
  115372. set pinchPrecision(value: number);
  115373. /**
  115374. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  115375. * It will be used instead of pinchDeltaPrecision if different from 0.
  115376. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115377. */
  115378. get pinchDeltaPercentage(): number;
  115379. set pinchDeltaPercentage(value: number);
  115380. /**
  115381. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  115382. * and pinch delta percentage.
  115383. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  115384. * that any object in the plane at the camera's target point will scale
  115385. * perfectly with finger motion.
  115386. */
  115387. get useNaturalPinchZoom(): boolean;
  115388. set useNaturalPinchZoom(value: boolean);
  115389. /**
  115390. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  115391. */
  115392. get panningSensibility(): number;
  115393. set panningSensibility(value: number);
  115394. /**
  115395. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  115396. */
  115397. get keysUp(): number[];
  115398. set keysUp(value: number[]);
  115399. /**
  115400. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  115401. */
  115402. get keysDown(): number[];
  115403. set keysDown(value: number[]);
  115404. /**
  115405. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  115406. */
  115407. get keysLeft(): number[];
  115408. set keysLeft(value: number[]);
  115409. /**
  115410. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  115411. */
  115412. get keysRight(): number[];
  115413. set keysRight(value: number[]);
  115414. /**
  115415. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115416. */
  115417. get wheelPrecision(): number;
  115418. set wheelPrecision(value: number);
  115419. /**
  115420. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  115421. * It will be used instead of pinchDeltaPrecision if different from 0.
  115422. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115423. */
  115424. get wheelDeltaPercentage(): number;
  115425. set wheelDeltaPercentage(value: number);
  115426. /**
  115427. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  115428. */
  115429. zoomOnFactor: number;
  115430. /**
  115431. * Defines a screen offset for the camera position.
  115432. */
  115433. targetScreenOffset: Vector2;
  115434. /**
  115435. * Allows the camera to be completely reversed.
  115436. * If false the camera can not arrive upside down.
  115437. */
  115438. allowUpsideDown: boolean;
  115439. /**
  115440. * Define if double tap/click is used to restore the previously saved state of the camera.
  115441. */
  115442. useInputToRestoreState: boolean;
  115443. /** @hidden */
  115444. _viewMatrix: Matrix;
  115445. /** @hidden */
  115446. _useCtrlForPanning: boolean;
  115447. /** @hidden */
  115448. _panningMouseButton: number;
  115449. /**
  115450. * Defines the input associated to the camera.
  115451. */
  115452. inputs: ArcRotateCameraInputsManager;
  115453. /** @hidden */
  115454. _reset: () => void;
  115455. /**
  115456. * Defines the allowed panning axis.
  115457. */
  115458. panningAxis: Vector3;
  115459. protected _localDirection: Vector3;
  115460. protected _transformedDirection: Vector3;
  115461. private _bouncingBehavior;
  115462. /**
  115463. * Gets the bouncing behavior of the camera if it has been enabled.
  115464. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115465. */
  115466. get bouncingBehavior(): Nullable<BouncingBehavior>;
  115467. /**
  115468. * Defines if the bouncing behavior of the camera is enabled on the camera.
  115469. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115470. */
  115471. get useBouncingBehavior(): boolean;
  115472. set useBouncingBehavior(value: boolean);
  115473. private _framingBehavior;
  115474. /**
  115475. * Gets the framing behavior of the camera if it has been enabled.
  115476. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115477. */
  115478. get framingBehavior(): Nullable<FramingBehavior>;
  115479. /**
  115480. * Defines if the framing behavior of the camera is enabled on the camera.
  115481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115482. */
  115483. get useFramingBehavior(): boolean;
  115484. set useFramingBehavior(value: boolean);
  115485. private _autoRotationBehavior;
  115486. /**
  115487. * Gets the auto rotation behavior of the camera if it has been enabled.
  115488. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115489. */
  115490. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  115491. /**
  115492. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  115493. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115494. */
  115495. get useAutoRotationBehavior(): boolean;
  115496. set useAutoRotationBehavior(value: boolean);
  115497. /**
  115498. * Observable triggered when the mesh target has been changed on the camera.
  115499. */
  115500. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  115501. /**
  115502. * Event raised when the camera is colliding with a mesh.
  115503. */
  115504. onCollide: (collidedMesh: AbstractMesh) => void;
  115505. /**
  115506. * Defines whether the camera should check collision with the objects oh the scene.
  115507. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  115508. */
  115509. checkCollisions: boolean;
  115510. /**
  115511. * Defines the collision radius of the camera.
  115512. * This simulates a sphere around the camera.
  115513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  115514. */
  115515. collisionRadius: Vector3;
  115516. protected _collider: Collider;
  115517. protected _previousPosition: Vector3;
  115518. protected _collisionVelocity: Vector3;
  115519. protected _newPosition: Vector3;
  115520. protected _previousAlpha: number;
  115521. protected _previousBeta: number;
  115522. protected _previousRadius: number;
  115523. protected _collisionTriggered: boolean;
  115524. protected _targetBoundingCenter: Nullable<Vector3>;
  115525. private _computationVector;
  115526. /**
  115527. * Instantiates a new ArcRotateCamera in a given scene
  115528. * @param name Defines the name of the camera
  115529. * @param alpha Defines the camera rotation along the logitudinal axis
  115530. * @param beta Defines the camera rotation along the latitudinal axis
  115531. * @param radius Defines the camera distance from its target
  115532. * @param target Defines the camera target
  115533. * @param scene Defines the scene the camera belongs to
  115534. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  115535. */
  115536. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115537. /** @hidden */
  115538. _initCache(): void;
  115539. /** @hidden */
  115540. _updateCache(ignoreParentClass?: boolean): void;
  115541. protected _getTargetPosition(): Vector3;
  115542. private _storedAlpha;
  115543. private _storedBeta;
  115544. private _storedRadius;
  115545. private _storedTarget;
  115546. private _storedTargetScreenOffset;
  115547. /**
  115548. * Stores the current state of the camera (alpha, beta, radius and target)
  115549. * @returns the camera itself
  115550. */
  115551. storeState(): Camera;
  115552. /**
  115553. * @hidden
  115554. * Restored camera state. You must call storeState() first
  115555. */
  115556. _restoreStateValues(): boolean;
  115557. /** @hidden */
  115558. _isSynchronizedViewMatrix(): boolean;
  115559. /**
  115560. * Attached controls to the current camera.
  115561. * @param element Defines the element the controls should be listened from
  115562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115563. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  115564. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  115565. */
  115566. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  115567. /**
  115568. * Detach the current controls from the camera.
  115569. * The camera will stop reacting to inputs.
  115570. * @param element Defines the element to stop listening the inputs from
  115571. */
  115572. detachControl(element: HTMLElement): void;
  115573. /** @hidden */
  115574. _checkInputs(): void;
  115575. protected _checkLimits(): void;
  115576. /**
  115577. * Rebuilds angles (alpha, beta) and radius from the give position and target
  115578. */
  115579. rebuildAnglesAndRadius(): void;
  115580. /**
  115581. * Use a position to define the current camera related information like alpha, beta and radius
  115582. * @param position Defines the position to set the camera at
  115583. */
  115584. setPosition(position: Vector3): void;
  115585. /**
  115586. * Defines the target the camera should look at.
  115587. * This will automatically adapt alpha beta and radius to fit within the new target.
  115588. * @param target Defines the new target as a Vector or a mesh
  115589. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  115590. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  115591. */
  115592. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  115593. /** @hidden */
  115594. _getViewMatrix(): Matrix;
  115595. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  115596. /**
  115597. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  115598. * @param meshes Defines the mesh to zoom on
  115599. * @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)
  115600. */
  115601. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  115602. /**
  115603. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  115604. * The target will be changed but the radius
  115605. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  115606. * @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)
  115607. */
  115608. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  115609. min: Vector3;
  115610. max: Vector3;
  115611. distance: number;
  115612. }, doNotUpdateMaxZ?: boolean): void;
  115613. /**
  115614. * @override
  115615. * Override Camera.createRigCamera
  115616. */
  115617. createRigCamera(name: string, cameraIndex: number): Camera;
  115618. /**
  115619. * @hidden
  115620. * @override
  115621. * Override Camera._updateRigCameras
  115622. */
  115623. _updateRigCameras(): void;
  115624. /**
  115625. * Destroy the camera and release the current resources hold by it.
  115626. */
  115627. dispose(): void;
  115628. /**
  115629. * Gets the current object class name.
  115630. * @return the class name
  115631. */
  115632. getClassName(): string;
  115633. }
  115634. }
  115635. declare module BABYLON {
  115636. /**
  115637. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  115638. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115639. */
  115640. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  115641. /**
  115642. * Gets the name of the behavior.
  115643. */
  115644. get name(): string;
  115645. private _zoomStopsAnimation;
  115646. private _idleRotationSpeed;
  115647. private _idleRotationWaitTime;
  115648. private _idleRotationSpinupTime;
  115649. /**
  115650. * Sets the flag that indicates if user zooming should stop animation.
  115651. */
  115652. set zoomStopsAnimation(flag: boolean);
  115653. /**
  115654. * Gets the flag that indicates if user zooming should stop animation.
  115655. */
  115656. get zoomStopsAnimation(): boolean;
  115657. /**
  115658. * Sets the default speed at which the camera rotates around the model.
  115659. */
  115660. set idleRotationSpeed(speed: number);
  115661. /**
  115662. * Gets the default speed at which the camera rotates around the model.
  115663. */
  115664. get idleRotationSpeed(): number;
  115665. /**
  115666. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  115667. */
  115668. set idleRotationWaitTime(time: number);
  115669. /**
  115670. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  115671. */
  115672. get idleRotationWaitTime(): number;
  115673. /**
  115674. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115675. */
  115676. set idleRotationSpinupTime(time: number);
  115677. /**
  115678. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115679. */
  115680. get idleRotationSpinupTime(): number;
  115681. /**
  115682. * Gets a value indicating if the camera is currently rotating because of this behavior
  115683. */
  115684. get rotationInProgress(): boolean;
  115685. private _onPrePointerObservableObserver;
  115686. private _onAfterCheckInputsObserver;
  115687. private _attachedCamera;
  115688. private _isPointerDown;
  115689. private _lastFrameTime;
  115690. private _lastInteractionTime;
  115691. private _cameraRotationSpeed;
  115692. /**
  115693. * Initializes the behavior.
  115694. */
  115695. init(): void;
  115696. /**
  115697. * Attaches the behavior to its arc rotate camera.
  115698. * @param camera Defines the camera to attach the behavior to
  115699. */
  115700. attach(camera: ArcRotateCamera): void;
  115701. /**
  115702. * Detaches the behavior from its current arc rotate camera.
  115703. */
  115704. detach(): void;
  115705. /**
  115706. * Returns true if user is scrolling.
  115707. * @return true if user is scrolling.
  115708. */
  115709. private _userIsZooming;
  115710. private _lastFrameRadius;
  115711. private _shouldAnimationStopForInteraction;
  115712. /**
  115713. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  115714. */
  115715. private _applyUserInteraction;
  115716. private _userIsMoving;
  115717. }
  115718. }
  115719. declare module BABYLON {
  115720. /**
  115721. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  115722. */
  115723. export class AttachToBoxBehavior implements Behavior<Mesh> {
  115724. private ui;
  115725. /**
  115726. * The name of the behavior
  115727. */
  115728. name: string;
  115729. /**
  115730. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  115731. */
  115732. distanceAwayFromFace: number;
  115733. /**
  115734. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  115735. */
  115736. distanceAwayFromBottomOfFace: number;
  115737. private _faceVectors;
  115738. private _target;
  115739. private _scene;
  115740. private _onRenderObserver;
  115741. private _tmpMatrix;
  115742. private _tmpVector;
  115743. /**
  115744. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  115745. * @param ui The transform node that should be attched to the mesh
  115746. */
  115747. constructor(ui: TransformNode);
  115748. /**
  115749. * Initializes the behavior
  115750. */
  115751. init(): void;
  115752. private _closestFace;
  115753. private _zeroVector;
  115754. private _lookAtTmpMatrix;
  115755. private _lookAtToRef;
  115756. /**
  115757. * Attaches the AttachToBoxBehavior to the passed in mesh
  115758. * @param target The mesh that the specified node will be attached to
  115759. */
  115760. attach(target: Mesh): void;
  115761. /**
  115762. * Detaches the behavior from the mesh
  115763. */
  115764. detach(): void;
  115765. }
  115766. }
  115767. declare module BABYLON {
  115768. /**
  115769. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  115770. */
  115771. export class FadeInOutBehavior implements Behavior<Mesh> {
  115772. /**
  115773. * Time in milliseconds to delay before fading in (Default: 0)
  115774. */
  115775. delay: number;
  115776. /**
  115777. * Time in milliseconds for the mesh to fade in (Default: 300)
  115778. */
  115779. fadeInTime: number;
  115780. private _millisecondsPerFrame;
  115781. private _hovered;
  115782. private _hoverValue;
  115783. private _ownerNode;
  115784. /**
  115785. * Instatiates the FadeInOutBehavior
  115786. */
  115787. constructor();
  115788. /**
  115789. * The name of the behavior
  115790. */
  115791. get name(): string;
  115792. /**
  115793. * Initializes the behavior
  115794. */
  115795. init(): void;
  115796. /**
  115797. * Attaches the fade behavior on the passed in mesh
  115798. * @param ownerNode The mesh that will be faded in/out once attached
  115799. */
  115800. attach(ownerNode: Mesh): void;
  115801. /**
  115802. * Detaches the behavior from the mesh
  115803. */
  115804. detach(): void;
  115805. /**
  115806. * Triggers the mesh to begin fading in or out
  115807. * @param value if the object should fade in or out (true to fade in)
  115808. */
  115809. fadeIn(value: boolean): void;
  115810. private _update;
  115811. private _setAllVisibility;
  115812. }
  115813. }
  115814. declare module BABYLON {
  115815. /**
  115816. * Class containing a set of static utilities functions for managing Pivots
  115817. * @hidden
  115818. */
  115819. export class PivotTools {
  115820. private static _PivotCached;
  115821. private static _OldPivotPoint;
  115822. private static _PivotTranslation;
  115823. private static _PivotTmpVector;
  115824. /** @hidden */
  115825. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  115826. /** @hidden */
  115827. static _RestorePivotPoint(mesh: AbstractMesh): void;
  115828. }
  115829. }
  115830. declare module BABYLON {
  115831. /**
  115832. * Class containing static functions to help procedurally build meshes
  115833. */
  115834. export class PlaneBuilder {
  115835. /**
  115836. * Creates a plane mesh
  115837. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115838. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115839. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115841. * * 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
  115842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115843. * @param name defines the name of the mesh
  115844. * @param options defines the options used to create the mesh
  115845. * @param scene defines the hosting scene
  115846. * @returns the plane mesh
  115847. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115848. */
  115849. static CreatePlane(name: string, options: {
  115850. size?: number;
  115851. width?: number;
  115852. height?: number;
  115853. sideOrientation?: number;
  115854. frontUVs?: Vector4;
  115855. backUVs?: Vector4;
  115856. updatable?: boolean;
  115857. sourcePlane?: Plane;
  115858. }, scene?: Nullable<Scene>): Mesh;
  115859. }
  115860. }
  115861. declare module BABYLON {
  115862. /**
  115863. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  115864. */
  115865. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  115866. private static _AnyMouseID;
  115867. /**
  115868. * Abstract mesh the behavior is set on
  115869. */
  115870. attachedNode: AbstractMesh;
  115871. private _dragPlane;
  115872. private _scene;
  115873. private _pointerObserver;
  115874. private _beforeRenderObserver;
  115875. private static _planeScene;
  115876. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  115877. /**
  115878. * 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)
  115879. */
  115880. maxDragAngle: number;
  115881. /**
  115882. * @hidden
  115883. */
  115884. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  115885. /**
  115886. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115887. */
  115888. currentDraggingPointerID: number;
  115889. /**
  115890. * The last position where the pointer hit the drag plane in world space
  115891. */
  115892. lastDragPosition: Vector3;
  115893. /**
  115894. * If the behavior is currently in a dragging state
  115895. */
  115896. dragging: boolean;
  115897. /**
  115898. * 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)
  115899. */
  115900. dragDeltaRatio: number;
  115901. /**
  115902. * If the drag plane orientation should be updated during the dragging (Default: true)
  115903. */
  115904. updateDragPlane: boolean;
  115905. private _debugMode;
  115906. private _moving;
  115907. /**
  115908. * Fires each time the attached mesh is dragged with the pointer
  115909. * * delta between last drag position and current drag position in world space
  115910. * * dragDistance along the drag axis
  115911. * * dragPlaneNormal normal of the current drag plane used during the drag
  115912. * * dragPlanePoint in world space where the drag intersects the drag plane
  115913. */
  115914. onDragObservable: Observable<{
  115915. delta: Vector3;
  115916. dragPlanePoint: Vector3;
  115917. dragPlaneNormal: Vector3;
  115918. dragDistance: number;
  115919. pointerId: number;
  115920. }>;
  115921. /**
  115922. * Fires each time a drag begins (eg. mouse down on mesh)
  115923. */
  115924. onDragStartObservable: Observable<{
  115925. dragPlanePoint: Vector3;
  115926. pointerId: number;
  115927. }>;
  115928. /**
  115929. * Fires each time a drag ends (eg. mouse release after drag)
  115930. */
  115931. onDragEndObservable: Observable<{
  115932. dragPlanePoint: Vector3;
  115933. pointerId: number;
  115934. }>;
  115935. /**
  115936. * If the attached mesh should be moved when dragged
  115937. */
  115938. moveAttached: boolean;
  115939. /**
  115940. * If the drag behavior will react to drag events (Default: true)
  115941. */
  115942. enabled: boolean;
  115943. /**
  115944. * If pointer events should start and release the drag (Default: true)
  115945. */
  115946. startAndReleaseDragOnPointerEvents: boolean;
  115947. /**
  115948. * If camera controls should be detached during the drag
  115949. */
  115950. detachCameraControls: boolean;
  115951. /**
  115952. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  115953. */
  115954. useObjectOrientationForDragging: boolean;
  115955. private _options;
  115956. /**
  115957. * Gets the options used by the behavior
  115958. */
  115959. get options(): {
  115960. dragAxis?: Vector3;
  115961. dragPlaneNormal?: Vector3;
  115962. };
  115963. /**
  115964. * Sets the options used by the behavior
  115965. */
  115966. set options(options: {
  115967. dragAxis?: Vector3;
  115968. dragPlaneNormal?: Vector3;
  115969. });
  115970. /**
  115971. * Creates a pointer drag behavior that can be attached to a mesh
  115972. * @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)
  115973. */
  115974. constructor(options?: {
  115975. dragAxis?: Vector3;
  115976. dragPlaneNormal?: Vector3;
  115977. });
  115978. /**
  115979. * Predicate to determine if it is valid to move the object to a new position when it is moved
  115980. */
  115981. validateDrag: (targetPosition: Vector3) => boolean;
  115982. /**
  115983. * The name of the behavior
  115984. */
  115985. get name(): string;
  115986. /**
  115987. * Initializes the behavior
  115988. */
  115989. init(): void;
  115990. private _tmpVector;
  115991. private _alternatePickedPoint;
  115992. private _worldDragAxis;
  115993. private _targetPosition;
  115994. private _attachedElement;
  115995. /**
  115996. * Attaches the drag behavior the passed in mesh
  115997. * @param ownerNode The mesh that will be dragged around once attached
  115998. * @param predicate Predicate to use for pick filtering
  115999. */
  116000. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  116001. /**
  116002. * Force relase the drag action by code.
  116003. */
  116004. releaseDrag(): void;
  116005. private _startDragRay;
  116006. private _lastPointerRay;
  116007. /**
  116008. * Simulates the start of a pointer drag event on the behavior
  116009. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  116010. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  116011. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  116012. */
  116013. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  116014. private _startDrag;
  116015. private _dragDelta;
  116016. private _moveDrag;
  116017. private _pickWithRayOnDragPlane;
  116018. private _pointA;
  116019. private _pointB;
  116020. private _pointC;
  116021. private _lineA;
  116022. private _lineB;
  116023. private _localAxis;
  116024. private _lookAt;
  116025. private _updateDragPlanePosition;
  116026. /**
  116027. * Detaches the behavior from the mesh
  116028. */
  116029. detach(): void;
  116030. }
  116031. }
  116032. declare module BABYLON {
  116033. /**
  116034. * A behavior that when attached to a mesh will allow the mesh to be scaled
  116035. */
  116036. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  116037. private _dragBehaviorA;
  116038. private _dragBehaviorB;
  116039. private _startDistance;
  116040. private _initialScale;
  116041. private _targetScale;
  116042. private _ownerNode;
  116043. private _sceneRenderObserver;
  116044. /**
  116045. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  116046. */
  116047. constructor();
  116048. /**
  116049. * The name of the behavior
  116050. */
  116051. get name(): string;
  116052. /**
  116053. * Initializes the behavior
  116054. */
  116055. init(): void;
  116056. private _getCurrentDistance;
  116057. /**
  116058. * Attaches the scale behavior the passed in mesh
  116059. * @param ownerNode The mesh that will be scaled around once attached
  116060. */
  116061. attach(ownerNode: Mesh): void;
  116062. /**
  116063. * Detaches the behavior from the mesh
  116064. */
  116065. detach(): void;
  116066. }
  116067. }
  116068. declare module BABYLON {
  116069. /**
  116070. * 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
  116071. */
  116072. export class SixDofDragBehavior implements Behavior<Mesh> {
  116073. private static _virtualScene;
  116074. private _ownerNode;
  116075. private _sceneRenderObserver;
  116076. private _scene;
  116077. private _targetPosition;
  116078. private _virtualOriginMesh;
  116079. private _virtualDragMesh;
  116080. private _pointerObserver;
  116081. private _moving;
  116082. private _startingOrientation;
  116083. private _attachedElement;
  116084. /**
  116085. * 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)
  116086. */
  116087. private zDragFactor;
  116088. /**
  116089. * If the object should rotate to face the drag origin
  116090. */
  116091. rotateDraggedObject: boolean;
  116092. /**
  116093. * If the behavior is currently in a dragging state
  116094. */
  116095. dragging: boolean;
  116096. /**
  116097. * 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)
  116098. */
  116099. dragDeltaRatio: number;
  116100. /**
  116101. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  116102. */
  116103. currentDraggingPointerID: number;
  116104. /**
  116105. * If camera controls should be detached during the drag
  116106. */
  116107. detachCameraControls: boolean;
  116108. /**
  116109. * Fires each time a drag starts
  116110. */
  116111. onDragStartObservable: Observable<{}>;
  116112. /**
  116113. * Fires each time a drag ends (eg. mouse release after drag)
  116114. */
  116115. onDragEndObservable: Observable<{}>;
  116116. /**
  116117. * 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
  116118. */
  116119. constructor();
  116120. /**
  116121. * The name of the behavior
  116122. */
  116123. get name(): string;
  116124. /**
  116125. * Initializes the behavior
  116126. */
  116127. init(): void;
  116128. /**
  116129. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  116130. */
  116131. private get _pointerCamera();
  116132. /**
  116133. * Attaches the scale behavior the passed in mesh
  116134. * @param ownerNode The mesh that will be scaled around once attached
  116135. */
  116136. attach(ownerNode: Mesh): void;
  116137. /**
  116138. * Detaches the behavior from the mesh
  116139. */
  116140. detach(): void;
  116141. }
  116142. }
  116143. declare module BABYLON {
  116144. /**
  116145. * Class used to apply inverse kinematics to bones
  116146. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  116147. */
  116148. export class BoneIKController {
  116149. private static _tmpVecs;
  116150. private static _tmpQuat;
  116151. private static _tmpMats;
  116152. /**
  116153. * Gets or sets the target mesh
  116154. */
  116155. targetMesh: AbstractMesh;
  116156. /** Gets or sets the mesh used as pole */
  116157. poleTargetMesh: AbstractMesh;
  116158. /**
  116159. * Gets or sets the bone used as pole
  116160. */
  116161. poleTargetBone: Nullable<Bone>;
  116162. /**
  116163. * Gets or sets the target position
  116164. */
  116165. targetPosition: Vector3;
  116166. /**
  116167. * Gets or sets the pole target position
  116168. */
  116169. poleTargetPosition: Vector3;
  116170. /**
  116171. * Gets or sets the pole target local offset
  116172. */
  116173. poleTargetLocalOffset: Vector3;
  116174. /**
  116175. * Gets or sets the pole angle
  116176. */
  116177. poleAngle: number;
  116178. /**
  116179. * Gets or sets the mesh associated with the controller
  116180. */
  116181. mesh: AbstractMesh;
  116182. /**
  116183. * 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)
  116184. */
  116185. slerpAmount: number;
  116186. private _bone1Quat;
  116187. private _bone1Mat;
  116188. private _bone2Ang;
  116189. private _bone1;
  116190. private _bone2;
  116191. private _bone1Length;
  116192. private _bone2Length;
  116193. private _maxAngle;
  116194. private _maxReach;
  116195. private _rightHandedSystem;
  116196. private _bendAxis;
  116197. private _slerping;
  116198. private _adjustRoll;
  116199. /**
  116200. * Gets or sets maximum allowed angle
  116201. */
  116202. get maxAngle(): number;
  116203. set maxAngle(value: number);
  116204. /**
  116205. * Creates a new BoneIKController
  116206. * @param mesh defines the mesh to control
  116207. * @param bone defines the bone to control
  116208. * @param options defines options to set up the controller
  116209. */
  116210. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  116211. targetMesh?: AbstractMesh;
  116212. poleTargetMesh?: AbstractMesh;
  116213. poleTargetBone?: Bone;
  116214. poleTargetLocalOffset?: Vector3;
  116215. poleAngle?: number;
  116216. bendAxis?: Vector3;
  116217. maxAngle?: number;
  116218. slerpAmount?: number;
  116219. });
  116220. private _setMaxAngle;
  116221. /**
  116222. * Force the controller to update the bones
  116223. */
  116224. update(): void;
  116225. }
  116226. }
  116227. declare module BABYLON {
  116228. /**
  116229. * Class used to make a bone look toward a point in space
  116230. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  116231. */
  116232. export class BoneLookController {
  116233. private static _tmpVecs;
  116234. private static _tmpQuat;
  116235. private static _tmpMats;
  116236. /**
  116237. * The target Vector3 that the bone will look at
  116238. */
  116239. target: Vector3;
  116240. /**
  116241. * The mesh that the bone is attached to
  116242. */
  116243. mesh: AbstractMesh;
  116244. /**
  116245. * The bone that will be looking to the target
  116246. */
  116247. bone: Bone;
  116248. /**
  116249. * The up axis of the coordinate system that is used when the bone is rotated
  116250. */
  116251. upAxis: Vector3;
  116252. /**
  116253. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  116254. */
  116255. upAxisSpace: Space;
  116256. /**
  116257. * Used to make an adjustment to the yaw of the bone
  116258. */
  116259. adjustYaw: number;
  116260. /**
  116261. * Used to make an adjustment to the pitch of the bone
  116262. */
  116263. adjustPitch: number;
  116264. /**
  116265. * Used to make an adjustment to the roll of the bone
  116266. */
  116267. adjustRoll: number;
  116268. /**
  116269. * 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)
  116270. */
  116271. slerpAmount: number;
  116272. private _minYaw;
  116273. private _maxYaw;
  116274. private _minPitch;
  116275. private _maxPitch;
  116276. private _minYawSin;
  116277. private _minYawCos;
  116278. private _maxYawSin;
  116279. private _maxYawCos;
  116280. private _midYawConstraint;
  116281. private _minPitchTan;
  116282. private _maxPitchTan;
  116283. private _boneQuat;
  116284. private _slerping;
  116285. private _transformYawPitch;
  116286. private _transformYawPitchInv;
  116287. private _firstFrameSkipped;
  116288. private _yawRange;
  116289. private _fowardAxis;
  116290. /**
  116291. * Gets or sets the minimum yaw angle that the bone can look to
  116292. */
  116293. get minYaw(): number;
  116294. set minYaw(value: number);
  116295. /**
  116296. * Gets or sets the maximum yaw angle that the bone can look to
  116297. */
  116298. get maxYaw(): number;
  116299. set maxYaw(value: number);
  116300. /**
  116301. * Gets or sets the minimum pitch angle that the bone can look to
  116302. */
  116303. get minPitch(): number;
  116304. set minPitch(value: number);
  116305. /**
  116306. * Gets or sets the maximum pitch angle that the bone can look to
  116307. */
  116308. get maxPitch(): number;
  116309. set maxPitch(value: number);
  116310. /**
  116311. * Create a BoneLookController
  116312. * @param mesh the mesh that the bone belongs to
  116313. * @param bone the bone that will be looking to the target
  116314. * @param target the target Vector3 to look at
  116315. * @param options optional settings:
  116316. * * maxYaw: the maximum angle the bone will yaw to
  116317. * * minYaw: the minimum angle the bone will yaw to
  116318. * * maxPitch: the maximum angle the bone will pitch to
  116319. * * minPitch: the minimum angle the bone will yaw to
  116320. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  116321. * * upAxis: the up axis of the coordinate system
  116322. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  116323. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  116324. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  116325. * * adjustYaw: used to make an adjustment to the yaw of the bone
  116326. * * adjustPitch: used to make an adjustment to the pitch of the bone
  116327. * * adjustRoll: used to make an adjustment to the roll of the bone
  116328. **/
  116329. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  116330. maxYaw?: number;
  116331. minYaw?: number;
  116332. maxPitch?: number;
  116333. minPitch?: number;
  116334. slerpAmount?: number;
  116335. upAxis?: Vector3;
  116336. upAxisSpace?: Space;
  116337. yawAxis?: Vector3;
  116338. pitchAxis?: Vector3;
  116339. adjustYaw?: number;
  116340. adjustPitch?: number;
  116341. adjustRoll?: number;
  116342. });
  116343. /**
  116344. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  116345. */
  116346. update(): void;
  116347. private _getAngleDiff;
  116348. private _getAngleBetween;
  116349. private _isAngleBetween;
  116350. }
  116351. }
  116352. declare module BABYLON {
  116353. /**
  116354. * Manage the gamepad inputs to control an arc rotate camera.
  116355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116356. */
  116357. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  116358. /**
  116359. * Defines the camera the input is attached to.
  116360. */
  116361. camera: ArcRotateCamera;
  116362. /**
  116363. * Defines the gamepad the input is gathering event from.
  116364. */
  116365. gamepad: Nullable<Gamepad>;
  116366. /**
  116367. * Defines the gamepad rotation sensiblity.
  116368. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116369. */
  116370. gamepadRotationSensibility: number;
  116371. /**
  116372. * Defines the gamepad move sensiblity.
  116373. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116374. */
  116375. gamepadMoveSensibility: number;
  116376. private _yAxisScale;
  116377. /**
  116378. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  116379. */
  116380. get invertYAxis(): boolean;
  116381. set invertYAxis(value: boolean);
  116382. private _onGamepadConnectedObserver;
  116383. private _onGamepadDisconnectedObserver;
  116384. /**
  116385. * Attach the input controls to a specific dom element to get the input from.
  116386. * @param element Defines the element the controls should be listened from
  116387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116388. */
  116389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116390. /**
  116391. * Detach the current controls from the specified dom element.
  116392. * @param element Defines the element to stop listening the inputs from
  116393. */
  116394. detachControl(element: Nullable<HTMLElement>): void;
  116395. /**
  116396. * Update the current camera state depending on the inputs that have been used this frame.
  116397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116398. */
  116399. checkInputs(): void;
  116400. /**
  116401. * Gets the class name of the current intput.
  116402. * @returns the class name
  116403. */
  116404. getClassName(): string;
  116405. /**
  116406. * Get the friendly name associated with the input class.
  116407. * @returns the input friendly name
  116408. */
  116409. getSimpleName(): string;
  116410. }
  116411. }
  116412. declare module BABYLON {
  116413. interface ArcRotateCameraInputsManager {
  116414. /**
  116415. * Add orientation input support to the input manager.
  116416. * @returns the current input manager
  116417. */
  116418. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  116419. }
  116420. /**
  116421. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  116422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116423. */
  116424. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  116425. /**
  116426. * Defines the camera the input is attached to.
  116427. */
  116428. camera: ArcRotateCamera;
  116429. /**
  116430. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  116431. */
  116432. alphaCorrection: number;
  116433. /**
  116434. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  116435. */
  116436. gammaCorrection: number;
  116437. private _alpha;
  116438. private _gamma;
  116439. private _dirty;
  116440. private _deviceOrientationHandler;
  116441. /**
  116442. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  116443. */
  116444. constructor();
  116445. /**
  116446. * Attach the input controls to a specific dom element to get the input from.
  116447. * @param element Defines the element the controls should be listened from
  116448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116449. */
  116450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116451. /** @hidden */
  116452. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  116453. /**
  116454. * Update the current camera state depending on the inputs that have been used this frame.
  116455. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116456. */
  116457. checkInputs(): void;
  116458. /**
  116459. * Detach the current controls from the specified dom element.
  116460. * @param element Defines the element to stop listening the inputs from
  116461. */
  116462. detachControl(element: Nullable<HTMLElement>): void;
  116463. /**
  116464. * Gets the class name of the current intput.
  116465. * @returns the class name
  116466. */
  116467. getClassName(): string;
  116468. /**
  116469. * Get the friendly name associated with the input class.
  116470. * @returns the input friendly name
  116471. */
  116472. getSimpleName(): string;
  116473. }
  116474. }
  116475. declare module BABYLON {
  116476. /**
  116477. * Listen to mouse events to control the camera.
  116478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116479. */
  116480. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  116481. /**
  116482. * Defines the camera the input is attached to.
  116483. */
  116484. camera: FlyCamera;
  116485. /**
  116486. * Defines if touch is enabled. (Default is true.)
  116487. */
  116488. touchEnabled: boolean;
  116489. /**
  116490. * Defines the buttons associated with the input to handle camera rotation.
  116491. */
  116492. buttons: number[];
  116493. /**
  116494. * Assign buttons for Yaw control.
  116495. */
  116496. buttonsYaw: number[];
  116497. /**
  116498. * Assign buttons for Pitch control.
  116499. */
  116500. buttonsPitch: number[];
  116501. /**
  116502. * Assign buttons for Roll control.
  116503. */
  116504. buttonsRoll: number[];
  116505. /**
  116506. * Detect if any button is being pressed while mouse is moved.
  116507. * -1 = Mouse locked.
  116508. * 0 = Left button.
  116509. * 1 = Middle Button.
  116510. * 2 = Right Button.
  116511. */
  116512. activeButton: number;
  116513. /**
  116514. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  116515. * Higher values reduce its sensitivity.
  116516. */
  116517. angularSensibility: number;
  116518. private _mousemoveCallback;
  116519. private _observer;
  116520. private _rollObserver;
  116521. private previousPosition;
  116522. private noPreventDefault;
  116523. private element;
  116524. /**
  116525. * Listen to mouse events to control the camera.
  116526. * @param touchEnabled Define if touch is enabled. (Default is true.)
  116527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116528. */
  116529. constructor(touchEnabled?: boolean);
  116530. /**
  116531. * Attach the mouse control to the HTML DOM element.
  116532. * @param element Defines the element that listens to the input events.
  116533. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  116534. */
  116535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116536. /**
  116537. * Detach the current controls from the specified dom element.
  116538. * @param element Defines the element to stop listening the inputs from
  116539. */
  116540. detachControl(element: Nullable<HTMLElement>): void;
  116541. /**
  116542. * Gets the class name of the current input.
  116543. * @returns the class name.
  116544. */
  116545. getClassName(): string;
  116546. /**
  116547. * Get the friendly name associated with the input class.
  116548. * @returns the input's friendly name.
  116549. */
  116550. getSimpleName(): string;
  116551. private _pointerInput;
  116552. private _onMouseMove;
  116553. /**
  116554. * Rotate camera by mouse offset.
  116555. */
  116556. private rotateCamera;
  116557. }
  116558. }
  116559. declare module BABYLON {
  116560. /**
  116561. * Default Inputs manager for the FlyCamera.
  116562. * It groups all the default supported inputs for ease of use.
  116563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116564. */
  116565. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  116566. /**
  116567. * Instantiates a new FlyCameraInputsManager.
  116568. * @param camera Defines the camera the inputs belong to.
  116569. */
  116570. constructor(camera: FlyCamera);
  116571. /**
  116572. * Add keyboard input support to the input manager.
  116573. * @returns the new FlyCameraKeyboardMoveInput().
  116574. */
  116575. addKeyboard(): FlyCameraInputsManager;
  116576. /**
  116577. * Add mouse input support to the input manager.
  116578. * @param touchEnabled Enable touch screen support.
  116579. * @returns the new FlyCameraMouseInput().
  116580. */
  116581. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  116582. }
  116583. }
  116584. declare module BABYLON {
  116585. /**
  116586. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116587. * such as in a 3D Space Shooter or a Flight Simulator.
  116588. */
  116589. export class FlyCamera extends TargetCamera {
  116590. /**
  116591. * Define the collision ellipsoid of the camera.
  116592. * This is helpful for simulating a camera body, like a player's body.
  116593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  116594. */
  116595. ellipsoid: Vector3;
  116596. /**
  116597. * Define an offset for the position of the ellipsoid around the camera.
  116598. * This can be helpful if the camera is attached away from the player's body center,
  116599. * such as at its head.
  116600. */
  116601. ellipsoidOffset: Vector3;
  116602. /**
  116603. * Enable or disable collisions of the camera with the rest of the scene objects.
  116604. */
  116605. checkCollisions: boolean;
  116606. /**
  116607. * Enable or disable gravity on the camera.
  116608. */
  116609. applyGravity: boolean;
  116610. /**
  116611. * Define the current direction the camera is moving to.
  116612. */
  116613. cameraDirection: Vector3;
  116614. /**
  116615. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  116616. * This overrides and empties cameraRotation.
  116617. */
  116618. rotationQuaternion: Quaternion;
  116619. /**
  116620. * Track Roll to maintain the wanted Rolling when looking around.
  116621. */
  116622. _trackRoll: number;
  116623. /**
  116624. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  116625. */
  116626. rollCorrect: number;
  116627. /**
  116628. * Mimic a banked turn, Rolling the camera when Yawing.
  116629. * It's recommended to use rollCorrect = 10 for faster banking correction.
  116630. */
  116631. bankedTurn: boolean;
  116632. /**
  116633. * Limit in radians for how much Roll banking will add. (Default: 90°)
  116634. */
  116635. bankedTurnLimit: number;
  116636. /**
  116637. * Value of 0 disables the banked Roll.
  116638. * Value of 1 is equal to the Yaw angle in radians.
  116639. */
  116640. bankedTurnMultiplier: number;
  116641. /**
  116642. * The inputs manager loads all the input sources, such as keyboard and mouse.
  116643. */
  116644. inputs: FlyCameraInputsManager;
  116645. /**
  116646. * Gets the input sensibility for mouse input.
  116647. * Higher values reduce sensitivity.
  116648. */
  116649. get angularSensibility(): number;
  116650. /**
  116651. * Sets the input sensibility for a mouse input.
  116652. * Higher values reduce sensitivity.
  116653. */
  116654. set angularSensibility(value: number);
  116655. /**
  116656. * Get the keys for camera movement forward.
  116657. */
  116658. get keysForward(): number[];
  116659. /**
  116660. * Set the keys for camera movement forward.
  116661. */
  116662. set keysForward(value: number[]);
  116663. /**
  116664. * Get the keys for camera movement backward.
  116665. */
  116666. get keysBackward(): number[];
  116667. set keysBackward(value: number[]);
  116668. /**
  116669. * Get the keys for camera movement up.
  116670. */
  116671. get keysUp(): number[];
  116672. /**
  116673. * Set the keys for camera movement up.
  116674. */
  116675. set keysUp(value: number[]);
  116676. /**
  116677. * Get the keys for camera movement down.
  116678. */
  116679. get keysDown(): number[];
  116680. /**
  116681. * Set the keys for camera movement down.
  116682. */
  116683. set keysDown(value: number[]);
  116684. /**
  116685. * Get the keys for camera movement left.
  116686. */
  116687. get keysLeft(): number[];
  116688. /**
  116689. * Set the keys for camera movement left.
  116690. */
  116691. set keysLeft(value: number[]);
  116692. /**
  116693. * Set the keys for camera movement right.
  116694. */
  116695. get keysRight(): number[];
  116696. /**
  116697. * Set the keys for camera movement right.
  116698. */
  116699. set keysRight(value: number[]);
  116700. /**
  116701. * Event raised when the camera collides with a mesh in the scene.
  116702. */
  116703. onCollide: (collidedMesh: AbstractMesh) => void;
  116704. private _collider;
  116705. private _needMoveForGravity;
  116706. private _oldPosition;
  116707. private _diffPosition;
  116708. private _newPosition;
  116709. /** @hidden */
  116710. _localDirection: Vector3;
  116711. /** @hidden */
  116712. _transformedDirection: Vector3;
  116713. /**
  116714. * Instantiates a FlyCamera.
  116715. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116716. * such as in a 3D Space Shooter or a Flight Simulator.
  116717. * @param name Define the name of the camera in the scene.
  116718. * @param position Define the starting position of the camera in the scene.
  116719. * @param scene Define the scene the camera belongs to.
  116720. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  116721. */
  116722. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  116723. /**
  116724. * Attach a control to the HTML DOM element.
  116725. * @param element Defines the element that listens to the input events.
  116726. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  116727. */
  116728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116729. /**
  116730. * Detach a control from the HTML DOM element.
  116731. * The camera will stop reacting to that input.
  116732. * @param element Defines the element that listens to the input events.
  116733. */
  116734. detachControl(element: HTMLElement): void;
  116735. private _collisionMask;
  116736. /**
  116737. * Get the mask that the camera ignores in collision events.
  116738. */
  116739. get collisionMask(): number;
  116740. /**
  116741. * Set the mask that the camera ignores in collision events.
  116742. */
  116743. set collisionMask(mask: number);
  116744. /** @hidden */
  116745. _collideWithWorld(displacement: Vector3): void;
  116746. /** @hidden */
  116747. private _onCollisionPositionChange;
  116748. /** @hidden */
  116749. _checkInputs(): void;
  116750. /** @hidden */
  116751. _decideIfNeedsToMove(): boolean;
  116752. /** @hidden */
  116753. _updatePosition(): void;
  116754. /**
  116755. * Restore the Roll to its target value at the rate specified.
  116756. * @param rate - Higher means slower restoring.
  116757. * @hidden
  116758. */
  116759. restoreRoll(rate: number): void;
  116760. /**
  116761. * Destroy the camera and release the current resources held by it.
  116762. */
  116763. dispose(): void;
  116764. /**
  116765. * Get the current object class name.
  116766. * @returns the class name.
  116767. */
  116768. getClassName(): string;
  116769. }
  116770. }
  116771. declare module BABYLON {
  116772. /**
  116773. * Listen to keyboard events to control the camera.
  116774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116775. */
  116776. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  116777. /**
  116778. * Defines the camera the input is attached to.
  116779. */
  116780. camera: FlyCamera;
  116781. /**
  116782. * The list of keyboard keys used to control the forward move of the camera.
  116783. */
  116784. keysForward: number[];
  116785. /**
  116786. * The list of keyboard keys used to control the backward move of the camera.
  116787. */
  116788. keysBackward: number[];
  116789. /**
  116790. * The list of keyboard keys used to control the forward move of the camera.
  116791. */
  116792. keysUp: number[];
  116793. /**
  116794. * The list of keyboard keys used to control the backward move of the camera.
  116795. */
  116796. keysDown: number[];
  116797. /**
  116798. * The list of keyboard keys used to control the right strafe move of the camera.
  116799. */
  116800. keysRight: number[];
  116801. /**
  116802. * The list of keyboard keys used to control the left strafe move of the camera.
  116803. */
  116804. keysLeft: number[];
  116805. private _keys;
  116806. private _onCanvasBlurObserver;
  116807. private _onKeyboardObserver;
  116808. private _engine;
  116809. private _scene;
  116810. /**
  116811. * Attach the input controls to a specific dom element to get the input from.
  116812. * @param element Defines the element the controls should be listened from
  116813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116814. */
  116815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116816. /**
  116817. * Detach the current controls from the specified dom element.
  116818. * @param element Defines the element to stop listening the inputs from
  116819. */
  116820. detachControl(element: Nullable<HTMLElement>): void;
  116821. /**
  116822. * Gets the class name of the current intput.
  116823. * @returns the class name
  116824. */
  116825. getClassName(): string;
  116826. /** @hidden */
  116827. _onLostFocus(e: FocusEvent): void;
  116828. /**
  116829. * Get the friendly name associated with the input class.
  116830. * @returns the input friendly name
  116831. */
  116832. getSimpleName(): string;
  116833. /**
  116834. * Update the current camera state depending on the inputs that have been used this frame.
  116835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116836. */
  116837. checkInputs(): void;
  116838. }
  116839. }
  116840. declare module BABYLON {
  116841. /**
  116842. * Manage the mouse wheel inputs to control a follow camera.
  116843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116844. */
  116845. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  116846. /**
  116847. * Defines the camera the input is attached to.
  116848. */
  116849. camera: FollowCamera;
  116850. /**
  116851. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  116852. */
  116853. axisControlRadius: boolean;
  116854. /**
  116855. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  116856. */
  116857. axisControlHeight: boolean;
  116858. /**
  116859. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  116860. */
  116861. axisControlRotation: boolean;
  116862. /**
  116863. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  116864. * relation to mouseWheel events.
  116865. */
  116866. wheelPrecision: number;
  116867. /**
  116868. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  116869. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  116870. */
  116871. wheelDeltaPercentage: number;
  116872. private _wheel;
  116873. private _observer;
  116874. /**
  116875. * Attach the input controls to a specific dom element to get the input from.
  116876. * @param element Defines the element the controls should be listened from
  116877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116878. */
  116879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116880. /**
  116881. * Detach the current controls from the specified dom element.
  116882. * @param element Defines the element to stop listening the inputs from
  116883. */
  116884. detachControl(element: Nullable<HTMLElement>): void;
  116885. /**
  116886. * Gets the class name of the current intput.
  116887. * @returns the class name
  116888. */
  116889. getClassName(): string;
  116890. /**
  116891. * Get the friendly name associated with the input class.
  116892. * @returns the input friendly name
  116893. */
  116894. getSimpleName(): string;
  116895. }
  116896. }
  116897. declare module BABYLON {
  116898. /**
  116899. * Manage the pointers inputs to control an follow camera.
  116900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116901. */
  116902. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  116903. /**
  116904. * Defines the camera the input is attached to.
  116905. */
  116906. camera: FollowCamera;
  116907. /**
  116908. * Gets the class name of the current input.
  116909. * @returns the class name
  116910. */
  116911. getClassName(): string;
  116912. /**
  116913. * Defines the pointer angular sensibility along the X axis or how fast is
  116914. * the camera rotating.
  116915. * A negative number will reverse the axis direction.
  116916. */
  116917. angularSensibilityX: number;
  116918. /**
  116919. * Defines the pointer angular sensibility along the Y axis or how fast is
  116920. * the camera rotating.
  116921. * A negative number will reverse the axis direction.
  116922. */
  116923. angularSensibilityY: number;
  116924. /**
  116925. * Defines the pointer pinch precision or how fast is the camera zooming.
  116926. * A negative number will reverse the axis direction.
  116927. */
  116928. pinchPrecision: number;
  116929. /**
  116930. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  116931. * from 0.
  116932. * It defines the percentage of current camera.radius to use as delta when
  116933. * pinch zoom is used.
  116934. */
  116935. pinchDeltaPercentage: number;
  116936. /**
  116937. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  116938. */
  116939. axisXControlRadius: boolean;
  116940. /**
  116941. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  116942. */
  116943. axisXControlHeight: boolean;
  116944. /**
  116945. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  116946. */
  116947. axisXControlRotation: boolean;
  116948. /**
  116949. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  116950. */
  116951. axisYControlRadius: boolean;
  116952. /**
  116953. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  116954. */
  116955. axisYControlHeight: boolean;
  116956. /**
  116957. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  116958. */
  116959. axisYControlRotation: boolean;
  116960. /**
  116961. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  116962. */
  116963. axisPinchControlRadius: boolean;
  116964. /**
  116965. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  116966. */
  116967. axisPinchControlHeight: boolean;
  116968. /**
  116969. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  116970. */
  116971. axisPinchControlRotation: boolean;
  116972. /**
  116973. * Log error messages if basic misconfiguration has occurred.
  116974. */
  116975. warningEnable: boolean;
  116976. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  116977. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  116978. private _warningCounter;
  116979. private _warning;
  116980. }
  116981. }
  116982. declare module BABYLON {
  116983. /**
  116984. * Default Inputs manager for the FollowCamera.
  116985. * It groups all the default supported inputs for ease of use.
  116986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116987. */
  116988. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  116989. /**
  116990. * Instantiates a new FollowCameraInputsManager.
  116991. * @param camera Defines the camera the inputs belong to
  116992. */
  116993. constructor(camera: FollowCamera);
  116994. /**
  116995. * Add keyboard input support to the input manager.
  116996. * @returns the current input manager
  116997. */
  116998. addKeyboard(): FollowCameraInputsManager;
  116999. /**
  117000. * Add mouse wheel input support to the input manager.
  117001. * @returns the current input manager
  117002. */
  117003. addMouseWheel(): FollowCameraInputsManager;
  117004. /**
  117005. * Add pointers input support to the input manager.
  117006. * @returns the current input manager
  117007. */
  117008. addPointers(): FollowCameraInputsManager;
  117009. /**
  117010. * Add orientation input support to the input manager.
  117011. * @returns the current input manager
  117012. */
  117013. addVRDeviceOrientation(): FollowCameraInputsManager;
  117014. }
  117015. }
  117016. declare module BABYLON {
  117017. /**
  117018. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  117019. * an arc rotate version arcFollowCamera are available.
  117020. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  117021. */
  117022. export class FollowCamera extends TargetCamera {
  117023. /**
  117024. * Distance the follow camera should follow an object at
  117025. */
  117026. radius: number;
  117027. /**
  117028. * Minimum allowed distance of the camera to the axis of rotation
  117029. * (The camera can not get closer).
  117030. * This can help limiting how the Camera is able to move in the scene.
  117031. */
  117032. lowerRadiusLimit: Nullable<number>;
  117033. /**
  117034. * Maximum allowed distance of the camera to the axis of rotation
  117035. * (The camera can not get further).
  117036. * This can help limiting how the Camera is able to move in the scene.
  117037. */
  117038. upperRadiusLimit: Nullable<number>;
  117039. /**
  117040. * Define a rotation offset between the camera and the object it follows
  117041. */
  117042. rotationOffset: number;
  117043. /**
  117044. * Minimum allowed angle to camera position relative to target object.
  117045. * This can help limiting how the Camera is able to move in the scene.
  117046. */
  117047. lowerRotationOffsetLimit: Nullable<number>;
  117048. /**
  117049. * Maximum allowed angle to camera position relative to target object.
  117050. * This can help limiting how the Camera is able to move in the scene.
  117051. */
  117052. upperRotationOffsetLimit: Nullable<number>;
  117053. /**
  117054. * Define a height offset between the camera and the object it follows.
  117055. * It can help following an object from the top (like a car chaing a plane)
  117056. */
  117057. heightOffset: number;
  117058. /**
  117059. * Minimum allowed height of camera position relative to target object.
  117060. * This can help limiting how the Camera is able to move in the scene.
  117061. */
  117062. lowerHeightOffsetLimit: Nullable<number>;
  117063. /**
  117064. * Maximum allowed height of camera position relative to target object.
  117065. * This can help limiting how the Camera is able to move in the scene.
  117066. */
  117067. upperHeightOffsetLimit: Nullable<number>;
  117068. /**
  117069. * Define how fast the camera can accelerate to follow it s target.
  117070. */
  117071. cameraAcceleration: number;
  117072. /**
  117073. * Define the speed limit of the camera following an object.
  117074. */
  117075. maxCameraSpeed: number;
  117076. /**
  117077. * Define the target of the camera.
  117078. */
  117079. lockedTarget: Nullable<AbstractMesh>;
  117080. /**
  117081. * Defines the input associated with the camera.
  117082. */
  117083. inputs: FollowCameraInputsManager;
  117084. /**
  117085. * Instantiates the follow camera.
  117086. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  117087. * @param name Define the name of the camera in the scene
  117088. * @param position Define the position of the camera
  117089. * @param scene Define the scene the camera belong to
  117090. * @param lockedTarget Define the target of the camera
  117091. */
  117092. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  117093. private _follow;
  117094. /**
  117095. * Attached controls to the current camera.
  117096. * @param element Defines the element the controls should be listened from
  117097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117098. */
  117099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117100. /**
  117101. * Detach the current controls from the camera.
  117102. * The camera will stop reacting to inputs.
  117103. * @param element Defines the element to stop listening the inputs from
  117104. */
  117105. detachControl(element: HTMLElement): void;
  117106. /** @hidden */
  117107. _checkInputs(): void;
  117108. private _checkLimits;
  117109. /**
  117110. * Gets the camera class name.
  117111. * @returns the class name
  117112. */
  117113. getClassName(): string;
  117114. }
  117115. /**
  117116. * Arc Rotate version of the follow camera.
  117117. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  117118. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  117119. */
  117120. export class ArcFollowCamera extends TargetCamera {
  117121. /** The longitudinal angle of the camera */
  117122. alpha: number;
  117123. /** The latitudinal angle of the camera */
  117124. beta: number;
  117125. /** The radius of the camera from its target */
  117126. radius: number;
  117127. /** Define the camera target (the messh it should follow) */
  117128. target: Nullable<AbstractMesh>;
  117129. private _cartesianCoordinates;
  117130. /**
  117131. * Instantiates a new ArcFollowCamera
  117132. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  117133. * @param name Define the name of the camera
  117134. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  117135. * @param beta Define the rotation angle of the camera around the elevation axis
  117136. * @param radius Define the radius of the camera from its target point
  117137. * @param target Define the target of the camera
  117138. * @param scene Define the scene the camera belongs to
  117139. */
  117140. constructor(name: string,
  117141. /** The longitudinal angle of the camera */
  117142. alpha: number,
  117143. /** The latitudinal angle of the camera */
  117144. beta: number,
  117145. /** The radius of the camera from its target */
  117146. radius: number,
  117147. /** Define the camera target (the messh it should follow) */
  117148. target: Nullable<AbstractMesh>, scene: Scene);
  117149. private _follow;
  117150. /** @hidden */
  117151. _checkInputs(): void;
  117152. /**
  117153. * Returns the class name of the object.
  117154. * It is mostly used internally for serialization purposes.
  117155. */
  117156. getClassName(): string;
  117157. }
  117158. }
  117159. declare module BABYLON {
  117160. /**
  117161. * Manage the keyboard inputs to control the movement of a follow camera.
  117162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117163. */
  117164. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  117165. /**
  117166. * Defines the camera the input is attached to.
  117167. */
  117168. camera: FollowCamera;
  117169. /**
  117170. * Defines the list of key codes associated with the up action (increase heightOffset)
  117171. */
  117172. keysHeightOffsetIncr: number[];
  117173. /**
  117174. * Defines the list of key codes associated with the down action (decrease heightOffset)
  117175. */
  117176. keysHeightOffsetDecr: number[];
  117177. /**
  117178. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  117179. */
  117180. keysHeightOffsetModifierAlt: boolean;
  117181. /**
  117182. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  117183. */
  117184. keysHeightOffsetModifierCtrl: boolean;
  117185. /**
  117186. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  117187. */
  117188. keysHeightOffsetModifierShift: boolean;
  117189. /**
  117190. * Defines the list of key codes associated with the left action (increase rotationOffset)
  117191. */
  117192. keysRotationOffsetIncr: number[];
  117193. /**
  117194. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  117195. */
  117196. keysRotationOffsetDecr: number[];
  117197. /**
  117198. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  117199. */
  117200. keysRotationOffsetModifierAlt: boolean;
  117201. /**
  117202. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  117203. */
  117204. keysRotationOffsetModifierCtrl: boolean;
  117205. /**
  117206. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  117207. */
  117208. keysRotationOffsetModifierShift: boolean;
  117209. /**
  117210. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  117211. */
  117212. keysRadiusIncr: number[];
  117213. /**
  117214. * Defines the list of key codes associated with the zoom-out action (increase radius)
  117215. */
  117216. keysRadiusDecr: number[];
  117217. /**
  117218. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  117219. */
  117220. keysRadiusModifierAlt: boolean;
  117221. /**
  117222. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  117223. */
  117224. keysRadiusModifierCtrl: boolean;
  117225. /**
  117226. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  117227. */
  117228. keysRadiusModifierShift: boolean;
  117229. /**
  117230. * Defines the rate of change of heightOffset.
  117231. */
  117232. heightSensibility: number;
  117233. /**
  117234. * Defines the rate of change of rotationOffset.
  117235. */
  117236. rotationSensibility: number;
  117237. /**
  117238. * Defines the rate of change of radius.
  117239. */
  117240. radiusSensibility: number;
  117241. private _keys;
  117242. private _ctrlPressed;
  117243. private _altPressed;
  117244. private _shiftPressed;
  117245. private _onCanvasBlurObserver;
  117246. private _onKeyboardObserver;
  117247. private _engine;
  117248. private _scene;
  117249. /**
  117250. * Attach the input controls to a specific dom element to get the input from.
  117251. * @param element Defines the element the controls should be listened from
  117252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117253. */
  117254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117255. /**
  117256. * Detach the current controls from the specified dom element.
  117257. * @param element Defines the element to stop listening the inputs from
  117258. */
  117259. detachControl(element: Nullable<HTMLElement>): void;
  117260. /**
  117261. * Update the current camera state depending on the inputs that have been used this frame.
  117262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117263. */
  117264. checkInputs(): void;
  117265. /**
  117266. * Gets the class name of the current input.
  117267. * @returns the class name
  117268. */
  117269. getClassName(): string;
  117270. /**
  117271. * Get the friendly name associated with the input class.
  117272. * @returns the input friendly name
  117273. */
  117274. getSimpleName(): string;
  117275. /**
  117276. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117277. * allow modification of the heightOffset value.
  117278. */
  117279. private _modifierHeightOffset;
  117280. /**
  117281. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117282. * allow modification of the rotationOffset value.
  117283. */
  117284. private _modifierRotationOffset;
  117285. /**
  117286. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117287. * allow modification of the radius value.
  117288. */
  117289. private _modifierRadius;
  117290. }
  117291. }
  117292. declare module BABYLON {
  117293. interface FreeCameraInputsManager {
  117294. /**
  117295. * @hidden
  117296. */
  117297. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  117298. /**
  117299. * Add orientation input support to the input manager.
  117300. * @returns the current input manager
  117301. */
  117302. addDeviceOrientation(): FreeCameraInputsManager;
  117303. }
  117304. /**
  117305. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  117306. * Screen rotation is taken into account.
  117307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117308. */
  117309. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  117310. private _camera;
  117311. private _screenOrientationAngle;
  117312. private _constantTranform;
  117313. private _screenQuaternion;
  117314. private _alpha;
  117315. private _beta;
  117316. private _gamma;
  117317. /**
  117318. * Can be used to detect if a device orientation sensor is available on a device
  117319. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  117320. * @returns a promise that will resolve on orientation change
  117321. */
  117322. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  117323. /**
  117324. * @hidden
  117325. */
  117326. _onDeviceOrientationChangedObservable: Observable<void>;
  117327. /**
  117328. * Instantiates a new input
  117329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117330. */
  117331. constructor();
  117332. /**
  117333. * Define the camera controlled by the input.
  117334. */
  117335. get camera(): FreeCamera;
  117336. set camera(camera: FreeCamera);
  117337. /**
  117338. * Attach the input controls to a specific dom element to get the input from.
  117339. * @param element Defines the element the controls should be listened from
  117340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117341. */
  117342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117343. private _orientationChanged;
  117344. private _deviceOrientation;
  117345. /**
  117346. * Detach the current controls from the specified dom element.
  117347. * @param element Defines the element to stop listening the inputs from
  117348. */
  117349. detachControl(element: Nullable<HTMLElement>): void;
  117350. /**
  117351. * Update the current camera state depending on the inputs that have been used this frame.
  117352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117353. */
  117354. checkInputs(): void;
  117355. /**
  117356. * Gets the class name of the current intput.
  117357. * @returns the class name
  117358. */
  117359. getClassName(): string;
  117360. /**
  117361. * Get the friendly name associated with the input class.
  117362. * @returns the input friendly name
  117363. */
  117364. getSimpleName(): string;
  117365. }
  117366. }
  117367. declare module BABYLON {
  117368. /**
  117369. * Manage the gamepad inputs to control a free camera.
  117370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117371. */
  117372. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  117373. /**
  117374. * Define the camera the input is attached to.
  117375. */
  117376. camera: FreeCamera;
  117377. /**
  117378. * Define the Gamepad controlling the input
  117379. */
  117380. gamepad: Nullable<Gamepad>;
  117381. /**
  117382. * Defines the gamepad rotation sensiblity.
  117383. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117384. */
  117385. gamepadAngularSensibility: number;
  117386. /**
  117387. * Defines the gamepad move sensiblity.
  117388. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117389. */
  117390. gamepadMoveSensibility: number;
  117391. private _yAxisScale;
  117392. /**
  117393. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  117394. */
  117395. get invertYAxis(): boolean;
  117396. set invertYAxis(value: boolean);
  117397. private _onGamepadConnectedObserver;
  117398. private _onGamepadDisconnectedObserver;
  117399. private _cameraTransform;
  117400. private _deltaTransform;
  117401. private _vector3;
  117402. private _vector2;
  117403. /**
  117404. * Attach the input controls to a specific dom element to get the input from.
  117405. * @param element Defines the element the controls should be listened from
  117406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117407. */
  117408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117409. /**
  117410. * Detach the current controls from the specified dom element.
  117411. * @param element Defines the element to stop listening the inputs from
  117412. */
  117413. detachControl(element: Nullable<HTMLElement>): void;
  117414. /**
  117415. * Update the current camera state depending on the inputs that have been used this frame.
  117416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117417. */
  117418. checkInputs(): void;
  117419. /**
  117420. * Gets the class name of the current intput.
  117421. * @returns the class name
  117422. */
  117423. getClassName(): string;
  117424. /**
  117425. * Get the friendly name associated with the input class.
  117426. * @returns the input friendly name
  117427. */
  117428. getSimpleName(): string;
  117429. }
  117430. }
  117431. declare module BABYLON {
  117432. /**
  117433. * Defines the potential axis of a Joystick
  117434. */
  117435. export enum JoystickAxis {
  117436. /** X axis */
  117437. X = 0,
  117438. /** Y axis */
  117439. Y = 1,
  117440. /** Z axis */
  117441. Z = 2
  117442. }
  117443. /**
  117444. * Class used to define virtual joystick (used in touch mode)
  117445. */
  117446. export class VirtualJoystick {
  117447. /**
  117448. * Gets or sets a boolean indicating that left and right values must be inverted
  117449. */
  117450. reverseLeftRight: boolean;
  117451. /**
  117452. * Gets or sets a boolean indicating that up and down values must be inverted
  117453. */
  117454. reverseUpDown: boolean;
  117455. /**
  117456. * Gets the offset value for the position (ie. the change of the position value)
  117457. */
  117458. deltaPosition: Vector3;
  117459. /**
  117460. * Gets a boolean indicating if the virtual joystick was pressed
  117461. */
  117462. pressed: boolean;
  117463. /**
  117464. * Canvas the virtual joystick will render onto, default z-index of this is 5
  117465. */
  117466. static Canvas: Nullable<HTMLCanvasElement>;
  117467. private static _globalJoystickIndex;
  117468. private static vjCanvasContext;
  117469. private static vjCanvasWidth;
  117470. private static vjCanvasHeight;
  117471. private static halfWidth;
  117472. private _action;
  117473. private _axisTargetedByLeftAndRight;
  117474. private _axisTargetedByUpAndDown;
  117475. private _joystickSensibility;
  117476. private _inversedSensibility;
  117477. private _joystickPointerID;
  117478. private _joystickColor;
  117479. private _joystickPointerPos;
  117480. private _joystickPreviousPointerPos;
  117481. private _joystickPointerStartPos;
  117482. private _deltaJoystickVector;
  117483. private _leftJoystick;
  117484. private _touches;
  117485. private _onPointerDownHandlerRef;
  117486. private _onPointerMoveHandlerRef;
  117487. private _onPointerUpHandlerRef;
  117488. private _onResize;
  117489. /**
  117490. * Creates a new virtual joystick
  117491. * @param leftJoystick defines that the joystick is for left hand (false by default)
  117492. */
  117493. constructor(leftJoystick?: boolean);
  117494. /**
  117495. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  117496. * @param newJoystickSensibility defines the new sensibility
  117497. */
  117498. setJoystickSensibility(newJoystickSensibility: number): void;
  117499. private _onPointerDown;
  117500. private _onPointerMove;
  117501. private _onPointerUp;
  117502. /**
  117503. * Change the color of the virtual joystick
  117504. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  117505. */
  117506. setJoystickColor(newColor: string): void;
  117507. /**
  117508. * Defines a callback to call when the joystick is touched
  117509. * @param action defines the callback
  117510. */
  117511. setActionOnTouch(action: () => any): void;
  117512. /**
  117513. * Defines which axis you'd like to control for left & right
  117514. * @param axis defines the axis to use
  117515. */
  117516. setAxisForLeftRight(axis: JoystickAxis): void;
  117517. /**
  117518. * Defines which axis you'd like to control for up & down
  117519. * @param axis defines the axis to use
  117520. */
  117521. setAxisForUpDown(axis: JoystickAxis): void;
  117522. private _drawVirtualJoystick;
  117523. /**
  117524. * Release internal HTML canvas
  117525. */
  117526. releaseCanvas(): void;
  117527. }
  117528. }
  117529. declare module BABYLON {
  117530. interface FreeCameraInputsManager {
  117531. /**
  117532. * Add virtual joystick input support to the input manager.
  117533. * @returns the current input manager
  117534. */
  117535. addVirtualJoystick(): FreeCameraInputsManager;
  117536. }
  117537. /**
  117538. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  117539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117540. */
  117541. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  117542. /**
  117543. * Defines the camera the input is attached to.
  117544. */
  117545. camera: FreeCamera;
  117546. private _leftjoystick;
  117547. private _rightjoystick;
  117548. /**
  117549. * Gets the left stick of the virtual joystick.
  117550. * @returns The virtual Joystick
  117551. */
  117552. getLeftJoystick(): VirtualJoystick;
  117553. /**
  117554. * Gets the right stick of the virtual joystick.
  117555. * @returns The virtual Joystick
  117556. */
  117557. getRightJoystick(): VirtualJoystick;
  117558. /**
  117559. * Update the current camera state depending on the inputs that have been used this frame.
  117560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117561. */
  117562. checkInputs(): void;
  117563. /**
  117564. * Attach the input controls to a specific dom element to get the input from.
  117565. * @param element Defines the element the controls should be listened from
  117566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117567. */
  117568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117569. /**
  117570. * Detach the current controls from the specified dom element.
  117571. * @param element Defines the element to stop listening the inputs from
  117572. */
  117573. detachControl(element: Nullable<HTMLElement>): void;
  117574. /**
  117575. * Gets the class name of the current intput.
  117576. * @returns the class name
  117577. */
  117578. getClassName(): string;
  117579. /**
  117580. * Get the friendly name associated with the input class.
  117581. * @returns the input friendly name
  117582. */
  117583. getSimpleName(): string;
  117584. }
  117585. }
  117586. declare module BABYLON {
  117587. /**
  117588. * This represents a FPS type of camera controlled by touch.
  117589. * This is like a universal camera minus the Gamepad controls.
  117590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117591. */
  117592. export class TouchCamera extends FreeCamera {
  117593. /**
  117594. * Defines the touch sensibility for rotation.
  117595. * The higher the faster.
  117596. */
  117597. get touchAngularSensibility(): number;
  117598. set touchAngularSensibility(value: number);
  117599. /**
  117600. * Defines the touch sensibility for move.
  117601. * The higher the faster.
  117602. */
  117603. get touchMoveSensibility(): number;
  117604. set touchMoveSensibility(value: number);
  117605. /**
  117606. * Instantiates a new touch camera.
  117607. * This represents a FPS type of camera controlled by touch.
  117608. * This is like a universal camera minus the Gamepad controls.
  117609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117610. * @param name Define the name of the camera in the scene
  117611. * @param position Define the start position of the camera in the scene
  117612. * @param scene Define the scene the camera belongs to
  117613. */
  117614. constructor(name: string, position: Vector3, scene: Scene);
  117615. /**
  117616. * Gets the current object class name.
  117617. * @return the class name
  117618. */
  117619. getClassName(): string;
  117620. /** @hidden */
  117621. _setupInputs(): void;
  117622. }
  117623. }
  117624. declare module BABYLON {
  117625. /**
  117626. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  117627. * being tilted forward or back and left or right.
  117628. */
  117629. export class DeviceOrientationCamera extends FreeCamera {
  117630. private _initialQuaternion;
  117631. private _quaternionCache;
  117632. private _tmpDragQuaternion;
  117633. private _disablePointerInputWhenUsingDeviceOrientation;
  117634. /**
  117635. * Creates a new device orientation camera
  117636. * @param name The name of the camera
  117637. * @param position The start position camera
  117638. * @param scene The scene the camera belongs to
  117639. */
  117640. constructor(name: string, position: Vector3, scene: Scene);
  117641. /**
  117642. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  117643. */
  117644. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  117645. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  117646. private _dragFactor;
  117647. /**
  117648. * Enabled turning on the y axis when the orientation sensor is active
  117649. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  117650. */
  117651. enableHorizontalDragging(dragFactor?: number): void;
  117652. /**
  117653. * Gets the current instance class name ("DeviceOrientationCamera").
  117654. * This helps avoiding instanceof at run time.
  117655. * @returns the class name
  117656. */
  117657. getClassName(): string;
  117658. /**
  117659. * @hidden
  117660. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  117661. */
  117662. _checkInputs(): void;
  117663. /**
  117664. * Reset the camera to its default orientation on the specified axis only.
  117665. * @param axis The axis to reset
  117666. */
  117667. resetToCurrentRotation(axis?: Axis): void;
  117668. }
  117669. }
  117670. declare module BABYLON {
  117671. /**
  117672. * Defines supported buttons for XBox360 compatible gamepads
  117673. */
  117674. export enum Xbox360Button {
  117675. /** A */
  117676. A = 0,
  117677. /** B */
  117678. B = 1,
  117679. /** X */
  117680. X = 2,
  117681. /** Y */
  117682. Y = 3,
  117683. /** Left button */
  117684. LB = 4,
  117685. /** Right button */
  117686. RB = 5,
  117687. /** Back */
  117688. Back = 8,
  117689. /** Start */
  117690. Start = 9,
  117691. /** Left stick */
  117692. LeftStick = 10,
  117693. /** Right stick */
  117694. RightStick = 11
  117695. }
  117696. /** Defines values for XBox360 DPad */
  117697. export enum Xbox360Dpad {
  117698. /** Up */
  117699. Up = 12,
  117700. /** Down */
  117701. Down = 13,
  117702. /** Left */
  117703. Left = 14,
  117704. /** Right */
  117705. Right = 15
  117706. }
  117707. /**
  117708. * Defines a XBox360 gamepad
  117709. */
  117710. export class Xbox360Pad extends Gamepad {
  117711. private _leftTrigger;
  117712. private _rightTrigger;
  117713. private _onlefttriggerchanged;
  117714. private _onrighttriggerchanged;
  117715. private _onbuttondown;
  117716. private _onbuttonup;
  117717. private _ondpaddown;
  117718. private _ondpadup;
  117719. /** Observable raised when a button is pressed */
  117720. onButtonDownObservable: Observable<Xbox360Button>;
  117721. /** Observable raised when a button is released */
  117722. onButtonUpObservable: Observable<Xbox360Button>;
  117723. /** Observable raised when a pad is pressed */
  117724. onPadDownObservable: Observable<Xbox360Dpad>;
  117725. /** Observable raised when a pad is released */
  117726. onPadUpObservable: Observable<Xbox360Dpad>;
  117727. private _buttonA;
  117728. private _buttonB;
  117729. private _buttonX;
  117730. private _buttonY;
  117731. private _buttonBack;
  117732. private _buttonStart;
  117733. private _buttonLB;
  117734. private _buttonRB;
  117735. private _buttonLeftStick;
  117736. private _buttonRightStick;
  117737. private _dPadUp;
  117738. private _dPadDown;
  117739. private _dPadLeft;
  117740. private _dPadRight;
  117741. private _isXboxOnePad;
  117742. /**
  117743. * Creates a new XBox360 gamepad object
  117744. * @param id defines the id of this gamepad
  117745. * @param index defines its index
  117746. * @param gamepad defines the internal HTML gamepad object
  117747. * @param xboxOne defines if it is a XBox One gamepad
  117748. */
  117749. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  117750. /**
  117751. * Defines the callback to call when left trigger is pressed
  117752. * @param callback defines the callback to use
  117753. */
  117754. onlefttriggerchanged(callback: (value: number) => void): void;
  117755. /**
  117756. * Defines the callback to call when right trigger is pressed
  117757. * @param callback defines the callback to use
  117758. */
  117759. onrighttriggerchanged(callback: (value: number) => void): void;
  117760. /**
  117761. * Gets the left trigger value
  117762. */
  117763. get leftTrigger(): number;
  117764. /**
  117765. * Sets the left trigger value
  117766. */
  117767. set leftTrigger(newValue: number);
  117768. /**
  117769. * Gets the right trigger value
  117770. */
  117771. get rightTrigger(): number;
  117772. /**
  117773. * Sets the right trigger value
  117774. */
  117775. set rightTrigger(newValue: number);
  117776. /**
  117777. * Defines the callback to call when a button is pressed
  117778. * @param callback defines the callback to use
  117779. */
  117780. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  117781. /**
  117782. * Defines the callback to call when a button is released
  117783. * @param callback defines the callback to use
  117784. */
  117785. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  117786. /**
  117787. * Defines the callback to call when a pad is pressed
  117788. * @param callback defines the callback to use
  117789. */
  117790. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  117791. /**
  117792. * Defines the callback to call when a pad is released
  117793. * @param callback defines the callback to use
  117794. */
  117795. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  117796. private _setButtonValue;
  117797. private _setDPadValue;
  117798. /**
  117799. * Gets the value of the `A` button
  117800. */
  117801. get buttonA(): number;
  117802. /**
  117803. * Sets the value of the `A` button
  117804. */
  117805. set buttonA(value: number);
  117806. /**
  117807. * Gets the value of the `B` button
  117808. */
  117809. get buttonB(): number;
  117810. /**
  117811. * Sets the value of the `B` button
  117812. */
  117813. set buttonB(value: number);
  117814. /**
  117815. * Gets the value of the `X` button
  117816. */
  117817. get buttonX(): number;
  117818. /**
  117819. * Sets the value of the `X` button
  117820. */
  117821. set buttonX(value: number);
  117822. /**
  117823. * Gets the value of the `Y` button
  117824. */
  117825. get buttonY(): number;
  117826. /**
  117827. * Sets the value of the `Y` button
  117828. */
  117829. set buttonY(value: number);
  117830. /**
  117831. * Gets the value of the `Start` button
  117832. */
  117833. get buttonStart(): number;
  117834. /**
  117835. * Sets the value of the `Start` button
  117836. */
  117837. set buttonStart(value: number);
  117838. /**
  117839. * Gets the value of the `Back` button
  117840. */
  117841. get buttonBack(): number;
  117842. /**
  117843. * Sets the value of the `Back` button
  117844. */
  117845. set buttonBack(value: number);
  117846. /**
  117847. * Gets the value of the `Left` button
  117848. */
  117849. get buttonLB(): number;
  117850. /**
  117851. * Sets the value of the `Left` button
  117852. */
  117853. set buttonLB(value: number);
  117854. /**
  117855. * Gets the value of the `Right` button
  117856. */
  117857. get buttonRB(): number;
  117858. /**
  117859. * Sets the value of the `Right` button
  117860. */
  117861. set buttonRB(value: number);
  117862. /**
  117863. * Gets the value of the Left joystick
  117864. */
  117865. get buttonLeftStick(): number;
  117866. /**
  117867. * Sets the value of the Left joystick
  117868. */
  117869. set buttonLeftStick(value: number);
  117870. /**
  117871. * Gets the value of the Right joystick
  117872. */
  117873. get buttonRightStick(): number;
  117874. /**
  117875. * Sets the value of the Right joystick
  117876. */
  117877. set buttonRightStick(value: number);
  117878. /**
  117879. * Gets the value of D-pad up
  117880. */
  117881. get dPadUp(): number;
  117882. /**
  117883. * Sets the value of D-pad up
  117884. */
  117885. set dPadUp(value: number);
  117886. /**
  117887. * Gets the value of D-pad down
  117888. */
  117889. get dPadDown(): number;
  117890. /**
  117891. * Sets the value of D-pad down
  117892. */
  117893. set dPadDown(value: number);
  117894. /**
  117895. * Gets the value of D-pad left
  117896. */
  117897. get dPadLeft(): number;
  117898. /**
  117899. * Sets the value of D-pad left
  117900. */
  117901. set dPadLeft(value: number);
  117902. /**
  117903. * Gets the value of D-pad right
  117904. */
  117905. get dPadRight(): number;
  117906. /**
  117907. * Sets the value of D-pad right
  117908. */
  117909. set dPadRight(value: number);
  117910. /**
  117911. * Force the gamepad to synchronize with device values
  117912. */
  117913. update(): void;
  117914. /**
  117915. * Disposes the gamepad
  117916. */
  117917. dispose(): void;
  117918. }
  117919. }
  117920. declare module BABYLON {
  117921. /**
  117922. * Defines supported buttons for DualShock compatible gamepads
  117923. */
  117924. export enum DualShockButton {
  117925. /** Cross */
  117926. Cross = 0,
  117927. /** Circle */
  117928. Circle = 1,
  117929. /** Square */
  117930. Square = 2,
  117931. /** Triangle */
  117932. Triangle = 3,
  117933. /** L1 */
  117934. L1 = 4,
  117935. /** R1 */
  117936. R1 = 5,
  117937. /** Share */
  117938. Share = 8,
  117939. /** Options */
  117940. Options = 9,
  117941. /** Left stick */
  117942. LeftStick = 10,
  117943. /** Right stick */
  117944. RightStick = 11
  117945. }
  117946. /** Defines values for DualShock DPad */
  117947. export enum DualShockDpad {
  117948. /** Up */
  117949. Up = 12,
  117950. /** Down */
  117951. Down = 13,
  117952. /** Left */
  117953. Left = 14,
  117954. /** Right */
  117955. Right = 15
  117956. }
  117957. /**
  117958. * Defines a DualShock gamepad
  117959. */
  117960. export class DualShockPad extends Gamepad {
  117961. private _leftTrigger;
  117962. private _rightTrigger;
  117963. private _onlefttriggerchanged;
  117964. private _onrighttriggerchanged;
  117965. private _onbuttondown;
  117966. private _onbuttonup;
  117967. private _ondpaddown;
  117968. private _ondpadup;
  117969. /** Observable raised when a button is pressed */
  117970. onButtonDownObservable: Observable<DualShockButton>;
  117971. /** Observable raised when a button is released */
  117972. onButtonUpObservable: Observable<DualShockButton>;
  117973. /** Observable raised when a pad is pressed */
  117974. onPadDownObservable: Observable<DualShockDpad>;
  117975. /** Observable raised when a pad is released */
  117976. onPadUpObservable: Observable<DualShockDpad>;
  117977. private _buttonCross;
  117978. private _buttonCircle;
  117979. private _buttonSquare;
  117980. private _buttonTriangle;
  117981. private _buttonShare;
  117982. private _buttonOptions;
  117983. private _buttonL1;
  117984. private _buttonR1;
  117985. private _buttonLeftStick;
  117986. private _buttonRightStick;
  117987. private _dPadUp;
  117988. private _dPadDown;
  117989. private _dPadLeft;
  117990. private _dPadRight;
  117991. /**
  117992. * Creates a new DualShock gamepad object
  117993. * @param id defines the id of this gamepad
  117994. * @param index defines its index
  117995. * @param gamepad defines the internal HTML gamepad object
  117996. */
  117997. constructor(id: string, index: number, gamepad: any);
  117998. /**
  117999. * Defines the callback to call when left trigger is pressed
  118000. * @param callback defines the callback to use
  118001. */
  118002. onlefttriggerchanged(callback: (value: number) => void): void;
  118003. /**
  118004. * Defines the callback to call when right trigger is pressed
  118005. * @param callback defines the callback to use
  118006. */
  118007. onrighttriggerchanged(callback: (value: number) => void): void;
  118008. /**
  118009. * Gets the left trigger value
  118010. */
  118011. get leftTrigger(): number;
  118012. /**
  118013. * Sets the left trigger value
  118014. */
  118015. set leftTrigger(newValue: number);
  118016. /**
  118017. * Gets the right trigger value
  118018. */
  118019. get rightTrigger(): number;
  118020. /**
  118021. * Sets the right trigger value
  118022. */
  118023. set rightTrigger(newValue: number);
  118024. /**
  118025. * Defines the callback to call when a button is pressed
  118026. * @param callback defines the callback to use
  118027. */
  118028. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  118029. /**
  118030. * Defines the callback to call when a button is released
  118031. * @param callback defines the callback to use
  118032. */
  118033. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  118034. /**
  118035. * Defines the callback to call when a pad is pressed
  118036. * @param callback defines the callback to use
  118037. */
  118038. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  118039. /**
  118040. * Defines the callback to call when a pad is released
  118041. * @param callback defines the callback to use
  118042. */
  118043. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  118044. private _setButtonValue;
  118045. private _setDPadValue;
  118046. /**
  118047. * Gets the value of the `Cross` button
  118048. */
  118049. get buttonCross(): number;
  118050. /**
  118051. * Sets the value of the `Cross` button
  118052. */
  118053. set buttonCross(value: number);
  118054. /**
  118055. * Gets the value of the `Circle` button
  118056. */
  118057. get buttonCircle(): number;
  118058. /**
  118059. * Sets the value of the `Circle` button
  118060. */
  118061. set buttonCircle(value: number);
  118062. /**
  118063. * Gets the value of the `Square` button
  118064. */
  118065. get buttonSquare(): number;
  118066. /**
  118067. * Sets the value of the `Square` button
  118068. */
  118069. set buttonSquare(value: number);
  118070. /**
  118071. * Gets the value of the `Triangle` button
  118072. */
  118073. get buttonTriangle(): number;
  118074. /**
  118075. * Sets the value of the `Triangle` button
  118076. */
  118077. set buttonTriangle(value: number);
  118078. /**
  118079. * Gets the value of the `Options` button
  118080. */
  118081. get buttonOptions(): number;
  118082. /**
  118083. * Sets the value of the `Options` button
  118084. */
  118085. set buttonOptions(value: number);
  118086. /**
  118087. * Gets the value of the `Share` button
  118088. */
  118089. get buttonShare(): number;
  118090. /**
  118091. * Sets the value of the `Share` button
  118092. */
  118093. set buttonShare(value: number);
  118094. /**
  118095. * Gets the value of the `L1` button
  118096. */
  118097. get buttonL1(): number;
  118098. /**
  118099. * Sets the value of the `L1` button
  118100. */
  118101. set buttonL1(value: number);
  118102. /**
  118103. * Gets the value of the `R1` button
  118104. */
  118105. get buttonR1(): number;
  118106. /**
  118107. * Sets the value of the `R1` button
  118108. */
  118109. set buttonR1(value: number);
  118110. /**
  118111. * Gets the value of the Left joystick
  118112. */
  118113. get buttonLeftStick(): number;
  118114. /**
  118115. * Sets the value of the Left joystick
  118116. */
  118117. set buttonLeftStick(value: number);
  118118. /**
  118119. * Gets the value of the Right joystick
  118120. */
  118121. get buttonRightStick(): number;
  118122. /**
  118123. * Sets the value of the Right joystick
  118124. */
  118125. set buttonRightStick(value: number);
  118126. /**
  118127. * Gets the value of D-pad up
  118128. */
  118129. get dPadUp(): number;
  118130. /**
  118131. * Sets the value of D-pad up
  118132. */
  118133. set dPadUp(value: number);
  118134. /**
  118135. * Gets the value of D-pad down
  118136. */
  118137. get dPadDown(): number;
  118138. /**
  118139. * Sets the value of D-pad down
  118140. */
  118141. set dPadDown(value: number);
  118142. /**
  118143. * Gets the value of D-pad left
  118144. */
  118145. get dPadLeft(): number;
  118146. /**
  118147. * Sets the value of D-pad left
  118148. */
  118149. set dPadLeft(value: number);
  118150. /**
  118151. * Gets the value of D-pad right
  118152. */
  118153. get dPadRight(): number;
  118154. /**
  118155. * Sets the value of D-pad right
  118156. */
  118157. set dPadRight(value: number);
  118158. /**
  118159. * Force the gamepad to synchronize with device values
  118160. */
  118161. update(): void;
  118162. /**
  118163. * Disposes the gamepad
  118164. */
  118165. dispose(): void;
  118166. }
  118167. }
  118168. declare module BABYLON {
  118169. /**
  118170. * Manager for handling gamepads
  118171. */
  118172. export class GamepadManager {
  118173. private _scene?;
  118174. private _babylonGamepads;
  118175. private _oneGamepadConnected;
  118176. /** @hidden */
  118177. _isMonitoring: boolean;
  118178. private _gamepadEventSupported;
  118179. private _gamepadSupport?;
  118180. /**
  118181. * observable to be triggered when the gamepad controller has been connected
  118182. */
  118183. onGamepadConnectedObservable: Observable<Gamepad>;
  118184. /**
  118185. * observable to be triggered when the gamepad controller has been disconnected
  118186. */
  118187. onGamepadDisconnectedObservable: Observable<Gamepad>;
  118188. private _onGamepadConnectedEvent;
  118189. private _onGamepadDisconnectedEvent;
  118190. /**
  118191. * Initializes the gamepad manager
  118192. * @param _scene BabylonJS scene
  118193. */
  118194. constructor(_scene?: Scene | undefined);
  118195. /**
  118196. * The gamepads in the game pad manager
  118197. */
  118198. get gamepads(): Gamepad[];
  118199. /**
  118200. * Get the gamepad controllers based on type
  118201. * @param type The type of gamepad controller
  118202. * @returns Nullable gamepad
  118203. */
  118204. getGamepadByType(type?: number): Nullable<Gamepad>;
  118205. /**
  118206. * Disposes the gamepad manager
  118207. */
  118208. dispose(): void;
  118209. private _addNewGamepad;
  118210. private _startMonitoringGamepads;
  118211. private _stopMonitoringGamepads;
  118212. /** @hidden */
  118213. _checkGamepadsStatus(): void;
  118214. private _updateGamepadObjects;
  118215. }
  118216. }
  118217. declare module BABYLON {
  118218. interface Scene {
  118219. /** @hidden */
  118220. _gamepadManager: Nullable<GamepadManager>;
  118221. /**
  118222. * Gets the gamepad manager associated with the scene
  118223. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  118224. */
  118225. gamepadManager: GamepadManager;
  118226. }
  118227. /**
  118228. * Interface representing a free camera inputs manager
  118229. */
  118230. interface FreeCameraInputsManager {
  118231. /**
  118232. * Adds gamepad input support to the FreeCameraInputsManager.
  118233. * @returns the FreeCameraInputsManager
  118234. */
  118235. addGamepad(): FreeCameraInputsManager;
  118236. }
  118237. /**
  118238. * Interface representing an arc rotate camera inputs manager
  118239. */
  118240. interface ArcRotateCameraInputsManager {
  118241. /**
  118242. * Adds gamepad input support to the ArcRotateCamera InputManager.
  118243. * @returns the camera inputs manager
  118244. */
  118245. addGamepad(): ArcRotateCameraInputsManager;
  118246. }
  118247. /**
  118248. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  118249. */
  118250. export class GamepadSystemSceneComponent implements ISceneComponent {
  118251. /**
  118252. * The component name helpfull to identify the component in the list of scene components.
  118253. */
  118254. readonly name: string;
  118255. /**
  118256. * The scene the component belongs to.
  118257. */
  118258. scene: Scene;
  118259. /**
  118260. * Creates a new instance of the component for the given scene
  118261. * @param scene Defines the scene to register the component in
  118262. */
  118263. constructor(scene: Scene);
  118264. /**
  118265. * Registers the component in a given scene
  118266. */
  118267. register(): void;
  118268. /**
  118269. * Rebuilds the elements related to this component in case of
  118270. * context lost for instance.
  118271. */
  118272. rebuild(): void;
  118273. /**
  118274. * Disposes the component and the associated ressources
  118275. */
  118276. dispose(): void;
  118277. private _beforeCameraUpdate;
  118278. }
  118279. }
  118280. declare module BABYLON {
  118281. /**
  118282. * 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,
  118283. * which still works and will still be found in many Playgrounds.
  118284. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118285. */
  118286. export class UniversalCamera extends TouchCamera {
  118287. /**
  118288. * Defines the gamepad rotation sensiblity.
  118289. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  118290. */
  118291. get gamepadAngularSensibility(): number;
  118292. set gamepadAngularSensibility(value: number);
  118293. /**
  118294. * Defines the gamepad move sensiblity.
  118295. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  118296. */
  118297. get gamepadMoveSensibility(): number;
  118298. set gamepadMoveSensibility(value: number);
  118299. /**
  118300. * 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,
  118301. * which still works and will still be found in many Playgrounds.
  118302. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118303. * @param name Define the name of the camera in the scene
  118304. * @param position Define the start position of the camera in the scene
  118305. * @param scene Define the scene the camera belongs to
  118306. */
  118307. constructor(name: string, position: Vector3, scene: Scene);
  118308. /**
  118309. * Gets the current object class name.
  118310. * @return the class name
  118311. */
  118312. getClassName(): string;
  118313. }
  118314. }
  118315. declare module BABYLON {
  118316. /**
  118317. * This represents a FPS type of camera. This is only here for back compat purpose.
  118318. * Please use the UniversalCamera instead as both are identical.
  118319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118320. */
  118321. export class GamepadCamera extends UniversalCamera {
  118322. /**
  118323. * Instantiates a new Gamepad Camera
  118324. * This represents a FPS type of camera. This is only here for back compat purpose.
  118325. * Please use the UniversalCamera instead as both are identical.
  118326. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118327. * @param name Define the name of the camera in the scene
  118328. * @param position Define the start position of the camera in the scene
  118329. * @param scene Define the scene the camera belongs to
  118330. */
  118331. constructor(name: string, position: Vector3, scene: Scene);
  118332. /**
  118333. * Gets the current object class name.
  118334. * @return the class name
  118335. */
  118336. getClassName(): string;
  118337. }
  118338. }
  118339. declare module BABYLON {
  118340. /** @hidden */
  118341. export var passPixelShader: {
  118342. name: string;
  118343. shader: string;
  118344. };
  118345. }
  118346. declare module BABYLON {
  118347. /** @hidden */
  118348. export var passCubePixelShader: {
  118349. name: string;
  118350. shader: string;
  118351. };
  118352. }
  118353. declare module BABYLON {
  118354. /**
  118355. * PassPostProcess which produces an output the same as it's input
  118356. */
  118357. export class PassPostProcess extends PostProcess {
  118358. /**
  118359. * Creates the PassPostProcess
  118360. * @param name The name of the effect.
  118361. * @param options The required width/height ratio to downsize to before computing the render pass.
  118362. * @param camera The camera to apply the render pass to.
  118363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118364. * @param engine The engine which the post process will be applied. (default: current engine)
  118365. * @param reusable If the post process can be reused on the same frame. (default: false)
  118366. * @param textureType The type of texture to be used when performing the post processing.
  118367. * @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)
  118368. */
  118369. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118370. }
  118371. /**
  118372. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118373. */
  118374. export class PassCubePostProcess extends PostProcess {
  118375. private _face;
  118376. /**
  118377. * Gets or sets the cube face to display.
  118378. * * 0 is +X
  118379. * * 1 is -X
  118380. * * 2 is +Y
  118381. * * 3 is -Y
  118382. * * 4 is +Z
  118383. * * 5 is -Z
  118384. */
  118385. get face(): number;
  118386. set face(value: number);
  118387. /**
  118388. * Creates the PassCubePostProcess
  118389. * @param name The name of the effect.
  118390. * @param options The required width/height ratio to downsize to before computing the render pass.
  118391. * @param camera The camera to apply the render pass to.
  118392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118393. * @param engine The engine which the post process will be applied. (default: current engine)
  118394. * @param reusable If the post process can be reused on the same frame. (default: false)
  118395. * @param textureType The type of texture to be used when performing the post processing.
  118396. * @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)
  118397. */
  118398. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118399. }
  118400. }
  118401. declare module BABYLON {
  118402. /** @hidden */
  118403. export var anaglyphPixelShader: {
  118404. name: string;
  118405. shader: string;
  118406. };
  118407. }
  118408. declare module BABYLON {
  118409. /**
  118410. * Postprocess used to generate anaglyphic rendering
  118411. */
  118412. export class AnaglyphPostProcess extends PostProcess {
  118413. private _passedProcess;
  118414. /**
  118415. * Creates a new AnaglyphPostProcess
  118416. * @param name defines postprocess name
  118417. * @param options defines creation options or target ratio scale
  118418. * @param rigCameras defines cameras using this postprocess
  118419. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  118420. * @param engine defines hosting engine
  118421. * @param reusable defines if the postprocess will be reused multiple times per frame
  118422. */
  118423. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  118424. }
  118425. }
  118426. declare module BABYLON {
  118427. /**
  118428. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  118429. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118430. */
  118431. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  118432. /**
  118433. * Creates a new AnaglyphArcRotateCamera
  118434. * @param name defines camera name
  118435. * @param alpha defines alpha angle (in radians)
  118436. * @param beta defines beta angle (in radians)
  118437. * @param radius defines radius
  118438. * @param target defines camera target
  118439. * @param interaxialDistance defines distance between each color axis
  118440. * @param scene defines the hosting scene
  118441. */
  118442. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  118443. /**
  118444. * Gets camera class name
  118445. * @returns AnaglyphArcRotateCamera
  118446. */
  118447. getClassName(): string;
  118448. }
  118449. }
  118450. declare module BABYLON {
  118451. /**
  118452. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  118453. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118454. */
  118455. export class AnaglyphFreeCamera extends FreeCamera {
  118456. /**
  118457. * Creates a new AnaglyphFreeCamera
  118458. * @param name defines camera name
  118459. * @param position defines initial position
  118460. * @param interaxialDistance defines distance between each color axis
  118461. * @param scene defines the hosting scene
  118462. */
  118463. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118464. /**
  118465. * Gets camera class name
  118466. * @returns AnaglyphFreeCamera
  118467. */
  118468. getClassName(): string;
  118469. }
  118470. }
  118471. declare module BABYLON {
  118472. /**
  118473. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  118474. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118475. */
  118476. export class AnaglyphGamepadCamera extends GamepadCamera {
  118477. /**
  118478. * Creates a new AnaglyphGamepadCamera
  118479. * @param name defines camera name
  118480. * @param position defines initial position
  118481. * @param interaxialDistance defines distance between each color axis
  118482. * @param scene defines the hosting scene
  118483. */
  118484. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118485. /**
  118486. * Gets camera class name
  118487. * @returns AnaglyphGamepadCamera
  118488. */
  118489. getClassName(): string;
  118490. }
  118491. }
  118492. declare module BABYLON {
  118493. /**
  118494. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  118495. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118496. */
  118497. export class AnaglyphUniversalCamera extends UniversalCamera {
  118498. /**
  118499. * Creates a new AnaglyphUniversalCamera
  118500. * @param name defines camera name
  118501. * @param position defines initial position
  118502. * @param interaxialDistance defines distance between each color axis
  118503. * @param scene defines the hosting scene
  118504. */
  118505. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118506. /**
  118507. * Gets camera class name
  118508. * @returns AnaglyphUniversalCamera
  118509. */
  118510. getClassName(): string;
  118511. }
  118512. }
  118513. declare module BABYLON {
  118514. /**
  118515. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  118516. * @see http://doc.babylonjs.com/features/cameras
  118517. */
  118518. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  118519. /**
  118520. * Creates a new StereoscopicArcRotateCamera
  118521. * @param name defines camera name
  118522. * @param alpha defines alpha angle (in radians)
  118523. * @param beta defines beta angle (in radians)
  118524. * @param radius defines radius
  118525. * @param target defines camera target
  118526. * @param interaxialDistance defines distance between each color axis
  118527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118528. * @param scene defines the hosting scene
  118529. */
  118530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118531. /**
  118532. * Gets camera class name
  118533. * @returns StereoscopicArcRotateCamera
  118534. */
  118535. getClassName(): string;
  118536. }
  118537. }
  118538. declare module BABYLON {
  118539. /**
  118540. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  118541. * @see http://doc.babylonjs.com/features/cameras
  118542. */
  118543. export class StereoscopicFreeCamera extends FreeCamera {
  118544. /**
  118545. * Creates a new StereoscopicFreeCamera
  118546. * @param name defines camera name
  118547. * @param position defines initial position
  118548. * @param interaxialDistance defines distance between each color axis
  118549. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118550. * @param scene defines the hosting scene
  118551. */
  118552. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118553. /**
  118554. * Gets camera class name
  118555. * @returns StereoscopicFreeCamera
  118556. */
  118557. getClassName(): string;
  118558. }
  118559. }
  118560. declare module BABYLON {
  118561. /**
  118562. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  118563. * @see http://doc.babylonjs.com/features/cameras
  118564. */
  118565. export class StereoscopicGamepadCamera extends GamepadCamera {
  118566. /**
  118567. * Creates a new StereoscopicGamepadCamera
  118568. * @param name defines camera name
  118569. * @param position defines initial position
  118570. * @param interaxialDistance defines distance between each color axis
  118571. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118572. * @param scene defines the hosting scene
  118573. */
  118574. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118575. /**
  118576. * Gets camera class name
  118577. * @returns StereoscopicGamepadCamera
  118578. */
  118579. getClassName(): string;
  118580. }
  118581. }
  118582. declare module BABYLON {
  118583. /**
  118584. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  118585. * @see http://doc.babylonjs.com/features/cameras
  118586. */
  118587. export class StereoscopicUniversalCamera extends UniversalCamera {
  118588. /**
  118589. * Creates a new StereoscopicUniversalCamera
  118590. * @param name defines camera name
  118591. * @param position defines initial position
  118592. * @param interaxialDistance defines distance between each color axis
  118593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118594. * @param scene defines the hosting scene
  118595. */
  118596. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118597. /**
  118598. * Gets camera class name
  118599. * @returns StereoscopicUniversalCamera
  118600. */
  118601. getClassName(): string;
  118602. }
  118603. }
  118604. declare module BABYLON {
  118605. /**
  118606. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  118607. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118608. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118609. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118610. */
  118611. export class VirtualJoysticksCamera extends FreeCamera {
  118612. /**
  118613. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  118614. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118615. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118616. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118617. * @param name Define the name of the camera in the scene
  118618. * @param position Define the start position of the camera in the scene
  118619. * @param scene Define the scene the camera belongs to
  118620. */
  118621. constructor(name: string, position: Vector3, scene: Scene);
  118622. /**
  118623. * Gets the current object class name.
  118624. * @return the class name
  118625. */
  118626. getClassName(): string;
  118627. }
  118628. }
  118629. declare module BABYLON {
  118630. /**
  118631. * This represents all the required metrics to create a VR camera.
  118632. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  118633. */
  118634. export class VRCameraMetrics {
  118635. /**
  118636. * Define the horizontal resolution off the screen.
  118637. */
  118638. hResolution: number;
  118639. /**
  118640. * Define the vertical resolution off the screen.
  118641. */
  118642. vResolution: number;
  118643. /**
  118644. * Define the horizontal screen size.
  118645. */
  118646. hScreenSize: number;
  118647. /**
  118648. * Define the vertical screen size.
  118649. */
  118650. vScreenSize: number;
  118651. /**
  118652. * Define the vertical screen center position.
  118653. */
  118654. vScreenCenter: number;
  118655. /**
  118656. * Define the distance of the eyes to the screen.
  118657. */
  118658. eyeToScreenDistance: number;
  118659. /**
  118660. * Define the distance between both lenses
  118661. */
  118662. lensSeparationDistance: number;
  118663. /**
  118664. * Define the distance between both viewer's eyes.
  118665. */
  118666. interpupillaryDistance: number;
  118667. /**
  118668. * Define the distortion factor of the VR postprocess.
  118669. * Please, touch with care.
  118670. */
  118671. distortionK: number[];
  118672. /**
  118673. * Define the chromatic aberration correction factors for the VR post process.
  118674. */
  118675. chromaAbCorrection: number[];
  118676. /**
  118677. * Define the scale factor of the post process.
  118678. * The smaller the better but the slower.
  118679. */
  118680. postProcessScaleFactor: number;
  118681. /**
  118682. * Define an offset for the lens center.
  118683. */
  118684. lensCenterOffset: number;
  118685. /**
  118686. * Define if the current vr camera should compensate the distortion of the lense or not.
  118687. */
  118688. compensateDistortion: boolean;
  118689. /**
  118690. * Defines if multiview should be enabled when rendering (Default: false)
  118691. */
  118692. multiviewEnabled: boolean;
  118693. /**
  118694. * Gets the rendering aspect ratio based on the provided resolutions.
  118695. */
  118696. get aspectRatio(): number;
  118697. /**
  118698. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  118699. */
  118700. get aspectRatioFov(): number;
  118701. /**
  118702. * @hidden
  118703. */
  118704. get leftHMatrix(): Matrix;
  118705. /**
  118706. * @hidden
  118707. */
  118708. get rightHMatrix(): Matrix;
  118709. /**
  118710. * @hidden
  118711. */
  118712. get leftPreViewMatrix(): Matrix;
  118713. /**
  118714. * @hidden
  118715. */
  118716. get rightPreViewMatrix(): Matrix;
  118717. /**
  118718. * Get the default VRMetrics based on the most generic setup.
  118719. * @returns the default vr metrics
  118720. */
  118721. static GetDefault(): VRCameraMetrics;
  118722. }
  118723. }
  118724. declare module BABYLON {
  118725. /** @hidden */
  118726. export var vrDistortionCorrectionPixelShader: {
  118727. name: string;
  118728. shader: string;
  118729. };
  118730. }
  118731. declare module BABYLON {
  118732. /**
  118733. * VRDistortionCorrectionPostProcess used for mobile VR
  118734. */
  118735. export class VRDistortionCorrectionPostProcess extends PostProcess {
  118736. private _isRightEye;
  118737. private _distortionFactors;
  118738. private _postProcessScaleFactor;
  118739. private _lensCenterOffset;
  118740. private _scaleIn;
  118741. private _scaleFactor;
  118742. private _lensCenter;
  118743. /**
  118744. * Initializes the VRDistortionCorrectionPostProcess
  118745. * @param name The name of the effect.
  118746. * @param camera The camera to apply the render pass to.
  118747. * @param isRightEye If this is for the right eye distortion
  118748. * @param vrMetrics All the required metrics for the VR camera
  118749. */
  118750. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  118751. }
  118752. }
  118753. declare module BABYLON {
  118754. /**
  118755. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  118756. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118757. */
  118758. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  118759. /**
  118760. * Creates a new VRDeviceOrientationArcRotateCamera
  118761. * @param name defines camera name
  118762. * @param alpha defines the camera rotation along the logitudinal axis
  118763. * @param beta defines the camera rotation along the latitudinal axis
  118764. * @param radius defines the camera distance from its target
  118765. * @param target defines the camera target
  118766. * @param scene defines the scene the camera belongs to
  118767. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118768. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118769. */
  118770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118771. /**
  118772. * Gets camera class name
  118773. * @returns VRDeviceOrientationArcRotateCamera
  118774. */
  118775. getClassName(): string;
  118776. }
  118777. }
  118778. declare module BABYLON {
  118779. /**
  118780. * Camera used to simulate VR rendering (based on FreeCamera)
  118781. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118782. */
  118783. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  118784. /**
  118785. * Creates a new VRDeviceOrientationFreeCamera
  118786. * @param name defines camera name
  118787. * @param position defines the start position of the camera
  118788. * @param scene defines the scene the camera belongs to
  118789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118791. */
  118792. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118793. /**
  118794. * Gets camera class name
  118795. * @returns VRDeviceOrientationFreeCamera
  118796. */
  118797. getClassName(): string;
  118798. }
  118799. }
  118800. declare module BABYLON {
  118801. /**
  118802. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  118803. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118804. */
  118805. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  118806. /**
  118807. * Creates a new VRDeviceOrientationGamepadCamera
  118808. * @param name defines camera name
  118809. * @param position defines the start position of the camera
  118810. * @param scene defines the scene the camera belongs to
  118811. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118812. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118813. */
  118814. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118815. /**
  118816. * Gets camera class name
  118817. * @returns VRDeviceOrientationGamepadCamera
  118818. */
  118819. getClassName(): string;
  118820. }
  118821. }
  118822. declare module BABYLON {
  118823. /** @hidden */
  118824. export var imageProcessingPixelShader: {
  118825. name: string;
  118826. shader: string;
  118827. };
  118828. }
  118829. declare module BABYLON {
  118830. /**
  118831. * ImageProcessingPostProcess
  118832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118833. */
  118834. export class ImageProcessingPostProcess extends PostProcess {
  118835. /**
  118836. * Default configuration related to image processing available in the PBR Material.
  118837. */
  118838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118839. /**
  118840. * Gets the image processing configuration used either in this material.
  118841. */
  118842. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118843. /**
  118844. * Sets the Default image processing configuration used either in the this material.
  118845. *
  118846. * If sets to null, the scene one is in use.
  118847. */
  118848. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  118849. /**
  118850. * Keep track of the image processing observer to allow dispose and replace.
  118851. */
  118852. private _imageProcessingObserver;
  118853. /**
  118854. * Attaches a new image processing configuration to the PBR Material.
  118855. * @param configuration
  118856. */
  118857. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  118858. /**
  118859. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118860. */
  118861. get colorCurves(): Nullable<ColorCurves>;
  118862. /**
  118863. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118864. */
  118865. set colorCurves(value: Nullable<ColorCurves>);
  118866. /**
  118867. * Gets wether the color curves effect is enabled.
  118868. */
  118869. get colorCurvesEnabled(): boolean;
  118870. /**
  118871. * Sets wether the color curves effect is enabled.
  118872. */
  118873. set colorCurvesEnabled(value: boolean);
  118874. /**
  118875. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118876. */
  118877. get colorGradingTexture(): Nullable<BaseTexture>;
  118878. /**
  118879. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118880. */
  118881. set colorGradingTexture(value: Nullable<BaseTexture>);
  118882. /**
  118883. * Gets wether the color grading effect is enabled.
  118884. */
  118885. get colorGradingEnabled(): boolean;
  118886. /**
  118887. * Gets wether the color grading effect is enabled.
  118888. */
  118889. set colorGradingEnabled(value: boolean);
  118890. /**
  118891. * Gets exposure used in the effect.
  118892. */
  118893. get exposure(): number;
  118894. /**
  118895. * Sets exposure used in the effect.
  118896. */
  118897. set exposure(value: number);
  118898. /**
  118899. * Gets wether tonemapping is enabled or not.
  118900. */
  118901. get toneMappingEnabled(): boolean;
  118902. /**
  118903. * Sets wether tonemapping is enabled or not
  118904. */
  118905. set toneMappingEnabled(value: boolean);
  118906. /**
  118907. * Gets the type of tone mapping effect.
  118908. */
  118909. get toneMappingType(): number;
  118910. /**
  118911. * Sets the type of tone mapping effect.
  118912. */
  118913. set toneMappingType(value: number);
  118914. /**
  118915. * Gets contrast used in the effect.
  118916. */
  118917. get contrast(): number;
  118918. /**
  118919. * Sets contrast used in the effect.
  118920. */
  118921. set contrast(value: number);
  118922. /**
  118923. * Gets Vignette stretch size.
  118924. */
  118925. get vignetteStretch(): number;
  118926. /**
  118927. * Sets Vignette stretch size.
  118928. */
  118929. set vignetteStretch(value: number);
  118930. /**
  118931. * Gets Vignette centre X Offset.
  118932. */
  118933. get vignetteCentreX(): number;
  118934. /**
  118935. * Sets Vignette centre X Offset.
  118936. */
  118937. set vignetteCentreX(value: number);
  118938. /**
  118939. * Gets Vignette centre Y Offset.
  118940. */
  118941. get vignetteCentreY(): number;
  118942. /**
  118943. * Sets Vignette centre Y Offset.
  118944. */
  118945. set vignetteCentreY(value: number);
  118946. /**
  118947. * Gets Vignette weight or intensity of the vignette effect.
  118948. */
  118949. get vignetteWeight(): number;
  118950. /**
  118951. * Sets Vignette weight or intensity of the vignette effect.
  118952. */
  118953. set vignetteWeight(value: number);
  118954. /**
  118955. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118956. * if vignetteEnabled is set to true.
  118957. */
  118958. get vignetteColor(): Color4;
  118959. /**
  118960. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118961. * if vignetteEnabled is set to true.
  118962. */
  118963. set vignetteColor(value: Color4);
  118964. /**
  118965. * Gets Camera field of view used by the Vignette effect.
  118966. */
  118967. get vignetteCameraFov(): number;
  118968. /**
  118969. * Sets Camera field of view used by the Vignette effect.
  118970. */
  118971. set vignetteCameraFov(value: number);
  118972. /**
  118973. * Gets the vignette blend mode allowing different kind of effect.
  118974. */
  118975. get vignetteBlendMode(): number;
  118976. /**
  118977. * Sets the vignette blend mode allowing different kind of effect.
  118978. */
  118979. set vignetteBlendMode(value: number);
  118980. /**
  118981. * Gets wether the vignette effect is enabled.
  118982. */
  118983. get vignetteEnabled(): boolean;
  118984. /**
  118985. * Sets wether the vignette effect is enabled.
  118986. */
  118987. set vignetteEnabled(value: boolean);
  118988. private _fromLinearSpace;
  118989. /**
  118990. * Gets wether the input of the processing is in Gamma or Linear Space.
  118991. */
  118992. get fromLinearSpace(): boolean;
  118993. /**
  118994. * Sets wether the input of the processing is in Gamma or Linear Space.
  118995. */
  118996. set fromLinearSpace(value: boolean);
  118997. /**
  118998. * Defines cache preventing GC.
  118999. */
  119000. private _defines;
  119001. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  119002. /**
  119003. * "ImageProcessingPostProcess"
  119004. * @returns "ImageProcessingPostProcess"
  119005. */
  119006. getClassName(): string;
  119007. protected _updateParameters(): void;
  119008. dispose(camera?: Camera): void;
  119009. }
  119010. }
  119011. declare module BABYLON {
  119012. /**
  119013. * Class containing static functions to help procedurally build meshes
  119014. */
  119015. export class GroundBuilder {
  119016. /**
  119017. * Creates a ground mesh
  119018. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  119019. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  119020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119021. * @param name defines the name of the mesh
  119022. * @param options defines the options used to create the mesh
  119023. * @param scene defines the hosting scene
  119024. * @returns the ground mesh
  119025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  119026. */
  119027. static CreateGround(name: string, options: {
  119028. width?: number;
  119029. height?: number;
  119030. subdivisions?: number;
  119031. subdivisionsX?: number;
  119032. subdivisionsY?: number;
  119033. updatable?: boolean;
  119034. }, scene: any): Mesh;
  119035. /**
  119036. * Creates a tiled ground mesh
  119037. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  119038. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  119039. * * 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
  119040. * * 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
  119041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119042. * @param name defines the name of the mesh
  119043. * @param options defines the options used to create the mesh
  119044. * @param scene defines the hosting scene
  119045. * @returns the tiled ground mesh
  119046. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  119047. */
  119048. static CreateTiledGround(name: string, options: {
  119049. xmin: number;
  119050. zmin: number;
  119051. xmax: number;
  119052. zmax: number;
  119053. subdivisions?: {
  119054. w: number;
  119055. h: number;
  119056. };
  119057. precision?: {
  119058. w: number;
  119059. h: number;
  119060. };
  119061. updatable?: boolean;
  119062. }, scene?: Nullable<Scene>): Mesh;
  119063. /**
  119064. * Creates a ground mesh from a height map
  119065. * * The parameter `url` sets the URL of the height map image resource.
  119066. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  119067. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  119068. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  119069. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  119070. * * 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.
  119071. * * 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).
  119072. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  119073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119074. * @param name defines the name of the mesh
  119075. * @param url defines the url to the height map
  119076. * @param options defines the options used to create the mesh
  119077. * @param scene defines the hosting scene
  119078. * @returns the ground mesh
  119079. * @see https://doc.babylonjs.com/babylon101/height_map
  119080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  119081. */
  119082. static CreateGroundFromHeightMap(name: string, url: string, options: {
  119083. width?: number;
  119084. height?: number;
  119085. subdivisions?: number;
  119086. minHeight?: number;
  119087. maxHeight?: number;
  119088. colorFilter?: Color3;
  119089. alphaFilter?: number;
  119090. updatable?: boolean;
  119091. onReady?: (mesh: GroundMesh) => void;
  119092. }, scene?: Nullable<Scene>): GroundMesh;
  119093. }
  119094. }
  119095. declare module BABYLON {
  119096. /**
  119097. * Class containing static functions to help procedurally build meshes
  119098. */
  119099. export class TorusBuilder {
  119100. /**
  119101. * Creates a torus mesh
  119102. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119103. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119104. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  119105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119106. * * 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
  119107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119108. * @param name defines the name of the mesh
  119109. * @param options defines the options used to create the mesh
  119110. * @param scene defines the hosting scene
  119111. * @returns the torus mesh
  119112. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  119113. */
  119114. static CreateTorus(name: string, options: {
  119115. diameter?: number;
  119116. thickness?: number;
  119117. tessellation?: number;
  119118. updatable?: boolean;
  119119. sideOrientation?: number;
  119120. frontUVs?: Vector4;
  119121. backUVs?: Vector4;
  119122. }, scene: any): Mesh;
  119123. }
  119124. }
  119125. declare module BABYLON {
  119126. /**
  119127. * Class containing static functions to help procedurally build meshes
  119128. */
  119129. export class CylinderBuilder {
  119130. /**
  119131. * Creates a cylinder or a cone mesh
  119132. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119133. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119134. * * 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.
  119135. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119136. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119137. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119138. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119139. * * 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).
  119140. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119141. * * 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).
  119142. * * 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
  119143. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119144. * * 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
  119145. * * 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.
  119146. * * If `enclose` is false, a ring surface is one element.
  119147. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119148. * * 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
  119149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119150. * * 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
  119151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119152. * @param name defines the name of the mesh
  119153. * @param options defines the options used to create the mesh
  119154. * @param scene defines the hosting scene
  119155. * @returns the cylinder mesh
  119156. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119157. */
  119158. static CreateCylinder(name: string, options: {
  119159. height?: number;
  119160. diameterTop?: number;
  119161. diameterBottom?: number;
  119162. diameter?: number;
  119163. tessellation?: number;
  119164. subdivisions?: number;
  119165. arc?: number;
  119166. faceColors?: Color4[];
  119167. faceUV?: Vector4[];
  119168. updatable?: boolean;
  119169. hasRings?: boolean;
  119170. enclose?: boolean;
  119171. cap?: number;
  119172. sideOrientation?: number;
  119173. frontUVs?: Vector4;
  119174. backUVs?: Vector4;
  119175. }, scene: any): Mesh;
  119176. }
  119177. }
  119178. declare module BABYLON {
  119179. /**
  119180. * States of the webXR experience
  119181. */
  119182. export enum WebXRState {
  119183. /**
  119184. * Transitioning to being in XR mode
  119185. */
  119186. ENTERING_XR = 0,
  119187. /**
  119188. * Transitioning to non XR mode
  119189. */
  119190. EXITING_XR = 1,
  119191. /**
  119192. * In XR mode and presenting
  119193. */
  119194. IN_XR = 2,
  119195. /**
  119196. * Not entered XR mode
  119197. */
  119198. NOT_IN_XR = 3
  119199. }
  119200. /**
  119201. * Abstraction of the XR render target
  119202. */
  119203. export interface WebXRRenderTarget extends IDisposable {
  119204. /**
  119205. * xrpresent context of the canvas which can be used to display/mirror xr content
  119206. */
  119207. canvasContext: WebGLRenderingContext;
  119208. /**
  119209. * xr layer for the canvas
  119210. */
  119211. xrLayer: Nullable<XRWebGLLayer>;
  119212. /**
  119213. * Initializes the xr layer for the session
  119214. * @param xrSession xr session
  119215. * @returns a promise that will resolve once the XR Layer has been created
  119216. */
  119217. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119218. }
  119219. }
  119220. declare module BABYLON {
  119221. /**
  119222. * COnfiguration object for WebXR output canvas
  119223. */
  119224. export class WebXRManagedOutputCanvasOptions {
  119225. /**
  119226. * An optional canvas in case you wish to create it yourself and provide it here.
  119227. * If not provided, a new canvas will be created
  119228. */
  119229. canvasElement?: HTMLCanvasElement;
  119230. /**
  119231. * Options for this XR Layer output
  119232. */
  119233. canvasOptions?: XRWebGLLayerOptions;
  119234. /**
  119235. * CSS styling for a newly created canvas (if not provided)
  119236. */
  119237. newCanvasCssStyle?: string;
  119238. /**
  119239. * Get the default values of the configuration object
  119240. * @returns default values of this configuration object
  119241. */
  119242. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  119243. }
  119244. /**
  119245. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  119246. */
  119247. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  119248. private _options;
  119249. private _canvas;
  119250. private _engine;
  119251. /**
  119252. * Rendering context of the canvas which can be used to display/mirror xr content
  119253. */
  119254. canvasContext: WebGLRenderingContext;
  119255. /**
  119256. * xr layer for the canvas
  119257. */
  119258. xrLayer: Nullable<XRWebGLLayer>;
  119259. /**
  119260. * Initializes the canvas to be added/removed upon entering/exiting xr
  119261. * @param _xrSessionManager The XR Session manager
  119262. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  119263. */
  119264. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  119265. /**
  119266. * Disposes of the object
  119267. */
  119268. dispose(): void;
  119269. /**
  119270. * Initializes the xr layer for the session
  119271. * @param xrSession xr session
  119272. * @returns a promise that will resolve once the XR Layer has been created
  119273. */
  119274. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119275. private _addCanvas;
  119276. private _removeCanvas;
  119277. private _setManagedOutputCanvas;
  119278. }
  119279. }
  119280. declare module BABYLON {
  119281. /**
  119282. * Manages an XRSession to work with Babylon's engine
  119283. * @see https://doc.babylonjs.com/how_to/webxr
  119284. */
  119285. export class WebXRSessionManager implements IDisposable {
  119286. /** The scene which the session should be created for */
  119287. scene: Scene;
  119288. private _referenceSpace;
  119289. private _rttProvider;
  119290. private _sessionEnded;
  119291. private _xrNavigator;
  119292. private baseLayer;
  119293. /**
  119294. * The base reference space from which the session started. good if you want to reset your
  119295. * reference space
  119296. */
  119297. baseReferenceSpace: XRReferenceSpace;
  119298. /**
  119299. * Current XR frame
  119300. */
  119301. currentFrame: Nullable<XRFrame>;
  119302. /** WebXR timestamp updated every frame */
  119303. currentTimestamp: number;
  119304. /**
  119305. * Used just in case of a failure to initialize an immersive session.
  119306. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  119307. */
  119308. defaultHeightCompensation: number;
  119309. /**
  119310. * Fires every time a new xrFrame arrives which can be used to update the camera
  119311. */
  119312. onXRFrameObservable: Observable<XRFrame>;
  119313. /**
  119314. * Fires when the reference space changed
  119315. */
  119316. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  119317. /**
  119318. * Fires when the xr session is ended either by the device or manually done
  119319. */
  119320. onXRSessionEnded: Observable<any>;
  119321. /**
  119322. * Fires when the xr session is ended either by the device or manually done
  119323. */
  119324. onXRSessionInit: Observable<XRSession>;
  119325. /**
  119326. * Underlying xr session
  119327. */
  119328. session: XRSession;
  119329. /**
  119330. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  119331. * or get the offset the player is currently at.
  119332. */
  119333. viewerReferenceSpace: XRReferenceSpace;
  119334. /**
  119335. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  119336. * @param scene The scene which the session should be created for
  119337. */
  119338. constructor(
  119339. /** The scene which the session should be created for */
  119340. scene: Scene);
  119341. /**
  119342. * The current reference space used in this session. This reference space can constantly change!
  119343. * It is mainly used to offset the camera's position.
  119344. */
  119345. get referenceSpace(): XRReferenceSpace;
  119346. /**
  119347. * Set a new reference space and triggers the observable
  119348. */
  119349. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  119350. /**
  119351. * Disposes of the session manager
  119352. */
  119353. dispose(): void;
  119354. /**
  119355. * Stops the xrSession and restores the render loop
  119356. * @returns Promise which resolves after it exits XR
  119357. */
  119358. exitXRAsync(): Promise<void>;
  119359. /**
  119360. * Gets the correct render target texture to be rendered this frame for this eye
  119361. * @param eye the eye for which to get the render target
  119362. * @returns the render target for the specified eye
  119363. */
  119364. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  119365. /**
  119366. * Creates a WebXRRenderTarget object for the XR session
  119367. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  119368. * @param options optional options to provide when creating a new render target
  119369. * @returns a WebXR render target to which the session can render
  119370. */
  119371. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  119372. /**
  119373. * Initializes the manager
  119374. * After initialization enterXR can be called to start an XR session
  119375. * @returns Promise which resolves after it is initialized
  119376. */
  119377. initializeAsync(): Promise<void>;
  119378. /**
  119379. * Initializes an xr session
  119380. * @param xrSessionMode mode to initialize
  119381. * @param xrSessionInit defines optional and required values to pass to the session builder
  119382. * @returns a promise which will resolve once the session has been initialized
  119383. */
  119384. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  119385. /**
  119386. * Checks if a session would be supported for the creation options specified
  119387. * @param sessionMode session mode to check if supported eg. immersive-vr
  119388. * @returns A Promise that resolves to true if supported and false if not
  119389. */
  119390. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119391. /**
  119392. * Resets the reference space to the one started the session
  119393. */
  119394. resetReferenceSpace(): void;
  119395. /**
  119396. * Starts rendering to the xr layer
  119397. */
  119398. runXRRenderLoop(): void;
  119399. /**
  119400. * Sets the reference space on the xr session
  119401. * @param referenceSpaceType space to set
  119402. * @returns a promise that will resolve once the reference space has been set
  119403. */
  119404. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  119405. /**
  119406. * Updates the render state of the session
  119407. * @param state state to set
  119408. * @returns a promise that resolves once the render state has been updated
  119409. */
  119410. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  119411. /**
  119412. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  119413. * @param sessionMode defines the session to test
  119414. * @returns a promise with boolean as final value
  119415. */
  119416. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119417. private _createRenderTargetTexture;
  119418. }
  119419. }
  119420. declare module BABYLON {
  119421. /**
  119422. * WebXR Camera which holds the views for the xrSession
  119423. * @see https://doc.babylonjs.com/how_to/webxr_camera
  119424. */
  119425. export class WebXRCamera extends FreeCamera {
  119426. private _xrSessionManager;
  119427. private _firstFrame;
  119428. private _referenceQuaternion;
  119429. private _referencedPosition;
  119430. private _xrInvPositionCache;
  119431. private _xrInvQuaternionCache;
  119432. /**
  119433. * Should position compensation execute on first frame.
  119434. * This is used when copying the position from a native (non XR) camera
  119435. */
  119436. compensateOnFirstFrame: boolean;
  119437. /**
  119438. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  119439. * @param name the name of the camera
  119440. * @param scene the scene to add the camera to
  119441. * @param _xrSessionManager a constructed xr session manager
  119442. */
  119443. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  119444. /**
  119445. * Return the user's height, unrelated to the current ground.
  119446. * This will be the y position of this camera, when ground level is 0.
  119447. */
  119448. get realWorldHeight(): number;
  119449. /** @hidden */
  119450. _updateForDualEyeDebugging(): void;
  119451. /**
  119452. * Sets this camera's transformation based on a non-vr camera
  119453. * @param otherCamera the non-vr camera to copy the transformation from
  119454. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  119455. */
  119456. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  119457. /**
  119458. * Gets the current instance class name ("WebXRCamera").
  119459. * @returns the class name
  119460. */
  119461. getClassName(): string;
  119462. private _updateFromXRSession;
  119463. private _updateNumberOfRigCameras;
  119464. private _updateReferenceSpace;
  119465. private _updateReferenceSpaceOffset;
  119466. }
  119467. }
  119468. declare module BABYLON {
  119469. /**
  119470. * Defining the interface required for a (webxr) feature
  119471. */
  119472. export interface IWebXRFeature extends IDisposable {
  119473. /**
  119474. * Is this feature attached
  119475. */
  119476. attached: boolean;
  119477. /**
  119478. * Should auto-attach be disabled?
  119479. */
  119480. disableAutoAttach: boolean;
  119481. /**
  119482. * Attach the feature to the session
  119483. * Will usually be called by the features manager
  119484. *
  119485. * @param force should attachment be forced (even when already attached)
  119486. * @returns true if successful.
  119487. */
  119488. attach(force?: boolean): boolean;
  119489. /**
  119490. * Detach the feature from the session
  119491. * Will usually be called by the features manager
  119492. *
  119493. * @returns true if successful.
  119494. */
  119495. detach(): boolean;
  119496. }
  119497. /**
  119498. * A list of the currently available features without referencing them
  119499. */
  119500. export class WebXRFeatureName {
  119501. /**
  119502. * The name of the anchor system feature
  119503. */
  119504. static ANCHOR_SYSTEM: string;
  119505. /**
  119506. * The name of the background remover feature
  119507. */
  119508. static BACKGROUND_REMOVER: string;
  119509. /**
  119510. * The name of the hit test feature
  119511. */
  119512. static HIT_TEST: string;
  119513. /**
  119514. * physics impostors for xr controllers feature
  119515. */
  119516. static PHYSICS_CONTROLLERS: string;
  119517. /**
  119518. * The name of the plane detection feature
  119519. */
  119520. static PLANE_DETECTION: string;
  119521. /**
  119522. * The name of the pointer selection feature
  119523. */
  119524. static POINTER_SELECTION: string;
  119525. /**
  119526. * The name of the teleportation feature
  119527. */
  119528. static TELEPORTATION: string;
  119529. }
  119530. /**
  119531. * Defining the constructor of a feature. Used to register the modules.
  119532. */
  119533. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  119534. /**
  119535. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  119536. * It is mainly used in AR sessions.
  119537. *
  119538. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  119539. */
  119540. export class WebXRFeaturesManager implements IDisposable {
  119541. private _xrSessionManager;
  119542. private static readonly _AvailableFeatures;
  119543. private _features;
  119544. /**
  119545. * constructs a new features manages.
  119546. *
  119547. * @param _xrSessionManager an instance of WebXRSessionManager
  119548. */
  119549. constructor(_xrSessionManager: WebXRSessionManager);
  119550. /**
  119551. * Used to register a module. After calling this function a developer can use this feature in the scene.
  119552. * Mainly used internally.
  119553. *
  119554. * @param featureName the name of the feature to register
  119555. * @param constructorFunction the function used to construct the module
  119556. * @param version the (babylon) version of the module
  119557. * @param stable is that a stable version of this module
  119558. */
  119559. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  119560. /**
  119561. * Returns a constructor of a specific feature.
  119562. *
  119563. * @param featureName the name of the feature to construct
  119564. * @param version the version of the feature to load
  119565. * @param xrSessionManager the xrSessionManager. Used to construct the module
  119566. * @param options optional options provided to the module.
  119567. * @returns a function that, when called, will return a new instance of this feature
  119568. */
  119569. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  119570. /**
  119571. * Can be used to return the list of features currently registered
  119572. *
  119573. * @returns an Array of available features
  119574. */
  119575. static GetAvailableFeatures(): string[];
  119576. /**
  119577. * Gets the versions available for a specific feature
  119578. * @param featureName the name of the feature
  119579. * @returns an array with the available versions
  119580. */
  119581. static GetAvailableVersions(featureName: string): string[];
  119582. /**
  119583. * Return the latest unstable version of this feature
  119584. * @param featureName the name of the feature to search
  119585. * @returns the version number. if not found will return -1
  119586. */
  119587. static GetLatestVersionOfFeature(featureName: string): number;
  119588. /**
  119589. * Return the latest stable version of this feature
  119590. * @param featureName the name of the feature to search
  119591. * @returns the version number. if not found will return -1
  119592. */
  119593. static GetStableVersionOfFeature(featureName: string): number;
  119594. /**
  119595. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  119596. * Can be used during a session to start a feature
  119597. * @param featureName the name of feature to attach
  119598. */
  119599. attachFeature(featureName: string): void;
  119600. /**
  119601. * Can be used inside a session or when the session ends to detach a specific feature
  119602. * @param featureName the name of the feature to detach
  119603. */
  119604. detachFeature(featureName: string): void;
  119605. /**
  119606. * Used to disable an already-enabled feature
  119607. * The feature will be disposed and will be recreated once enabled.
  119608. * @param featureName the feature to disable
  119609. * @returns true if disable was successful
  119610. */
  119611. disableFeature(featureName: string | {
  119612. Name: string;
  119613. }): boolean;
  119614. /**
  119615. * dispose this features manager
  119616. */
  119617. dispose(): void;
  119618. /**
  119619. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  119620. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  119621. *
  119622. * @param featureName the name of the feature to load or the class of the feature
  119623. * @param version optional version to load. if not provided the latest version will be enabled
  119624. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  119625. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  119626. * @returns a new constructed feature or throws an error if feature not found.
  119627. */
  119628. enableFeature(featureName: string | {
  119629. Name: string;
  119630. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  119631. /**
  119632. * get the implementation of an enabled feature.
  119633. * @param featureName the name of the feature to load
  119634. * @returns the feature class, if found
  119635. */
  119636. getEnabledFeature(featureName: string): IWebXRFeature;
  119637. /**
  119638. * Get the list of enabled features
  119639. * @returns an array of enabled features
  119640. */
  119641. getEnabledFeatures(): string[];
  119642. }
  119643. }
  119644. declare module BABYLON {
  119645. /**
  119646. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  119647. * @see https://doc.babylonjs.com/how_to/webxr
  119648. */
  119649. export class WebXRExperienceHelper implements IDisposable {
  119650. private scene;
  119651. private _nonVRCamera;
  119652. private _originalSceneAutoClear;
  119653. private _supported;
  119654. /**
  119655. * Camera used to render xr content
  119656. */
  119657. camera: WebXRCamera;
  119658. /** A features manager for this xr session */
  119659. featuresManager: WebXRFeaturesManager;
  119660. /**
  119661. * Observers registered here will be triggered after the camera's initial transformation is set
  119662. * This can be used to set a different ground level or an extra rotation.
  119663. *
  119664. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  119665. * to the position set after this observable is done executing.
  119666. */
  119667. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  119668. /**
  119669. * Fires when the state of the experience helper has changed
  119670. */
  119671. onStateChangedObservable: Observable<WebXRState>;
  119672. /** Session manager used to keep track of xr session */
  119673. sessionManager: WebXRSessionManager;
  119674. /**
  119675. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  119676. */
  119677. state: WebXRState;
  119678. /**
  119679. * Creates a WebXRExperienceHelper
  119680. * @param scene The scene the helper should be created in
  119681. */
  119682. private constructor();
  119683. /**
  119684. * Creates the experience helper
  119685. * @param scene the scene to attach the experience helper to
  119686. * @returns a promise for the experience helper
  119687. */
  119688. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  119689. /**
  119690. * Disposes of the experience helper
  119691. */
  119692. dispose(): void;
  119693. /**
  119694. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  119695. * @param sessionMode options for the XR session
  119696. * @param referenceSpaceType frame of reference of the XR session
  119697. * @param renderTarget the output canvas that will be used to enter XR mode
  119698. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  119699. * @returns promise that resolves after xr mode has entered
  119700. */
  119701. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  119702. /**
  119703. * Exits XR mode and returns the scene to its original state
  119704. * @returns promise that resolves after xr mode has exited
  119705. */
  119706. exitXRAsync(): Promise<void>;
  119707. private _nonXRToXRCamera;
  119708. private _setState;
  119709. }
  119710. }
  119711. declare module BABYLON {
  119712. /**
  119713. * X-Y values for axes in WebXR
  119714. */
  119715. export interface IWebXRMotionControllerAxesValue {
  119716. /**
  119717. * The value of the x axis
  119718. */
  119719. x: number;
  119720. /**
  119721. * The value of the y-axis
  119722. */
  119723. y: number;
  119724. }
  119725. /**
  119726. * changed / previous values for the values of this component
  119727. */
  119728. export interface IWebXRMotionControllerComponentChangesValues<T> {
  119729. /**
  119730. * current (this frame) value
  119731. */
  119732. current: T;
  119733. /**
  119734. * previous (last change) value
  119735. */
  119736. previous: T;
  119737. }
  119738. /**
  119739. * Represents changes in the component between current frame and last values recorded
  119740. */
  119741. export interface IWebXRMotionControllerComponentChanges {
  119742. /**
  119743. * will be populated with previous and current values if axes changed
  119744. */
  119745. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  119746. /**
  119747. * will be populated with previous and current values if pressed changed
  119748. */
  119749. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119750. /**
  119751. * will be populated with previous and current values if touched changed
  119752. */
  119753. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119754. /**
  119755. * will be populated with previous and current values if value changed
  119756. */
  119757. value?: IWebXRMotionControllerComponentChangesValues<number>;
  119758. }
  119759. /**
  119760. * This class represents a single component (for example button or thumbstick) of a motion controller
  119761. */
  119762. export class WebXRControllerComponent implements IDisposable {
  119763. /**
  119764. * the id of this component
  119765. */
  119766. id: string;
  119767. /**
  119768. * the type of the component
  119769. */
  119770. type: MotionControllerComponentType;
  119771. private _buttonIndex;
  119772. private _axesIndices;
  119773. private _axes;
  119774. private _changes;
  119775. private _currentValue;
  119776. private _hasChanges;
  119777. private _pressed;
  119778. private _touched;
  119779. /**
  119780. * button component type
  119781. */
  119782. static BUTTON_TYPE: MotionControllerComponentType;
  119783. /**
  119784. * squeeze component type
  119785. */
  119786. static SQUEEZE_TYPE: MotionControllerComponentType;
  119787. /**
  119788. * Thumbstick component type
  119789. */
  119790. static THUMBSTICK_TYPE: MotionControllerComponentType;
  119791. /**
  119792. * Touchpad component type
  119793. */
  119794. static TOUCHPAD_TYPE: MotionControllerComponentType;
  119795. /**
  119796. * trigger component type
  119797. */
  119798. static TRIGGER_TYPE: MotionControllerComponentType;
  119799. /**
  119800. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  119801. * the axes data changes
  119802. */
  119803. onAxisValueChangedObservable: Observable<{
  119804. x: number;
  119805. y: number;
  119806. }>;
  119807. /**
  119808. * Observers registered here will be triggered when the state of a button changes
  119809. * State change is either pressed / touched / value
  119810. */
  119811. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  119812. /**
  119813. * Creates a new component for a motion controller.
  119814. * It is created by the motion controller itself
  119815. *
  119816. * @param id the id of this component
  119817. * @param type the type of the component
  119818. * @param _buttonIndex index in the buttons array of the gamepad
  119819. * @param _axesIndices indices of the values in the axes array of the gamepad
  119820. */
  119821. constructor(
  119822. /**
  119823. * the id of this component
  119824. */
  119825. id: string,
  119826. /**
  119827. * the type of the component
  119828. */
  119829. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  119830. /**
  119831. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  119832. */
  119833. get axes(): IWebXRMotionControllerAxesValue;
  119834. /**
  119835. * Get the changes. Elements will be populated only if they changed with their previous and current value
  119836. */
  119837. get changes(): IWebXRMotionControllerComponentChanges;
  119838. /**
  119839. * Return whether or not the component changed the last frame
  119840. */
  119841. get hasChanges(): boolean;
  119842. /**
  119843. * is the button currently pressed
  119844. */
  119845. get pressed(): boolean;
  119846. /**
  119847. * is the button currently touched
  119848. */
  119849. get touched(): boolean;
  119850. /**
  119851. * Get the current value of this component
  119852. */
  119853. get value(): number;
  119854. /**
  119855. * Dispose this component
  119856. */
  119857. dispose(): void;
  119858. /**
  119859. * Are there axes correlating to this component
  119860. * @return true is axes data is available
  119861. */
  119862. isAxes(): boolean;
  119863. /**
  119864. * Is this component a button (hence - pressable)
  119865. * @returns true if can be pressed
  119866. */
  119867. isButton(): boolean;
  119868. /**
  119869. * update this component using the gamepad object it is in. Called on every frame
  119870. * @param nativeController the native gamepad controller object
  119871. */
  119872. update(nativeController: IMinimalMotionControllerObject): void;
  119873. }
  119874. }
  119875. declare module BABYLON {
  119876. /**
  119877. * Class used to represent data loading progression
  119878. */
  119879. export class SceneLoaderProgressEvent {
  119880. /** defines if data length to load can be evaluated */
  119881. readonly lengthComputable: boolean;
  119882. /** defines the loaded data length */
  119883. readonly loaded: number;
  119884. /** defines the data length to load */
  119885. readonly total: number;
  119886. /**
  119887. * Create a new progress event
  119888. * @param lengthComputable defines if data length to load can be evaluated
  119889. * @param loaded defines the loaded data length
  119890. * @param total defines the data length to load
  119891. */
  119892. constructor(
  119893. /** defines if data length to load can be evaluated */
  119894. lengthComputable: boolean,
  119895. /** defines the loaded data length */
  119896. loaded: number,
  119897. /** defines the data length to load */
  119898. total: number);
  119899. /**
  119900. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  119901. * @param event defines the source event
  119902. * @returns a new SceneLoaderProgressEvent
  119903. */
  119904. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  119905. }
  119906. /**
  119907. * Interface used by SceneLoader plugins to define supported file extensions
  119908. */
  119909. export interface ISceneLoaderPluginExtensions {
  119910. /**
  119911. * Defines the list of supported extensions
  119912. */
  119913. [extension: string]: {
  119914. isBinary: boolean;
  119915. };
  119916. }
  119917. /**
  119918. * Interface used by SceneLoader plugin factory
  119919. */
  119920. export interface ISceneLoaderPluginFactory {
  119921. /**
  119922. * Defines the name of the factory
  119923. */
  119924. name: string;
  119925. /**
  119926. * Function called to create a new plugin
  119927. * @return the new plugin
  119928. */
  119929. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  119930. /**
  119931. * The callback that returns true if the data can be directly loaded.
  119932. * @param data string containing the file data
  119933. * @returns if the data can be loaded directly
  119934. */
  119935. canDirectLoad?(data: string): boolean;
  119936. }
  119937. /**
  119938. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  119939. */
  119940. export interface ISceneLoaderPluginBase {
  119941. /**
  119942. * The friendly name of this plugin.
  119943. */
  119944. name: string;
  119945. /**
  119946. * The file extensions supported by this plugin.
  119947. */
  119948. extensions: string | ISceneLoaderPluginExtensions;
  119949. /**
  119950. * The callback called when loading from a url.
  119951. * @param scene scene loading this url
  119952. * @param url url to load
  119953. * @param onSuccess callback called when the file successfully loads
  119954. * @param onProgress callback called while file is loading (if the server supports this mode)
  119955. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119956. * @param onError callback called when the file fails to load
  119957. * @returns a file request object
  119958. */
  119959. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119960. /**
  119961. * The callback called when loading from a file object.
  119962. * @param scene scene loading this file
  119963. * @param file defines the file to load
  119964. * @param onSuccess defines the callback to call when data is loaded
  119965. * @param onProgress defines the callback to call during loading process
  119966. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119967. * @param onError defines the callback to call when an error occurs
  119968. * @returns a file request object
  119969. */
  119970. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119971. /**
  119972. * The callback that returns true if the data can be directly loaded.
  119973. * @param data string containing the file data
  119974. * @returns if the data can be loaded directly
  119975. */
  119976. canDirectLoad?(data: string): boolean;
  119977. /**
  119978. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  119979. * @param scene scene loading this data
  119980. * @param data string containing the data
  119981. * @returns data to pass to the plugin
  119982. */
  119983. directLoad?(scene: Scene, data: string): any;
  119984. /**
  119985. * The callback that allows custom handling of the root url based on the response url.
  119986. * @param rootUrl the original root url
  119987. * @param responseURL the response url if available
  119988. * @returns the new root url
  119989. */
  119990. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  119991. }
  119992. /**
  119993. * Interface used to define a SceneLoader plugin
  119994. */
  119995. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  119996. /**
  119997. * Import meshes into a scene.
  119998. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119999. * @param scene The scene to import into
  120000. * @param data The data to import
  120001. * @param rootUrl The root url for scene and resources
  120002. * @param meshes The meshes array to import into
  120003. * @param particleSystems The particle systems array to import into
  120004. * @param skeletons The skeletons array to import into
  120005. * @param onError The callback when import fails
  120006. * @returns True if successful or false otherwise
  120007. */
  120008. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  120009. /**
  120010. * Load into a scene.
  120011. * @param scene The scene to load into
  120012. * @param data The data to import
  120013. * @param rootUrl The root url for scene and resources
  120014. * @param onError The callback when import fails
  120015. * @returns True if successful or false otherwise
  120016. */
  120017. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  120018. /**
  120019. * Load into an asset container.
  120020. * @param scene The scene to load into
  120021. * @param data The data to import
  120022. * @param rootUrl The root url for scene and resources
  120023. * @param onError The callback when import fails
  120024. * @returns The loaded asset container
  120025. */
  120026. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  120027. }
  120028. /**
  120029. * Interface used to define an async SceneLoader plugin
  120030. */
  120031. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  120032. /**
  120033. * Import meshes into a scene.
  120034. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120035. * @param scene The scene to import into
  120036. * @param data The data to import
  120037. * @param rootUrl The root url for scene and resources
  120038. * @param onProgress The callback when the load progresses
  120039. * @param fileName Defines the name of the file to load
  120040. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  120041. */
  120042. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  120043. meshes: AbstractMesh[];
  120044. particleSystems: IParticleSystem[];
  120045. skeletons: Skeleton[];
  120046. animationGroups: AnimationGroup[];
  120047. }>;
  120048. /**
  120049. * Load into a scene.
  120050. * @param scene The scene to load into
  120051. * @param data The data to import
  120052. * @param rootUrl The root url for scene and resources
  120053. * @param onProgress The callback when the load progresses
  120054. * @param fileName Defines the name of the file to load
  120055. * @returns Nothing
  120056. */
  120057. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  120058. /**
  120059. * Load into an asset container.
  120060. * @param scene The scene to load into
  120061. * @param data The data to import
  120062. * @param rootUrl The root url for scene and resources
  120063. * @param onProgress The callback when the load progresses
  120064. * @param fileName Defines the name of the file to load
  120065. * @returns The loaded asset container
  120066. */
  120067. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  120068. }
  120069. /**
  120070. * Mode that determines how to handle old animation groups before loading new ones.
  120071. */
  120072. export enum SceneLoaderAnimationGroupLoadingMode {
  120073. /**
  120074. * Reset all old animations to initial state then dispose them.
  120075. */
  120076. Clean = 0,
  120077. /**
  120078. * Stop all old animations.
  120079. */
  120080. Stop = 1,
  120081. /**
  120082. * Restart old animations from first frame.
  120083. */
  120084. Sync = 2,
  120085. /**
  120086. * Old animations remains untouched.
  120087. */
  120088. NoSync = 3
  120089. }
  120090. /**
  120091. * Class used to load scene from various file formats using registered plugins
  120092. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  120093. */
  120094. export class SceneLoader {
  120095. /**
  120096. * No logging while loading
  120097. */
  120098. static readonly NO_LOGGING: number;
  120099. /**
  120100. * Minimal logging while loading
  120101. */
  120102. static readonly MINIMAL_LOGGING: number;
  120103. /**
  120104. * Summary logging while loading
  120105. */
  120106. static readonly SUMMARY_LOGGING: number;
  120107. /**
  120108. * Detailled logging while loading
  120109. */
  120110. static readonly DETAILED_LOGGING: number;
  120111. /**
  120112. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  120113. */
  120114. static get ForceFullSceneLoadingForIncremental(): boolean;
  120115. static set ForceFullSceneLoadingForIncremental(value: boolean);
  120116. /**
  120117. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  120118. */
  120119. static get ShowLoadingScreen(): boolean;
  120120. static set ShowLoadingScreen(value: boolean);
  120121. /**
  120122. * Defines the current logging level (while loading the scene)
  120123. * @ignorenaming
  120124. */
  120125. static get loggingLevel(): number;
  120126. static set loggingLevel(value: number);
  120127. /**
  120128. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  120129. */
  120130. static get CleanBoneMatrixWeights(): boolean;
  120131. static set CleanBoneMatrixWeights(value: boolean);
  120132. /**
  120133. * Event raised when a plugin is used to load a scene
  120134. */
  120135. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  120136. private static _registeredPlugins;
  120137. private static _getDefaultPlugin;
  120138. private static _getPluginForExtension;
  120139. private static _getPluginForDirectLoad;
  120140. private static _getPluginForFilename;
  120141. private static _getDirectLoad;
  120142. private static _loadData;
  120143. private static _getFileInfo;
  120144. /**
  120145. * Gets a plugin that can load the given extension
  120146. * @param extension defines the extension to load
  120147. * @returns a plugin or null if none works
  120148. */
  120149. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  120150. /**
  120151. * Gets a boolean indicating that the given extension can be loaded
  120152. * @param extension defines the extension to load
  120153. * @returns true if the extension is supported
  120154. */
  120155. static IsPluginForExtensionAvailable(extension: string): boolean;
  120156. /**
  120157. * Adds a new plugin to the list of registered plugins
  120158. * @param plugin defines the plugin to add
  120159. */
  120160. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  120161. /**
  120162. * Import meshes into a scene
  120163. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120164. * @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)
  120165. * @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)
  120166. * @param scene the instance of BABYLON.Scene to append to
  120167. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  120168. * @param onProgress a callback with a progress event for each file being loaded
  120169. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120170. * @param pluginExtension the extension used to determine the plugin
  120171. * @returns The loaded plugin
  120172. */
  120173. 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>;
  120174. /**
  120175. * Import meshes into a scene
  120176. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120177. * @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)
  120178. * @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)
  120179. * @param scene the instance of BABYLON.Scene to append to
  120180. * @param onProgress a callback with a progress event for each file being loaded
  120181. * @param pluginExtension the extension used to determine the plugin
  120182. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  120183. */
  120184. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  120185. meshes: AbstractMesh[];
  120186. particleSystems: IParticleSystem[];
  120187. skeletons: Skeleton[];
  120188. animationGroups: AnimationGroup[];
  120189. }>;
  120190. /**
  120191. * Load a scene
  120192. * @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)
  120193. * @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)
  120194. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120195. * @param onSuccess a callback with the scene when import succeeds
  120196. * @param onProgress a callback with a progress event for each file being loaded
  120197. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120198. * @param pluginExtension the extension used to determine the plugin
  120199. * @returns The loaded plugin
  120200. */
  120201. 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>;
  120202. /**
  120203. * Load a scene
  120204. * @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)
  120205. * @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)
  120206. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120207. * @param onProgress a callback with a progress event for each file being loaded
  120208. * @param pluginExtension the extension used to determine the plugin
  120209. * @returns The loaded scene
  120210. */
  120211. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120212. /**
  120213. * Append a scene
  120214. * @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)
  120215. * @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)
  120216. * @param scene is the instance of BABYLON.Scene to append to
  120217. * @param onSuccess a callback with the scene when import succeeds
  120218. * @param onProgress a callback with a progress event for each file being loaded
  120219. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120220. * @param pluginExtension the extension used to determine the plugin
  120221. * @returns The loaded plugin
  120222. */
  120223. 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>;
  120224. /**
  120225. * Append a scene
  120226. * @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)
  120227. * @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)
  120228. * @param scene is the instance of BABYLON.Scene to append to
  120229. * @param onProgress a callback with a progress event for each file being loaded
  120230. * @param pluginExtension the extension used to determine the plugin
  120231. * @returns The given scene
  120232. */
  120233. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120234. /**
  120235. * Load a scene into an asset container
  120236. * @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)
  120237. * @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)
  120238. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120239. * @param onSuccess a callback with the scene when import succeeds
  120240. * @param onProgress a callback with a progress event for each file being loaded
  120241. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120242. * @param pluginExtension the extension used to determine the plugin
  120243. * @returns The loaded plugin
  120244. */
  120245. 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>;
  120246. /**
  120247. * Load a scene into an asset container
  120248. * @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)
  120249. * @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)
  120250. * @param scene is the instance of Scene to append to
  120251. * @param onProgress a callback with a progress event for each file being loaded
  120252. * @param pluginExtension the extension used to determine the plugin
  120253. * @returns The loaded asset container
  120254. */
  120255. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  120256. /**
  120257. * Import animations from a file into a scene
  120258. * @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)
  120259. * @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)
  120260. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120261. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120262. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120263. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120264. * @param onSuccess a callback with the scene when import succeeds
  120265. * @param onProgress a callback with a progress event for each file being loaded
  120266. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120267. */
  120268. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  120269. /**
  120270. * Import animations from a file into a scene
  120271. * @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)
  120272. * @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)
  120273. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120274. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120275. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120276. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120277. * @param onSuccess a callback with the scene when import succeeds
  120278. * @param onProgress a callback with a progress event for each file being loaded
  120279. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120280. * @returns the updated scene with imported animations
  120281. */
  120282. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  120283. }
  120284. }
  120285. declare module BABYLON {
  120286. /**
  120287. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  120288. */
  120289. export type MotionControllerHandedness = "none" | "left" | "right";
  120290. /**
  120291. * The type of components available in motion controllers.
  120292. * This is not the name of the component.
  120293. */
  120294. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  120295. /**
  120296. * The state of a controller component
  120297. */
  120298. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  120299. /**
  120300. * The schema of motion controller layout.
  120301. * No object will be initialized using this interface
  120302. * This is used just to define the profile.
  120303. */
  120304. export interface IMotionControllerLayout {
  120305. /**
  120306. * Path to load the assets. Usually relative to the base path
  120307. */
  120308. assetPath: string;
  120309. /**
  120310. * Available components (unsorted)
  120311. */
  120312. components: {
  120313. /**
  120314. * A map of component Ids
  120315. */
  120316. [componentId: string]: {
  120317. /**
  120318. * The type of input the component outputs
  120319. */
  120320. type: MotionControllerComponentType;
  120321. /**
  120322. * The indices of this component in the gamepad object
  120323. */
  120324. gamepadIndices: {
  120325. /**
  120326. * Index of button
  120327. */
  120328. button?: number;
  120329. /**
  120330. * If available, index of x-axis
  120331. */
  120332. xAxis?: number;
  120333. /**
  120334. * If available, index of y-axis
  120335. */
  120336. yAxis?: number;
  120337. };
  120338. /**
  120339. * The mesh's root node name
  120340. */
  120341. rootNodeName: string;
  120342. /**
  120343. * Animation definitions for this model
  120344. */
  120345. visualResponses: {
  120346. [stateKey: string]: {
  120347. /**
  120348. * What property will be animated
  120349. */
  120350. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  120351. /**
  120352. * What states influence this visual response
  120353. */
  120354. states: MotionControllerComponentStateType[];
  120355. /**
  120356. * Type of animation - movement or visibility
  120357. */
  120358. valueNodeProperty: "transform" | "visibility";
  120359. /**
  120360. * Base node name to move. Its position will be calculated according to the min and max nodes
  120361. */
  120362. valueNodeName?: string;
  120363. /**
  120364. * Minimum movement node
  120365. */
  120366. minNodeName?: string;
  120367. /**
  120368. * Max movement node
  120369. */
  120370. maxNodeName?: string;
  120371. };
  120372. };
  120373. /**
  120374. * If touch enabled, what is the name of node to display user feedback
  120375. */
  120376. touchPointNodeName?: string;
  120377. };
  120378. };
  120379. /**
  120380. * Is it xr standard mapping or not
  120381. */
  120382. gamepadMapping: "" | "xr-standard";
  120383. /**
  120384. * Base root node of this entire model
  120385. */
  120386. rootNodeName: string;
  120387. /**
  120388. * Defines the main button component id
  120389. */
  120390. selectComponentId: string;
  120391. }
  120392. /**
  120393. * A definition for the layout map in the input profile
  120394. */
  120395. export interface IMotionControllerLayoutMap {
  120396. /**
  120397. * Layouts with handedness type as a key
  120398. */
  120399. [handedness: string]: IMotionControllerLayout;
  120400. }
  120401. /**
  120402. * The XR Input profile schema
  120403. * Profiles can be found here:
  120404. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  120405. */
  120406. export interface IMotionControllerProfile {
  120407. /**
  120408. * fallback profiles for this profileId
  120409. */
  120410. fallbackProfileIds: string[];
  120411. /**
  120412. * The layout map, with handedness as key
  120413. */
  120414. layouts: IMotionControllerLayoutMap;
  120415. /**
  120416. * The id of this profile
  120417. * correlates to the profile(s) in the xrInput.profiles array
  120418. */
  120419. profileId: string;
  120420. }
  120421. /**
  120422. * A helper-interface for the 3 meshes needed for controller button animation
  120423. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  120424. */
  120425. export interface IMotionControllerButtonMeshMap {
  120426. /**
  120427. * the mesh that defines the pressed value mesh position.
  120428. * This is used to find the max-position of this button
  120429. */
  120430. pressedMesh: AbstractMesh;
  120431. /**
  120432. * the mesh that defines the unpressed value mesh position.
  120433. * This is used to find the min (or initial) position of this button
  120434. */
  120435. unpressedMesh: AbstractMesh;
  120436. /**
  120437. * The mesh that will be changed when value changes
  120438. */
  120439. valueMesh: AbstractMesh;
  120440. }
  120441. /**
  120442. * A helper-interface for the 3 meshes needed for controller axis animation.
  120443. * This will be expanded when touchpad animations are fully supported
  120444. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  120445. */
  120446. export interface IMotionControllerMeshMap {
  120447. /**
  120448. * the mesh that defines the maximum value mesh position.
  120449. */
  120450. maxMesh?: AbstractMesh;
  120451. /**
  120452. * the mesh that defines the minimum value mesh position.
  120453. */
  120454. minMesh?: AbstractMesh;
  120455. /**
  120456. * The mesh that will be changed when axis value changes
  120457. */
  120458. valueMesh: AbstractMesh;
  120459. }
  120460. /**
  120461. * The elements needed for change-detection of the gamepad objects in motion controllers
  120462. */
  120463. export interface IMinimalMotionControllerObject {
  120464. /**
  120465. * Available axes of this controller
  120466. */
  120467. axes: number[];
  120468. /**
  120469. * An array of available buttons
  120470. */
  120471. buttons: Array<{
  120472. /**
  120473. * Value of the button/trigger
  120474. */
  120475. value: number;
  120476. /**
  120477. * If the button/trigger is currently touched
  120478. */
  120479. touched: boolean;
  120480. /**
  120481. * If the button/trigger is currently pressed
  120482. */
  120483. pressed: boolean;
  120484. }>;
  120485. /**
  120486. * EXPERIMENTAL haptic support.
  120487. */
  120488. hapticActuators?: Array<{
  120489. pulse: (value: number, duration: number) => Promise<boolean>;
  120490. }>;
  120491. }
  120492. /**
  120493. * An Abstract Motion controller
  120494. * This class receives an xrInput and a profile layout and uses those to initialize the components
  120495. * Each component has an observable to check for changes in value and state
  120496. */
  120497. export abstract class WebXRAbstractMotionController implements IDisposable {
  120498. protected scene: Scene;
  120499. protected layout: IMotionControllerLayout;
  120500. /**
  120501. * The gamepad object correlating to this controller
  120502. */
  120503. gamepadObject: IMinimalMotionControllerObject;
  120504. /**
  120505. * handedness (left/right/none) of this controller
  120506. */
  120507. handedness: MotionControllerHandedness;
  120508. private _initComponent;
  120509. private _modelReady;
  120510. /**
  120511. * A map of components (WebXRControllerComponent) in this motion controller
  120512. * Components have a ComponentType and can also have both button and axis definitions
  120513. */
  120514. readonly components: {
  120515. [id: string]: WebXRControllerComponent;
  120516. };
  120517. /**
  120518. * Disable the model's animation. Can be set at any time.
  120519. */
  120520. disableAnimation: boolean;
  120521. /**
  120522. * Observers registered here will be triggered when the model of this controller is done loading
  120523. */
  120524. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  120525. /**
  120526. * The profile id of this motion controller
  120527. */
  120528. abstract profileId: string;
  120529. /**
  120530. * The root mesh of the model. It is null if the model was not yet initialized
  120531. */
  120532. rootMesh: Nullable<AbstractMesh>;
  120533. /**
  120534. * constructs a new abstract motion controller
  120535. * @param scene the scene to which the model of the controller will be added
  120536. * @param layout The profile layout to load
  120537. * @param gamepadObject The gamepad object correlating to this controller
  120538. * @param handedness handedness (left/right/none) of this controller
  120539. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  120540. */
  120541. constructor(scene: Scene, layout: IMotionControllerLayout,
  120542. /**
  120543. * The gamepad object correlating to this controller
  120544. */
  120545. gamepadObject: IMinimalMotionControllerObject,
  120546. /**
  120547. * handedness (left/right/none) of this controller
  120548. */
  120549. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  120550. /**
  120551. * Dispose this controller, the model mesh and all its components
  120552. */
  120553. dispose(): void;
  120554. /**
  120555. * Returns all components of specific type
  120556. * @param type the type to search for
  120557. * @return an array of components with this type
  120558. */
  120559. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  120560. /**
  120561. * get a component based an its component id as defined in layout.components
  120562. * @param id the id of the component
  120563. * @returns the component correlates to the id or undefined if not found
  120564. */
  120565. getComponent(id: string): WebXRControllerComponent;
  120566. /**
  120567. * Get the list of components available in this motion controller
  120568. * @returns an array of strings correlating to available components
  120569. */
  120570. getComponentIds(): string[];
  120571. /**
  120572. * Get the first component of specific type
  120573. * @param type type of component to find
  120574. * @return a controller component or null if not found
  120575. */
  120576. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  120577. /**
  120578. * Get the main (Select) component of this controller as defined in the layout
  120579. * @returns the main component of this controller
  120580. */
  120581. getMainComponent(): WebXRControllerComponent;
  120582. /**
  120583. * Loads the model correlating to this controller
  120584. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  120585. * @returns A promise fulfilled with the result of the model loading
  120586. */
  120587. loadModel(): Promise<boolean>;
  120588. /**
  120589. * Update this model using the current XRFrame
  120590. * @param xrFrame the current xr frame to use and update the model
  120591. */
  120592. updateFromXRFrame(xrFrame: XRFrame): void;
  120593. /**
  120594. * Backwards compatibility due to a deeply-integrated typo
  120595. */
  120596. get handness(): XREye;
  120597. /**
  120598. * Pulse (vibrate) this controller
  120599. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  120600. * Consecutive calls to this function will cancel the last pulse call
  120601. *
  120602. * @param value the strength of the pulse in 0.0...1.0 range
  120603. * @param duration Duration of the pulse in milliseconds
  120604. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  120605. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  120606. */
  120607. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  120608. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120609. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120610. /**
  120611. * Moves the axis on the controller mesh based on its current state
  120612. * @param axis the index of the axis
  120613. * @param axisValue the value of the axis which determines the meshes new position
  120614. * @hidden
  120615. */
  120616. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  120617. /**
  120618. * Update the model itself with the current frame data
  120619. * @param xrFrame the frame to use for updating the model mesh
  120620. */
  120621. protected updateModel(xrFrame: XRFrame): void;
  120622. /**
  120623. * Get the filename and path for this controller's model
  120624. * @returns a map of filename and path
  120625. */
  120626. protected abstract _getFilenameAndPath(): {
  120627. filename: string;
  120628. path: string;
  120629. };
  120630. /**
  120631. * This function is called before the mesh is loaded. It checks for loading constraints.
  120632. * For example, this function can check if the GLB loader is available
  120633. * If this function returns false, the generic controller will be loaded instead
  120634. * @returns Is the client ready to load the mesh
  120635. */
  120636. protected abstract _getModelLoadingConstraints(): boolean;
  120637. /**
  120638. * This function will be called after the model was successfully loaded and can be used
  120639. * for mesh transformations before it is available for the user
  120640. * @param meshes the loaded meshes
  120641. */
  120642. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  120643. /**
  120644. * Set the root mesh for this controller. Important for the WebXR controller class
  120645. * @param meshes the loaded meshes
  120646. */
  120647. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  120648. /**
  120649. * A function executed each frame that updates the mesh (if needed)
  120650. * @param xrFrame the current xrFrame
  120651. */
  120652. protected abstract _updateModel(xrFrame: XRFrame): void;
  120653. private _getGenericFilenameAndPath;
  120654. private _getGenericParentMesh;
  120655. }
  120656. }
  120657. declare module BABYLON {
  120658. /**
  120659. * A generic trigger-only motion controller for WebXR
  120660. */
  120661. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  120662. /**
  120663. * Static version of the profile id of this controller
  120664. */
  120665. static ProfileId: string;
  120666. profileId: string;
  120667. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  120668. protected _getFilenameAndPath(): {
  120669. filename: string;
  120670. path: string;
  120671. };
  120672. protected _getModelLoadingConstraints(): boolean;
  120673. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  120674. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120675. protected _updateModel(): void;
  120676. }
  120677. }
  120678. declare module BABYLON {
  120679. /**
  120680. * Class containing static functions to help procedurally build meshes
  120681. */
  120682. export class SphereBuilder {
  120683. /**
  120684. * Creates a sphere mesh
  120685. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120686. * * 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`)
  120687. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120688. * * 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
  120689. * * 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)
  120690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120691. * * 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
  120692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120693. * @param name defines the name of the mesh
  120694. * @param options defines the options used to create the mesh
  120695. * @param scene defines the hosting scene
  120696. * @returns the sphere mesh
  120697. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120698. */
  120699. static CreateSphere(name: string, options: {
  120700. segments?: number;
  120701. diameter?: number;
  120702. diameterX?: number;
  120703. diameterY?: number;
  120704. diameterZ?: number;
  120705. arc?: number;
  120706. slice?: number;
  120707. sideOrientation?: number;
  120708. frontUVs?: Vector4;
  120709. backUVs?: Vector4;
  120710. updatable?: boolean;
  120711. }, scene?: Nullable<Scene>): Mesh;
  120712. }
  120713. }
  120714. declare module BABYLON {
  120715. /**
  120716. * A profiled motion controller has its profile loaded from an online repository.
  120717. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  120718. */
  120719. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  120720. private _repositoryUrl;
  120721. private _buttonMeshMapping;
  120722. private _touchDots;
  120723. /**
  120724. * The profile ID of this controller. Will be populated when the controller initializes.
  120725. */
  120726. profileId: string;
  120727. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  120728. dispose(): void;
  120729. protected _getFilenameAndPath(): {
  120730. filename: string;
  120731. path: string;
  120732. };
  120733. protected _getModelLoadingConstraints(): boolean;
  120734. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  120735. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120736. protected _updateModel(_xrFrame: XRFrame): void;
  120737. }
  120738. }
  120739. declare module BABYLON {
  120740. /**
  120741. * A construction function type to create a new controller based on an xrInput object
  120742. */
  120743. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  120744. /**
  120745. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  120746. *
  120747. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  120748. * it should be replaced with auto-loaded controllers.
  120749. *
  120750. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  120751. */
  120752. export class WebXRMotionControllerManager {
  120753. private static _AvailableControllers;
  120754. private static _Fallbacks;
  120755. private static _ProfileLoadingPromises;
  120756. private static _ProfilesList;
  120757. /**
  120758. * The base URL of the online controller repository. Can be changed at any time.
  120759. */
  120760. static BaseRepositoryUrl: string;
  120761. /**
  120762. * Which repository gets priority - local or online
  120763. */
  120764. static PrioritizeOnlineRepository: boolean;
  120765. /**
  120766. * Use the online repository, or use only locally-defined controllers
  120767. */
  120768. static UseOnlineRepository: boolean;
  120769. /**
  120770. * Clear the cache used for profile loading and reload when requested again
  120771. */
  120772. static ClearProfilesCache(): void;
  120773. /**
  120774. * Register the default fallbacks.
  120775. * This function is called automatically when this file is imported.
  120776. */
  120777. static DefaultFallbacks(): void;
  120778. /**
  120779. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  120780. * @param profileId the profile to which a fallback needs to be found
  120781. * @return an array with corresponding fallback profiles
  120782. */
  120783. static FindFallbackWithProfileId(profileId: string): string[];
  120784. /**
  120785. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  120786. * The order of search:
  120787. *
  120788. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  120789. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  120790. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  120791. * 4) return the generic trigger controller if none were found
  120792. *
  120793. * @param xrInput the xrInput to which a new controller is initialized
  120794. * @param scene the scene to which the model will be added
  120795. * @param forceProfile force a certain profile for this controller
  120796. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  120797. */
  120798. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  120799. /**
  120800. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  120801. *
  120802. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  120803. *
  120804. * @param type the profile type to register
  120805. * @param constructFunction the function to be called when loading this profile
  120806. */
  120807. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  120808. /**
  120809. * Register a fallback to a specific profile.
  120810. * @param profileId the profileId that will receive the fallbacks
  120811. * @param fallbacks A list of fallback profiles
  120812. */
  120813. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  120814. /**
  120815. * Will update the list of profiles available in the repository
  120816. * @return a promise that resolves to a map of profiles available online
  120817. */
  120818. static UpdateProfilesList(): Promise<{
  120819. [profile: string]: string;
  120820. }>;
  120821. private static _LoadProfileFromRepository;
  120822. private static _LoadProfilesFromAvailableControllers;
  120823. }
  120824. }
  120825. declare module BABYLON {
  120826. /**
  120827. * Configuration options for the WebXR controller creation
  120828. */
  120829. export interface IWebXRControllerOptions {
  120830. /**
  120831. * Should the controller mesh be animated when a user interacts with it
  120832. * The pressed buttons / thumbstick and touchpad animations will be disabled
  120833. */
  120834. disableMotionControllerAnimation?: boolean;
  120835. /**
  120836. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  120837. */
  120838. doNotLoadControllerMesh?: boolean;
  120839. /**
  120840. * Force a specific controller type for this controller.
  120841. * This can be used when creating your own profile or when testing different controllers
  120842. */
  120843. forceControllerProfile?: string;
  120844. /**
  120845. * Defines a rendering group ID for meshes that will be loaded.
  120846. * This is for the default controllers only.
  120847. */
  120848. renderingGroupId?: number;
  120849. }
  120850. /**
  120851. * Represents an XR controller
  120852. */
  120853. export class WebXRInputSource {
  120854. private _scene;
  120855. /** The underlying input source for the controller */
  120856. inputSource: XRInputSource;
  120857. private _options;
  120858. private _tmpQuaternion;
  120859. private _tmpVector;
  120860. private _uniqueId;
  120861. /**
  120862. * 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
  120863. */
  120864. grip?: AbstractMesh;
  120865. /**
  120866. * If available, this is the gamepad object related to this controller.
  120867. * Using this object it is possible to get click events and trackpad changes of the
  120868. * webxr controller that is currently being used.
  120869. */
  120870. motionController?: WebXRAbstractMotionController;
  120871. /**
  120872. * Event that fires when the controller is removed/disposed.
  120873. * The object provided as event data is this controller, after associated assets were disposed.
  120874. * uniqueId is still available.
  120875. */
  120876. onDisposeObservable: Observable<WebXRInputSource>;
  120877. /**
  120878. * Will be triggered when the mesh associated with the motion controller is done loading.
  120879. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  120880. * A shortened version of controller -> motion controller -> on mesh loaded.
  120881. */
  120882. onMeshLoadedObservable: Observable<AbstractMesh>;
  120883. /**
  120884. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  120885. */
  120886. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  120887. /**
  120888. * Pointer which can be used to select objects or attach a visible laser to
  120889. */
  120890. pointer: AbstractMesh;
  120891. /**
  120892. * Creates the controller
  120893. * @see https://doc.babylonjs.com/how_to/webxr
  120894. * @param _scene the scene which the controller should be associated to
  120895. * @param inputSource the underlying input source for the controller
  120896. * @param _options options for this controller creation
  120897. */
  120898. constructor(_scene: Scene,
  120899. /** The underlying input source for the controller */
  120900. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  120901. /**
  120902. * Get this controllers unique id
  120903. */
  120904. get uniqueId(): string;
  120905. /**
  120906. * Disposes of the object
  120907. */
  120908. dispose(): void;
  120909. /**
  120910. * Gets a world space ray coming from the pointer or grip
  120911. * @param result the resulting ray
  120912. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  120913. */
  120914. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  120915. /**
  120916. * Updates the controller pose based on the given XRFrame
  120917. * @param xrFrame xr frame to update the pose with
  120918. * @param referenceSpace reference space to use
  120919. */
  120920. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  120921. }
  120922. }
  120923. declare module BABYLON {
  120924. /**
  120925. * The schema for initialization options of the XR Input class
  120926. */
  120927. export interface IWebXRInputOptions {
  120928. /**
  120929. * If set to true no model will be automatically loaded
  120930. */
  120931. doNotLoadControllerMeshes?: boolean;
  120932. /**
  120933. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  120934. * If not found, the xr input profile data will be used.
  120935. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  120936. */
  120937. forceInputProfile?: string;
  120938. /**
  120939. * Do not send a request to the controller repository to load the profile.
  120940. *
  120941. * Instead, use the controllers available in babylon itself.
  120942. */
  120943. disableOnlineControllerRepository?: boolean;
  120944. /**
  120945. * A custom URL for the controllers repository
  120946. */
  120947. customControllersRepositoryURL?: string;
  120948. /**
  120949. * Should the controller model's components not move according to the user input
  120950. */
  120951. disableControllerAnimation?: boolean;
  120952. /**
  120953. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  120954. */
  120955. controllerOptions?: IWebXRControllerOptions;
  120956. }
  120957. /**
  120958. * XR input used to track XR inputs such as controllers/rays
  120959. */
  120960. export class WebXRInput implements IDisposable {
  120961. /**
  120962. * the xr session manager for this session
  120963. */
  120964. xrSessionManager: WebXRSessionManager;
  120965. /**
  120966. * the WebXR camera for this session. Mainly used for teleportation
  120967. */
  120968. xrCamera: WebXRCamera;
  120969. private readonly options;
  120970. /**
  120971. * XR controllers being tracked
  120972. */
  120973. controllers: Array<WebXRInputSource>;
  120974. private _frameObserver;
  120975. private _sessionEndedObserver;
  120976. private _sessionInitObserver;
  120977. /**
  120978. * Event when a controller has been connected/added
  120979. */
  120980. onControllerAddedObservable: Observable<WebXRInputSource>;
  120981. /**
  120982. * Event when a controller has been removed/disconnected
  120983. */
  120984. onControllerRemovedObservable: Observable<WebXRInputSource>;
  120985. /**
  120986. * Initializes the WebXRInput
  120987. * @param xrSessionManager the xr session manager for this session
  120988. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  120989. * @param options = initialization options for this xr input
  120990. */
  120991. constructor(
  120992. /**
  120993. * the xr session manager for this session
  120994. */
  120995. xrSessionManager: WebXRSessionManager,
  120996. /**
  120997. * the WebXR camera for this session. Mainly used for teleportation
  120998. */
  120999. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  121000. private _onInputSourcesChange;
  121001. private _addAndRemoveControllers;
  121002. /**
  121003. * Disposes of the object
  121004. */
  121005. dispose(): void;
  121006. }
  121007. }
  121008. declare module BABYLON {
  121009. /**
  121010. * This is the base class for all WebXR features.
  121011. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  121012. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  121013. */
  121014. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  121015. protected _xrSessionManager: WebXRSessionManager;
  121016. private _attached;
  121017. private _removeOnDetach;
  121018. /**
  121019. * Should auto-attach be disabled?
  121020. */
  121021. disableAutoAttach: boolean;
  121022. /**
  121023. * Construct a new (abstract) WebXR feature
  121024. * @param _xrSessionManager the xr session manager for this feature
  121025. */
  121026. constructor(_xrSessionManager: WebXRSessionManager);
  121027. /**
  121028. * Is this feature attached
  121029. */
  121030. get attached(): boolean;
  121031. /**
  121032. * attach this feature
  121033. *
  121034. * @param force should attachment be forced (even when already attached)
  121035. * @returns true if successful, false is failed or already attached
  121036. */
  121037. attach(force?: boolean): boolean;
  121038. /**
  121039. * detach this feature.
  121040. *
  121041. * @returns true if successful, false if failed or already detached
  121042. */
  121043. detach(): boolean;
  121044. /**
  121045. * Dispose this feature and all of the resources attached
  121046. */
  121047. dispose(): void;
  121048. /**
  121049. * This is used to register callbacks that will automatically be removed when detach is called.
  121050. * @param observable the observable to which the observer will be attached
  121051. * @param callback the callback to register
  121052. */
  121053. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  121054. /**
  121055. * Code in this function will be executed on each xrFrame received from the browser.
  121056. * This function will not execute after the feature is detached.
  121057. * @param _xrFrame the current frame
  121058. */
  121059. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  121060. }
  121061. }
  121062. declare module BABYLON {
  121063. /**
  121064. * Renders a layer on top of an existing scene
  121065. */
  121066. export class UtilityLayerRenderer implements IDisposable {
  121067. /** the original scene that will be rendered on top of */
  121068. originalScene: Scene;
  121069. private _pointerCaptures;
  121070. private _lastPointerEvents;
  121071. private static _DefaultUtilityLayer;
  121072. private static _DefaultKeepDepthUtilityLayer;
  121073. private _sharedGizmoLight;
  121074. private _renderCamera;
  121075. /**
  121076. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  121077. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  121078. * @returns the camera that is used when rendering the utility layer
  121079. */
  121080. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  121081. /**
  121082. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  121083. * @param cam the camera that should be used when rendering the utility layer
  121084. */
  121085. setRenderCamera(cam: Nullable<Camera>): void;
  121086. /**
  121087. * @hidden
  121088. * Light which used by gizmos to get light shading
  121089. */
  121090. _getSharedGizmoLight(): HemisphericLight;
  121091. /**
  121092. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  121093. */
  121094. pickUtilitySceneFirst: boolean;
  121095. /**
  121096. * 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)
  121097. */
  121098. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  121099. /**
  121100. * 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)
  121101. */
  121102. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  121103. /**
  121104. * The scene that is rendered on top of the original scene
  121105. */
  121106. utilityLayerScene: Scene;
  121107. /**
  121108. * If the utility layer should automatically be rendered on top of existing scene
  121109. */
  121110. shouldRender: boolean;
  121111. /**
  121112. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  121113. */
  121114. onlyCheckPointerDownEvents: boolean;
  121115. /**
  121116. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  121117. */
  121118. processAllEvents: boolean;
  121119. /**
  121120. * Observable raised when the pointer move from the utility layer scene to the main scene
  121121. */
  121122. onPointerOutObservable: Observable<number>;
  121123. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  121124. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  121125. private _afterRenderObserver;
  121126. private _sceneDisposeObserver;
  121127. private _originalPointerObserver;
  121128. /**
  121129. * Instantiates a UtilityLayerRenderer
  121130. * @param originalScene the original scene that will be rendered on top of
  121131. * @param handleEvents boolean indicating if the utility layer should handle events
  121132. */
  121133. constructor(
  121134. /** the original scene that will be rendered on top of */
  121135. originalScene: Scene, handleEvents?: boolean);
  121136. private _notifyObservers;
  121137. /**
  121138. * Renders the utility layers scene on top of the original scene
  121139. */
  121140. render(): void;
  121141. /**
  121142. * Disposes of the renderer
  121143. */
  121144. dispose(): void;
  121145. private _updateCamera;
  121146. }
  121147. }
  121148. declare module BABYLON {
  121149. /**
  121150. * Options interface for the pointer selection module
  121151. */
  121152. export interface IWebXRControllerPointerSelectionOptions {
  121153. /**
  121154. * if provided, this scene will be used to render meshes.
  121155. */
  121156. customUtilityLayerScene?: Scene;
  121157. /**
  121158. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  121159. * If not disabled, the last picked point will be used to execute a pointer up event
  121160. * If disabled, pointer up event will be triggered right after the pointer down event.
  121161. * Used in screen and gaze target ray mode only
  121162. */
  121163. disablePointerUpOnTouchOut: boolean;
  121164. /**
  121165. * For gaze mode (time to select instead of press)
  121166. */
  121167. forceGazeMode: boolean;
  121168. /**
  121169. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  121170. * to start a new countdown to the pointer down event.
  121171. * Defaults to 1.
  121172. */
  121173. gazeModePointerMovedFactor?: number;
  121174. /**
  121175. * Different button type to use instead of the main component
  121176. */
  121177. overrideButtonId?: string;
  121178. /**
  121179. * use this rendering group id for the meshes (optional)
  121180. */
  121181. renderingGroupId?: number;
  121182. /**
  121183. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  121184. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  121185. * 3000 means 3 seconds between pointing at something and selecting it
  121186. */
  121187. timeToSelect?: number;
  121188. /**
  121189. * Should meshes created here be added to a utility layer or the main scene
  121190. */
  121191. useUtilityLayer?: boolean;
  121192. /**
  121193. * the xr input to use with this pointer selection
  121194. */
  121195. xrInput: WebXRInput;
  121196. }
  121197. /**
  121198. * A module that will enable pointer selection for motion controllers of XR Input Sources
  121199. */
  121200. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  121201. private readonly _options;
  121202. private static _idCounter;
  121203. private _attachController;
  121204. private _controllers;
  121205. private _scene;
  121206. private _tmpVectorForPickCompare;
  121207. /**
  121208. * The module's name
  121209. */
  121210. static readonly Name: string;
  121211. /**
  121212. * The (Babylon) version of this module.
  121213. * This is an integer representing the implementation version.
  121214. * This number does not correspond to the WebXR specs version
  121215. */
  121216. static readonly Version: number;
  121217. /**
  121218. * Disable lighting on the laser pointer (so it will always be visible)
  121219. */
  121220. disablePointerLighting: boolean;
  121221. /**
  121222. * Disable lighting on the selection mesh (so it will always be visible)
  121223. */
  121224. disableSelectionMeshLighting: boolean;
  121225. /**
  121226. * Should the laser pointer be displayed
  121227. */
  121228. displayLaserPointer: boolean;
  121229. /**
  121230. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  121231. */
  121232. displaySelectionMesh: boolean;
  121233. /**
  121234. * This color will be set to the laser pointer when selection is triggered
  121235. */
  121236. laserPointerPickedColor: Color3;
  121237. /**
  121238. * Default color of the laser pointer
  121239. */
  121240. lasterPointerDefaultColor: Color3;
  121241. /**
  121242. * default color of the selection ring
  121243. */
  121244. selectionMeshDefaultColor: Color3;
  121245. /**
  121246. * This color will be applied to the selection ring when selection is triggered
  121247. */
  121248. selectionMeshPickedColor: Color3;
  121249. /**
  121250. * Optional filter to be used for ray selection. This predicate shares behavior with
  121251. * scene.pointerMovePredicate which takes priority if it is also assigned.
  121252. */
  121253. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121254. /**
  121255. * constructs a new background remover module
  121256. * @param _xrSessionManager the session manager for this module
  121257. * @param _options read-only options to be used in this module
  121258. */
  121259. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  121260. /**
  121261. * attach this feature
  121262. * Will usually be called by the features manager
  121263. *
  121264. * @returns true if successful.
  121265. */
  121266. attach(): boolean;
  121267. /**
  121268. * detach this feature.
  121269. * Will usually be called by the features manager
  121270. *
  121271. * @returns true if successful.
  121272. */
  121273. detach(): boolean;
  121274. /**
  121275. * Will get the mesh under a specific pointer.
  121276. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  121277. * @param controllerId the controllerId to check
  121278. * @returns The mesh under pointer or null if no mesh is under the pointer
  121279. */
  121280. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  121281. /**
  121282. * Get the xr controller that correlates to the pointer id in the pointer event
  121283. *
  121284. * @param id the pointer id to search for
  121285. * @returns the controller that correlates to this id or null if not found
  121286. */
  121287. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  121288. protected _onXRFrame(_xrFrame: XRFrame): void;
  121289. private _attachGazeMode;
  121290. private _attachScreenRayMode;
  121291. private _attachTrackedPointerRayMode;
  121292. private _convertNormalToDirectionOfRay;
  121293. private _detachController;
  121294. private _generateNewMeshPair;
  121295. private _pickingMoved;
  121296. private _updatePointerDistance;
  121297. }
  121298. }
  121299. declare module BABYLON {
  121300. /**
  121301. * Button which can be used to enter a different mode of XR
  121302. */
  121303. export class WebXREnterExitUIButton {
  121304. /** button element */
  121305. element: HTMLElement;
  121306. /** XR initialization options for the button */
  121307. sessionMode: XRSessionMode;
  121308. /** Reference space type */
  121309. referenceSpaceType: XRReferenceSpaceType;
  121310. /**
  121311. * Creates a WebXREnterExitUIButton
  121312. * @param element button element
  121313. * @param sessionMode XR initialization session mode
  121314. * @param referenceSpaceType the type of reference space to be used
  121315. */
  121316. constructor(
  121317. /** button element */
  121318. element: HTMLElement,
  121319. /** XR initialization options for the button */
  121320. sessionMode: XRSessionMode,
  121321. /** Reference space type */
  121322. referenceSpaceType: XRReferenceSpaceType);
  121323. /**
  121324. * Extendable function which can be used to update the button's visuals when the state changes
  121325. * @param activeButton the current active button in the UI
  121326. */
  121327. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  121328. }
  121329. /**
  121330. * Options to create the webXR UI
  121331. */
  121332. export class WebXREnterExitUIOptions {
  121333. /**
  121334. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  121335. */
  121336. customButtons?: Array<WebXREnterExitUIButton>;
  121337. /**
  121338. * A reference space type to use when creating the default button.
  121339. * Default is local-floor
  121340. */
  121341. referenceSpaceType?: XRReferenceSpaceType;
  121342. /**
  121343. * Context to enter xr with
  121344. */
  121345. renderTarget?: Nullable<WebXRRenderTarget>;
  121346. /**
  121347. * A session mode to use when creating the default button.
  121348. * Default is immersive-vr
  121349. */
  121350. sessionMode?: XRSessionMode;
  121351. /**
  121352. * A list of optional features to init the session with
  121353. */
  121354. optionalFeatures?: string[];
  121355. }
  121356. /**
  121357. * UI to allow the user to enter/exit XR mode
  121358. */
  121359. export class WebXREnterExitUI implements IDisposable {
  121360. private scene;
  121361. /** version of the options passed to this UI */
  121362. options: WebXREnterExitUIOptions;
  121363. private _activeButton;
  121364. private _buttons;
  121365. private _overlay;
  121366. /**
  121367. * Fired every time the active button is changed.
  121368. *
  121369. * When xr is entered via a button that launches xr that button will be the callback parameter
  121370. *
  121371. * When exiting xr the callback parameter will be null)
  121372. */
  121373. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  121374. /**
  121375. *
  121376. * @param scene babylon scene object to use
  121377. * @param options (read-only) version of the options passed to this UI
  121378. */
  121379. private constructor();
  121380. /**
  121381. * Creates UI to allow the user to enter/exit XR mode
  121382. * @param scene the scene to add the ui to
  121383. * @param helper the xr experience helper to enter/exit xr with
  121384. * @param options options to configure the UI
  121385. * @returns the created ui
  121386. */
  121387. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  121388. /**
  121389. * Disposes of the XR UI component
  121390. */
  121391. dispose(): void;
  121392. private _updateButtons;
  121393. }
  121394. }
  121395. declare module BABYLON {
  121396. /**
  121397. * Class containing static functions to help procedurally build meshes
  121398. */
  121399. export class LinesBuilder {
  121400. /**
  121401. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121402. * * 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
  121403. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121404. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121405. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121406. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121407. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121408. * * 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
  121409. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121412. * @param name defines the name of the new line system
  121413. * @param options defines the options used to create the line system
  121414. * @param scene defines the hosting scene
  121415. * @returns a new line system mesh
  121416. */
  121417. static CreateLineSystem(name: string, options: {
  121418. lines: Vector3[][];
  121419. updatable?: boolean;
  121420. instance?: Nullable<LinesMesh>;
  121421. colors?: Nullable<Color4[][]>;
  121422. useVertexAlpha?: boolean;
  121423. }, scene: Nullable<Scene>): LinesMesh;
  121424. /**
  121425. * Creates a line mesh
  121426. * 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
  121427. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121428. * * The parameter `points` is an array successive Vector3
  121429. * * 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
  121430. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121431. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121432. * * When updating an instance, remember that only point positions can change, not the number of points
  121433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121435. * @param name defines the name of the new line system
  121436. * @param options defines the options used to create the line system
  121437. * @param scene defines the hosting scene
  121438. * @returns a new line mesh
  121439. */
  121440. static CreateLines(name: string, options: {
  121441. points: Vector3[];
  121442. updatable?: boolean;
  121443. instance?: Nullable<LinesMesh>;
  121444. colors?: Color4[];
  121445. useVertexAlpha?: boolean;
  121446. }, scene?: Nullable<Scene>): LinesMesh;
  121447. /**
  121448. * Creates a dashed line mesh
  121449. * * 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
  121450. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121451. * * The parameter `points` is an array successive Vector3
  121452. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121453. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121454. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121455. * * 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
  121456. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121457. * * When updating an instance, remember that only point positions can change, not the number of points
  121458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121459. * @param name defines the name of the mesh
  121460. * @param options defines the options used to create the mesh
  121461. * @param scene defines the hosting scene
  121462. * @returns the dashed line mesh
  121463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121464. */
  121465. static CreateDashedLines(name: string, options: {
  121466. points: Vector3[];
  121467. dashSize?: number;
  121468. gapSize?: number;
  121469. dashNb?: number;
  121470. updatable?: boolean;
  121471. instance?: LinesMesh;
  121472. useVertexAlpha?: boolean;
  121473. }, scene?: Nullable<Scene>): LinesMesh;
  121474. }
  121475. }
  121476. declare module BABYLON {
  121477. /**
  121478. * The options container for the teleportation module
  121479. */
  121480. export interface IWebXRTeleportationOptions {
  121481. /**
  121482. * if provided, this scene will be used to render meshes.
  121483. */
  121484. customUtilityLayerScene?: Scene;
  121485. /**
  121486. * Values to configure the default target mesh
  121487. */
  121488. defaultTargetMeshOptions?: {
  121489. /**
  121490. * Fill color of the teleportation area
  121491. */
  121492. teleportationFillColor?: string;
  121493. /**
  121494. * Border color for the teleportation area
  121495. */
  121496. teleportationBorderColor?: string;
  121497. /**
  121498. * Disable the mesh's animation sequence
  121499. */
  121500. disableAnimation?: boolean;
  121501. /**
  121502. * Disable lighting on the material or the ring and arrow
  121503. */
  121504. disableLighting?: boolean;
  121505. /**
  121506. * Override the default material of the torus and arrow
  121507. */
  121508. torusArrowMaterial?: Material;
  121509. };
  121510. /**
  121511. * A list of meshes to use as floor meshes.
  121512. * Meshes can be added and removed after initializing the feature using the
  121513. * addFloorMesh and removeFloorMesh functions
  121514. * If empty, rotation will still work
  121515. */
  121516. floorMeshes?: AbstractMesh[];
  121517. /**
  121518. * use this rendering group id for the meshes (optional)
  121519. */
  121520. renderingGroupId?: number;
  121521. /**
  121522. * Should teleportation move only to snap points
  121523. */
  121524. snapPointsOnly?: boolean;
  121525. /**
  121526. * An array of points to which the teleportation will snap to.
  121527. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  121528. */
  121529. snapPositions?: Vector3[];
  121530. /**
  121531. * How close should the teleportation ray be in order to snap to position.
  121532. * Default to 0.8 units (meters)
  121533. */
  121534. snapToPositionRadius?: number;
  121535. /**
  121536. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  121537. * If you want to support rotation, make sure your mesh has a direction indicator.
  121538. *
  121539. * When left untouched, the default mesh will be initialized.
  121540. */
  121541. teleportationTargetMesh?: AbstractMesh;
  121542. /**
  121543. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  121544. */
  121545. timeToTeleport?: number;
  121546. /**
  121547. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  121548. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  121549. */
  121550. useMainComponentOnly?: boolean;
  121551. /**
  121552. * Should meshes created here be added to a utility layer or the main scene
  121553. */
  121554. useUtilityLayer?: boolean;
  121555. /**
  121556. * Babylon XR Input class for controller
  121557. */
  121558. xrInput: WebXRInput;
  121559. }
  121560. /**
  121561. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  121562. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  121563. * the input of the attached controllers.
  121564. */
  121565. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  121566. private _options;
  121567. private _controllers;
  121568. private _currentTeleportationControllerId;
  121569. private _floorMeshes;
  121570. private _quadraticBezierCurve;
  121571. private _selectionFeature;
  121572. private _snapToPositions;
  121573. private _snappedToPoint;
  121574. private _teleportationRingMaterial?;
  121575. private _tmpRay;
  121576. private _tmpVector;
  121577. /**
  121578. * The module's name
  121579. */
  121580. static readonly Name: string;
  121581. /**
  121582. * The (Babylon) version of this module.
  121583. * This is an integer representing the implementation version.
  121584. * This number does not correspond to the webxr specs version
  121585. */
  121586. static readonly Version: number;
  121587. /**
  121588. * Is movement backwards enabled
  121589. */
  121590. backwardsMovementEnabled: boolean;
  121591. /**
  121592. * Distance to travel when moving backwards
  121593. */
  121594. backwardsTeleportationDistance: number;
  121595. /**
  121596. * The distance from the user to the inspection point in the direction of the controller
  121597. * A higher number will allow the user to move further
  121598. * defaults to 5 (meters, in xr units)
  121599. */
  121600. parabolicCheckRadius: number;
  121601. /**
  121602. * Should the module support parabolic ray on top of direct ray
  121603. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  121604. * Very helpful when moving between floors / different heights
  121605. */
  121606. parabolicRayEnabled: boolean;
  121607. /**
  121608. * How much rotation should be applied when rotating right and left
  121609. */
  121610. rotationAngle: number;
  121611. /**
  121612. * Is rotation enabled when moving forward?
  121613. * Disabling this feature will prevent the user from deciding the direction when teleporting
  121614. */
  121615. rotationEnabled: boolean;
  121616. /**
  121617. * constructs a new anchor system
  121618. * @param _xrSessionManager an instance of WebXRSessionManager
  121619. * @param _options configuration object for this feature
  121620. */
  121621. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  121622. /**
  121623. * Get the snapPointsOnly flag
  121624. */
  121625. get snapPointsOnly(): boolean;
  121626. /**
  121627. * Sets the snapPointsOnly flag
  121628. * @param snapToPoints should teleportation be exclusively to snap points
  121629. */
  121630. set snapPointsOnly(snapToPoints: boolean);
  121631. /**
  121632. * Add a new mesh to the floor meshes array
  121633. * @param mesh the mesh to use as floor mesh
  121634. */
  121635. addFloorMesh(mesh: AbstractMesh): void;
  121636. /**
  121637. * Add a new snap-to point to fix teleportation to this position
  121638. * @param newSnapPoint The new Snap-To point
  121639. */
  121640. addSnapPoint(newSnapPoint: Vector3): void;
  121641. attach(): boolean;
  121642. detach(): boolean;
  121643. dispose(): void;
  121644. /**
  121645. * Remove a mesh from the floor meshes array
  121646. * @param mesh the mesh to remove
  121647. */
  121648. removeFloorMesh(mesh: AbstractMesh): void;
  121649. /**
  121650. * Remove a mesh from the floor meshes array using its name
  121651. * @param name the mesh name to remove
  121652. */
  121653. removeFloorMeshByName(name: string): void;
  121654. /**
  121655. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  121656. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  121657. * @returns was the point found and removed or not
  121658. */
  121659. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  121660. /**
  121661. * This function sets a selection feature that will be disabled when
  121662. * the forward ray is shown and will be reattached when hidden.
  121663. * This is used to remove the selection rays when moving.
  121664. * @param selectionFeature the feature to disable when forward movement is enabled
  121665. */
  121666. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  121667. protected _onXRFrame(_xrFrame: XRFrame): void;
  121668. private _attachController;
  121669. private _createDefaultTargetMesh;
  121670. private _detachController;
  121671. private _findClosestSnapPointWithRadius;
  121672. private _setTargetMeshPosition;
  121673. private _setTargetMeshVisibility;
  121674. private _showParabolicPath;
  121675. private _teleportForward;
  121676. }
  121677. }
  121678. declare module BABYLON {
  121679. /**
  121680. * Options for the default xr helper
  121681. */
  121682. export class WebXRDefaultExperienceOptions {
  121683. /**
  121684. * Enable or disable default UI to enter XR
  121685. */
  121686. disableDefaultUI?: boolean;
  121687. /**
  121688. * Should teleportation not initialize. defaults to false.
  121689. */
  121690. disableTeleportation?: boolean;
  121691. /**
  121692. * Floor meshes that will be used for teleport
  121693. */
  121694. floorMeshes?: Array<AbstractMesh>;
  121695. /**
  121696. * If set to true, the first frame will not be used to reset position
  121697. * The first frame is mainly used when copying transformation from the old camera
  121698. * Mainly used in AR
  121699. */
  121700. ignoreNativeCameraTransformation?: boolean;
  121701. /**
  121702. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  121703. */
  121704. inputOptions?: IWebXRInputOptions;
  121705. /**
  121706. * optional configuration for the output canvas
  121707. */
  121708. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  121709. /**
  121710. * optional UI options. This can be used among other to change session mode and reference space type
  121711. */
  121712. uiOptions?: WebXREnterExitUIOptions;
  121713. /**
  121714. * When loading teleportation and pointer select, use stable versions instead of latest.
  121715. */
  121716. useStablePlugins?: boolean;
  121717. /**
  121718. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  121719. */
  121720. renderingGroupId?: number;
  121721. /**
  121722. * A list of optional features to init the session with
  121723. * If set to true, all features we support will be added
  121724. */
  121725. optionalFeatures?: boolean | string[];
  121726. }
  121727. /**
  121728. * Default experience which provides a similar setup to the previous webVRExperience
  121729. */
  121730. export class WebXRDefaultExperience {
  121731. /**
  121732. * Base experience
  121733. */
  121734. baseExperience: WebXRExperienceHelper;
  121735. /**
  121736. * Enables ui for entering/exiting xr
  121737. */
  121738. enterExitUI: WebXREnterExitUI;
  121739. /**
  121740. * Input experience extension
  121741. */
  121742. input: WebXRInput;
  121743. /**
  121744. * Enables laser pointer and selection
  121745. */
  121746. pointerSelection: WebXRControllerPointerSelection;
  121747. /**
  121748. * Default target xr should render to
  121749. */
  121750. renderTarget: WebXRRenderTarget;
  121751. /**
  121752. * Enables teleportation
  121753. */
  121754. teleportation: WebXRMotionControllerTeleportation;
  121755. private constructor();
  121756. /**
  121757. * Creates the default xr experience
  121758. * @param scene scene
  121759. * @param options options for basic configuration
  121760. * @returns resulting WebXRDefaultExperience
  121761. */
  121762. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121763. /**
  121764. * DIsposes of the experience helper
  121765. */
  121766. dispose(): void;
  121767. }
  121768. }
  121769. declare module BABYLON {
  121770. /**
  121771. * Options to modify the vr teleportation behavior.
  121772. */
  121773. export interface VRTeleportationOptions {
  121774. /**
  121775. * The name of the mesh which should be used as the teleportation floor. (default: null)
  121776. */
  121777. floorMeshName?: string;
  121778. /**
  121779. * A list of meshes to be used as the teleportation floor. (default: empty)
  121780. */
  121781. floorMeshes?: Mesh[];
  121782. /**
  121783. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  121784. */
  121785. teleportationMode?: number;
  121786. /**
  121787. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  121788. */
  121789. teleportationTime?: number;
  121790. /**
  121791. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  121792. */
  121793. teleportationSpeed?: number;
  121794. /**
  121795. * The easing function used in the animation or null for Linear. (default CircleEase)
  121796. */
  121797. easingFunction?: EasingFunction;
  121798. }
  121799. /**
  121800. * Options to modify the vr experience helper's behavior.
  121801. */
  121802. export interface VRExperienceHelperOptions extends WebVROptions {
  121803. /**
  121804. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  121805. */
  121806. createDeviceOrientationCamera?: boolean;
  121807. /**
  121808. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  121809. */
  121810. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  121811. /**
  121812. * Uses the main button on the controller to toggle the laser casted. (default: true)
  121813. */
  121814. laserToggle?: boolean;
  121815. /**
  121816. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  121817. */
  121818. floorMeshes?: Mesh[];
  121819. /**
  121820. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  121821. */
  121822. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  121823. /**
  121824. * Defines if WebXR should be used instead of WebVR (if available)
  121825. */
  121826. useXR?: boolean;
  121827. }
  121828. /**
  121829. * Event containing information after VR has been entered
  121830. */
  121831. export class OnAfterEnteringVRObservableEvent {
  121832. /**
  121833. * If entering vr was successful
  121834. */
  121835. success: boolean;
  121836. }
  121837. /**
  121838. * Helps to quickly add VR support to an existing scene.
  121839. * See http://doc.babylonjs.com/how_to/webvr_helper
  121840. */
  121841. export class VRExperienceHelper {
  121842. /** Options to modify the vr experience helper's behavior. */
  121843. webVROptions: VRExperienceHelperOptions;
  121844. private _scene;
  121845. private _position;
  121846. private _btnVR;
  121847. private _btnVRDisplayed;
  121848. private _webVRsupported;
  121849. private _webVRready;
  121850. private _webVRrequesting;
  121851. private _webVRpresenting;
  121852. private _hasEnteredVR;
  121853. private _fullscreenVRpresenting;
  121854. private _inputElement;
  121855. private _webVRCamera;
  121856. private _vrDeviceOrientationCamera;
  121857. private _deviceOrientationCamera;
  121858. private _existingCamera;
  121859. private _onKeyDown;
  121860. private _onVrDisplayPresentChange;
  121861. private _onVRDisplayChanged;
  121862. private _onVRRequestPresentStart;
  121863. private _onVRRequestPresentComplete;
  121864. /**
  121865. * 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)
  121866. */
  121867. enableGazeEvenWhenNoPointerLock: boolean;
  121868. /**
  121869. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  121870. */
  121871. exitVROnDoubleTap: boolean;
  121872. /**
  121873. * Observable raised right before entering VR.
  121874. */
  121875. onEnteringVRObservable: Observable<VRExperienceHelper>;
  121876. /**
  121877. * Observable raised when entering VR has completed.
  121878. */
  121879. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  121880. /**
  121881. * Observable raised when exiting VR.
  121882. */
  121883. onExitingVRObservable: Observable<VRExperienceHelper>;
  121884. /**
  121885. * Observable raised when controller mesh is loaded.
  121886. */
  121887. onControllerMeshLoadedObservable: Observable<WebVRController>;
  121888. /** Return this.onEnteringVRObservable
  121889. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  121890. */
  121891. get onEnteringVR(): Observable<VRExperienceHelper>;
  121892. /** Return this.onExitingVRObservable
  121893. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  121894. */
  121895. get onExitingVR(): Observable<VRExperienceHelper>;
  121896. /** Return this.onControllerMeshLoadedObservable
  121897. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  121898. */
  121899. get onControllerMeshLoaded(): Observable<WebVRController>;
  121900. private _rayLength;
  121901. private _useCustomVRButton;
  121902. private _teleportationRequested;
  121903. private _teleportActive;
  121904. private _floorMeshName;
  121905. private _floorMeshesCollection;
  121906. private _teleportationMode;
  121907. private _teleportationTime;
  121908. private _teleportationSpeed;
  121909. private _teleportationEasing;
  121910. private _rotationAllowed;
  121911. private _teleportBackwardsVector;
  121912. private _teleportationTarget;
  121913. private _isDefaultTeleportationTarget;
  121914. private _postProcessMove;
  121915. private _teleportationFillColor;
  121916. private _teleportationBorderColor;
  121917. private _rotationAngle;
  121918. private _haloCenter;
  121919. private _cameraGazer;
  121920. private _padSensibilityUp;
  121921. private _padSensibilityDown;
  121922. private _leftController;
  121923. private _rightController;
  121924. private _gazeColor;
  121925. private _laserColor;
  121926. private _pickedLaserColor;
  121927. private _pickedGazeColor;
  121928. /**
  121929. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  121930. */
  121931. onNewMeshSelected: Observable<AbstractMesh>;
  121932. /**
  121933. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  121934. * This observable will provide the mesh and the controller used to select the mesh
  121935. */
  121936. onMeshSelectedWithController: Observable<{
  121937. mesh: AbstractMesh;
  121938. controller: WebVRController;
  121939. }>;
  121940. /**
  121941. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  121942. */
  121943. onNewMeshPicked: Observable<PickingInfo>;
  121944. private _circleEase;
  121945. /**
  121946. * Observable raised before camera teleportation
  121947. */
  121948. onBeforeCameraTeleport: Observable<Vector3>;
  121949. /**
  121950. * Observable raised after camera teleportation
  121951. */
  121952. onAfterCameraTeleport: Observable<Vector3>;
  121953. /**
  121954. * Observable raised when current selected mesh gets unselected
  121955. */
  121956. onSelectedMeshUnselected: Observable<AbstractMesh>;
  121957. private _raySelectionPredicate;
  121958. /**
  121959. * To be optionaly changed by user to define custom ray selection
  121960. */
  121961. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121962. /**
  121963. * To be optionaly changed by user to define custom selection logic (after ray selection)
  121964. */
  121965. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  121966. /**
  121967. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  121968. */
  121969. teleportationEnabled: boolean;
  121970. private _defaultHeight;
  121971. private _teleportationInitialized;
  121972. private _interactionsEnabled;
  121973. private _interactionsRequested;
  121974. private _displayGaze;
  121975. private _displayLaserPointer;
  121976. /**
  121977. * The mesh used to display where the user is going to teleport.
  121978. */
  121979. get teleportationTarget(): Mesh;
  121980. /**
  121981. * Sets the mesh to be used to display where the user is going to teleport.
  121982. */
  121983. set teleportationTarget(value: Mesh);
  121984. /**
  121985. * 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
  121986. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  121987. * See http://doc.babylonjs.com/resources/baking_transformations
  121988. */
  121989. get gazeTrackerMesh(): Mesh;
  121990. set gazeTrackerMesh(value: Mesh);
  121991. /**
  121992. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  121993. */
  121994. updateGazeTrackerScale: boolean;
  121995. /**
  121996. * If the gaze trackers color should be updated when selecting meshes
  121997. */
  121998. updateGazeTrackerColor: boolean;
  121999. /**
  122000. * If the controller laser color should be updated when selecting meshes
  122001. */
  122002. updateControllerLaserColor: boolean;
  122003. /**
  122004. * The gaze tracking mesh corresponding to the left controller
  122005. */
  122006. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  122007. /**
  122008. * The gaze tracking mesh corresponding to the right controller
  122009. */
  122010. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  122011. /**
  122012. * If the ray of the gaze should be displayed.
  122013. */
  122014. get displayGaze(): boolean;
  122015. /**
  122016. * Sets if the ray of the gaze should be displayed.
  122017. */
  122018. set displayGaze(value: boolean);
  122019. /**
  122020. * If the ray of the LaserPointer should be displayed.
  122021. */
  122022. get displayLaserPointer(): boolean;
  122023. /**
  122024. * Sets if the ray of the LaserPointer should be displayed.
  122025. */
  122026. set displayLaserPointer(value: boolean);
  122027. /**
  122028. * The deviceOrientationCamera used as the camera when not in VR.
  122029. */
  122030. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  122031. /**
  122032. * Based on the current WebVR support, returns the current VR camera used.
  122033. */
  122034. get currentVRCamera(): Nullable<Camera>;
  122035. /**
  122036. * The webVRCamera which is used when in VR.
  122037. */
  122038. get webVRCamera(): WebVRFreeCamera;
  122039. /**
  122040. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  122041. */
  122042. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  122043. /**
  122044. * The html button that is used to trigger entering into VR.
  122045. */
  122046. get vrButton(): Nullable<HTMLButtonElement>;
  122047. private get _teleportationRequestInitiated();
  122048. /**
  122049. * Defines whether or not Pointer lock should be requested when switching to
  122050. * full screen.
  122051. */
  122052. requestPointerLockOnFullScreen: boolean;
  122053. /**
  122054. * If asking to force XR, this will be populated with the default xr experience
  122055. */
  122056. xr: WebXRDefaultExperience;
  122057. /**
  122058. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  122059. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  122060. */
  122061. xrTestDone: boolean;
  122062. /**
  122063. * Instantiates a VRExperienceHelper.
  122064. * Helps to quickly add VR support to an existing scene.
  122065. * @param scene The scene the VRExperienceHelper belongs to.
  122066. * @param webVROptions Options to modify the vr experience helper's behavior.
  122067. */
  122068. constructor(scene: Scene,
  122069. /** Options to modify the vr experience helper's behavior. */
  122070. webVROptions?: VRExperienceHelperOptions);
  122071. private completeVRInit;
  122072. private _onDefaultMeshLoaded;
  122073. private _onResize;
  122074. private _onFullscreenChange;
  122075. /**
  122076. * Gets a value indicating if we are currently in VR mode.
  122077. */
  122078. get isInVRMode(): boolean;
  122079. private onVrDisplayPresentChange;
  122080. private onVRDisplayChanged;
  122081. private moveButtonToBottomRight;
  122082. private displayVRButton;
  122083. private updateButtonVisibility;
  122084. private _cachedAngularSensibility;
  122085. /**
  122086. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  122087. * Otherwise, will use the fullscreen API.
  122088. */
  122089. enterVR(): void;
  122090. /**
  122091. * Attempt to exit VR, or fullscreen.
  122092. */
  122093. exitVR(): void;
  122094. /**
  122095. * The position of the vr experience helper.
  122096. */
  122097. get position(): Vector3;
  122098. /**
  122099. * Sets the position of the vr experience helper.
  122100. */
  122101. set position(value: Vector3);
  122102. /**
  122103. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  122104. */
  122105. enableInteractions(): void;
  122106. private get _noControllerIsActive();
  122107. private beforeRender;
  122108. private _isTeleportationFloor;
  122109. /**
  122110. * Adds a floor mesh to be used for teleportation.
  122111. * @param floorMesh the mesh to be used for teleportation.
  122112. */
  122113. addFloorMesh(floorMesh: Mesh): void;
  122114. /**
  122115. * Removes a floor mesh from being used for teleportation.
  122116. * @param floorMesh the mesh to be removed.
  122117. */
  122118. removeFloorMesh(floorMesh: Mesh): void;
  122119. /**
  122120. * Enables interactions and teleportation using the VR controllers and gaze.
  122121. * @param vrTeleportationOptions options to modify teleportation behavior.
  122122. */
  122123. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  122124. private _onNewGamepadConnected;
  122125. private _tryEnableInteractionOnController;
  122126. private _onNewGamepadDisconnected;
  122127. private _enableInteractionOnController;
  122128. private _checkTeleportWithRay;
  122129. private _checkRotate;
  122130. private _checkTeleportBackwards;
  122131. private _enableTeleportationOnController;
  122132. private _createTeleportationCircles;
  122133. private _displayTeleportationTarget;
  122134. private _hideTeleportationTarget;
  122135. private _rotateCamera;
  122136. private _moveTeleportationSelectorTo;
  122137. private _workingVector;
  122138. private _workingQuaternion;
  122139. private _workingMatrix;
  122140. /**
  122141. * Time Constant Teleportation Mode
  122142. */
  122143. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  122144. /**
  122145. * Speed Constant Teleportation Mode
  122146. */
  122147. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  122148. /**
  122149. * Teleports the users feet to the desired location
  122150. * @param location The location where the user's feet should be placed
  122151. */
  122152. teleportCamera(location: Vector3): void;
  122153. private _convertNormalToDirectionOfRay;
  122154. private _castRayAndSelectObject;
  122155. private _notifySelectedMeshUnselected;
  122156. /**
  122157. * Permanently set new colors for the laser pointer
  122158. * @param color the new laser color
  122159. * @param pickedColor the new laser color when picked mesh detected
  122160. */
  122161. setLaserColor(color: Color3, pickedColor?: Color3): void;
  122162. /**
  122163. * Set lighting enabled / disabled on the laser pointer of both controllers
  122164. * @param enabled should the lighting be enabled on the laser pointer
  122165. */
  122166. setLaserLightingState(enabled?: boolean): void;
  122167. /**
  122168. * Permanently set new colors for the gaze pointer
  122169. * @param color the new gaze color
  122170. * @param pickedColor the new gaze color when picked mesh detected
  122171. */
  122172. setGazeColor(color: Color3, pickedColor?: Color3): void;
  122173. /**
  122174. * Sets the color of the laser ray from the vr controllers.
  122175. * @param color new color for the ray.
  122176. */
  122177. changeLaserColor(color: Color3): void;
  122178. /**
  122179. * Sets the color of the ray from the vr headsets gaze.
  122180. * @param color new color for the ray.
  122181. */
  122182. changeGazeColor(color: Color3): void;
  122183. /**
  122184. * Exits VR and disposes of the vr experience helper
  122185. */
  122186. dispose(): void;
  122187. /**
  122188. * Gets the name of the VRExperienceHelper class
  122189. * @returns "VRExperienceHelper"
  122190. */
  122191. getClassName(): string;
  122192. }
  122193. }
  122194. declare module BABYLON {
  122195. /**
  122196. * Contains an array of blocks representing the octree
  122197. */
  122198. export interface IOctreeContainer<T> {
  122199. /**
  122200. * Blocks within the octree
  122201. */
  122202. blocks: Array<OctreeBlock<T>>;
  122203. }
  122204. /**
  122205. * Class used to store a cell in an octree
  122206. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122207. */
  122208. export class OctreeBlock<T> {
  122209. /**
  122210. * Gets the content of the current block
  122211. */
  122212. entries: T[];
  122213. /**
  122214. * Gets the list of block children
  122215. */
  122216. blocks: Array<OctreeBlock<T>>;
  122217. private _depth;
  122218. private _maxDepth;
  122219. private _capacity;
  122220. private _minPoint;
  122221. private _maxPoint;
  122222. private _boundingVectors;
  122223. private _creationFunc;
  122224. /**
  122225. * Creates a new block
  122226. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  122227. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  122228. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122229. * @param depth defines the current depth of this block in the octree
  122230. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  122231. * @param creationFunc defines a callback to call when an element is added to the block
  122232. */
  122233. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  122234. /**
  122235. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122236. */
  122237. get capacity(): number;
  122238. /**
  122239. * Gets the minimum vector (in world space) of the block's bounding box
  122240. */
  122241. get minPoint(): Vector3;
  122242. /**
  122243. * Gets the maximum vector (in world space) of the block's bounding box
  122244. */
  122245. get maxPoint(): Vector3;
  122246. /**
  122247. * Add a new element to this block
  122248. * @param entry defines the element to add
  122249. */
  122250. addEntry(entry: T): void;
  122251. /**
  122252. * Remove an element from this block
  122253. * @param entry defines the element to remove
  122254. */
  122255. removeEntry(entry: T): void;
  122256. /**
  122257. * Add an array of elements to this block
  122258. * @param entries defines the array of elements to add
  122259. */
  122260. addEntries(entries: T[]): void;
  122261. /**
  122262. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  122263. * @param frustumPlanes defines the frustum planes to test
  122264. * @param selection defines the array to store current content if selection is positive
  122265. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122266. */
  122267. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122268. /**
  122269. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  122270. * @param sphereCenter defines the bounding sphere center
  122271. * @param sphereRadius defines the bounding sphere radius
  122272. * @param selection defines the array to store current content if selection is positive
  122273. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122274. */
  122275. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122276. /**
  122277. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  122278. * @param ray defines the ray to test with
  122279. * @param selection defines the array to store current content if selection is positive
  122280. */
  122281. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  122282. /**
  122283. * Subdivide the content into child blocks (this block will then be empty)
  122284. */
  122285. createInnerBlocks(): void;
  122286. /**
  122287. * @hidden
  122288. */
  122289. 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;
  122290. }
  122291. }
  122292. declare module BABYLON {
  122293. /**
  122294. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  122295. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122296. */
  122297. export class Octree<T> {
  122298. /** 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.) */
  122299. maxDepth: number;
  122300. /**
  122301. * Blocks within the octree containing objects
  122302. */
  122303. blocks: Array<OctreeBlock<T>>;
  122304. /**
  122305. * Content stored in the octree
  122306. */
  122307. dynamicContent: T[];
  122308. private _maxBlockCapacity;
  122309. private _selectionContent;
  122310. private _creationFunc;
  122311. /**
  122312. * Creates a octree
  122313. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122314. * @param creationFunc function to be used to instatiate the octree
  122315. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  122316. * @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.)
  122317. */
  122318. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  122319. /** 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.) */
  122320. maxDepth?: number);
  122321. /**
  122322. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  122323. * @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);
  122324. * @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);
  122325. * @param entries meshes to be added to the octree blocks
  122326. */
  122327. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  122328. /**
  122329. * Adds a mesh to the octree
  122330. * @param entry Mesh to add to the octree
  122331. */
  122332. addMesh(entry: T): void;
  122333. /**
  122334. * Remove an element from the octree
  122335. * @param entry defines the element to remove
  122336. */
  122337. removeMesh(entry: T): void;
  122338. /**
  122339. * Selects an array of meshes within the frustum
  122340. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  122341. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  122342. * @returns array of meshes within the frustum
  122343. */
  122344. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  122345. /**
  122346. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  122347. * @param sphereCenter defines the bounding sphere center
  122348. * @param sphereRadius defines the bounding sphere radius
  122349. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122350. * @returns an array of objects that intersect the sphere
  122351. */
  122352. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  122353. /**
  122354. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  122355. * @param ray defines the ray to test with
  122356. * @returns array of intersected objects
  122357. */
  122358. intersectsRay(ray: Ray): SmartArray<T>;
  122359. /**
  122360. * Adds a mesh into the octree block if it intersects the block
  122361. */
  122362. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  122363. /**
  122364. * Adds a submesh into the octree block if it intersects the block
  122365. */
  122366. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  122367. }
  122368. }
  122369. declare module BABYLON {
  122370. interface Scene {
  122371. /**
  122372. * @hidden
  122373. * Backing Filed
  122374. */
  122375. _selectionOctree: Octree<AbstractMesh>;
  122376. /**
  122377. * Gets the octree used to boost mesh selection (picking)
  122378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122379. */
  122380. selectionOctree: Octree<AbstractMesh>;
  122381. /**
  122382. * Creates or updates the octree used to boost selection (picking)
  122383. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122384. * @param maxCapacity defines the maximum capacity per leaf
  122385. * @param maxDepth defines the maximum depth of the octree
  122386. * @returns an octree of AbstractMesh
  122387. */
  122388. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  122389. }
  122390. interface AbstractMesh {
  122391. /**
  122392. * @hidden
  122393. * Backing Field
  122394. */
  122395. _submeshesOctree: Octree<SubMesh>;
  122396. /**
  122397. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  122398. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  122399. * @param maxCapacity defines the maximum size of each block (64 by default)
  122400. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  122401. * @returns the new octree
  122402. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  122403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122404. */
  122405. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  122406. }
  122407. /**
  122408. * Defines the octree scene component responsible to manage any octrees
  122409. * in a given scene.
  122410. */
  122411. export class OctreeSceneComponent {
  122412. /**
  122413. * The component name help to identify the component in the list of scene components.
  122414. */
  122415. readonly name: string;
  122416. /**
  122417. * The scene the component belongs to.
  122418. */
  122419. scene: Scene;
  122420. /**
  122421. * Indicates if the meshes have been checked to make sure they are isEnabled()
  122422. */
  122423. readonly checksIsEnabled: boolean;
  122424. /**
  122425. * Creates a new instance of the component for the given scene
  122426. * @param scene Defines the scene to register the component in
  122427. */
  122428. constructor(scene: Scene);
  122429. /**
  122430. * Registers the component in a given scene
  122431. */
  122432. register(): void;
  122433. /**
  122434. * Return the list of active meshes
  122435. * @returns the list of active meshes
  122436. */
  122437. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  122438. /**
  122439. * Return the list of active sub meshes
  122440. * @param mesh The mesh to get the candidates sub meshes from
  122441. * @returns the list of active sub meshes
  122442. */
  122443. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  122444. private _tempRay;
  122445. /**
  122446. * Return the list of sub meshes intersecting with a given local ray
  122447. * @param mesh defines the mesh to find the submesh for
  122448. * @param localRay defines the ray in local space
  122449. * @returns the list of intersecting sub meshes
  122450. */
  122451. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  122452. /**
  122453. * Return the list of sub meshes colliding with a collider
  122454. * @param mesh defines the mesh to find the submesh for
  122455. * @param collider defines the collider to evaluate the collision against
  122456. * @returns the list of colliding sub meshes
  122457. */
  122458. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  122459. /**
  122460. * Rebuilds the elements related to this component in case of
  122461. * context lost for instance.
  122462. */
  122463. rebuild(): void;
  122464. /**
  122465. * Disposes the component and the associated ressources.
  122466. */
  122467. dispose(): void;
  122468. }
  122469. }
  122470. declare module BABYLON {
  122471. /**
  122472. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  122473. */
  122474. export class Gizmo implements IDisposable {
  122475. /** The utility layer the gizmo will be added to */
  122476. gizmoLayer: UtilityLayerRenderer;
  122477. /**
  122478. * The root mesh of the gizmo
  122479. */
  122480. _rootMesh: Mesh;
  122481. private _attachedMesh;
  122482. /**
  122483. * Ratio for the scale of the gizmo (Default: 1)
  122484. */
  122485. scaleRatio: number;
  122486. /**
  122487. * If a custom mesh has been set (Default: false)
  122488. */
  122489. protected _customMeshSet: boolean;
  122490. /**
  122491. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  122492. * * When set, interactions will be enabled
  122493. */
  122494. get attachedMesh(): Nullable<AbstractMesh>;
  122495. set attachedMesh(value: Nullable<AbstractMesh>);
  122496. /**
  122497. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122498. * @param mesh The mesh to replace the default mesh of the gizmo
  122499. */
  122500. setCustomMesh(mesh: Mesh): void;
  122501. /**
  122502. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  122503. */
  122504. updateGizmoRotationToMatchAttachedMesh: boolean;
  122505. /**
  122506. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  122507. */
  122508. updateGizmoPositionToMatchAttachedMesh: boolean;
  122509. /**
  122510. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  122511. */
  122512. updateScale: boolean;
  122513. protected _interactionsEnabled: boolean;
  122514. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122515. private _beforeRenderObserver;
  122516. private _tempVector;
  122517. /**
  122518. * Creates a gizmo
  122519. * @param gizmoLayer The utility layer the gizmo will be added to
  122520. */
  122521. constructor(
  122522. /** The utility layer the gizmo will be added to */
  122523. gizmoLayer?: UtilityLayerRenderer);
  122524. /**
  122525. * Updates the gizmo to match the attached mesh's position/rotation
  122526. */
  122527. protected _update(): void;
  122528. /**
  122529. * Disposes of the gizmo
  122530. */
  122531. dispose(): void;
  122532. }
  122533. }
  122534. declare module BABYLON {
  122535. /**
  122536. * Single plane drag gizmo
  122537. */
  122538. export class PlaneDragGizmo extends Gizmo {
  122539. /**
  122540. * Drag behavior responsible for the gizmos dragging interactions
  122541. */
  122542. dragBehavior: PointerDragBehavior;
  122543. private _pointerObserver;
  122544. /**
  122545. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122546. */
  122547. snapDistance: number;
  122548. /**
  122549. * Event that fires each time the gizmo snaps to a new location.
  122550. * * snapDistance is the the change in distance
  122551. */
  122552. onSnapObservable: Observable<{
  122553. snapDistance: number;
  122554. }>;
  122555. private _plane;
  122556. private _coloredMaterial;
  122557. private _hoverMaterial;
  122558. private _isEnabled;
  122559. private _parent;
  122560. /** @hidden */
  122561. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  122562. /** @hidden */
  122563. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122564. /**
  122565. * Creates a PlaneDragGizmo
  122566. * @param gizmoLayer The utility layer the gizmo will be added to
  122567. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  122568. * @param color The color of the gizmo
  122569. */
  122570. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122571. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122572. /**
  122573. * If the gizmo is enabled
  122574. */
  122575. set isEnabled(value: boolean);
  122576. get isEnabled(): boolean;
  122577. /**
  122578. * Disposes of the gizmo
  122579. */
  122580. dispose(): void;
  122581. }
  122582. }
  122583. declare module BABYLON {
  122584. /**
  122585. * Gizmo that enables dragging a mesh along 3 axis
  122586. */
  122587. export class PositionGizmo extends Gizmo {
  122588. /**
  122589. * Internal gizmo used for interactions on the x axis
  122590. */
  122591. xGizmo: AxisDragGizmo;
  122592. /**
  122593. * Internal gizmo used for interactions on the y axis
  122594. */
  122595. yGizmo: AxisDragGizmo;
  122596. /**
  122597. * Internal gizmo used for interactions on the z axis
  122598. */
  122599. zGizmo: AxisDragGizmo;
  122600. /**
  122601. * Internal gizmo used for interactions on the yz plane
  122602. */
  122603. xPlaneGizmo: PlaneDragGizmo;
  122604. /**
  122605. * Internal gizmo used for interactions on the xz plane
  122606. */
  122607. yPlaneGizmo: PlaneDragGizmo;
  122608. /**
  122609. * Internal gizmo used for interactions on the xy plane
  122610. */
  122611. zPlaneGizmo: PlaneDragGizmo;
  122612. /**
  122613. * private variables
  122614. */
  122615. private _meshAttached;
  122616. private _updateGizmoRotationToMatchAttachedMesh;
  122617. private _snapDistance;
  122618. private _scaleRatio;
  122619. /** Fires an event when any of it's sub gizmos are dragged */
  122620. onDragStartObservable: Observable<unknown>;
  122621. /** Fires an event when any of it's sub gizmos are released from dragging */
  122622. onDragEndObservable: Observable<unknown>;
  122623. /**
  122624. * If set to true, planar drag is enabled
  122625. */
  122626. private _planarGizmoEnabled;
  122627. get attachedMesh(): Nullable<AbstractMesh>;
  122628. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122629. /**
  122630. * Creates a PositionGizmo
  122631. * @param gizmoLayer The utility layer the gizmo will be added to
  122632. */
  122633. constructor(gizmoLayer?: UtilityLayerRenderer);
  122634. /**
  122635. * If the planar drag gizmo is enabled
  122636. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  122637. */
  122638. set planarGizmoEnabled(value: boolean);
  122639. get planarGizmoEnabled(): boolean;
  122640. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122641. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122642. /**
  122643. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122644. */
  122645. set snapDistance(value: number);
  122646. get snapDistance(): number;
  122647. /**
  122648. * Ratio for the scale of the gizmo (Default: 1)
  122649. */
  122650. set scaleRatio(value: number);
  122651. get scaleRatio(): number;
  122652. /**
  122653. * Disposes of the gizmo
  122654. */
  122655. dispose(): void;
  122656. /**
  122657. * CustomMeshes are not supported by this gizmo
  122658. * @param mesh The mesh to replace the default mesh of the gizmo
  122659. */
  122660. setCustomMesh(mesh: Mesh): void;
  122661. }
  122662. }
  122663. declare module BABYLON {
  122664. /**
  122665. * Single axis drag gizmo
  122666. */
  122667. export class AxisDragGizmo extends Gizmo {
  122668. /**
  122669. * Drag behavior responsible for the gizmos dragging interactions
  122670. */
  122671. dragBehavior: PointerDragBehavior;
  122672. private _pointerObserver;
  122673. /**
  122674. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122675. */
  122676. snapDistance: number;
  122677. /**
  122678. * Event that fires each time the gizmo snaps to a new location.
  122679. * * snapDistance is the the change in distance
  122680. */
  122681. onSnapObservable: Observable<{
  122682. snapDistance: number;
  122683. }>;
  122684. private _isEnabled;
  122685. private _parent;
  122686. private _arrow;
  122687. private _coloredMaterial;
  122688. private _hoverMaterial;
  122689. /** @hidden */
  122690. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  122691. /** @hidden */
  122692. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122693. /**
  122694. * Creates an AxisDragGizmo
  122695. * @param gizmoLayer The utility layer the gizmo will be added to
  122696. * @param dragAxis The axis which the gizmo will be able to drag on
  122697. * @param color The color of the gizmo
  122698. */
  122699. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122700. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122701. /**
  122702. * If the gizmo is enabled
  122703. */
  122704. set isEnabled(value: boolean);
  122705. get isEnabled(): boolean;
  122706. /**
  122707. * Disposes of the gizmo
  122708. */
  122709. dispose(): void;
  122710. }
  122711. }
  122712. declare module BABYLON.Debug {
  122713. /**
  122714. * The Axes viewer will show 3 axes in a specific point in space
  122715. */
  122716. export class AxesViewer {
  122717. private _xAxis;
  122718. private _yAxis;
  122719. private _zAxis;
  122720. private _scaleLinesFactor;
  122721. private _instanced;
  122722. /**
  122723. * Gets the hosting scene
  122724. */
  122725. scene: Scene;
  122726. /**
  122727. * Gets or sets a number used to scale line length
  122728. */
  122729. scaleLines: number;
  122730. /** Gets the node hierarchy used to render x-axis */
  122731. get xAxis(): TransformNode;
  122732. /** Gets the node hierarchy used to render y-axis */
  122733. get yAxis(): TransformNode;
  122734. /** Gets the node hierarchy used to render z-axis */
  122735. get zAxis(): TransformNode;
  122736. /**
  122737. * Creates a new AxesViewer
  122738. * @param scene defines the hosting scene
  122739. * @param scaleLines defines a number used to scale line length (1 by default)
  122740. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  122741. * @param xAxis defines the node hierarchy used to render the x-axis
  122742. * @param yAxis defines the node hierarchy used to render the y-axis
  122743. * @param zAxis defines the node hierarchy used to render the z-axis
  122744. */
  122745. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  122746. /**
  122747. * Force the viewer to update
  122748. * @param position defines the position of the viewer
  122749. * @param xaxis defines the x axis of the viewer
  122750. * @param yaxis defines the y axis of the viewer
  122751. * @param zaxis defines the z axis of the viewer
  122752. */
  122753. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  122754. /**
  122755. * Creates an instance of this axes viewer.
  122756. * @returns a new axes viewer with instanced meshes
  122757. */
  122758. createInstance(): AxesViewer;
  122759. /** Releases resources */
  122760. dispose(): void;
  122761. private static _SetRenderingGroupId;
  122762. }
  122763. }
  122764. declare module BABYLON.Debug {
  122765. /**
  122766. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  122767. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  122768. */
  122769. export class BoneAxesViewer extends AxesViewer {
  122770. /**
  122771. * Gets or sets the target mesh where to display the axes viewer
  122772. */
  122773. mesh: Nullable<Mesh>;
  122774. /**
  122775. * Gets or sets the target bone where to display the axes viewer
  122776. */
  122777. bone: Nullable<Bone>;
  122778. /** Gets current position */
  122779. pos: Vector3;
  122780. /** Gets direction of X axis */
  122781. xaxis: Vector3;
  122782. /** Gets direction of Y axis */
  122783. yaxis: Vector3;
  122784. /** Gets direction of Z axis */
  122785. zaxis: Vector3;
  122786. /**
  122787. * Creates a new BoneAxesViewer
  122788. * @param scene defines the hosting scene
  122789. * @param bone defines the target bone
  122790. * @param mesh defines the target mesh
  122791. * @param scaleLines defines a scaling factor for line length (1 by default)
  122792. */
  122793. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  122794. /**
  122795. * Force the viewer to update
  122796. */
  122797. update(): void;
  122798. /** Releases resources */
  122799. dispose(): void;
  122800. }
  122801. }
  122802. declare module BABYLON {
  122803. /**
  122804. * Interface used to define scene explorer extensibility option
  122805. */
  122806. export interface IExplorerExtensibilityOption {
  122807. /**
  122808. * Define the option label
  122809. */
  122810. label: string;
  122811. /**
  122812. * Defines the action to execute on click
  122813. */
  122814. action: (entity: any) => void;
  122815. }
  122816. /**
  122817. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  122818. */
  122819. export interface IExplorerExtensibilityGroup {
  122820. /**
  122821. * Defines a predicate to test if a given type mut be extended
  122822. */
  122823. predicate: (entity: any) => boolean;
  122824. /**
  122825. * Gets the list of options added to a type
  122826. */
  122827. entries: IExplorerExtensibilityOption[];
  122828. }
  122829. /**
  122830. * Interface used to define the options to use to create the Inspector
  122831. */
  122832. export interface IInspectorOptions {
  122833. /**
  122834. * Display in overlay mode (default: false)
  122835. */
  122836. overlay?: boolean;
  122837. /**
  122838. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  122839. */
  122840. globalRoot?: HTMLElement;
  122841. /**
  122842. * Display the Scene explorer
  122843. */
  122844. showExplorer?: boolean;
  122845. /**
  122846. * Display the property inspector
  122847. */
  122848. showInspector?: boolean;
  122849. /**
  122850. * Display in embed mode (both panes on the right)
  122851. */
  122852. embedMode?: boolean;
  122853. /**
  122854. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  122855. */
  122856. handleResize?: boolean;
  122857. /**
  122858. * Allow the panes to popup (default: true)
  122859. */
  122860. enablePopup?: boolean;
  122861. /**
  122862. * Allow the panes to be closed by users (default: true)
  122863. */
  122864. enableClose?: boolean;
  122865. /**
  122866. * Optional list of extensibility entries
  122867. */
  122868. explorerExtensibility?: IExplorerExtensibilityGroup[];
  122869. /**
  122870. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  122871. */
  122872. inspectorURL?: string;
  122873. /**
  122874. * Optional initial tab (default to DebugLayerTab.Properties)
  122875. */
  122876. initialTab?: DebugLayerTab;
  122877. }
  122878. interface Scene {
  122879. /**
  122880. * @hidden
  122881. * Backing field
  122882. */
  122883. _debugLayer: DebugLayer;
  122884. /**
  122885. * Gets the debug layer (aka Inspector) associated with the scene
  122886. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122887. */
  122888. debugLayer: DebugLayer;
  122889. }
  122890. /**
  122891. * Enum of inspector action tab
  122892. */
  122893. export enum DebugLayerTab {
  122894. /**
  122895. * Properties tag (default)
  122896. */
  122897. Properties = 0,
  122898. /**
  122899. * Debug tab
  122900. */
  122901. Debug = 1,
  122902. /**
  122903. * Statistics tab
  122904. */
  122905. Statistics = 2,
  122906. /**
  122907. * Tools tab
  122908. */
  122909. Tools = 3,
  122910. /**
  122911. * Settings tab
  122912. */
  122913. Settings = 4
  122914. }
  122915. /**
  122916. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122917. * what is happening in your scene
  122918. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122919. */
  122920. export class DebugLayer {
  122921. /**
  122922. * Define the url to get the inspector script from.
  122923. * By default it uses the babylonjs CDN.
  122924. * @ignoreNaming
  122925. */
  122926. static InspectorURL: string;
  122927. private _scene;
  122928. private BJSINSPECTOR;
  122929. private _onPropertyChangedObservable?;
  122930. /**
  122931. * Observable triggered when a property is changed through the inspector.
  122932. */
  122933. get onPropertyChangedObservable(): any;
  122934. /**
  122935. * Instantiates a new debug layer.
  122936. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122937. * what is happening in your scene
  122938. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122939. * @param scene Defines the scene to inspect
  122940. */
  122941. constructor(scene: Scene);
  122942. /** Creates the inspector window. */
  122943. private _createInspector;
  122944. /**
  122945. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  122946. * @param entity defines the entity to select
  122947. * @param lineContainerTitle defines the specific block to highlight
  122948. */
  122949. select(entity: any, lineContainerTitle?: string): void;
  122950. /** Get the inspector from bundle or global */
  122951. private _getGlobalInspector;
  122952. /**
  122953. * Get if the inspector is visible or not.
  122954. * @returns true if visible otherwise, false
  122955. */
  122956. isVisible(): boolean;
  122957. /**
  122958. * Hide the inspector and close its window.
  122959. */
  122960. hide(): void;
  122961. /**
  122962. * Update the scene in the inspector
  122963. */
  122964. setAsActiveScene(): void;
  122965. /**
  122966. * Launch the debugLayer.
  122967. * @param config Define the configuration of the inspector
  122968. * @return a promise fulfilled when the debug layer is visible
  122969. */
  122970. show(config?: IInspectorOptions): Promise<DebugLayer>;
  122971. }
  122972. }
  122973. declare module BABYLON {
  122974. /**
  122975. * Class containing static functions to help procedurally build meshes
  122976. */
  122977. export class BoxBuilder {
  122978. /**
  122979. * Creates a box mesh
  122980. * * The parameter `size` sets the size (float) of each box side (default 1)
  122981. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122982. * * 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)
  122983. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122985. * * 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
  122986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122987. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122988. * @param name defines the name of the mesh
  122989. * @param options defines the options used to create the mesh
  122990. * @param scene defines the hosting scene
  122991. * @returns the box mesh
  122992. */
  122993. static CreateBox(name: string, options: {
  122994. size?: number;
  122995. width?: number;
  122996. height?: number;
  122997. depth?: number;
  122998. faceUV?: Vector4[];
  122999. faceColors?: Color4[];
  123000. sideOrientation?: number;
  123001. frontUVs?: Vector4;
  123002. backUVs?: Vector4;
  123003. wrap?: boolean;
  123004. topBaseAt?: number;
  123005. bottomBaseAt?: number;
  123006. updatable?: boolean;
  123007. }, scene?: Nullable<Scene>): Mesh;
  123008. }
  123009. }
  123010. declare module BABYLON.Debug {
  123011. /**
  123012. * Used to show the physics impostor around the specific mesh
  123013. */
  123014. export class PhysicsViewer {
  123015. /** @hidden */
  123016. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  123017. /** @hidden */
  123018. protected _meshes: Array<Nullable<AbstractMesh>>;
  123019. /** @hidden */
  123020. protected _scene: Nullable<Scene>;
  123021. /** @hidden */
  123022. protected _numMeshes: number;
  123023. /** @hidden */
  123024. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  123025. private _renderFunction;
  123026. private _utilityLayer;
  123027. private _debugBoxMesh;
  123028. private _debugSphereMesh;
  123029. private _debugCylinderMesh;
  123030. private _debugMaterial;
  123031. private _debugMeshMeshes;
  123032. /**
  123033. * Creates a new PhysicsViewer
  123034. * @param scene defines the hosting scene
  123035. */
  123036. constructor(scene: Scene);
  123037. /** @hidden */
  123038. protected _updateDebugMeshes(): void;
  123039. /**
  123040. * Renders a specified physic impostor
  123041. * @param impostor defines the impostor to render
  123042. * @param targetMesh defines the mesh represented by the impostor
  123043. * @returns the new debug mesh used to render the impostor
  123044. */
  123045. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  123046. /**
  123047. * Hides a specified physic impostor
  123048. * @param impostor defines the impostor to hide
  123049. */
  123050. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  123051. private _getDebugMaterial;
  123052. private _getDebugBoxMesh;
  123053. private _getDebugSphereMesh;
  123054. private _getDebugCylinderMesh;
  123055. private _getDebugMeshMesh;
  123056. private _getDebugMesh;
  123057. /** Releases all resources */
  123058. dispose(): void;
  123059. }
  123060. }
  123061. declare module BABYLON {
  123062. /**
  123063. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  123064. * in order to better appreciate the issue one might have.
  123065. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  123066. */
  123067. export class RayHelper {
  123068. /**
  123069. * Defines the ray we are currently tryin to visualize.
  123070. */
  123071. ray: Nullable<Ray>;
  123072. private _renderPoints;
  123073. private _renderLine;
  123074. private _renderFunction;
  123075. private _scene;
  123076. private _updateToMeshFunction;
  123077. private _attachedToMesh;
  123078. private _meshSpaceDirection;
  123079. private _meshSpaceOrigin;
  123080. /**
  123081. * Helper function to create a colored helper in a scene in one line.
  123082. * @param ray Defines the ray we are currently tryin to visualize
  123083. * @param scene Defines the scene the ray is used in
  123084. * @param color Defines the color we want to see the ray in
  123085. * @returns The newly created ray helper.
  123086. */
  123087. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  123088. /**
  123089. * Instantiate a new ray helper.
  123090. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  123091. * in order to better appreciate the issue one might have.
  123092. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  123093. * @param ray Defines the ray we are currently tryin to visualize
  123094. */
  123095. constructor(ray: Ray);
  123096. /**
  123097. * Shows the ray we are willing to debug.
  123098. * @param scene Defines the scene the ray needs to be rendered in
  123099. * @param color Defines the color the ray needs to be rendered in
  123100. */
  123101. show(scene: Scene, color?: Color3): void;
  123102. /**
  123103. * Hides the ray we are debugging.
  123104. */
  123105. hide(): void;
  123106. private _render;
  123107. /**
  123108. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  123109. * @param mesh Defines the mesh we want the helper attached to
  123110. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  123111. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  123112. * @param length Defines the length of the ray
  123113. */
  123114. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  123115. /**
  123116. * Detach the ray helper from the mesh it has previously been attached to.
  123117. */
  123118. detachFromMesh(): void;
  123119. private _updateToMesh;
  123120. /**
  123121. * Dispose the helper and release its associated resources.
  123122. */
  123123. dispose(): void;
  123124. }
  123125. }
  123126. declare module BABYLON.Debug {
  123127. /**
  123128. * Class used to render a debug view of a given skeleton
  123129. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  123130. */
  123131. export class SkeletonViewer {
  123132. /** defines the skeleton to render */
  123133. skeleton: Skeleton;
  123134. /** defines the mesh attached to the skeleton */
  123135. mesh: AbstractMesh;
  123136. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123137. autoUpdateBonesMatrices: boolean;
  123138. /** defines the rendering group id to use with the viewer */
  123139. renderingGroupId: number;
  123140. /** Gets or sets the color used to render the skeleton */
  123141. color: Color3;
  123142. private _scene;
  123143. private _debugLines;
  123144. private _debugMesh;
  123145. private _isEnabled;
  123146. private _renderFunction;
  123147. private _utilityLayer;
  123148. /**
  123149. * Returns the mesh used to render the bones
  123150. */
  123151. get debugMesh(): Nullable<LinesMesh>;
  123152. /**
  123153. * Creates a new SkeletonViewer
  123154. * @param skeleton defines the skeleton to render
  123155. * @param mesh defines the mesh attached to the skeleton
  123156. * @param scene defines the hosting scene
  123157. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  123158. * @param renderingGroupId defines the rendering group id to use with the viewer
  123159. */
  123160. constructor(
  123161. /** defines the skeleton to render */
  123162. skeleton: Skeleton,
  123163. /** defines the mesh attached to the skeleton */
  123164. mesh: AbstractMesh, scene: Scene,
  123165. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123166. autoUpdateBonesMatrices?: boolean,
  123167. /** defines the rendering group id to use with the viewer */
  123168. renderingGroupId?: number);
  123169. /** Gets or sets a boolean indicating if the viewer is enabled */
  123170. set isEnabled(value: boolean);
  123171. get isEnabled(): boolean;
  123172. private _getBonePosition;
  123173. private _getLinesForBonesWithLength;
  123174. private _getLinesForBonesNoLength;
  123175. /** Update the viewer to sync with current skeleton state */
  123176. update(): void;
  123177. /** Release associated resources */
  123178. dispose(): void;
  123179. }
  123180. }
  123181. declare module BABYLON {
  123182. /**
  123183. * This class will take all inputs from Keyboard, Pointer, and
  123184. * any Gamepads and provide a polling system that all devices
  123185. * will use. This class assumes that there will only be one
  123186. * pointer device and one keyboard.
  123187. */
  123188. export class DeviceInputSystem implements IDisposable {
  123189. /** POINTER_DEVICE */
  123190. static readonly POINTER_DEVICE: string;
  123191. /** KEYBOARD_DEVICE */
  123192. static readonly KEYBOARD_DEVICE: string;
  123193. /**
  123194. * Observable to be triggered when a device is connected
  123195. */
  123196. onDeviceConnectedObservable: Observable<string>;
  123197. /**
  123198. * Observable to be triggered when a device is disconnected
  123199. */
  123200. onDeviceDisconnectedObservable: Observable<string>;
  123201. private _inputs;
  123202. private _gamepads;
  123203. private _keyboardActive;
  123204. private _pointerActive;
  123205. private _elementToAttachTo;
  123206. private _keyboardDownEvent;
  123207. private _keyboardUpEvent;
  123208. private _pointerMoveEvent;
  123209. private _pointerDownEvent;
  123210. private _pointerUpEvent;
  123211. private _gamepadConnectedEvent;
  123212. private _gamepadDisconnectedEvent;
  123213. private static _MAX_KEYCODES;
  123214. private static _MAX_POINTER_INPUTS;
  123215. /**
  123216. * Default Constructor
  123217. * @param engine - engine to pull input element from
  123218. */
  123219. constructor(engine: Engine);
  123220. /**
  123221. * Checks for current device input value, given an id and input index
  123222. * @param deviceName Id of connected device
  123223. * @param inputIndex Index of device input
  123224. * @returns Current value of input
  123225. */
  123226. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  123227. /**
  123228. * Dispose of all the eventlisteners and clears the observables
  123229. */
  123230. dispose(): void;
  123231. /**
  123232. * Add device and inputs to device map
  123233. * @param deviceName Assigned name of device (may be SN)
  123234. * @param numberOfInputs Number of input entries to create for given device
  123235. */
  123236. private _registerDevice;
  123237. /**
  123238. * Given a specific device name, remove that device from the device map
  123239. * @param deviceName Name of device to be removed
  123240. */
  123241. private _unregisterDevice;
  123242. /**
  123243. * Handle all actions that come from keyboard interaction
  123244. */
  123245. private _handleKeyActions;
  123246. /**
  123247. * Handle all actions that come from pointer interaction
  123248. */
  123249. private _handlePointerActions;
  123250. /**
  123251. * Handle all actions that come from gamepad interaction
  123252. */
  123253. private _handleGamepadActions;
  123254. /**
  123255. * Update all non-event based devices with each frame
  123256. */
  123257. private _updateDevice;
  123258. }
  123259. }
  123260. declare module BABYLON {
  123261. /**
  123262. * Options to create the null engine
  123263. */
  123264. export class NullEngineOptions {
  123265. /**
  123266. * Render width (Default: 512)
  123267. */
  123268. renderWidth: number;
  123269. /**
  123270. * Render height (Default: 256)
  123271. */
  123272. renderHeight: number;
  123273. /**
  123274. * Texture size (Default: 512)
  123275. */
  123276. textureSize: number;
  123277. /**
  123278. * If delta time between frames should be constant
  123279. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123280. */
  123281. deterministicLockstep: boolean;
  123282. /**
  123283. * Maximum about of steps between frames (Default: 4)
  123284. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123285. */
  123286. lockstepMaxSteps: number;
  123287. }
  123288. /**
  123289. * The null engine class provides support for headless version of babylon.js.
  123290. * This can be used in server side scenario or for testing purposes
  123291. */
  123292. export class NullEngine extends Engine {
  123293. private _options;
  123294. /**
  123295. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  123296. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123297. * @returns true if engine is in deterministic lock step mode
  123298. */
  123299. isDeterministicLockStep(): boolean;
  123300. /**
  123301. * Gets the max steps when engine is running in deterministic lock step
  123302. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123303. * @returns the max steps
  123304. */
  123305. getLockstepMaxSteps(): number;
  123306. /**
  123307. * Gets the current hardware scaling level.
  123308. * By default the hardware scaling level is computed from the window device ratio.
  123309. * 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.
  123310. * @returns a number indicating the current hardware scaling level
  123311. */
  123312. getHardwareScalingLevel(): number;
  123313. constructor(options?: NullEngineOptions);
  123314. /**
  123315. * Creates a vertex buffer
  123316. * @param vertices the data for the vertex buffer
  123317. * @returns the new WebGL static buffer
  123318. */
  123319. createVertexBuffer(vertices: FloatArray): DataBuffer;
  123320. /**
  123321. * Creates a new index buffer
  123322. * @param indices defines the content of the index buffer
  123323. * @param updatable defines if the index buffer must be updatable
  123324. * @returns a new webGL buffer
  123325. */
  123326. createIndexBuffer(indices: IndicesArray): DataBuffer;
  123327. /**
  123328. * Clear the current render buffer or the current render target (if any is set up)
  123329. * @param color defines the color to use
  123330. * @param backBuffer defines if the back buffer must be cleared
  123331. * @param depth defines if the depth buffer must be cleared
  123332. * @param stencil defines if the stencil buffer must be cleared
  123333. */
  123334. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  123335. /**
  123336. * Gets the current render width
  123337. * @param useScreen defines if screen size must be used (or the current render target if any)
  123338. * @returns a number defining the current render width
  123339. */
  123340. getRenderWidth(useScreen?: boolean): number;
  123341. /**
  123342. * Gets the current render height
  123343. * @param useScreen defines if screen size must be used (or the current render target if any)
  123344. * @returns a number defining the current render height
  123345. */
  123346. getRenderHeight(useScreen?: boolean): number;
  123347. /**
  123348. * Set the WebGL's viewport
  123349. * @param viewport defines the viewport element to be used
  123350. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  123351. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  123352. */
  123353. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  123354. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  123355. /**
  123356. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  123357. * @param pipelineContext defines the pipeline context to use
  123358. * @param uniformsNames defines the list of uniform names
  123359. * @returns an array of webGL uniform locations
  123360. */
  123361. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  123362. /**
  123363. * Gets the lsit of active attributes for a given webGL program
  123364. * @param pipelineContext defines the pipeline context to use
  123365. * @param attributesNames defines the list of attribute names to get
  123366. * @returns an array of indices indicating the offset of each attribute
  123367. */
  123368. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  123369. /**
  123370. * Binds an effect to the webGL context
  123371. * @param effect defines the effect to bind
  123372. */
  123373. bindSamplers(effect: Effect): void;
  123374. /**
  123375. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  123376. * @param effect defines the effect to activate
  123377. */
  123378. enableEffect(effect: Effect): void;
  123379. /**
  123380. * Set various states to the webGL context
  123381. * @param culling defines backface culling state
  123382. * @param zOffset defines the value to apply to zOffset (0 by default)
  123383. * @param force defines if states must be applied even if cache is up to date
  123384. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  123385. */
  123386. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  123387. /**
  123388. * Set the value of an uniform to an array of int32
  123389. * @param uniform defines the webGL uniform location where to store the value
  123390. * @param array defines the array of int32 to store
  123391. */
  123392. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  123393. /**
  123394. * Set the value of an uniform to an array of int32 (stored as vec2)
  123395. * @param uniform defines the webGL uniform location where to store the value
  123396. * @param array defines the array of int32 to store
  123397. */
  123398. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  123399. /**
  123400. * Set the value of an uniform to an array of int32 (stored as vec3)
  123401. * @param uniform defines the webGL uniform location where to store the value
  123402. * @param array defines the array of int32 to store
  123403. */
  123404. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  123405. /**
  123406. * Set the value of an uniform to an array of int32 (stored as vec4)
  123407. * @param uniform defines the webGL uniform location where to store the value
  123408. * @param array defines the array of int32 to store
  123409. */
  123410. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  123411. /**
  123412. * Set the value of an uniform to an array of float32
  123413. * @param uniform defines the webGL uniform location where to store the value
  123414. * @param array defines the array of float32 to store
  123415. */
  123416. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  123417. /**
  123418. * Set the value of an uniform to an array of float32 (stored as vec2)
  123419. * @param uniform defines the webGL uniform location where to store the value
  123420. * @param array defines the array of float32 to store
  123421. */
  123422. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  123423. /**
  123424. * Set the value of an uniform to an array of float32 (stored as vec3)
  123425. * @param uniform defines the webGL uniform location where to store the value
  123426. * @param array defines the array of float32 to store
  123427. */
  123428. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  123429. /**
  123430. * Set the value of an uniform to an array of float32 (stored as vec4)
  123431. * @param uniform defines the webGL uniform location where to store the value
  123432. * @param array defines the array of float32 to store
  123433. */
  123434. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  123435. /**
  123436. * Set the value of an uniform to an array of number
  123437. * @param uniform defines the webGL uniform location where to store the value
  123438. * @param array defines the array of number to store
  123439. */
  123440. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  123441. /**
  123442. * Set the value of an uniform to an array of number (stored as vec2)
  123443. * @param uniform defines the webGL uniform location where to store the value
  123444. * @param array defines the array of number to store
  123445. */
  123446. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  123447. /**
  123448. * Set the value of an uniform to an array of number (stored as vec3)
  123449. * @param uniform defines the webGL uniform location where to store the value
  123450. * @param array defines the array of number to store
  123451. */
  123452. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  123453. /**
  123454. * Set the value of an uniform to an array of number (stored as vec4)
  123455. * @param uniform defines the webGL uniform location where to store the value
  123456. * @param array defines the array of number to store
  123457. */
  123458. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  123459. /**
  123460. * Set the value of an uniform to an array of float32 (stored as matrices)
  123461. * @param uniform defines the webGL uniform location where to store the value
  123462. * @param matrices defines the array of float32 to store
  123463. */
  123464. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  123465. /**
  123466. * Set the value of an uniform to a matrix (3x3)
  123467. * @param uniform defines the webGL uniform location where to store the value
  123468. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  123469. */
  123470. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123471. /**
  123472. * Set the value of an uniform to a matrix (2x2)
  123473. * @param uniform defines the webGL uniform location where to store the value
  123474. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  123475. */
  123476. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123477. /**
  123478. * Set the value of an uniform to a number (float)
  123479. * @param uniform defines the webGL uniform location where to store the value
  123480. * @param value defines the float number to store
  123481. */
  123482. setFloat(uniform: WebGLUniformLocation, value: number): void;
  123483. /**
  123484. * Set the value of an uniform to a vec2
  123485. * @param uniform defines the webGL uniform location where to store the value
  123486. * @param x defines the 1st component of the value
  123487. * @param y defines the 2nd component of the value
  123488. */
  123489. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  123490. /**
  123491. * Set the value of an uniform to a vec3
  123492. * @param uniform defines the webGL uniform location where to store the value
  123493. * @param x defines the 1st component of the value
  123494. * @param y defines the 2nd component of the value
  123495. * @param z defines the 3rd component of the value
  123496. */
  123497. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  123498. /**
  123499. * Set the value of an uniform to a boolean
  123500. * @param uniform defines the webGL uniform location where to store the value
  123501. * @param bool defines the boolean to store
  123502. */
  123503. setBool(uniform: WebGLUniformLocation, bool: number): void;
  123504. /**
  123505. * Set the value of an uniform to a vec4
  123506. * @param uniform defines the webGL uniform location where to store the value
  123507. * @param x defines the 1st component of the value
  123508. * @param y defines the 2nd component of the value
  123509. * @param z defines the 3rd component of the value
  123510. * @param w defines the 4th component of the value
  123511. */
  123512. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  123513. /**
  123514. * Sets the current alpha mode
  123515. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  123516. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  123517. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123518. */
  123519. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  123520. /**
  123521. * Bind webGl buffers directly to the webGL context
  123522. * @param vertexBuffers defines the vertex buffer to bind
  123523. * @param indexBuffer defines the index buffer to bind
  123524. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  123525. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  123526. * @param effect defines the effect associated with the vertex buffer
  123527. */
  123528. bindBuffers(vertexBuffers: {
  123529. [key: string]: VertexBuffer;
  123530. }, indexBuffer: DataBuffer, effect: Effect): void;
  123531. /**
  123532. * Force the entire cache to be cleared
  123533. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  123534. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  123535. */
  123536. wipeCaches(bruteForce?: boolean): void;
  123537. /**
  123538. * Send a draw order
  123539. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  123540. * @param indexStart defines the starting index
  123541. * @param indexCount defines the number of index to draw
  123542. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123543. */
  123544. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  123545. /**
  123546. * Draw a list of indexed primitives
  123547. * @param fillMode defines the primitive to use
  123548. * @param indexStart defines the starting index
  123549. * @param indexCount defines the number of index to draw
  123550. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123551. */
  123552. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  123553. /**
  123554. * Draw a list of unindexed primitives
  123555. * @param fillMode defines the primitive to use
  123556. * @param verticesStart defines the index of first vertex to draw
  123557. * @param verticesCount defines the count of vertices to draw
  123558. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123559. */
  123560. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  123561. /** @hidden */
  123562. _createTexture(): WebGLTexture;
  123563. /** @hidden */
  123564. _releaseTexture(texture: InternalTexture): void;
  123565. /**
  123566. * Usually called from Texture.ts.
  123567. * Passed information to create a WebGLTexture
  123568. * @param urlArg defines a value which contains one of the following:
  123569. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  123570. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  123571. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  123572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  123573. * @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)
  123574. * @param scene needed for loading to the correct scene
  123575. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  123576. * @param onLoad optional callback to be called upon successful completion
  123577. * @param onError optional callback to be called upon failure
  123578. * @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
  123579. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  123580. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  123581. * @param forcedExtension defines the extension to use to pick the right loader
  123582. * @param mimeType defines an optional mime type
  123583. * @returns a InternalTexture for assignment back into BABYLON.Texture
  123584. */
  123585. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  123586. /**
  123587. * Creates a new render target texture
  123588. * @param size defines the size of the texture
  123589. * @param options defines the options used to create the texture
  123590. * @returns a new render target texture stored in an InternalTexture
  123591. */
  123592. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  123593. /**
  123594. * Update the sampling mode of a given texture
  123595. * @param samplingMode defines the required sampling mode
  123596. * @param texture defines the texture to update
  123597. */
  123598. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  123599. /**
  123600. * Binds the frame buffer to the specified texture.
  123601. * @param texture The texture to render to or null for the default canvas
  123602. * @param faceIndex The face of the texture to render to in case of cube texture
  123603. * @param requiredWidth The width of the target to render to
  123604. * @param requiredHeight The height of the target to render to
  123605. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  123606. * @param lodLevel defines le lod level to bind to the frame buffer
  123607. */
  123608. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  123609. /**
  123610. * Unbind the current render target texture from the webGL context
  123611. * @param texture defines the render target texture to unbind
  123612. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123613. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123614. */
  123615. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  123616. /**
  123617. * Creates a dynamic vertex buffer
  123618. * @param vertices the data for the dynamic vertex buffer
  123619. * @returns the new WebGL dynamic buffer
  123620. */
  123621. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  123622. /**
  123623. * Update the content of a dynamic texture
  123624. * @param texture defines the texture to update
  123625. * @param canvas defines the canvas containing the source
  123626. * @param invertY defines if data must be stored with Y axis inverted
  123627. * @param premulAlpha defines if alpha is stored as premultiplied
  123628. * @param format defines the format of the data
  123629. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  123630. */
  123631. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  123632. /**
  123633. * Gets a boolean indicating if all created effects are ready
  123634. * @returns true if all effects are ready
  123635. */
  123636. areAllEffectsReady(): boolean;
  123637. /**
  123638. * @hidden
  123639. * Get the current error code of the webGL context
  123640. * @returns the error code
  123641. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  123642. */
  123643. getError(): number;
  123644. /** @hidden */
  123645. _getUnpackAlignement(): number;
  123646. /** @hidden */
  123647. _unpackFlipY(value: boolean): void;
  123648. /**
  123649. * Update a dynamic index buffer
  123650. * @param indexBuffer defines the target index buffer
  123651. * @param indices defines the data to update
  123652. * @param offset defines the offset in the target index buffer where update should start
  123653. */
  123654. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  123655. /**
  123656. * Updates a dynamic vertex buffer.
  123657. * @param vertexBuffer the vertex buffer to update
  123658. * @param vertices the data used to update the vertex buffer
  123659. * @param byteOffset the byte offset of the data (optional)
  123660. * @param byteLength the byte length of the data (optional)
  123661. */
  123662. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  123663. /** @hidden */
  123664. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  123665. /** @hidden */
  123666. _bindTexture(channel: number, texture: InternalTexture): void;
  123667. protected _deleteBuffer(buffer: WebGLBuffer): void;
  123668. /**
  123669. * 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
  123670. */
  123671. releaseEffects(): void;
  123672. displayLoadingUI(): void;
  123673. hideLoadingUI(): void;
  123674. /** @hidden */
  123675. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123676. /** @hidden */
  123677. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123678. /** @hidden */
  123679. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123680. /** @hidden */
  123681. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  123682. }
  123683. }
  123684. declare module BABYLON {
  123685. /**
  123686. * @hidden
  123687. **/
  123688. export class _TimeToken {
  123689. _startTimeQuery: Nullable<WebGLQuery>;
  123690. _endTimeQuery: Nullable<WebGLQuery>;
  123691. _timeElapsedQuery: Nullable<WebGLQuery>;
  123692. _timeElapsedQueryEnded: boolean;
  123693. }
  123694. }
  123695. declare module BABYLON {
  123696. /** @hidden */
  123697. export class _OcclusionDataStorage {
  123698. /** @hidden */
  123699. occlusionInternalRetryCounter: number;
  123700. /** @hidden */
  123701. isOcclusionQueryInProgress: boolean;
  123702. /** @hidden */
  123703. isOccluded: boolean;
  123704. /** @hidden */
  123705. occlusionRetryCount: number;
  123706. /** @hidden */
  123707. occlusionType: number;
  123708. /** @hidden */
  123709. occlusionQueryAlgorithmType: number;
  123710. }
  123711. interface Engine {
  123712. /**
  123713. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  123714. * @return the new query
  123715. */
  123716. createQuery(): WebGLQuery;
  123717. /**
  123718. * Delete and release a webGL query
  123719. * @param query defines the query to delete
  123720. * @return the current engine
  123721. */
  123722. deleteQuery(query: WebGLQuery): Engine;
  123723. /**
  123724. * Check if a given query has resolved and got its value
  123725. * @param query defines the query to check
  123726. * @returns true if the query got its value
  123727. */
  123728. isQueryResultAvailable(query: WebGLQuery): boolean;
  123729. /**
  123730. * Gets the value of a given query
  123731. * @param query defines the query to check
  123732. * @returns the value of the query
  123733. */
  123734. getQueryResult(query: WebGLQuery): number;
  123735. /**
  123736. * Initiates an occlusion query
  123737. * @param algorithmType defines the algorithm to use
  123738. * @param query defines the query to use
  123739. * @returns the current engine
  123740. * @see http://doc.babylonjs.com/features/occlusionquery
  123741. */
  123742. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  123743. /**
  123744. * Ends an occlusion query
  123745. * @see http://doc.babylonjs.com/features/occlusionquery
  123746. * @param algorithmType defines the algorithm to use
  123747. * @returns the current engine
  123748. */
  123749. endOcclusionQuery(algorithmType: number): Engine;
  123750. /**
  123751. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  123752. * Please note that only one query can be issued at a time
  123753. * @returns a time token used to track the time span
  123754. */
  123755. startTimeQuery(): Nullable<_TimeToken>;
  123756. /**
  123757. * Ends a time query
  123758. * @param token defines the token used to measure the time span
  123759. * @returns the time spent (in ns)
  123760. */
  123761. endTimeQuery(token: _TimeToken): int;
  123762. /** @hidden */
  123763. _currentNonTimestampToken: Nullable<_TimeToken>;
  123764. /** @hidden */
  123765. _createTimeQuery(): WebGLQuery;
  123766. /** @hidden */
  123767. _deleteTimeQuery(query: WebGLQuery): void;
  123768. /** @hidden */
  123769. _getGlAlgorithmType(algorithmType: number): number;
  123770. /** @hidden */
  123771. _getTimeQueryResult(query: WebGLQuery): any;
  123772. /** @hidden */
  123773. _getTimeQueryAvailability(query: WebGLQuery): any;
  123774. }
  123775. interface AbstractMesh {
  123776. /**
  123777. * Backing filed
  123778. * @hidden
  123779. */
  123780. __occlusionDataStorage: _OcclusionDataStorage;
  123781. /**
  123782. * Access property
  123783. * @hidden
  123784. */
  123785. _occlusionDataStorage: _OcclusionDataStorage;
  123786. /**
  123787. * 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.
  123788. * The default value is -1 which means don't break the query and wait till the result
  123789. * @see http://doc.babylonjs.com/features/occlusionquery
  123790. */
  123791. occlusionRetryCount: number;
  123792. /**
  123793. * 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:
  123794. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  123795. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  123796. * * 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.
  123797. * @see http://doc.babylonjs.com/features/occlusionquery
  123798. */
  123799. occlusionType: number;
  123800. /**
  123801. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  123802. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  123803. * * 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.
  123804. * @see http://doc.babylonjs.com/features/occlusionquery
  123805. */
  123806. occlusionQueryAlgorithmType: number;
  123807. /**
  123808. * 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
  123809. * @see http://doc.babylonjs.com/features/occlusionquery
  123810. */
  123811. isOccluded: boolean;
  123812. /**
  123813. * Flag to check the progress status of the query
  123814. * @see http://doc.babylonjs.com/features/occlusionquery
  123815. */
  123816. isOcclusionQueryInProgress: boolean;
  123817. }
  123818. }
  123819. declare module BABYLON {
  123820. /** @hidden */
  123821. export var _forceTransformFeedbackToBundle: boolean;
  123822. interface Engine {
  123823. /**
  123824. * Creates a webGL transform feedback object
  123825. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  123826. * @returns the webGL transform feedback object
  123827. */
  123828. createTransformFeedback(): WebGLTransformFeedback;
  123829. /**
  123830. * Delete a webGL transform feedback object
  123831. * @param value defines the webGL transform feedback object to delete
  123832. */
  123833. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  123834. /**
  123835. * Bind a webGL transform feedback object to the webgl context
  123836. * @param value defines the webGL transform feedback object to bind
  123837. */
  123838. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  123839. /**
  123840. * Begins a transform feedback operation
  123841. * @param usePoints defines if points or triangles must be used
  123842. */
  123843. beginTransformFeedback(usePoints: boolean): void;
  123844. /**
  123845. * Ends a transform feedback operation
  123846. */
  123847. endTransformFeedback(): void;
  123848. /**
  123849. * Specify the varyings to use with transform feedback
  123850. * @param program defines the associated webGL program
  123851. * @param value defines the list of strings representing the varying names
  123852. */
  123853. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  123854. /**
  123855. * Bind a webGL buffer for a transform feedback operation
  123856. * @param value defines the webGL buffer to bind
  123857. */
  123858. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  123859. }
  123860. }
  123861. declare module BABYLON {
  123862. /**
  123863. * Creation options of the multi render target texture.
  123864. */
  123865. export interface IMultiRenderTargetOptions {
  123866. /**
  123867. * Define if the texture needs to create mip maps after render.
  123868. */
  123869. generateMipMaps?: boolean;
  123870. /**
  123871. * Define the types of all the draw buffers we want to create
  123872. */
  123873. types?: number[];
  123874. /**
  123875. * Define the sampling modes of all the draw buffers we want to create
  123876. */
  123877. samplingModes?: number[];
  123878. /**
  123879. * Define if a depth buffer is required
  123880. */
  123881. generateDepthBuffer?: boolean;
  123882. /**
  123883. * Define if a stencil buffer is required
  123884. */
  123885. generateStencilBuffer?: boolean;
  123886. /**
  123887. * Define if a depth texture is required instead of a depth buffer
  123888. */
  123889. generateDepthTexture?: boolean;
  123890. /**
  123891. * Define the number of desired draw buffers
  123892. */
  123893. textureCount?: number;
  123894. /**
  123895. * Define if aspect ratio should be adapted to the texture or stay the scene one
  123896. */
  123897. doNotChangeAspectRatio?: boolean;
  123898. /**
  123899. * Define the default type of the buffers we are creating
  123900. */
  123901. defaultType?: number;
  123902. }
  123903. /**
  123904. * A multi render target, like a render target provides the ability to render to a texture.
  123905. * Unlike the render target, it can render to several draw buffers in one draw.
  123906. * This is specially interesting in deferred rendering or for any effects requiring more than
  123907. * just one color from a single pass.
  123908. */
  123909. export class MultiRenderTarget extends RenderTargetTexture {
  123910. private _internalTextures;
  123911. private _textures;
  123912. private _multiRenderTargetOptions;
  123913. /**
  123914. * Get if draw buffers are currently supported by the used hardware and browser.
  123915. */
  123916. get isSupported(): boolean;
  123917. /**
  123918. * Get the list of textures generated by the multi render target.
  123919. */
  123920. get textures(): Texture[];
  123921. /**
  123922. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  123923. */
  123924. get depthTexture(): Texture;
  123925. /**
  123926. * Set the wrapping mode on U of all the textures we are rendering to.
  123927. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123928. */
  123929. set wrapU(wrap: number);
  123930. /**
  123931. * Set the wrapping mode on V of all the textures we are rendering to.
  123932. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123933. */
  123934. set wrapV(wrap: number);
  123935. /**
  123936. * Instantiate a new multi render target texture.
  123937. * A multi render target, like a render target provides the ability to render to a texture.
  123938. * Unlike the render target, it can render to several draw buffers in one draw.
  123939. * This is specially interesting in deferred rendering or for any effects requiring more than
  123940. * just one color from a single pass.
  123941. * @param name Define the name of the texture
  123942. * @param size Define the size of the buffers to render to
  123943. * @param count Define the number of target we are rendering into
  123944. * @param scene Define the scene the texture belongs to
  123945. * @param options Define the options used to create the multi render target
  123946. */
  123947. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  123948. /** @hidden */
  123949. _rebuild(): void;
  123950. private _createInternalTextures;
  123951. private _createTextures;
  123952. /**
  123953. * Define the number of samples used if MSAA is enabled.
  123954. */
  123955. get samples(): number;
  123956. set samples(value: number);
  123957. /**
  123958. * Resize all the textures in the multi render target.
  123959. * Be carrefull as it will recreate all the data in the new texture.
  123960. * @param size Define the new size
  123961. */
  123962. resize(size: any): void;
  123963. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123964. /**
  123965. * Dispose the render targets and their associated resources
  123966. */
  123967. dispose(): void;
  123968. /**
  123969. * Release all the underlying texture used as draw buffers.
  123970. */
  123971. releaseInternalTextures(): void;
  123972. }
  123973. }
  123974. declare module BABYLON {
  123975. interface ThinEngine {
  123976. /**
  123977. * Unbind a list of render target textures from the webGL context
  123978. * This is used only when drawBuffer extension or webGL2 are active
  123979. * @param textures defines the render target textures to unbind
  123980. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123981. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123982. */
  123983. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  123984. /**
  123985. * Create a multi render target texture
  123986. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  123987. * @param size defines the size of the texture
  123988. * @param options defines the creation options
  123989. * @returns the cube texture as an InternalTexture
  123990. */
  123991. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  123992. /**
  123993. * Update the sample count for a given multiple render target texture
  123994. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123995. * @param textures defines the textures to update
  123996. * @param samples defines the sample count to set
  123997. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123998. */
  123999. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  124000. }
  124001. }
  124002. declare module BABYLON {
  124003. /**
  124004. * Class used to define an additional view for the engine
  124005. * @see https://doc.babylonjs.com/how_to/multi_canvases
  124006. */
  124007. export class EngineView {
  124008. /** Defines the canvas where to render the view */
  124009. target: HTMLCanvasElement;
  124010. /** Defines an optional camera used to render the view (will use active camera else) */
  124011. camera?: Camera;
  124012. }
  124013. interface Engine {
  124014. /**
  124015. * Gets or sets the HTML element to use for attaching events
  124016. */
  124017. inputElement: Nullable<HTMLElement>;
  124018. /**
  124019. * Gets the current engine view
  124020. * @see https://doc.babylonjs.com/how_to/multi_canvases
  124021. */
  124022. activeView: Nullable<EngineView>;
  124023. /** Gets or sets the list of views */
  124024. views: EngineView[];
  124025. /**
  124026. * Register a new child canvas
  124027. * @param canvas defines the canvas to register
  124028. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  124029. * @returns the associated view
  124030. */
  124031. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  124032. /**
  124033. * Remove a registered child canvas
  124034. * @param canvas defines the canvas to remove
  124035. * @returns the current engine
  124036. */
  124037. unRegisterView(canvas: HTMLCanvasElement): Engine;
  124038. }
  124039. }
  124040. declare module BABYLON {
  124041. interface Engine {
  124042. /** @hidden */
  124043. _excludedCompressedTextures: string[];
  124044. /** @hidden */
  124045. _textureFormatInUse: string;
  124046. /**
  124047. * Gets the list of texture formats supported
  124048. */
  124049. readonly texturesSupported: Array<string>;
  124050. /**
  124051. * Gets the texture format in use
  124052. */
  124053. readonly textureFormatInUse: Nullable<string>;
  124054. /**
  124055. * Set the compressed texture extensions or file names to skip.
  124056. *
  124057. * @param skippedFiles defines the list of those texture files you want to skip
  124058. * Example: [".dds", ".env", "myfile.png"]
  124059. */
  124060. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  124061. /**
  124062. * Set the compressed texture format to use, based on the formats you have, and the formats
  124063. * supported by the hardware / browser.
  124064. *
  124065. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  124066. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  124067. * to API arguments needed to compressed textures. This puts the burden on the container
  124068. * generator to house the arcane code for determining these for current & future formats.
  124069. *
  124070. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  124071. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  124072. *
  124073. * Note: The result of this call is not taken into account when a texture is base64.
  124074. *
  124075. * @param formatsAvailable defines the list of those format families you have created
  124076. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  124077. *
  124078. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  124079. * @returns The extension selected.
  124080. */
  124081. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  124082. }
  124083. }
  124084. declare module BABYLON {
  124085. /**
  124086. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  124087. */
  124088. export interface CubeMapInfo {
  124089. /**
  124090. * The pixel array for the front face.
  124091. * This is stored in format, left to right, up to down format.
  124092. */
  124093. front: Nullable<ArrayBufferView>;
  124094. /**
  124095. * The pixel array for the back face.
  124096. * This is stored in format, left to right, up to down format.
  124097. */
  124098. back: Nullable<ArrayBufferView>;
  124099. /**
  124100. * The pixel array for the left face.
  124101. * This is stored in format, left to right, up to down format.
  124102. */
  124103. left: Nullable<ArrayBufferView>;
  124104. /**
  124105. * The pixel array for the right face.
  124106. * This is stored in format, left to right, up to down format.
  124107. */
  124108. right: Nullable<ArrayBufferView>;
  124109. /**
  124110. * The pixel array for the up face.
  124111. * This is stored in format, left to right, up to down format.
  124112. */
  124113. up: Nullable<ArrayBufferView>;
  124114. /**
  124115. * The pixel array for the down face.
  124116. * This is stored in format, left to right, up to down format.
  124117. */
  124118. down: Nullable<ArrayBufferView>;
  124119. /**
  124120. * The size of the cubemap stored.
  124121. *
  124122. * Each faces will be size * size pixels.
  124123. */
  124124. size: number;
  124125. /**
  124126. * The format of the texture.
  124127. *
  124128. * RGBA, RGB.
  124129. */
  124130. format: number;
  124131. /**
  124132. * The type of the texture data.
  124133. *
  124134. * UNSIGNED_INT, FLOAT.
  124135. */
  124136. type: number;
  124137. /**
  124138. * Specifies whether the texture is in gamma space.
  124139. */
  124140. gammaSpace: boolean;
  124141. }
  124142. /**
  124143. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  124144. */
  124145. export class PanoramaToCubeMapTools {
  124146. private static FACE_LEFT;
  124147. private static FACE_RIGHT;
  124148. private static FACE_FRONT;
  124149. private static FACE_BACK;
  124150. private static FACE_DOWN;
  124151. private static FACE_UP;
  124152. /**
  124153. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  124154. *
  124155. * @param float32Array The source data.
  124156. * @param inputWidth The width of the input panorama.
  124157. * @param inputHeight The height of the input panorama.
  124158. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  124159. * @return The cubemap data
  124160. */
  124161. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  124162. private static CreateCubemapTexture;
  124163. private static CalcProjectionSpherical;
  124164. }
  124165. }
  124166. declare module BABYLON {
  124167. /**
  124168. * Helper class dealing with the extraction of spherical polynomial dataArray
  124169. * from a cube map.
  124170. */
  124171. export class CubeMapToSphericalPolynomialTools {
  124172. private static FileFaces;
  124173. /**
  124174. * Converts a texture to the according Spherical Polynomial data.
  124175. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124176. *
  124177. * @param texture The texture to extract the information from.
  124178. * @return The Spherical Polynomial data.
  124179. */
  124180. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  124181. /**
  124182. * Converts a cubemap to the according Spherical Polynomial data.
  124183. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124184. *
  124185. * @param cubeInfo The Cube map to extract the information from.
  124186. * @return The Spherical Polynomial data.
  124187. */
  124188. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  124189. }
  124190. }
  124191. declare module BABYLON {
  124192. interface BaseTexture {
  124193. /**
  124194. * Get the polynomial representation of the texture data.
  124195. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  124196. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  124197. */
  124198. sphericalPolynomial: Nullable<SphericalPolynomial>;
  124199. }
  124200. }
  124201. declare module BABYLON {
  124202. /** @hidden */
  124203. export var rgbdEncodePixelShader: {
  124204. name: string;
  124205. shader: string;
  124206. };
  124207. }
  124208. declare module BABYLON {
  124209. /** @hidden */
  124210. export var rgbdDecodePixelShader: {
  124211. name: string;
  124212. shader: string;
  124213. };
  124214. }
  124215. declare module BABYLON {
  124216. /**
  124217. * Raw texture data and descriptor sufficient for WebGL texture upload
  124218. */
  124219. export interface EnvironmentTextureInfo {
  124220. /**
  124221. * Version of the environment map
  124222. */
  124223. version: number;
  124224. /**
  124225. * Width of image
  124226. */
  124227. width: number;
  124228. /**
  124229. * Irradiance information stored in the file.
  124230. */
  124231. irradiance: any;
  124232. /**
  124233. * Specular information stored in the file.
  124234. */
  124235. specular: any;
  124236. }
  124237. /**
  124238. * Defines One Image in the file. It requires only the position in the file
  124239. * as well as the length.
  124240. */
  124241. interface BufferImageData {
  124242. /**
  124243. * Length of the image data.
  124244. */
  124245. length: number;
  124246. /**
  124247. * Position of the data from the null terminator delimiting the end of the JSON.
  124248. */
  124249. position: number;
  124250. }
  124251. /**
  124252. * Defines the specular data enclosed in the file.
  124253. * This corresponds to the version 1 of the data.
  124254. */
  124255. export interface EnvironmentTextureSpecularInfoV1 {
  124256. /**
  124257. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  124258. */
  124259. specularDataPosition?: number;
  124260. /**
  124261. * This contains all the images data needed to reconstruct the cubemap.
  124262. */
  124263. mipmaps: Array<BufferImageData>;
  124264. /**
  124265. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  124266. */
  124267. lodGenerationScale: number;
  124268. }
  124269. /**
  124270. * Sets of helpers addressing the serialization and deserialization of environment texture
  124271. * stored in a BabylonJS env file.
  124272. * Those files are usually stored as .env files.
  124273. */
  124274. export class EnvironmentTextureTools {
  124275. /**
  124276. * Magic number identifying the env file.
  124277. */
  124278. private static _MagicBytes;
  124279. /**
  124280. * Gets the environment info from an env file.
  124281. * @param data The array buffer containing the .env bytes.
  124282. * @returns the environment file info (the json header) if successfully parsed.
  124283. */
  124284. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  124285. /**
  124286. * Creates an environment texture from a loaded cube texture.
  124287. * @param texture defines the cube texture to convert in env file
  124288. * @return a promise containing the environment data if succesfull.
  124289. */
  124290. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  124291. /**
  124292. * Creates a JSON representation of the spherical data.
  124293. * @param texture defines the texture containing the polynomials
  124294. * @return the JSON representation of the spherical info
  124295. */
  124296. private static _CreateEnvTextureIrradiance;
  124297. /**
  124298. * Creates the ArrayBufferViews used for initializing environment texture image data.
  124299. * @param data the image data
  124300. * @param info parameters that determine what views will be created for accessing the underlying buffer
  124301. * @return the views described by info providing access to the underlying buffer
  124302. */
  124303. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  124304. /**
  124305. * Uploads the texture info contained in the env file to the GPU.
  124306. * @param texture defines the internal texture to upload to
  124307. * @param data defines the data to load
  124308. * @param info defines the texture info retrieved through the GetEnvInfo method
  124309. * @returns a promise
  124310. */
  124311. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  124312. private static _OnImageReadyAsync;
  124313. /**
  124314. * Uploads the levels of image data to the GPU.
  124315. * @param texture defines the internal texture to upload to
  124316. * @param imageData defines the array buffer views of image data [mipmap][face]
  124317. * @returns a promise
  124318. */
  124319. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  124320. /**
  124321. * Uploads spherical polynomials information to the texture.
  124322. * @param texture defines the texture we are trying to upload the information to
  124323. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  124324. */
  124325. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  124326. /** @hidden */
  124327. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  124328. }
  124329. }
  124330. declare module BABYLON {
  124331. /**
  124332. * Contains position and normal vectors for a vertex
  124333. */
  124334. export class PositionNormalVertex {
  124335. /** the position of the vertex (defaut: 0,0,0) */
  124336. position: Vector3;
  124337. /** the normal of the vertex (defaut: 0,1,0) */
  124338. normal: Vector3;
  124339. /**
  124340. * Creates a PositionNormalVertex
  124341. * @param position the position of the vertex (defaut: 0,0,0)
  124342. * @param normal the normal of the vertex (defaut: 0,1,0)
  124343. */
  124344. constructor(
  124345. /** the position of the vertex (defaut: 0,0,0) */
  124346. position?: Vector3,
  124347. /** the normal of the vertex (defaut: 0,1,0) */
  124348. normal?: Vector3);
  124349. /**
  124350. * Clones the PositionNormalVertex
  124351. * @returns the cloned PositionNormalVertex
  124352. */
  124353. clone(): PositionNormalVertex;
  124354. }
  124355. /**
  124356. * Contains position, normal and uv vectors for a vertex
  124357. */
  124358. export class PositionNormalTextureVertex {
  124359. /** the position of the vertex (defaut: 0,0,0) */
  124360. position: Vector3;
  124361. /** the normal of the vertex (defaut: 0,1,0) */
  124362. normal: Vector3;
  124363. /** the uv of the vertex (default: 0,0) */
  124364. uv: Vector2;
  124365. /**
  124366. * Creates a PositionNormalTextureVertex
  124367. * @param position the position of the vertex (defaut: 0,0,0)
  124368. * @param normal the normal of the vertex (defaut: 0,1,0)
  124369. * @param uv the uv of the vertex (default: 0,0)
  124370. */
  124371. constructor(
  124372. /** the position of the vertex (defaut: 0,0,0) */
  124373. position?: Vector3,
  124374. /** the normal of the vertex (defaut: 0,1,0) */
  124375. normal?: Vector3,
  124376. /** the uv of the vertex (default: 0,0) */
  124377. uv?: Vector2);
  124378. /**
  124379. * Clones the PositionNormalTextureVertex
  124380. * @returns the cloned PositionNormalTextureVertex
  124381. */
  124382. clone(): PositionNormalTextureVertex;
  124383. }
  124384. }
  124385. declare module BABYLON {
  124386. /** @hidden */
  124387. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  124388. private _genericAttributeLocation;
  124389. private _varyingLocationCount;
  124390. private _varyingLocationMap;
  124391. private _replacements;
  124392. private _textureCount;
  124393. private _uniforms;
  124394. lineProcessor(line: string): string;
  124395. attributeProcessor(attribute: string): string;
  124396. varyingProcessor(varying: string, isFragment: boolean): string;
  124397. uniformProcessor(uniform: string): string;
  124398. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  124399. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  124400. }
  124401. }
  124402. declare module BABYLON {
  124403. /**
  124404. * Container for accessors for natively-stored mesh data buffers.
  124405. */
  124406. class NativeDataBuffer extends DataBuffer {
  124407. /**
  124408. * Accessor value used to identify/retrieve a natively-stored index buffer.
  124409. */
  124410. nativeIndexBuffer?: any;
  124411. /**
  124412. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  124413. */
  124414. nativeVertexBuffer?: any;
  124415. }
  124416. /** @hidden */
  124417. class NativeTexture extends InternalTexture {
  124418. getInternalTexture(): InternalTexture;
  124419. getViewCount(): number;
  124420. }
  124421. /** @hidden */
  124422. export class NativeEngine extends Engine {
  124423. private readonly _native;
  124424. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  124425. private readonly INVALID_HANDLE;
  124426. getHardwareScalingLevel(): number;
  124427. constructor();
  124428. dispose(): void;
  124429. /**
  124430. * Can be used to override the current requestAnimationFrame requester.
  124431. * @hidden
  124432. */
  124433. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124434. /**
  124435. * Override default engine behavior.
  124436. * @param color
  124437. * @param backBuffer
  124438. * @param depth
  124439. * @param stencil
  124440. */
  124441. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124442. /**
  124443. * Gets host document
  124444. * @returns the host document object
  124445. */
  124446. getHostDocument(): Nullable<Document>;
  124447. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124448. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  124449. createVertexBuffer(data: DataArray): NativeDataBuffer;
  124450. recordVertexArrayObject(vertexBuffers: {
  124451. [key: string]: VertexBuffer;
  124452. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124453. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124454. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124455. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  124456. /**
  124457. * Draw a list of indexed primitives
  124458. * @param fillMode defines the primitive to use
  124459. * @param indexStart defines the starting index
  124460. * @param indexCount defines the number of index to draw
  124461. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124462. */
  124463. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  124464. /**
  124465. * Draw a list of unindexed primitives
  124466. * @param fillMode defines the primitive to use
  124467. * @param verticesStart defines the index of first vertex to draw
  124468. * @param verticesCount defines the count of vertices to draw
  124469. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124470. */
  124471. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124472. createPipelineContext(): IPipelineContext;
  124473. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  124474. /** @hidden */
  124475. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  124476. /** @hidden */
  124477. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  124478. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124479. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124480. protected _setProgram(program: WebGLProgram): void;
  124481. _releaseEffect(effect: Effect): void;
  124482. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  124483. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  124484. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  124485. bindSamplers(effect: Effect): void;
  124486. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  124487. getRenderWidth(useScreen?: boolean): number;
  124488. getRenderHeight(useScreen?: boolean): number;
  124489. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  124490. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  124491. /**
  124492. * Set the z offset to apply to current rendering
  124493. * @param value defines the offset to apply
  124494. */
  124495. setZOffset(value: number): void;
  124496. /**
  124497. * Gets the current value of the zOffset
  124498. * @returns the current zOffset state
  124499. */
  124500. getZOffset(): number;
  124501. /**
  124502. * Enable or disable depth buffering
  124503. * @param enable defines the state to set
  124504. */
  124505. setDepthBuffer(enable: boolean): void;
  124506. /**
  124507. * Gets a boolean indicating if depth writing is enabled
  124508. * @returns the current depth writing state
  124509. */
  124510. getDepthWrite(): boolean;
  124511. /**
  124512. * Enable or disable depth writing
  124513. * @param enable defines the state to set
  124514. */
  124515. setDepthWrite(enable: boolean): void;
  124516. /**
  124517. * Enable or disable color writing
  124518. * @param enable defines the state to set
  124519. */
  124520. setColorWrite(enable: boolean): void;
  124521. /**
  124522. * Gets a boolean indicating if color writing is enabled
  124523. * @returns the current color writing state
  124524. */
  124525. getColorWrite(): boolean;
  124526. /**
  124527. * Sets alpha constants used by some alpha blending modes
  124528. * @param r defines the red component
  124529. * @param g defines the green component
  124530. * @param b defines the blue component
  124531. * @param a defines the alpha component
  124532. */
  124533. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  124534. /**
  124535. * Sets the current alpha mode
  124536. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  124537. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  124538. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124539. */
  124540. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  124541. /**
  124542. * Gets the current alpha mode
  124543. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124544. * @returns the current alpha mode
  124545. */
  124546. getAlphaMode(): number;
  124547. setInt(uniform: WebGLUniformLocation, int: number): void;
  124548. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  124549. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  124550. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  124551. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  124552. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  124553. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  124554. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  124555. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  124556. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  124557. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  124558. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  124559. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  124560. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  124561. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124562. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124563. setFloat(uniform: WebGLUniformLocation, value: number): void;
  124564. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  124565. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  124566. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  124567. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  124568. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  124569. wipeCaches(bruteForce?: boolean): void;
  124570. _createTexture(): WebGLTexture;
  124571. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  124572. /**
  124573. * Usually called from Texture.ts.
  124574. * Passed information to create a WebGLTexture
  124575. * @param url defines a value which contains one of the following:
  124576. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  124577. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  124578. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  124579. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  124580. * @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)
  124581. * @param scene needed for loading to the correct scene
  124582. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  124583. * @param onLoad optional callback to be called upon successful completion
  124584. * @param onError optional callback to be called upon failure
  124585. * @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
  124586. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  124587. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  124588. * @param forcedExtension defines the extension to use to pick the right loader
  124589. * @param mimeType defines an optional mime type
  124590. * @returns a InternalTexture for assignment back into BABYLON.Texture
  124591. */
  124592. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  124593. /**
  124594. * Creates a cube texture
  124595. * @param rootUrl defines the url where the files to load is located
  124596. * @param scene defines the current scene
  124597. * @param files defines the list of files to load (1 per face)
  124598. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  124599. * @param onLoad defines an optional callback raised when the texture is loaded
  124600. * @param onError defines an optional callback raised if there is an issue to load the texture
  124601. * @param format defines the format of the data
  124602. * @param forcedExtension defines the extension to use to pick the right loader
  124603. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  124604. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  124605. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  124606. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  124607. * @returns the cube texture as an InternalTexture
  124608. */
  124609. 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;
  124610. private _getSamplingFilter;
  124611. private static _GetNativeTextureFormat;
  124612. createRenderTargetTexture(size: number | {
  124613. width: number;
  124614. height: number;
  124615. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  124616. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  124617. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  124618. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124619. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124620. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  124621. /**
  124622. * Updates a dynamic vertex buffer.
  124623. * @param vertexBuffer the vertex buffer to update
  124624. * @param data the data used to update the vertex buffer
  124625. * @param byteOffset the byte offset of the data (optional)
  124626. * @param byteLength the byte length of the data (optional)
  124627. */
  124628. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  124629. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  124630. private _updateAnisotropicLevel;
  124631. private _getAddressMode;
  124632. /** @hidden */
  124633. _bindTexture(channel: number, texture: InternalTexture): void;
  124634. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  124635. releaseEffects(): void;
  124636. /** @hidden */
  124637. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124638. /** @hidden */
  124639. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124640. /** @hidden */
  124641. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124642. /** @hidden */
  124643. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  124644. }
  124645. }
  124646. declare module BABYLON {
  124647. /**
  124648. * Gather the list of clipboard event types as constants.
  124649. */
  124650. export class ClipboardEventTypes {
  124651. /**
  124652. * The clipboard event is fired when a copy command is active (pressed).
  124653. */
  124654. static readonly COPY: number;
  124655. /**
  124656. * The clipboard event is fired when a cut command is active (pressed).
  124657. */
  124658. static readonly CUT: number;
  124659. /**
  124660. * The clipboard event is fired when a paste command is active (pressed).
  124661. */
  124662. static readonly PASTE: number;
  124663. }
  124664. /**
  124665. * This class is used to store clipboard related info for the onClipboardObservable event.
  124666. */
  124667. export class ClipboardInfo {
  124668. /**
  124669. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124670. */
  124671. type: number;
  124672. /**
  124673. * Defines the related dom event
  124674. */
  124675. event: ClipboardEvent;
  124676. /**
  124677. *Creates an instance of ClipboardInfo.
  124678. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  124679. * @param event Defines the related dom event
  124680. */
  124681. constructor(
  124682. /**
  124683. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124684. */
  124685. type: number,
  124686. /**
  124687. * Defines the related dom event
  124688. */
  124689. event: ClipboardEvent);
  124690. /**
  124691. * Get the clipboard event's type from the keycode.
  124692. * @param keyCode Defines the keyCode for the current keyboard event.
  124693. * @return {number}
  124694. */
  124695. static GetTypeFromCharacter(keyCode: number): number;
  124696. }
  124697. }
  124698. declare module BABYLON {
  124699. /**
  124700. * Google Daydream controller
  124701. */
  124702. export class DaydreamController extends WebVRController {
  124703. /**
  124704. * Base Url for the controller model.
  124705. */
  124706. static MODEL_BASE_URL: string;
  124707. /**
  124708. * File name for the controller model.
  124709. */
  124710. static MODEL_FILENAME: string;
  124711. /**
  124712. * Gamepad Id prefix used to identify Daydream Controller.
  124713. */
  124714. static readonly GAMEPAD_ID_PREFIX: string;
  124715. /**
  124716. * Creates a new DaydreamController from a gamepad
  124717. * @param vrGamepad the gamepad that the controller should be created from
  124718. */
  124719. constructor(vrGamepad: any);
  124720. /**
  124721. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124722. * @param scene scene in which to add meshes
  124723. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124724. */
  124725. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124726. /**
  124727. * Called once for each button that changed state since the last frame
  124728. * @param buttonIdx Which button index changed
  124729. * @param state New state of the button
  124730. * @param changes Which properties on the state changed since last frame
  124731. */
  124732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124733. }
  124734. }
  124735. declare module BABYLON {
  124736. /**
  124737. * Gear VR Controller
  124738. */
  124739. export class GearVRController extends WebVRController {
  124740. /**
  124741. * Base Url for the controller model.
  124742. */
  124743. static MODEL_BASE_URL: string;
  124744. /**
  124745. * File name for the controller model.
  124746. */
  124747. static MODEL_FILENAME: string;
  124748. /**
  124749. * Gamepad Id prefix used to identify this controller.
  124750. */
  124751. static readonly GAMEPAD_ID_PREFIX: string;
  124752. private readonly _buttonIndexToObservableNameMap;
  124753. /**
  124754. * Creates a new GearVRController from a gamepad
  124755. * @param vrGamepad the gamepad that the controller should be created from
  124756. */
  124757. constructor(vrGamepad: any);
  124758. /**
  124759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124760. * @param scene scene in which to add meshes
  124761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124762. */
  124763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124764. /**
  124765. * Called once for each button that changed state since the last frame
  124766. * @param buttonIdx Which button index changed
  124767. * @param state New state of the button
  124768. * @param changes Which properties on the state changed since last frame
  124769. */
  124770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124771. }
  124772. }
  124773. declare module BABYLON {
  124774. /**
  124775. * Generic Controller
  124776. */
  124777. export class GenericController extends WebVRController {
  124778. /**
  124779. * Base Url for the controller model.
  124780. */
  124781. static readonly MODEL_BASE_URL: string;
  124782. /**
  124783. * File name for the controller model.
  124784. */
  124785. static readonly MODEL_FILENAME: string;
  124786. /**
  124787. * Creates a new GenericController from a gamepad
  124788. * @param vrGamepad the gamepad that the controller should be created from
  124789. */
  124790. constructor(vrGamepad: any);
  124791. /**
  124792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124793. * @param scene scene in which to add meshes
  124794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124795. */
  124796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124797. /**
  124798. * Called once for each button that changed state since the last frame
  124799. * @param buttonIdx Which button index changed
  124800. * @param state New state of the button
  124801. * @param changes Which properties on the state changed since last frame
  124802. */
  124803. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124804. }
  124805. }
  124806. declare module BABYLON {
  124807. /**
  124808. * Oculus Touch Controller
  124809. */
  124810. export class OculusTouchController extends WebVRController {
  124811. /**
  124812. * Base Url for the controller model.
  124813. */
  124814. static MODEL_BASE_URL: string;
  124815. /**
  124816. * File name for the left controller model.
  124817. */
  124818. static MODEL_LEFT_FILENAME: string;
  124819. /**
  124820. * File name for the right controller model.
  124821. */
  124822. static MODEL_RIGHT_FILENAME: string;
  124823. /**
  124824. * Base Url for the Quest controller model.
  124825. */
  124826. static QUEST_MODEL_BASE_URL: string;
  124827. /**
  124828. * @hidden
  124829. * If the controllers are running on a device that needs the updated Quest controller models
  124830. */
  124831. static _IsQuest: boolean;
  124832. /**
  124833. * Fired when the secondary trigger on this controller is modified
  124834. */
  124835. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  124836. /**
  124837. * Fired when the thumb rest on this controller is modified
  124838. */
  124839. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  124840. /**
  124841. * Creates a new OculusTouchController from a gamepad
  124842. * @param vrGamepad the gamepad that the controller should be created from
  124843. */
  124844. constructor(vrGamepad: any);
  124845. /**
  124846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124847. * @param scene scene in which to add meshes
  124848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124849. */
  124850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124851. /**
  124852. * Fired when the A button on this controller is modified
  124853. */
  124854. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124855. /**
  124856. * Fired when the B button on this controller is modified
  124857. */
  124858. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124859. /**
  124860. * Fired when the X button on this controller is modified
  124861. */
  124862. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124863. /**
  124864. * Fired when the Y button on this controller is modified
  124865. */
  124866. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124867. /**
  124868. * Called once for each button that changed state since the last frame
  124869. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  124870. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  124871. * 2) secondary trigger (same)
  124872. * 3) A (right) X (left), touch, pressed = value
  124873. * 4) B / Y
  124874. * 5) thumb rest
  124875. * @param buttonIdx Which button index changed
  124876. * @param state New state of the button
  124877. * @param changes Which properties on the state changed since last frame
  124878. */
  124879. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124880. }
  124881. }
  124882. declare module BABYLON {
  124883. /**
  124884. * Vive Controller
  124885. */
  124886. export class ViveController extends WebVRController {
  124887. /**
  124888. * Base Url for the controller model.
  124889. */
  124890. static MODEL_BASE_URL: string;
  124891. /**
  124892. * File name for the controller model.
  124893. */
  124894. static MODEL_FILENAME: string;
  124895. /**
  124896. * Creates a new ViveController from a gamepad
  124897. * @param vrGamepad the gamepad that the controller should be created from
  124898. */
  124899. constructor(vrGamepad: any);
  124900. /**
  124901. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124902. * @param scene scene in which to add meshes
  124903. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124904. */
  124905. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124906. /**
  124907. * Fired when the left button on this controller is modified
  124908. */
  124909. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124910. /**
  124911. * Fired when the right button on this controller is modified
  124912. */
  124913. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124914. /**
  124915. * Fired when the menu button on this controller is modified
  124916. */
  124917. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124918. /**
  124919. * Called once for each button that changed state since the last frame
  124920. * Vive mapping:
  124921. * 0: touchpad
  124922. * 1: trigger
  124923. * 2: left AND right buttons
  124924. * 3: menu button
  124925. * @param buttonIdx Which button index changed
  124926. * @param state New state of the button
  124927. * @param changes Which properties on the state changed since last frame
  124928. */
  124929. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124930. }
  124931. }
  124932. declare module BABYLON {
  124933. /**
  124934. * Defines the WindowsMotionController object that the state of the windows motion controller
  124935. */
  124936. export class WindowsMotionController extends WebVRController {
  124937. /**
  124938. * The base url used to load the left and right controller models
  124939. */
  124940. static MODEL_BASE_URL: string;
  124941. /**
  124942. * The name of the left controller model file
  124943. */
  124944. static MODEL_LEFT_FILENAME: string;
  124945. /**
  124946. * The name of the right controller model file
  124947. */
  124948. static MODEL_RIGHT_FILENAME: string;
  124949. /**
  124950. * The controller name prefix for this controller type
  124951. */
  124952. static readonly GAMEPAD_ID_PREFIX: string;
  124953. /**
  124954. * The controller id pattern for this controller type
  124955. */
  124956. private static readonly GAMEPAD_ID_PATTERN;
  124957. private _loadedMeshInfo;
  124958. protected readonly _mapping: {
  124959. buttons: string[];
  124960. buttonMeshNames: {
  124961. trigger: string;
  124962. menu: string;
  124963. grip: string;
  124964. thumbstick: string;
  124965. trackpad: string;
  124966. };
  124967. buttonObservableNames: {
  124968. trigger: string;
  124969. menu: string;
  124970. grip: string;
  124971. thumbstick: string;
  124972. trackpad: string;
  124973. };
  124974. axisMeshNames: string[];
  124975. pointingPoseMeshName: string;
  124976. };
  124977. /**
  124978. * Fired when the trackpad on this controller is clicked
  124979. */
  124980. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124981. /**
  124982. * Fired when the trackpad on this controller is modified
  124983. */
  124984. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124985. /**
  124986. * The current x and y values of this controller's trackpad
  124987. */
  124988. trackpad: StickValues;
  124989. /**
  124990. * Creates a new WindowsMotionController from a gamepad
  124991. * @param vrGamepad the gamepad that the controller should be created from
  124992. */
  124993. constructor(vrGamepad: any);
  124994. /**
  124995. * Fired when the trigger on this controller is modified
  124996. */
  124997. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124998. /**
  124999. * Fired when the menu button on this controller is modified
  125000. */
  125001. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  125002. /**
  125003. * Fired when the grip button on this controller is modified
  125004. */
  125005. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  125006. /**
  125007. * Fired when the thumbstick button on this controller is modified
  125008. */
  125009. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  125010. /**
  125011. * Fired when the touchpad button on this controller is modified
  125012. */
  125013. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  125014. /**
  125015. * Fired when the touchpad values on this controller are modified
  125016. */
  125017. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  125018. protected _updateTrackpad(): void;
  125019. /**
  125020. * Called once per frame by the engine.
  125021. */
  125022. update(): void;
  125023. /**
  125024. * Called once for each button that changed state since the last frame
  125025. * @param buttonIdx Which button index changed
  125026. * @param state New state of the button
  125027. * @param changes Which properties on the state changed since last frame
  125028. */
  125029. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  125030. /**
  125031. * Moves the buttons on the controller mesh based on their current state
  125032. * @param buttonName the name of the button to move
  125033. * @param buttonValue the value of the button which determines the buttons new position
  125034. */
  125035. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  125036. /**
  125037. * Moves the axis on the controller mesh based on its current state
  125038. * @param axis the index of the axis
  125039. * @param axisValue the value of the axis which determines the meshes new position
  125040. * @hidden
  125041. */
  125042. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  125043. /**
  125044. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  125045. * @param scene scene in which to add meshes
  125046. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  125047. */
  125048. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  125049. /**
  125050. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  125051. * can be transformed by button presses and axes values, based on this._mapping.
  125052. *
  125053. * @param scene scene in which the meshes exist
  125054. * @param meshes list of meshes that make up the controller model to process
  125055. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  125056. */
  125057. private processModel;
  125058. private createMeshInfo;
  125059. /**
  125060. * Gets the ray of the controller in the direction the controller is pointing
  125061. * @param length the length the resulting ray should be
  125062. * @returns a ray in the direction the controller is pointing
  125063. */
  125064. getForwardRay(length?: number): Ray;
  125065. /**
  125066. * Disposes of the controller
  125067. */
  125068. dispose(): void;
  125069. }
  125070. /**
  125071. * This class represents a new windows motion controller in XR.
  125072. */
  125073. export class XRWindowsMotionController extends WindowsMotionController {
  125074. /**
  125075. * Changing the original WIndowsMotionController mapping to fir the new mapping
  125076. */
  125077. protected readonly _mapping: {
  125078. buttons: string[];
  125079. buttonMeshNames: {
  125080. trigger: string;
  125081. menu: string;
  125082. grip: string;
  125083. thumbstick: string;
  125084. trackpad: string;
  125085. };
  125086. buttonObservableNames: {
  125087. trigger: string;
  125088. menu: string;
  125089. grip: string;
  125090. thumbstick: string;
  125091. trackpad: string;
  125092. };
  125093. axisMeshNames: string[];
  125094. pointingPoseMeshName: string;
  125095. };
  125096. /**
  125097. * Construct a new XR-Based windows motion controller
  125098. *
  125099. * @param gamepadInfo the gamepad object from the browser
  125100. */
  125101. constructor(gamepadInfo: any);
  125102. /**
  125103. * holds the thumbstick values (X,Y)
  125104. */
  125105. thumbstickValues: StickValues;
  125106. /**
  125107. * Fired when the thumbstick on this controller is clicked
  125108. */
  125109. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  125110. /**
  125111. * Fired when the thumbstick on this controller is modified
  125112. */
  125113. onThumbstickValuesChangedObservable: Observable<StickValues>;
  125114. /**
  125115. * Fired when the touchpad button on this controller is modified
  125116. */
  125117. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  125118. /**
  125119. * Fired when the touchpad values on this controller are modified
  125120. */
  125121. onTrackpadValuesChangedObservable: Observable<StickValues>;
  125122. /**
  125123. * Fired when the thumbstick button on this controller is modified
  125124. * here to prevent breaking changes
  125125. */
  125126. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  125127. /**
  125128. * updating the thumbstick(!) and not the trackpad.
  125129. * This is named this way due to the difference between WebVR and XR and to avoid
  125130. * changing the parent class.
  125131. */
  125132. protected _updateTrackpad(): void;
  125133. /**
  125134. * Disposes the class with joy
  125135. */
  125136. dispose(): void;
  125137. }
  125138. }
  125139. declare module BABYLON {
  125140. /**
  125141. * Class containing static functions to help procedurally build meshes
  125142. */
  125143. export class PolyhedronBuilder {
  125144. /**
  125145. * Creates a polyhedron mesh
  125146. * * 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
  125147. * * The parameter `size` (positive float, default 1) sets the polygon size
  125148. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125149. * * 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`
  125150. * * 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
  125151. * * 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)`)
  125152. * * 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
  125153. * * 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
  125154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125155. * * 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
  125156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125157. * @param name defines the name of the mesh
  125158. * @param options defines the options used to create the mesh
  125159. * @param scene defines the hosting scene
  125160. * @returns the polyhedron mesh
  125161. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125162. */
  125163. static CreatePolyhedron(name: string, options: {
  125164. type?: number;
  125165. size?: number;
  125166. sizeX?: number;
  125167. sizeY?: number;
  125168. sizeZ?: number;
  125169. custom?: any;
  125170. faceUV?: Vector4[];
  125171. faceColors?: Color4[];
  125172. flat?: boolean;
  125173. updatable?: boolean;
  125174. sideOrientation?: number;
  125175. frontUVs?: Vector4;
  125176. backUVs?: Vector4;
  125177. }, scene?: Nullable<Scene>): Mesh;
  125178. }
  125179. }
  125180. declare module BABYLON {
  125181. /**
  125182. * Gizmo that enables scaling a mesh along 3 axis
  125183. */
  125184. export class ScaleGizmo extends Gizmo {
  125185. /**
  125186. * Internal gizmo used for interactions on the x axis
  125187. */
  125188. xGizmo: AxisScaleGizmo;
  125189. /**
  125190. * Internal gizmo used for interactions on the y axis
  125191. */
  125192. yGizmo: AxisScaleGizmo;
  125193. /**
  125194. * Internal gizmo used for interactions on the z axis
  125195. */
  125196. zGizmo: AxisScaleGizmo;
  125197. /**
  125198. * Internal gizmo used to scale all axis equally
  125199. */
  125200. uniformScaleGizmo: AxisScaleGizmo;
  125201. private _meshAttached;
  125202. private _updateGizmoRotationToMatchAttachedMesh;
  125203. private _snapDistance;
  125204. private _scaleRatio;
  125205. private _uniformScalingMesh;
  125206. private _octahedron;
  125207. private _sensitivity;
  125208. /** Fires an event when any of it's sub gizmos are dragged */
  125209. onDragStartObservable: Observable<unknown>;
  125210. /** Fires an event when any of it's sub gizmos are released from dragging */
  125211. onDragEndObservable: Observable<unknown>;
  125212. get attachedMesh(): Nullable<AbstractMesh>;
  125213. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125214. /**
  125215. * Creates a ScaleGizmo
  125216. * @param gizmoLayer The utility layer the gizmo will be added to
  125217. */
  125218. constructor(gizmoLayer?: UtilityLayerRenderer);
  125219. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125220. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125221. /**
  125222. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125223. */
  125224. set snapDistance(value: number);
  125225. get snapDistance(): number;
  125226. /**
  125227. * Ratio for the scale of the gizmo (Default: 1)
  125228. */
  125229. set scaleRatio(value: number);
  125230. get scaleRatio(): number;
  125231. /**
  125232. * Sensitivity factor for dragging (Default: 1)
  125233. */
  125234. set sensitivity(value: number);
  125235. get sensitivity(): number;
  125236. /**
  125237. * Disposes of the gizmo
  125238. */
  125239. dispose(): void;
  125240. }
  125241. }
  125242. declare module BABYLON {
  125243. /**
  125244. * Single axis scale gizmo
  125245. */
  125246. export class AxisScaleGizmo extends Gizmo {
  125247. /**
  125248. * Drag behavior responsible for the gizmos dragging interactions
  125249. */
  125250. dragBehavior: PointerDragBehavior;
  125251. private _pointerObserver;
  125252. /**
  125253. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125254. */
  125255. snapDistance: number;
  125256. /**
  125257. * Event that fires each time the gizmo snaps to a new location.
  125258. * * snapDistance is the the change in distance
  125259. */
  125260. onSnapObservable: Observable<{
  125261. snapDistance: number;
  125262. }>;
  125263. /**
  125264. * If the scaling operation should be done on all axis (default: false)
  125265. */
  125266. uniformScaling: boolean;
  125267. /**
  125268. * Custom sensitivity value for the drag strength
  125269. */
  125270. sensitivity: number;
  125271. private _isEnabled;
  125272. private _parent;
  125273. private _arrow;
  125274. private _coloredMaterial;
  125275. private _hoverMaterial;
  125276. /**
  125277. * Creates an AxisScaleGizmo
  125278. * @param gizmoLayer The utility layer the gizmo will be added to
  125279. * @param dragAxis The axis which the gizmo will be able to scale on
  125280. * @param color The color of the gizmo
  125281. */
  125282. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  125283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125284. /**
  125285. * If the gizmo is enabled
  125286. */
  125287. set isEnabled(value: boolean);
  125288. get isEnabled(): boolean;
  125289. /**
  125290. * Disposes of the gizmo
  125291. */
  125292. dispose(): void;
  125293. /**
  125294. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  125295. * @param mesh The mesh to replace the default mesh of the gizmo
  125296. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  125297. */
  125298. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  125299. }
  125300. }
  125301. declare module BABYLON {
  125302. /**
  125303. * Bounding box gizmo
  125304. */
  125305. export class BoundingBoxGizmo extends Gizmo {
  125306. private _lineBoundingBox;
  125307. private _rotateSpheresParent;
  125308. private _scaleBoxesParent;
  125309. private _boundingDimensions;
  125310. private _renderObserver;
  125311. private _pointerObserver;
  125312. private _scaleDragSpeed;
  125313. private _tmpQuaternion;
  125314. private _tmpVector;
  125315. private _tmpRotationMatrix;
  125316. /**
  125317. * 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)
  125318. */
  125319. ignoreChildren: boolean;
  125320. /**
  125321. * 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)
  125322. */
  125323. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  125324. /**
  125325. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  125326. */
  125327. rotationSphereSize: number;
  125328. /**
  125329. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  125330. */
  125331. scaleBoxSize: number;
  125332. /**
  125333. * 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)
  125334. */
  125335. fixedDragMeshScreenSize: boolean;
  125336. /**
  125337. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  125338. */
  125339. fixedDragMeshScreenSizeDistanceFactor: number;
  125340. /**
  125341. * Fired when a rotation sphere or scale box is dragged
  125342. */
  125343. onDragStartObservable: Observable<{}>;
  125344. /**
  125345. * Fired when a scale box is dragged
  125346. */
  125347. onScaleBoxDragObservable: Observable<{}>;
  125348. /**
  125349. * Fired when a scale box drag is ended
  125350. */
  125351. onScaleBoxDragEndObservable: Observable<{}>;
  125352. /**
  125353. * Fired when a rotation sphere is dragged
  125354. */
  125355. onRotationSphereDragObservable: Observable<{}>;
  125356. /**
  125357. * Fired when a rotation sphere drag is ended
  125358. */
  125359. onRotationSphereDragEndObservable: Observable<{}>;
  125360. /**
  125361. * 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)
  125362. */
  125363. scalePivot: Nullable<Vector3>;
  125364. /**
  125365. * Mesh used as a pivot to rotate the attached mesh
  125366. */
  125367. private _anchorMesh;
  125368. private _existingMeshScale;
  125369. private _dragMesh;
  125370. private pointerDragBehavior;
  125371. private coloredMaterial;
  125372. private hoverColoredMaterial;
  125373. /**
  125374. * Sets the color of the bounding box gizmo
  125375. * @param color the color to set
  125376. */
  125377. setColor(color: Color3): void;
  125378. /**
  125379. * Creates an BoundingBoxGizmo
  125380. * @param gizmoLayer The utility layer the gizmo will be added to
  125381. * @param color The color of the gizmo
  125382. */
  125383. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  125384. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125385. private _selectNode;
  125386. /**
  125387. * Updates the bounding box information for the Gizmo
  125388. */
  125389. updateBoundingBox(): void;
  125390. private _updateRotationSpheres;
  125391. private _updateScaleBoxes;
  125392. /**
  125393. * Enables rotation on the specified axis and disables rotation on the others
  125394. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  125395. */
  125396. setEnabledRotationAxis(axis: string): void;
  125397. /**
  125398. * Enables/disables scaling
  125399. * @param enable if scaling should be enabled
  125400. * @param homogeneousScaling defines if scaling should only be homogeneous
  125401. */
  125402. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  125403. private _updateDummy;
  125404. /**
  125405. * Enables a pointer drag behavior on the bounding box of the gizmo
  125406. */
  125407. enableDragBehavior(): void;
  125408. /**
  125409. * Disposes of the gizmo
  125410. */
  125411. dispose(): void;
  125412. /**
  125413. * 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)
  125414. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  125415. * @returns the bounding box mesh with the passed in mesh as a child
  125416. */
  125417. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  125418. /**
  125419. * CustomMeshes are not supported by this gizmo
  125420. * @param mesh The mesh to replace the default mesh of the gizmo
  125421. */
  125422. setCustomMesh(mesh: Mesh): void;
  125423. }
  125424. }
  125425. declare module BABYLON {
  125426. /**
  125427. * Single plane rotation gizmo
  125428. */
  125429. export class PlaneRotationGizmo extends Gizmo {
  125430. /**
  125431. * Drag behavior responsible for the gizmos dragging interactions
  125432. */
  125433. dragBehavior: PointerDragBehavior;
  125434. private _pointerObserver;
  125435. /**
  125436. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  125437. */
  125438. snapDistance: number;
  125439. /**
  125440. * Event that fires each time the gizmo snaps to a new location.
  125441. * * snapDistance is the the change in distance
  125442. */
  125443. onSnapObservable: Observable<{
  125444. snapDistance: number;
  125445. }>;
  125446. private _isEnabled;
  125447. private _parent;
  125448. /**
  125449. * Creates a PlaneRotationGizmo
  125450. * @param gizmoLayer The utility layer the gizmo will be added to
  125451. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  125452. * @param color The color of the gizmo
  125453. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125454. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125455. */
  125456. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  125457. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125458. /**
  125459. * If the gizmo is enabled
  125460. */
  125461. set isEnabled(value: boolean);
  125462. get isEnabled(): boolean;
  125463. /**
  125464. * Disposes of the gizmo
  125465. */
  125466. dispose(): void;
  125467. }
  125468. }
  125469. declare module BABYLON {
  125470. /**
  125471. * Gizmo that enables rotating a mesh along 3 axis
  125472. */
  125473. export class RotationGizmo extends Gizmo {
  125474. /**
  125475. * Internal gizmo used for interactions on the x axis
  125476. */
  125477. xGizmo: PlaneRotationGizmo;
  125478. /**
  125479. * Internal gizmo used for interactions on the y axis
  125480. */
  125481. yGizmo: PlaneRotationGizmo;
  125482. /**
  125483. * Internal gizmo used for interactions on the z axis
  125484. */
  125485. zGizmo: PlaneRotationGizmo;
  125486. /** Fires an event when any of it's sub gizmos are dragged */
  125487. onDragStartObservable: Observable<unknown>;
  125488. /** Fires an event when any of it's sub gizmos are released from dragging */
  125489. onDragEndObservable: Observable<unknown>;
  125490. private _meshAttached;
  125491. get attachedMesh(): Nullable<AbstractMesh>;
  125492. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125493. /**
  125494. * Creates a RotationGizmo
  125495. * @param gizmoLayer The utility layer the gizmo will be added to
  125496. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125497. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125498. */
  125499. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  125500. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125501. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125502. /**
  125503. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125504. */
  125505. set snapDistance(value: number);
  125506. get snapDistance(): number;
  125507. /**
  125508. * Ratio for the scale of the gizmo (Default: 1)
  125509. */
  125510. set scaleRatio(value: number);
  125511. get scaleRatio(): number;
  125512. /**
  125513. * Disposes of the gizmo
  125514. */
  125515. dispose(): void;
  125516. /**
  125517. * CustomMeshes are not supported by this gizmo
  125518. * @param mesh The mesh to replace the default mesh of the gizmo
  125519. */
  125520. setCustomMesh(mesh: Mesh): void;
  125521. }
  125522. }
  125523. declare module BABYLON {
  125524. /**
  125525. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  125526. */
  125527. export class GizmoManager implements IDisposable {
  125528. private scene;
  125529. /**
  125530. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  125531. */
  125532. gizmos: {
  125533. positionGizmo: Nullable<PositionGizmo>;
  125534. rotationGizmo: Nullable<RotationGizmo>;
  125535. scaleGizmo: Nullable<ScaleGizmo>;
  125536. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  125537. };
  125538. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  125539. clearGizmoOnEmptyPointerEvent: boolean;
  125540. /** Fires an event when the manager is attached to a mesh */
  125541. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  125542. private _gizmosEnabled;
  125543. private _pointerObserver;
  125544. private _attachedMesh;
  125545. private _boundingBoxColor;
  125546. private _defaultUtilityLayer;
  125547. private _defaultKeepDepthUtilityLayer;
  125548. /**
  125549. * When bounding box gizmo is enabled, this can be used to track drag/end events
  125550. */
  125551. boundingBoxDragBehavior: SixDofDragBehavior;
  125552. /**
  125553. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  125554. */
  125555. attachableMeshes: Nullable<Array<AbstractMesh>>;
  125556. /**
  125557. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  125558. */
  125559. usePointerToAttachGizmos: boolean;
  125560. /**
  125561. * Utility layer that the bounding box gizmo belongs to
  125562. */
  125563. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  125564. /**
  125565. * Utility layer that all gizmos besides bounding box belong to
  125566. */
  125567. get utilityLayer(): UtilityLayerRenderer;
  125568. /**
  125569. * Instatiates a gizmo manager
  125570. * @param scene the scene to overlay the gizmos on top of
  125571. */
  125572. constructor(scene: Scene);
  125573. /**
  125574. * Attaches a set of gizmos to the specified mesh
  125575. * @param mesh The mesh the gizmo's should be attached to
  125576. */
  125577. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  125578. /**
  125579. * If the position gizmo is enabled
  125580. */
  125581. set positionGizmoEnabled(value: boolean);
  125582. get positionGizmoEnabled(): boolean;
  125583. /**
  125584. * If the rotation gizmo is enabled
  125585. */
  125586. set rotationGizmoEnabled(value: boolean);
  125587. get rotationGizmoEnabled(): boolean;
  125588. /**
  125589. * If the scale gizmo is enabled
  125590. */
  125591. set scaleGizmoEnabled(value: boolean);
  125592. get scaleGizmoEnabled(): boolean;
  125593. /**
  125594. * If the boundingBox gizmo is enabled
  125595. */
  125596. set boundingBoxGizmoEnabled(value: boolean);
  125597. get boundingBoxGizmoEnabled(): boolean;
  125598. /**
  125599. * Disposes of the gizmo manager
  125600. */
  125601. dispose(): void;
  125602. }
  125603. }
  125604. declare module BABYLON {
  125605. /**
  125606. * A directional light is defined by a direction (what a surprise!).
  125607. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  125608. * 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.
  125609. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125610. */
  125611. export class DirectionalLight extends ShadowLight {
  125612. private _shadowFrustumSize;
  125613. /**
  125614. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  125615. */
  125616. get shadowFrustumSize(): number;
  125617. /**
  125618. * Specifies a fix frustum size for the shadow generation.
  125619. */
  125620. set shadowFrustumSize(value: number);
  125621. private _shadowOrthoScale;
  125622. /**
  125623. * Gets the shadow projection scale against the optimal computed one.
  125624. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125625. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125626. */
  125627. get shadowOrthoScale(): number;
  125628. /**
  125629. * Sets the shadow projection scale against the optimal computed one.
  125630. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125631. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125632. */
  125633. set shadowOrthoScale(value: number);
  125634. /**
  125635. * Automatically compute the projection matrix to best fit (including all the casters)
  125636. * on each frame.
  125637. */
  125638. autoUpdateExtends: boolean;
  125639. /**
  125640. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  125641. * on each frame. autoUpdateExtends must be set to true for this to work
  125642. */
  125643. autoCalcShadowZBounds: boolean;
  125644. private _orthoLeft;
  125645. private _orthoRight;
  125646. private _orthoTop;
  125647. private _orthoBottom;
  125648. /**
  125649. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  125650. * The directional light is emitted from everywhere in the given direction.
  125651. * It can cast shadows.
  125652. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125653. * @param name The friendly name of the light
  125654. * @param direction The direction of the light
  125655. * @param scene The scene the light belongs to
  125656. */
  125657. constructor(name: string, direction: Vector3, scene: Scene);
  125658. /**
  125659. * Returns the string "DirectionalLight".
  125660. * @return The class name
  125661. */
  125662. getClassName(): string;
  125663. /**
  125664. * Returns the integer 1.
  125665. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125666. */
  125667. getTypeID(): number;
  125668. /**
  125669. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  125670. * Returns the DirectionalLight Shadow projection matrix.
  125671. */
  125672. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125673. /**
  125674. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  125675. * Returns the DirectionalLight Shadow projection matrix.
  125676. */
  125677. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  125678. /**
  125679. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  125680. * Returns the DirectionalLight Shadow projection matrix.
  125681. */
  125682. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125683. protected _buildUniformLayout(): void;
  125684. /**
  125685. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  125686. * @param effect The effect to update
  125687. * @param lightIndex The index of the light in the effect to update
  125688. * @returns The directional light
  125689. */
  125690. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  125691. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  125692. /**
  125693. * Gets the minZ used for shadow according to both the scene and the light.
  125694. *
  125695. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125696. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125697. * @param activeCamera The camera we are returning the min for
  125698. * @returns the depth min z
  125699. */
  125700. getDepthMinZ(activeCamera: Camera): number;
  125701. /**
  125702. * Gets the maxZ used for shadow according to both the scene and the light.
  125703. *
  125704. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125705. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125706. * @param activeCamera The camera we are returning the max for
  125707. * @returns the depth max z
  125708. */
  125709. getDepthMaxZ(activeCamera: Camera): number;
  125710. /**
  125711. * Prepares the list of defines specific to the light type.
  125712. * @param defines the list of defines
  125713. * @param lightIndex defines the index of the light for the effect
  125714. */
  125715. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125716. }
  125717. }
  125718. declare module BABYLON {
  125719. /**
  125720. * Class containing static functions to help procedurally build meshes
  125721. */
  125722. export class HemisphereBuilder {
  125723. /**
  125724. * Creates a hemisphere mesh
  125725. * @param name defines the name of the mesh
  125726. * @param options defines the options used to create the mesh
  125727. * @param scene defines the hosting scene
  125728. * @returns the hemisphere mesh
  125729. */
  125730. static CreateHemisphere(name: string, options: {
  125731. segments?: number;
  125732. diameter?: number;
  125733. sideOrientation?: number;
  125734. }, scene: any): Mesh;
  125735. }
  125736. }
  125737. declare module BABYLON {
  125738. /**
  125739. * A spot light is defined by a position, a direction, an angle, and an exponent.
  125740. * These values define a cone of light starting from the position, emitting toward the direction.
  125741. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  125742. * and the exponent defines the speed of the decay of the light with distance (reach).
  125743. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125744. */
  125745. export class SpotLight extends ShadowLight {
  125746. private _angle;
  125747. private _innerAngle;
  125748. private _cosHalfAngle;
  125749. private _lightAngleScale;
  125750. private _lightAngleOffset;
  125751. /**
  125752. * Gets the cone angle of the spot light in Radians.
  125753. */
  125754. get angle(): number;
  125755. /**
  125756. * Sets the cone angle of the spot light in Radians.
  125757. */
  125758. set angle(value: number);
  125759. /**
  125760. * Only used in gltf falloff mode, this defines the angle where
  125761. * the directional falloff will start before cutting at angle which could be seen
  125762. * as outer angle.
  125763. */
  125764. get innerAngle(): number;
  125765. /**
  125766. * Only used in gltf falloff mode, this defines the angle where
  125767. * the directional falloff will start before cutting at angle which could be seen
  125768. * as outer angle.
  125769. */
  125770. set innerAngle(value: number);
  125771. private _shadowAngleScale;
  125772. /**
  125773. * Allows scaling the angle of the light for shadow generation only.
  125774. */
  125775. get shadowAngleScale(): number;
  125776. /**
  125777. * Allows scaling the angle of the light for shadow generation only.
  125778. */
  125779. set shadowAngleScale(value: number);
  125780. /**
  125781. * The light decay speed with the distance from the emission spot.
  125782. */
  125783. exponent: number;
  125784. private _projectionTextureMatrix;
  125785. /**
  125786. * Allows reading the projecton texture
  125787. */
  125788. get projectionTextureMatrix(): Matrix;
  125789. protected _projectionTextureLightNear: number;
  125790. /**
  125791. * Gets the near clip of the Spotlight for texture projection.
  125792. */
  125793. get projectionTextureLightNear(): number;
  125794. /**
  125795. * Sets the near clip of the Spotlight for texture projection.
  125796. */
  125797. set projectionTextureLightNear(value: number);
  125798. protected _projectionTextureLightFar: number;
  125799. /**
  125800. * Gets the far clip of the Spotlight for texture projection.
  125801. */
  125802. get projectionTextureLightFar(): number;
  125803. /**
  125804. * Sets the far clip of the Spotlight for texture projection.
  125805. */
  125806. set projectionTextureLightFar(value: number);
  125807. protected _projectionTextureUpDirection: Vector3;
  125808. /**
  125809. * Gets the Up vector of the Spotlight for texture projection.
  125810. */
  125811. get projectionTextureUpDirection(): Vector3;
  125812. /**
  125813. * Sets the Up vector of the Spotlight for texture projection.
  125814. */
  125815. set projectionTextureUpDirection(value: Vector3);
  125816. private _projectionTexture;
  125817. /**
  125818. * Gets the projection texture of the light.
  125819. */
  125820. get projectionTexture(): Nullable<BaseTexture>;
  125821. /**
  125822. * Sets the projection texture of the light.
  125823. */
  125824. set projectionTexture(value: Nullable<BaseTexture>);
  125825. private _projectionTextureViewLightDirty;
  125826. private _projectionTextureProjectionLightDirty;
  125827. private _projectionTextureDirty;
  125828. private _projectionTextureViewTargetVector;
  125829. private _projectionTextureViewLightMatrix;
  125830. private _projectionTextureProjectionLightMatrix;
  125831. private _projectionTextureScalingMatrix;
  125832. /**
  125833. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  125834. * It can cast shadows.
  125835. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125836. * @param name The light friendly name
  125837. * @param position The position of the spot light in the scene
  125838. * @param direction The direction of the light in the scene
  125839. * @param angle The cone angle of the light in Radians
  125840. * @param exponent The light decay speed with the distance from the emission spot
  125841. * @param scene The scene the lights belongs to
  125842. */
  125843. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  125844. /**
  125845. * Returns the string "SpotLight".
  125846. * @returns the class name
  125847. */
  125848. getClassName(): string;
  125849. /**
  125850. * Returns the integer 2.
  125851. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125852. */
  125853. getTypeID(): number;
  125854. /**
  125855. * Overrides the direction setter to recompute the projection texture view light Matrix.
  125856. */
  125857. protected _setDirection(value: Vector3): void;
  125858. /**
  125859. * Overrides the position setter to recompute the projection texture view light Matrix.
  125860. */
  125861. protected _setPosition(value: Vector3): void;
  125862. /**
  125863. * 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.
  125864. * Returns the SpotLight.
  125865. */
  125866. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125867. protected _computeProjectionTextureViewLightMatrix(): void;
  125868. protected _computeProjectionTextureProjectionLightMatrix(): void;
  125869. /**
  125870. * Main function for light texture projection matrix computing.
  125871. */
  125872. protected _computeProjectionTextureMatrix(): void;
  125873. protected _buildUniformLayout(): void;
  125874. private _computeAngleValues;
  125875. /**
  125876. * Sets the passed Effect "effect" with the Light textures.
  125877. * @param effect The effect to update
  125878. * @param lightIndex The index of the light in the effect to update
  125879. * @returns The light
  125880. */
  125881. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  125882. /**
  125883. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  125884. * @param effect The effect to update
  125885. * @param lightIndex The index of the light in the effect to update
  125886. * @returns The spot light
  125887. */
  125888. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  125889. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125890. /**
  125891. * Disposes the light and the associated resources.
  125892. */
  125893. dispose(): void;
  125894. /**
  125895. * Prepares the list of defines specific to the light type.
  125896. * @param defines the list of defines
  125897. * @param lightIndex defines the index of the light for the effect
  125898. */
  125899. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125900. }
  125901. }
  125902. declare module BABYLON {
  125903. /**
  125904. * Gizmo that enables viewing a light
  125905. */
  125906. export class LightGizmo extends Gizmo {
  125907. private _lightMesh;
  125908. private _material;
  125909. private _cachedPosition;
  125910. private _cachedForward;
  125911. private _attachedMeshParent;
  125912. /**
  125913. * Creates a LightGizmo
  125914. * @param gizmoLayer The utility layer the gizmo will be added to
  125915. */
  125916. constructor(gizmoLayer?: UtilityLayerRenderer);
  125917. private _light;
  125918. /**
  125919. * The light that the gizmo is attached to
  125920. */
  125921. set light(light: Nullable<Light>);
  125922. get light(): Nullable<Light>;
  125923. /**
  125924. * Gets the material used to render the light gizmo
  125925. */
  125926. get material(): StandardMaterial;
  125927. /**
  125928. * @hidden
  125929. * Updates the gizmo to match the attached mesh's position/rotation
  125930. */
  125931. protected _update(): void;
  125932. private static _Scale;
  125933. /**
  125934. * Creates the lines for a light mesh
  125935. */
  125936. private static _CreateLightLines;
  125937. /**
  125938. * Disposes of the light gizmo
  125939. */
  125940. dispose(): void;
  125941. private static _CreateHemisphericLightMesh;
  125942. private static _CreatePointLightMesh;
  125943. private static _CreateSpotLightMesh;
  125944. private static _CreateDirectionalLightMesh;
  125945. }
  125946. }
  125947. declare module BABYLON {
  125948. /** @hidden */
  125949. export var backgroundFragmentDeclaration: {
  125950. name: string;
  125951. shader: string;
  125952. };
  125953. }
  125954. declare module BABYLON {
  125955. /** @hidden */
  125956. export var backgroundUboDeclaration: {
  125957. name: string;
  125958. shader: string;
  125959. };
  125960. }
  125961. declare module BABYLON {
  125962. /** @hidden */
  125963. export var backgroundPixelShader: {
  125964. name: string;
  125965. shader: string;
  125966. };
  125967. }
  125968. declare module BABYLON {
  125969. /** @hidden */
  125970. export var backgroundVertexDeclaration: {
  125971. name: string;
  125972. shader: string;
  125973. };
  125974. }
  125975. declare module BABYLON {
  125976. /** @hidden */
  125977. export var backgroundVertexShader: {
  125978. name: string;
  125979. shader: string;
  125980. };
  125981. }
  125982. declare module BABYLON {
  125983. /**
  125984. * Background material used to create an efficient environement around your scene.
  125985. */
  125986. export class BackgroundMaterial extends PushMaterial {
  125987. /**
  125988. * Standard reflectance value at parallel view angle.
  125989. */
  125990. static StandardReflectance0: number;
  125991. /**
  125992. * Standard reflectance value at grazing angle.
  125993. */
  125994. static StandardReflectance90: number;
  125995. protected _primaryColor: Color3;
  125996. /**
  125997. * Key light Color (multiply against the environement texture)
  125998. */
  125999. primaryColor: Color3;
  126000. protected __perceptualColor: Nullable<Color3>;
  126001. /**
  126002. * Experimental Internal Use Only.
  126003. *
  126004. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  126005. * This acts as a helper to set the primary color to a more "human friendly" value.
  126006. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  126007. * output color as close as possible from the chosen value.
  126008. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  126009. * part of lighting setup.)
  126010. */
  126011. get _perceptualColor(): Nullable<Color3>;
  126012. set _perceptualColor(value: Nullable<Color3>);
  126013. protected _primaryColorShadowLevel: float;
  126014. /**
  126015. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  126016. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  126017. */
  126018. get primaryColorShadowLevel(): float;
  126019. set primaryColorShadowLevel(value: float);
  126020. protected _primaryColorHighlightLevel: float;
  126021. /**
  126022. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  126023. * The primary color is used at the level chosen to define what the white area would look.
  126024. */
  126025. get primaryColorHighlightLevel(): float;
  126026. set primaryColorHighlightLevel(value: float);
  126027. protected _reflectionTexture: Nullable<BaseTexture>;
  126028. /**
  126029. * Reflection Texture used in the material.
  126030. * Should be author in a specific way for the best result (refer to the documentation).
  126031. */
  126032. reflectionTexture: Nullable<BaseTexture>;
  126033. protected _reflectionBlur: float;
  126034. /**
  126035. * Reflection Texture level of blur.
  126036. *
  126037. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  126038. * texture twice.
  126039. */
  126040. reflectionBlur: float;
  126041. protected _diffuseTexture: Nullable<BaseTexture>;
  126042. /**
  126043. * Diffuse Texture used in the material.
  126044. * Should be author in a specific way for the best result (refer to the documentation).
  126045. */
  126046. diffuseTexture: Nullable<BaseTexture>;
  126047. protected _shadowLights: Nullable<IShadowLight[]>;
  126048. /**
  126049. * Specify the list of lights casting shadow on the material.
  126050. * All scene shadow lights will be included if null.
  126051. */
  126052. shadowLights: Nullable<IShadowLight[]>;
  126053. protected _shadowLevel: float;
  126054. /**
  126055. * Helps adjusting the shadow to a softer level if required.
  126056. * 0 means black shadows and 1 means no shadows.
  126057. */
  126058. shadowLevel: float;
  126059. protected _sceneCenter: Vector3;
  126060. /**
  126061. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  126062. * It is usually zero but might be interesting to modify according to your setup.
  126063. */
  126064. sceneCenter: Vector3;
  126065. protected _opacityFresnel: boolean;
  126066. /**
  126067. * This helps specifying that the material is falling off to the sky box at grazing angle.
  126068. * This helps ensuring a nice transition when the camera goes under the ground.
  126069. */
  126070. opacityFresnel: boolean;
  126071. protected _reflectionFresnel: boolean;
  126072. /**
  126073. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  126074. * This helps adding a mirror texture on the ground.
  126075. */
  126076. reflectionFresnel: boolean;
  126077. protected _reflectionFalloffDistance: number;
  126078. /**
  126079. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  126080. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  126081. */
  126082. reflectionFalloffDistance: number;
  126083. protected _reflectionAmount: number;
  126084. /**
  126085. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  126086. */
  126087. reflectionAmount: number;
  126088. protected _reflectionReflectance0: number;
  126089. /**
  126090. * This specifies the weight of the reflection at grazing angle.
  126091. */
  126092. reflectionReflectance0: number;
  126093. protected _reflectionReflectance90: number;
  126094. /**
  126095. * This specifies the weight of the reflection at a perpendicular point of view.
  126096. */
  126097. reflectionReflectance90: number;
  126098. /**
  126099. * Sets the reflection reflectance fresnel values according to the default standard
  126100. * empirically know to work well :-)
  126101. */
  126102. set reflectionStandardFresnelWeight(value: number);
  126103. protected _useRGBColor: boolean;
  126104. /**
  126105. * Helps to directly use the maps channels instead of their level.
  126106. */
  126107. useRGBColor: boolean;
  126108. protected _enableNoise: boolean;
  126109. /**
  126110. * This helps reducing the banding effect that could occur on the background.
  126111. */
  126112. enableNoise: boolean;
  126113. /**
  126114. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126115. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  126116. * Recommended to be keep at 1.0 except for special cases.
  126117. */
  126118. get fovMultiplier(): number;
  126119. set fovMultiplier(value: number);
  126120. private _fovMultiplier;
  126121. /**
  126122. * Enable the FOV adjustment feature controlled by fovMultiplier.
  126123. */
  126124. useEquirectangularFOV: boolean;
  126125. private _maxSimultaneousLights;
  126126. /**
  126127. * Number of Simultaneous lights allowed on the material.
  126128. */
  126129. maxSimultaneousLights: int;
  126130. /**
  126131. * Default configuration related to image processing available in the Background Material.
  126132. */
  126133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126134. /**
  126135. * Keep track of the image processing observer to allow dispose and replace.
  126136. */
  126137. private _imageProcessingObserver;
  126138. /**
  126139. * Attaches a new image processing configuration to the PBR Material.
  126140. * @param configuration (if null the scene configuration will be use)
  126141. */
  126142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126143. /**
  126144. * Gets the image processing configuration used either in this material.
  126145. */
  126146. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  126147. /**
  126148. * Sets the Default image processing configuration used either in the this material.
  126149. *
  126150. * If sets to null, the scene one is in use.
  126151. */
  126152. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  126153. /**
  126154. * Gets wether the color curves effect is enabled.
  126155. */
  126156. get cameraColorCurvesEnabled(): boolean;
  126157. /**
  126158. * Sets wether the color curves effect is enabled.
  126159. */
  126160. set cameraColorCurvesEnabled(value: boolean);
  126161. /**
  126162. * Gets wether the color grading effect is enabled.
  126163. */
  126164. get cameraColorGradingEnabled(): boolean;
  126165. /**
  126166. * Gets wether the color grading effect is enabled.
  126167. */
  126168. set cameraColorGradingEnabled(value: boolean);
  126169. /**
  126170. * Gets wether tonemapping is enabled or not.
  126171. */
  126172. get cameraToneMappingEnabled(): boolean;
  126173. /**
  126174. * Sets wether tonemapping is enabled or not
  126175. */
  126176. set cameraToneMappingEnabled(value: boolean);
  126177. /**
  126178. * The camera exposure used on this material.
  126179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126180. * This corresponds to a photographic exposure.
  126181. */
  126182. get cameraExposure(): float;
  126183. /**
  126184. * The camera exposure used on this material.
  126185. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126186. * This corresponds to a photographic exposure.
  126187. */
  126188. set cameraExposure(value: float);
  126189. /**
  126190. * Gets The camera contrast used on this material.
  126191. */
  126192. get cameraContrast(): float;
  126193. /**
  126194. * Sets The camera contrast used on this material.
  126195. */
  126196. set cameraContrast(value: float);
  126197. /**
  126198. * Gets the Color Grading 2D Lookup Texture.
  126199. */
  126200. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126201. /**
  126202. * Sets the Color Grading 2D Lookup Texture.
  126203. */
  126204. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126205. /**
  126206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126208. * 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;
  126209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126210. */
  126211. get cameraColorCurves(): Nullable<ColorCurves>;
  126212. /**
  126213. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126214. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126215. * 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;
  126216. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126217. */
  126218. set cameraColorCurves(value: Nullable<ColorCurves>);
  126219. /**
  126220. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  126221. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  126222. */
  126223. switchToBGR: boolean;
  126224. private _renderTargets;
  126225. private _reflectionControls;
  126226. private _white;
  126227. private _primaryShadowColor;
  126228. private _primaryHighlightColor;
  126229. /**
  126230. * Instantiates a Background Material in the given scene
  126231. * @param name The friendly name of the material
  126232. * @param scene The scene to add the material to
  126233. */
  126234. constructor(name: string, scene: Scene);
  126235. /**
  126236. * Gets a boolean indicating that current material needs to register RTT
  126237. */
  126238. get hasRenderTargetTextures(): boolean;
  126239. /**
  126240. * The entire material has been created in order to prevent overdraw.
  126241. * @returns false
  126242. */
  126243. needAlphaTesting(): boolean;
  126244. /**
  126245. * The entire material has been created in order to prevent overdraw.
  126246. * @returns true if blending is enable
  126247. */
  126248. needAlphaBlending(): boolean;
  126249. /**
  126250. * Checks wether the material is ready to be rendered for a given mesh.
  126251. * @param mesh The mesh to render
  126252. * @param subMesh The submesh to check against
  126253. * @param useInstances Specify wether or not the material is used with instances
  126254. * @returns true if all the dependencies are ready (Textures, Effects...)
  126255. */
  126256. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126257. /**
  126258. * Compute the primary color according to the chosen perceptual color.
  126259. */
  126260. private _computePrimaryColorFromPerceptualColor;
  126261. /**
  126262. * Compute the highlights and shadow colors according to their chosen levels.
  126263. */
  126264. private _computePrimaryColors;
  126265. /**
  126266. * Build the uniform buffer used in the material.
  126267. */
  126268. buildUniformLayout(): void;
  126269. /**
  126270. * Unbind the material.
  126271. */
  126272. unbind(): void;
  126273. /**
  126274. * Bind only the world matrix to the material.
  126275. * @param world The world matrix to bind.
  126276. */
  126277. bindOnlyWorldMatrix(world: Matrix): void;
  126278. /**
  126279. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  126280. * @param world The world matrix to bind.
  126281. * @param subMesh The submesh to bind for.
  126282. */
  126283. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126284. /**
  126285. * Checks to see if a texture is used in the material.
  126286. * @param texture - Base texture to use.
  126287. * @returns - Boolean specifying if a texture is used in the material.
  126288. */
  126289. hasTexture(texture: BaseTexture): boolean;
  126290. /**
  126291. * Dispose the material.
  126292. * @param forceDisposeEffect Force disposal of the associated effect.
  126293. * @param forceDisposeTextures Force disposal of the associated textures.
  126294. */
  126295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126296. /**
  126297. * Clones the material.
  126298. * @param name The cloned name.
  126299. * @returns The cloned material.
  126300. */
  126301. clone(name: string): BackgroundMaterial;
  126302. /**
  126303. * Serializes the current material to its JSON representation.
  126304. * @returns The JSON representation.
  126305. */
  126306. serialize(): any;
  126307. /**
  126308. * Gets the class name of the material
  126309. * @returns "BackgroundMaterial"
  126310. */
  126311. getClassName(): string;
  126312. /**
  126313. * Parse a JSON input to create back a background material.
  126314. * @param source The JSON data to parse
  126315. * @param scene The scene to create the parsed material in
  126316. * @param rootUrl The root url of the assets the material depends upon
  126317. * @returns the instantiated BackgroundMaterial.
  126318. */
  126319. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  126320. }
  126321. }
  126322. declare module BABYLON {
  126323. /**
  126324. * Represents the different options available during the creation of
  126325. * a Environment helper.
  126326. *
  126327. * This can control the default ground, skybox and image processing setup of your scene.
  126328. */
  126329. export interface IEnvironmentHelperOptions {
  126330. /**
  126331. * Specifies whether or not to create a ground.
  126332. * True by default.
  126333. */
  126334. createGround: boolean;
  126335. /**
  126336. * Specifies the ground size.
  126337. * 15 by default.
  126338. */
  126339. groundSize: number;
  126340. /**
  126341. * The texture used on the ground for the main color.
  126342. * Comes from the BabylonJS CDN by default.
  126343. *
  126344. * Remarks: Can be either a texture or a url.
  126345. */
  126346. groundTexture: string | BaseTexture;
  126347. /**
  126348. * The color mixed in the ground texture by default.
  126349. * BabylonJS clearColor by default.
  126350. */
  126351. groundColor: Color3;
  126352. /**
  126353. * Specifies the ground opacity.
  126354. * 1 by default.
  126355. */
  126356. groundOpacity: number;
  126357. /**
  126358. * Enables the ground to receive shadows.
  126359. * True by default.
  126360. */
  126361. enableGroundShadow: boolean;
  126362. /**
  126363. * Helps preventing the shadow to be fully black on the ground.
  126364. * 0.5 by default.
  126365. */
  126366. groundShadowLevel: number;
  126367. /**
  126368. * Creates a mirror texture attach to the ground.
  126369. * false by default.
  126370. */
  126371. enableGroundMirror: boolean;
  126372. /**
  126373. * Specifies the ground mirror size ratio.
  126374. * 0.3 by default as the default kernel is 64.
  126375. */
  126376. groundMirrorSizeRatio: number;
  126377. /**
  126378. * Specifies the ground mirror blur kernel size.
  126379. * 64 by default.
  126380. */
  126381. groundMirrorBlurKernel: number;
  126382. /**
  126383. * Specifies the ground mirror visibility amount.
  126384. * 1 by default
  126385. */
  126386. groundMirrorAmount: number;
  126387. /**
  126388. * Specifies the ground mirror reflectance weight.
  126389. * This uses the standard weight of the background material to setup the fresnel effect
  126390. * of the mirror.
  126391. * 1 by default.
  126392. */
  126393. groundMirrorFresnelWeight: number;
  126394. /**
  126395. * Specifies the ground mirror Falloff distance.
  126396. * This can helps reducing the size of the reflection.
  126397. * 0 by Default.
  126398. */
  126399. groundMirrorFallOffDistance: number;
  126400. /**
  126401. * Specifies the ground mirror texture type.
  126402. * Unsigned Int by Default.
  126403. */
  126404. groundMirrorTextureType: number;
  126405. /**
  126406. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  126407. * the shown objects.
  126408. */
  126409. groundYBias: number;
  126410. /**
  126411. * Specifies whether or not to create a skybox.
  126412. * True by default.
  126413. */
  126414. createSkybox: boolean;
  126415. /**
  126416. * Specifies the skybox size.
  126417. * 20 by default.
  126418. */
  126419. skyboxSize: number;
  126420. /**
  126421. * The texture used on the skybox for the main color.
  126422. * Comes from the BabylonJS CDN by default.
  126423. *
  126424. * Remarks: Can be either a texture or a url.
  126425. */
  126426. skyboxTexture: string | BaseTexture;
  126427. /**
  126428. * The color mixed in the skybox texture by default.
  126429. * BabylonJS clearColor by default.
  126430. */
  126431. skyboxColor: Color3;
  126432. /**
  126433. * The background rotation around the Y axis of the scene.
  126434. * This helps aligning the key lights of your scene with the background.
  126435. * 0 by default.
  126436. */
  126437. backgroundYRotation: number;
  126438. /**
  126439. * Compute automatically the size of the elements to best fit with the scene.
  126440. */
  126441. sizeAuto: boolean;
  126442. /**
  126443. * Default position of the rootMesh if autoSize is not true.
  126444. */
  126445. rootPosition: Vector3;
  126446. /**
  126447. * Sets up the image processing in the scene.
  126448. * true by default.
  126449. */
  126450. setupImageProcessing: boolean;
  126451. /**
  126452. * The texture used as your environment texture in the scene.
  126453. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  126454. *
  126455. * Remarks: Can be either a texture or a url.
  126456. */
  126457. environmentTexture: string | BaseTexture;
  126458. /**
  126459. * The value of the exposure to apply to the scene.
  126460. * 0.6 by default if setupImageProcessing is true.
  126461. */
  126462. cameraExposure: number;
  126463. /**
  126464. * The value of the contrast to apply to the scene.
  126465. * 1.6 by default if setupImageProcessing is true.
  126466. */
  126467. cameraContrast: number;
  126468. /**
  126469. * Specifies whether or not tonemapping should be enabled in the scene.
  126470. * true by default if setupImageProcessing is true.
  126471. */
  126472. toneMappingEnabled: boolean;
  126473. }
  126474. /**
  126475. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  126476. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  126477. * It also helps with the default setup of your imageProcessing configuration.
  126478. */
  126479. export class EnvironmentHelper {
  126480. /**
  126481. * Default ground texture URL.
  126482. */
  126483. private static _groundTextureCDNUrl;
  126484. /**
  126485. * Default skybox texture URL.
  126486. */
  126487. private static _skyboxTextureCDNUrl;
  126488. /**
  126489. * Default environment texture URL.
  126490. */
  126491. private static _environmentTextureCDNUrl;
  126492. /**
  126493. * Creates the default options for the helper.
  126494. */
  126495. private static _getDefaultOptions;
  126496. private _rootMesh;
  126497. /**
  126498. * Gets the root mesh created by the helper.
  126499. */
  126500. get rootMesh(): Mesh;
  126501. private _skybox;
  126502. /**
  126503. * Gets the skybox created by the helper.
  126504. */
  126505. get skybox(): Nullable<Mesh>;
  126506. private _skyboxTexture;
  126507. /**
  126508. * Gets the skybox texture created by the helper.
  126509. */
  126510. get skyboxTexture(): Nullable<BaseTexture>;
  126511. private _skyboxMaterial;
  126512. /**
  126513. * Gets the skybox material created by the helper.
  126514. */
  126515. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  126516. private _ground;
  126517. /**
  126518. * Gets the ground mesh created by the helper.
  126519. */
  126520. get ground(): Nullable<Mesh>;
  126521. private _groundTexture;
  126522. /**
  126523. * Gets the ground texture created by the helper.
  126524. */
  126525. get groundTexture(): Nullable<BaseTexture>;
  126526. private _groundMirror;
  126527. /**
  126528. * Gets the ground mirror created by the helper.
  126529. */
  126530. get groundMirror(): Nullable<MirrorTexture>;
  126531. /**
  126532. * Gets the ground mirror render list to helps pushing the meshes
  126533. * you wish in the ground reflection.
  126534. */
  126535. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  126536. private _groundMaterial;
  126537. /**
  126538. * Gets the ground material created by the helper.
  126539. */
  126540. get groundMaterial(): Nullable<BackgroundMaterial>;
  126541. /**
  126542. * Stores the creation options.
  126543. */
  126544. private readonly _scene;
  126545. private _options;
  126546. /**
  126547. * This observable will be notified with any error during the creation of the environment,
  126548. * mainly texture creation errors.
  126549. */
  126550. onErrorObservable: Observable<{
  126551. message?: string;
  126552. exception?: any;
  126553. }>;
  126554. /**
  126555. * constructor
  126556. * @param options Defines the options we want to customize the helper
  126557. * @param scene The scene to add the material to
  126558. */
  126559. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  126560. /**
  126561. * Updates the background according to the new options
  126562. * @param options
  126563. */
  126564. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  126565. /**
  126566. * Sets the primary color of all the available elements.
  126567. * @param color the main color to affect to the ground and the background
  126568. */
  126569. setMainColor(color: Color3): void;
  126570. /**
  126571. * Setup the image processing according to the specified options.
  126572. */
  126573. private _setupImageProcessing;
  126574. /**
  126575. * Setup the environment texture according to the specified options.
  126576. */
  126577. private _setupEnvironmentTexture;
  126578. /**
  126579. * Setup the background according to the specified options.
  126580. */
  126581. private _setupBackground;
  126582. /**
  126583. * Get the scene sizes according to the setup.
  126584. */
  126585. private _getSceneSize;
  126586. /**
  126587. * Setup the ground according to the specified options.
  126588. */
  126589. private _setupGround;
  126590. /**
  126591. * Setup the ground material according to the specified options.
  126592. */
  126593. private _setupGroundMaterial;
  126594. /**
  126595. * Setup the ground diffuse texture according to the specified options.
  126596. */
  126597. private _setupGroundDiffuseTexture;
  126598. /**
  126599. * Setup the ground mirror texture according to the specified options.
  126600. */
  126601. private _setupGroundMirrorTexture;
  126602. /**
  126603. * Setup the ground to receive the mirror texture.
  126604. */
  126605. private _setupMirrorInGroundMaterial;
  126606. /**
  126607. * Setup the skybox according to the specified options.
  126608. */
  126609. private _setupSkybox;
  126610. /**
  126611. * Setup the skybox material according to the specified options.
  126612. */
  126613. private _setupSkyboxMaterial;
  126614. /**
  126615. * Setup the skybox reflection texture according to the specified options.
  126616. */
  126617. private _setupSkyboxReflectionTexture;
  126618. private _errorHandler;
  126619. /**
  126620. * Dispose all the elements created by the Helper.
  126621. */
  126622. dispose(): void;
  126623. }
  126624. }
  126625. declare module BABYLON {
  126626. /**
  126627. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  126628. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  126629. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  126630. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126631. */
  126632. export class PhotoDome extends TransformNode {
  126633. /**
  126634. * Define the image as a Monoscopic panoramic 360 image.
  126635. */
  126636. static readonly MODE_MONOSCOPIC: number;
  126637. /**
  126638. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126639. */
  126640. static readonly MODE_TOPBOTTOM: number;
  126641. /**
  126642. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126643. */
  126644. static readonly MODE_SIDEBYSIDE: number;
  126645. private _useDirectMapping;
  126646. /**
  126647. * The texture being displayed on the sphere
  126648. */
  126649. protected _photoTexture: Texture;
  126650. /**
  126651. * Gets or sets the texture being displayed on the sphere
  126652. */
  126653. get photoTexture(): Texture;
  126654. set photoTexture(value: Texture);
  126655. /**
  126656. * Observable raised when an error occured while loading the 360 image
  126657. */
  126658. onLoadErrorObservable: Observable<string>;
  126659. /**
  126660. * The skybox material
  126661. */
  126662. protected _material: BackgroundMaterial;
  126663. /**
  126664. * The surface used for the skybox
  126665. */
  126666. protected _mesh: Mesh;
  126667. /**
  126668. * Gets the mesh used for the skybox.
  126669. */
  126670. get mesh(): Mesh;
  126671. /**
  126672. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126673. * Also see the options.resolution property.
  126674. */
  126675. get fovMultiplier(): number;
  126676. set fovMultiplier(value: number);
  126677. private _imageMode;
  126678. /**
  126679. * Gets or set the current video mode for the video. It can be:
  126680. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  126681. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126682. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126683. */
  126684. get imageMode(): number;
  126685. set imageMode(value: number);
  126686. /**
  126687. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  126688. * @param name Element's name, child elements will append suffixes for their own names.
  126689. * @param urlsOfPhoto defines the url of the photo to display
  126690. * @param options defines an object containing optional or exposed sub element properties
  126691. * @param onError defines a callback called when an error occured while loading the texture
  126692. */
  126693. constructor(name: string, urlOfPhoto: string, options: {
  126694. resolution?: number;
  126695. size?: number;
  126696. useDirectMapping?: boolean;
  126697. faceForward?: boolean;
  126698. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  126699. private _onBeforeCameraRenderObserver;
  126700. private _changeImageMode;
  126701. /**
  126702. * Releases resources associated with this node.
  126703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126705. */
  126706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126707. }
  126708. }
  126709. declare module BABYLON {
  126710. /**
  126711. * Class used to host RGBD texture specific utilities
  126712. */
  126713. export class RGBDTextureTools {
  126714. /**
  126715. * Expand the RGBD Texture from RGBD to Half Float if possible.
  126716. * @param texture the texture to expand.
  126717. */
  126718. static ExpandRGBDTexture(texture: Texture): void;
  126719. }
  126720. }
  126721. declare module BABYLON {
  126722. /**
  126723. * Class used to host texture specific utilities
  126724. */
  126725. export class BRDFTextureTools {
  126726. /**
  126727. * Prevents texture cache collision
  126728. */
  126729. private static _instanceNumber;
  126730. /**
  126731. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  126732. * @param scene defines the hosting scene
  126733. * @returns the environment BRDF texture
  126734. */
  126735. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  126736. private static _environmentBRDFBase64Texture;
  126737. }
  126738. }
  126739. declare module BABYLON {
  126740. /**
  126741. * @hidden
  126742. */
  126743. export interface IMaterialClearCoatDefines {
  126744. CLEARCOAT: boolean;
  126745. CLEARCOAT_DEFAULTIOR: boolean;
  126746. CLEARCOAT_TEXTURE: boolean;
  126747. CLEARCOAT_TEXTUREDIRECTUV: number;
  126748. CLEARCOAT_BUMP: boolean;
  126749. CLEARCOAT_BUMPDIRECTUV: number;
  126750. CLEARCOAT_TINT: boolean;
  126751. CLEARCOAT_TINT_TEXTURE: boolean;
  126752. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  126753. /** @hidden */
  126754. _areTexturesDirty: boolean;
  126755. }
  126756. /**
  126757. * Define the code related to the clear coat parameters of the pbr material.
  126758. */
  126759. export class PBRClearCoatConfiguration {
  126760. /**
  126761. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126762. * The default fits with a polyurethane material.
  126763. */
  126764. private static readonly _DefaultIndexOfRefraction;
  126765. private _isEnabled;
  126766. /**
  126767. * Defines if the clear coat is enabled in the material.
  126768. */
  126769. isEnabled: boolean;
  126770. /**
  126771. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  126772. */
  126773. intensity: number;
  126774. /**
  126775. * Defines the clear coat layer roughness.
  126776. */
  126777. roughness: number;
  126778. private _indexOfRefraction;
  126779. /**
  126780. * Defines the index of refraction of the clear coat.
  126781. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126782. * The default fits with a polyurethane material.
  126783. * Changing the default value is more performance intensive.
  126784. */
  126785. indexOfRefraction: number;
  126786. private _texture;
  126787. /**
  126788. * Stores the clear coat values in a texture.
  126789. */
  126790. texture: Nullable<BaseTexture>;
  126791. private _bumpTexture;
  126792. /**
  126793. * Define the clear coat specific bump texture.
  126794. */
  126795. bumpTexture: Nullable<BaseTexture>;
  126796. private _isTintEnabled;
  126797. /**
  126798. * Defines if the clear coat tint is enabled in the material.
  126799. */
  126800. isTintEnabled: boolean;
  126801. /**
  126802. * Defines the clear coat tint of the material.
  126803. * This is only use if tint is enabled
  126804. */
  126805. tintColor: Color3;
  126806. /**
  126807. * Defines the distance at which the tint color should be found in the
  126808. * clear coat media.
  126809. * This is only use if tint is enabled
  126810. */
  126811. tintColorAtDistance: number;
  126812. /**
  126813. * Defines the clear coat layer thickness.
  126814. * This is only use if tint is enabled
  126815. */
  126816. tintThickness: number;
  126817. private _tintTexture;
  126818. /**
  126819. * Stores the clear tint values in a texture.
  126820. * rgb is tint
  126821. * a is a thickness factor
  126822. */
  126823. tintTexture: Nullable<BaseTexture>;
  126824. /** @hidden */
  126825. private _internalMarkAllSubMeshesAsTexturesDirty;
  126826. /** @hidden */
  126827. _markAllSubMeshesAsTexturesDirty(): void;
  126828. /**
  126829. * Instantiate a new istance of clear coat configuration.
  126830. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126831. */
  126832. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126833. /**
  126834. * Gets wehter the submesh is ready to be used or not.
  126835. * @param defines the list of "defines" to update.
  126836. * @param scene defines the scene the material belongs to.
  126837. * @param engine defines the engine the material belongs to.
  126838. * @param disableBumpMap defines wether the material disables bump or not.
  126839. * @returns - boolean indicating that the submesh is ready or not.
  126840. */
  126841. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  126842. /**
  126843. * Checks to see if a texture is used in the material.
  126844. * @param defines the list of "defines" to update.
  126845. * @param scene defines the scene to the material belongs to.
  126846. */
  126847. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  126848. /**
  126849. * Binds the material data.
  126850. * @param uniformBuffer defines the Uniform buffer to fill in.
  126851. * @param scene defines the scene the material belongs to.
  126852. * @param engine defines the engine the material belongs to.
  126853. * @param disableBumpMap defines wether the material disables bump or not.
  126854. * @param isFrozen defines wether the material is frozen or not.
  126855. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126856. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126857. */
  126858. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  126859. /**
  126860. * Checks to see if a texture is used in the material.
  126861. * @param texture - Base texture to use.
  126862. * @returns - Boolean specifying if a texture is used in the material.
  126863. */
  126864. hasTexture(texture: BaseTexture): boolean;
  126865. /**
  126866. * Returns an array of the actively used textures.
  126867. * @param activeTextures Array of BaseTextures
  126868. */
  126869. getActiveTextures(activeTextures: BaseTexture[]): void;
  126870. /**
  126871. * Returns the animatable textures.
  126872. * @param animatables Array of animatable textures.
  126873. */
  126874. getAnimatables(animatables: IAnimatable[]): void;
  126875. /**
  126876. * Disposes the resources of the material.
  126877. * @param forceDisposeTextures - Forces the disposal of all textures.
  126878. */
  126879. dispose(forceDisposeTextures?: boolean): void;
  126880. /**
  126881. * Get the current class name of the texture useful for serialization or dynamic coding.
  126882. * @returns "PBRClearCoatConfiguration"
  126883. */
  126884. getClassName(): string;
  126885. /**
  126886. * Add fallbacks to the effect fallbacks list.
  126887. * @param defines defines the Base texture to use.
  126888. * @param fallbacks defines the current fallback list.
  126889. * @param currentRank defines the current fallback rank.
  126890. * @returns the new fallback rank.
  126891. */
  126892. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126893. /**
  126894. * Add the required uniforms to the current list.
  126895. * @param uniforms defines the current uniform list.
  126896. */
  126897. static AddUniforms(uniforms: string[]): void;
  126898. /**
  126899. * Add the required samplers to the current list.
  126900. * @param samplers defines the current sampler list.
  126901. */
  126902. static AddSamplers(samplers: string[]): void;
  126903. /**
  126904. * Add the required uniforms to the current buffer.
  126905. * @param uniformBuffer defines the current uniform buffer.
  126906. */
  126907. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126908. /**
  126909. * Makes a duplicate of the current configuration into another one.
  126910. * @param clearCoatConfiguration define the config where to copy the info
  126911. */
  126912. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  126913. /**
  126914. * Serializes this clear coat configuration.
  126915. * @returns - An object with the serialized config.
  126916. */
  126917. serialize(): any;
  126918. /**
  126919. * Parses a anisotropy Configuration from a serialized object.
  126920. * @param source - Serialized object.
  126921. * @param scene Defines the scene we are parsing for
  126922. * @param rootUrl Defines the rootUrl to load from
  126923. */
  126924. parse(source: any, scene: Scene, rootUrl: string): void;
  126925. }
  126926. }
  126927. declare module BABYLON {
  126928. /**
  126929. * @hidden
  126930. */
  126931. export interface IMaterialAnisotropicDefines {
  126932. ANISOTROPIC: boolean;
  126933. ANISOTROPIC_TEXTURE: boolean;
  126934. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126935. MAINUV1: boolean;
  126936. _areTexturesDirty: boolean;
  126937. _needUVs: boolean;
  126938. }
  126939. /**
  126940. * Define the code related to the anisotropic parameters of the pbr material.
  126941. */
  126942. export class PBRAnisotropicConfiguration {
  126943. private _isEnabled;
  126944. /**
  126945. * Defines if the anisotropy is enabled in the material.
  126946. */
  126947. isEnabled: boolean;
  126948. /**
  126949. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  126950. */
  126951. intensity: number;
  126952. /**
  126953. * Defines if the effect is along the tangents, bitangents or in between.
  126954. * By default, the effect is "strectching" the highlights along the tangents.
  126955. */
  126956. direction: Vector2;
  126957. private _texture;
  126958. /**
  126959. * Stores the anisotropy values in a texture.
  126960. * rg is direction (like normal from -1 to 1)
  126961. * b is a intensity
  126962. */
  126963. texture: Nullable<BaseTexture>;
  126964. /** @hidden */
  126965. private _internalMarkAllSubMeshesAsTexturesDirty;
  126966. /** @hidden */
  126967. _markAllSubMeshesAsTexturesDirty(): void;
  126968. /**
  126969. * Instantiate a new istance of anisotropy configuration.
  126970. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126971. */
  126972. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126973. /**
  126974. * Specifies that the submesh is ready to be used.
  126975. * @param defines the list of "defines" to update.
  126976. * @param scene defines the scene the material belongs to.
  126977. * @returns - boolean indicating that the submesh is ready or not.
  126978. */
  126979. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  126980. /**
  126981. * Checks to see if a texture is used in the material.
  126982. * @param defines the list of "defines" to update.
  126983. * @param mesh the mesh we are preparing the defines for.
  126984. * @param scene defines the scene the material belongs to.
  126985. */
  126986. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  126987. /**
  126988. * Binds the material data.
  126989. * @param uniformBuffer defines the Uniform buffer to fill in.
  126990. * @param scene defines the scene the material belongs to.
  126991. * @param isFrozen defines wether the material is frozen or not.
  126992. */
  126993. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126994. /**
  126995. * Checks to see if a texture is used in the material.
  126996. * @param texture - Base texture to use.
  126997. * @returns - Boolean specifying if a texture is used in the material.
  126998. */
  126999. hasTexture(texture: BaseTexture): boolean;
  127000. /**
  127001. * Returns an array of the actively used textures.
  127002. * @param activeTextures Array of BaseTextures
  127003. */
  127004. getActiveTextures(activeTextures: BaseTexture[]): void;
  127005. /**
  127006. * Returns the animatable textures.
  127007. * @param animatables Array of animatable textures.
  127008. */
  127009. getAnimatables(animatables: IAnimatable[]): void;
  127010. /**
  127011. * Disposes the resources of the material.
  127012. * @param forceDisposeTextures - Forces the disposal of all textures.
  127013. */
  127014. dispose(forceDisposeTextures?: boolean): void;
  127015. /**
  127016. * Get the current class name of the texture useful for serialization or dynamic coding.
  127017. * @returns "PBRAnisotropicConfiguration"
  127018. */
  127019. getClassName(): string;
  127020. /**
  127021. * Add fallbacks to the effect fallbacks list.
  127022. * @param defines defines the Base texture to use.
  127023. * @param fallbacks defines the current fallback list.
  127024. * @param currentRank defines the current fallback rank.
  127025. * @returns the new fallback rank.
  127026. */
  127027. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127028. /**
  127029. * Add the required uniforms to the current list.
  127030. * @param uniforms defines the current uniform list.
  127031. */
  127032. static AddUniforms(uniforms: string[]): void;
  127033. /**
  127034. * Add the required uniforms to the current buffer.
  127035. * @param uniformBuffer defines the current uniform buffer.
  127036. */
  127037. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127038. /**
  127039. * Add the required samplers to the current list.
  127040. * @param samplers defines the current sampler list.
  127041. */
  127042. static AddSamplers(samplers: string[]): void;
  127043. /**
  127044. * Makes a duplicate of the current configuration into another one.
  127045. * @param anisotropicConfiguration define the config where to copy the info
  127046. */
  127047. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  127048. /**
  127049. * Serializes this anisotropy configuration.
  127050. * @returns - An object with the serialized config.
  127051. */
  127052. serialize(): any;
  127053. /**
  127054. * Parses a anisotropy Configuration from a serialized object.
  127055. * @param source - Serialized object.
  127056. * @param scene Defines the scene we are parsing for
  127057. * @param rootUrl Defines the rootUrl to load from
  127058. */
  127059. parse(source: any, scene: Scene, rootUrl: string): void;
  127060. }
  127061. }
  127062. declare module BABYLON {
  127063. /**
  127064. * @hidden
  127065. */
  127066. export interface IMaterialBRDFDefines {
  127067. BRDF_V_HEIGHT_CORRELATED: boolean;
  127068. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127069. SPHERICAL_HARMONICS: boolean;
  127070. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127071. /** @hidden */
  127072. _areMiscDirty: boolean;
  127073. }
  127074. /**
  127075. * Define the code related to the BRDF parameters of the pbr material.
  127076. */
  127077. export class PBRBRDFConfiguration {
  127078. /**
  127079. * Default value used for the energy conservation.
  127080. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  127081. */
  127082. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  127083. /**
  127084. * Default value used for the Smith Visibility Height Correlated mode.
  127085. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  127086. */
  127087. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  127088. /**
  127089. * Default value used for the IBL diffuse part.
  127090. * This can help switching back to the polynomials mode globally which is a tiny bit
  127091. * less GPU intensive at the drawback of a lower quality.
  127092. */
  127093. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  127094. /**
  127095. * Default value used for activating energy conservation for the specular workflow.
  127096. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  127097. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  127098. */
  127099. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  127100. private _useEnergyConservation;
  127101. /**
  127102. * Defines if the material uses energy conservation.
  127103. */
  127104. useEnergyConservation: boolean;
  127105. private _useSmithVisibilityHeightCorrelated;
  127106. /**
  127107. * LEGACY Mode set to false
  127108. * Defines if the material uses height smith correlated visibility term.
  127109. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  127110. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  127111. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  127112. * Not relying on height correlated will also disable energy conservation.
  127113. */
  127114. useSmithVisibilityHeightCorrelated: boolean;
  127115. private _useSphericalHarmonics;
  127116. /**
  127117. * LEGACY Mode set to false
  127118. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  127119. * diffuse part of the IBL.
  127120. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  127121. * to the ground truth.
  127122. */
  127123. useSphericalHarmonics: boolean;
  127124. private _useSpecularGlossinessInputEnergyConservation;
  127125. /**
  127126. * Defines if the material uses energy conservation, when the specular workflow is active.
  127127. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  127128. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  127129. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  127130. */
  127131. useSpecularGlossinessInputEnergyConservation: boolean;
  127132. /** @hidden */
  127133. private _internalMarkAllSubMeshesAsMiscDirty;
  127134. /** @hidden */
  127135. _markAllSubMeshesAsMiscDirty(): void;
  127136. /**
  127137. * Instantiate a new istance of clear coat configuration.
  127138. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  127139. */
  127140. constructor(markAllSubMeshesAsMiscDirty: () => void);
  127141. /**
  127142. * Checks to see if a texture is used in the material.
  127143. * @param defines the list of "defines" to update.
  127144. */
  127145. prepareDefines(defines: IMaterialBRDFDefines): void;
  127146. /**
  127147. * Get the current class name of the texture useful for serialization or dynamic coding.
  127148. * @returns "PBRClearCoatConfiguration"
  127149. */
  127150. getClassName(): string;
  127151. /**
  127152. * Makes a duplicate of the current configuration into another one.
  127153. * @param brdfConfiguration define the config where to copy the info
  127154. */
  127155. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  127156. /**
  127157. * Serializes this BRDF configuration.
  127158. * @returns - An object with the serialized config.
  127159. */
  127160. serialize(): any;
  127161. /**
  127162. * Parses a anisotropy Configuration from a serialized object.
  127163. * @param source - Serialized object.
  127164. * @param scene Defines the scene we are parsing for
  127165. * @param rootUrl Defines the rootUrl to load from
  127166. */
  127167. parse(source: any, scene: Scene, rootUrl: string): void;
  127168. }
  127169. }
  127170. declare module BABYLON {
  127171. /**
  127172. * @hidden
  127173. */
  127174. export interface IMaterialSheenDefines {
  127175. SHEEN: boolean;
  127176. SHEEN_TEXTURE: boolean;
  127177. SHEEN_TEXTUREDIRECTUV: number;
  127178. SHEEN_LINKWITHALBEDO: boolean;
  127179. SHEEN_ROUGHNESS: boolean;
  127180. SHEEN_ALBEDOSCALING: boolean;
  127181. /** @hidden */
  127182. _areTexturesDirty: boolean;
  127183. }
  127184. /**
  127185. * Define the code related to the Sheen parameters of the pbr material.
  127186. */
  127187. export class PBRSheenConfiguration {
  127188. private _isEnabled;
  127189. /**
  127190. * Defines if the material uses sheen.
  127191. */
  127192. isEnabled: boolean;
  127193. private _linkSheenWithAlbedo;
  127194. /**
  127195. * Defines if the sheen is linked to the sheen color.
  127196. */
  127197. linkSheenWithAlbedo: boolean;
  127198. /**
  127199. * Defines the sheen intensity.
  127200. */
  127201. intensity: number;
  127202. /**
  127203. * Defines the sheen color.
  127204. */
  127205. color: Color3;
  127206. private _texture;
  127207. /**
  127208. * Stores the sheen tint values in a texture.
  127209. * rgb is tint
  127210. * a is a intensity
  127211. */
  127212. texture: Nullable<BaseTexture>;
  127213. private _roughness;
  127214. /**
  127215. * Defines the sheen roughness.
  127216. * It is not taken into account if linkSheenWithAlbedo is true.
  127217. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  127218. */
  127219. roughness: Nullable<number>;
  127220. private _albedoScaling;
  127221. /**
  127222. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  127223. * It allows the strength of the sheen effect to not depend on the base color of the material,
  127224. * making it easier to setup and tweak the effect
  127225. */
  127226. albedoScaling: boolean;
  127227. /** @hidden */
  127228. private _internalMarkAllSubMeshesAsTexturesDirty;
  127229. /** @hidden */
  127230. _markAllSubMeshesAsTexturesDirty(): void;
  127231. /**
  127232. * Instantiate a new istance of clear coat configuration.
  127233. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127234. */
  127235. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127236. /**
  127237. * Specifies that the submesh is ready to be used.
  127238. * @param defines the list of "defines" to update.
  127239. * @param scene defines the scene the material belongs to.
  127240. * @returns - boolean indicating that the submesh is ready or not.
  127241. */
  127242. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  127243. /**
  127244. * Checks to see if a texture is used in the material.
  127245. * @param defines the list of "defines" to update.
  127246. * @param scene defines the scene the material belongs to.
  127247. */
  127248. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  127249. /**
  127250. * Binds the material data.
  127251. * @param uniformBuffer defines the Uniform buffer to fill in.
  127252. * @param scene defines the scene the material belongs to.
  127253. * @param isFrozen defines wether the material is frozen or not.
  127254. */
  127255. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  127256. /**
  127257. * Checks to see if a texture is used in the material.
  127258. * @param texture - Base texture to use.
  127259. * @returns - Boolean specifying if a texture is used in the material.
  127260. */
  127261. hasTexture(texture: BaseTexture): boolean;
  127262. /**
  127263. * Returns an array of the actively used textures.
  127264. * @param activeTextures Array of BaseTextures
  127265. */
  127266. getActiveTextures(activeTextures: BaseTexture[]): void;
  127267. /**
  127268. * Returns the animatable textures.
  127269. * @param animatables Array of animatable textures.
  127270. */
  127271. getAnimatables(animatables: IAnimatable[]): void;
  127272. /**
  127273. * Disposes the resources of the material.
  127274. * @param forceDisposeTextures - Forces the disposal of all textures.
  127275. */
  127276. dispose(forceDisposeTextures?: boolean): void;
  127277. /**
  127278. * Get the current class name of the texture useful for serialization or dynamic coding.
  127279. * @returns "PBRSheenConfiguration"
  127280. */
  127281. getClassName(): string;
  127282. /**
  127283. * Add fallbacks to the effect fallbacks list.
  127284. * @param defines defines the Base texture to use.
  127285. * @param fallbacks defines the current fallback list.
  127286. * @param currentRank defines the current fallback rank.
  127287. * @returns the new fallback rank.
  127288. */
  127289. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127290. /**
  127291. * Add the required uniforms to the current list.
  127292. * @param uniforms defines the current uniform list.
  127293. */
  127294. static AddUniforms(uniforms: string[]): void;
  127295. /**
  127296. * Add the required uniforms to the current buffer.
  127297. * @param uniformBuffer defines the current uniform buffer.
  127298. */
  127299. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127300. /**
  127301. * Add the required samplers to the current list.
  127302. * @param samplers defines the current sampler list.
  127303. */
  127304. static AddSamplers(samplers: string[]): void;
  127305. /**
  127306. * Makes a duplicate of the current configuration into another one.
  127307. * @param sheenConfiguration define the config where to copy the info
  127308. */
  127309. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  127310. /**
  127311. * Serializes this BRDF configuration.
  127312. * @returns - An object with the serialized config.
  127313. */
  127314. serialize(): any;
  127315. /**
  127316. * Parses a anisotropy Configuration from a serialized object.
  127317. * @param source - Serialized object.
  127318. * @param scene Defines the scene we are parsing for
  127319. * @param rootUrl Defines the rootUrl to load from
  127320. */
  127321. parse(source: any, scene: Scene, rootUrl: string): void;
  127322. }
  127323. }
  127324. declare module BABYLON {
  127325. /**
  127326. * @hidden
  127327. */
  127328. export interface IMaterialSubSurfaceDefines {
  127329. SUBSURFACE: boolean;
  127330. SS_REFRACTION: boolean;
  127331. SS_TRANSLUCENCY: boolean;
  127332. SS_SCATERRING: boolean;
  127333. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127334. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127335. SS_REFRACTIONMAP_3D: boolean;
  127336. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127337. SS_LODINREFRACTIONALPHA: boolean;
  127338. SS_GAMMAREFRACTION: boolean;
  127339. SS_RGBDREFRACTION: boolean;
  127340. SS_LINEARSPECULARREFRACTION: boolean;
  127341. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127342. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127343. /** @hidden */
  127344. _areTexturesDirty: boolean;
  127345. }
  127346. /**
  127347. * Define the code related to the sub surface parameters of the pbr material.
  127348. */
  127349. export class PBRSubSurfaceConfiguration {
  127350. private _isRefractionEnabled;
  127351. /**
  127352. * Defines if the refraction is enabled in the material.
  127353. */
  127354. isRefractionEnabled: boolean;
  127355. private _isTranslucencyEnabled;
  127356. /**
  127357. * Defines if the translucency is enabled in the material.
  127358. */
  127359. isTranslucencyEnabled: boolean;
  127360. private _isScatteringEnabled;
  127361. /**
  127362. * Defines the refraction intensity of the material.
  127363. * The refraction when enabled replaces the Diffuse part of the material.
  127364. * The intensity helps transitionning between diffuse and refraction.
  127365. */
  127366. refractionIntensity: number;
  127367. /**
  127368. * Defines the translucency intensity of the material.
  127369. * When translucency has been enabled, this defines how much of the "translucency"
  127370. * is addded to the diffuse part of the material.
  127371. */
  127372. translucencyIntensity: number;
  127373. /**
  127374. * Defines the scattering intensity of the material.
  127375. * When scattering has been enabled, this defines how much of the "scattered light"
  127376. * is addded to the diffuse part of the material.
  127377. */
  127378. scatteringIntensity: number;
  127379. private _thicknessTexture;
  127380. /**
  127381. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  127382. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  127383. * 0 would mean minimumThickness
  127384. * 1 would mean maximumThickness
  127385. * The other channels might be use as a mask to vary the different effects intensity.
  127386. */
  127387. thicknessTexture: Nullable<BaseTexture>;
  127388. private _refractionTexture;
  127389. /**
  127390. * Defines the texture to use for refraction.
  127391. */
  127392. refractionTexture: Nullable<BaseTexture>;
  127393. private _indexOfRefraction;
  127394. /**
  127395. * Defines the index of refraction used in the material.
  127396. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  127397. */
  127398. indexOfRefraction: number;
  127399. private _invertRefractionY;
  127400. /**
  127401. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  127402. */
  127403. invertRefractionY: boolean;
  127404. private _linkRefractionWithTransparency;
  127405. /**
  127406. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  127407. * Materials half opaque for instance using refraction could benefit from this control.
  127408. */
  127409. linkRefractionWithTransparency: boolean;
  127410. /**
  127411. * Defines the minimum thickness stored in the thickness map.
  127412. * If no thickness map is defined, this value will be used to simulate thickness.
  127413. */
  127414. minimumThickness: number;
  127415. /**
  127416. * Defines the maximum thickness stored in the thickness map.
  127417. */
  127418. maximumThickness: number;
  127419. /**
  127420. * Defines the volume tint of the material.
  127421. * This is used for both translucency and scattering.
  127422. */
  127423. tintColor: Color3;
  127424. /**
  127425. * Defines the distance at which the tint color should be found in the media.
  127426. * This is used for refraction only.
  127427. */
  127428. tintColorAtDistance: number;
  127429. /**
  127430. * Defines how far each channel transmit through the media.
  127431. * It is defined as a color to simplify it selection.
  127432. */
  127433. diffusionDistance: Color3;
  127434. private _useMaskFromThicknessTexture;
  127435. /**
  127436. * Stores the intensity of the different subsurface effects in the thickness texture.
  127437. * * the green channel is the translucency intensity.
  127438. * * the blue channel is the scattering intensity.
  127439. * * the alpha channel is the refraction intensity.
  127440. */
  127441. useMaskFromThicknessTexture: boolean;
  127442. /** @hidden */
  127443. private _internalMarkAllSubMeshesAsTexturesDirty;
  127444. /** @hidden */
  127445. _markAllSubMeshesAsTexturesDirty(): void;
  127446. /**
  127447. * Instantiate a new istance of sub surface configuration.
  127448. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127449. */
  127450. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127451. /**
  127452. * Gets wehter the submesh is ready to be used or not.
  127453. * @param defines the list of "defines" to update.
  127454. * @param scene defines the scene the material belongs to.
  127455. * @returns - boolean indicating that the submesh is ready or not.
  127456. */
  127457. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  127458. /**
  127459. * Checks to see if a texture is used in the material.
  127460. * @param defines the list of "defines" to update.
  127461. * @param scene defines the scene to the material belongs to.
  127462. */
  127463. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  127464. /**
  127465. * Binds the material data.
  127466. * @param uniformBuffer defines the Uniform buffer to fill in.
  127467. * @param scene defines the scene the material belongs to.
  127468. * @param engine defines the engine the material belongs to.
  127469. * @param isFrozen defines wether the material is frozen or not.
  127470. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  127471. */
  127472. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  127473. /**
  127474. * Unbinds the material from the mesh.
  127475. * @param activeEffect defines the effect that should be unbound from.
  127476. * @returns true if unbound, otherwise false
  127477. */
  127478. unbind(activeEffect: Effect): boolean;
  127479. /**
  127480. * Returns the texture used for refraction or null if none is used.
  127481. * @param scene defines the scene the material belongs to.
  127482. * @returns - Refraction texture if present. If no refraction texture and refraction
  127483. * is linked with transparency, returns environment texture. Otherwise, returns null.
  127484. */
  127485. private _getRefractionTexture;
  127486. /**
  127487. * Returns true if alpha blending should be disabled.
  127488. */
  127489. get disableAlphaBlending(): boolean;
  127490. /**
  127491. * Fills the list of render target textures.
  127492. * @param renderTargets the list of render targets to update
  127493. */
  127494. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  127495. /**
  127496. * Checks to see if a texture is used in the material.
  127497. * @param texture - Base texture to use.
  127498. * @returns - Boolean specifying if a texture is used in the material.
  127499. */
  127500. hasTexture(texture: BaseTexture): boolean;
  127501. /**
  127502. * Gets a boolean indicating that current material needs to register RTT
  127503. * @returns true if this uses a render target otherwise false.
  127504. */
  127505. hasRenderTargetTextures(): boolean;
  127506. /**
  127507. * Returns an array of the actively used textures.
  127508. * @param activeTextures Array of BaseTextures
  127509. */
  127510. getActiveTextures(activeTextures: BaseTexture[]): void;
  127511. /**
  127512. * Returns the animatable textures.
  127513. * @param animatables Array of animatable textures.
  127514. */
  127515. getAnimatables(animatables: IAnimatable[]): void;
  127516. /**
  127517. * Disposes the resources of the material.
  127518. * @param forceDisposeTextures - Forces the disposal of all textures.
  127519. */
  127520. dispose(forceDisposeTextures?: boolean): void;
  127521. /**
  127522. * Get the current class name of the texture useful for serialization or dynamic coding.
  127523. * @returns "PBRSubSurfaceConfiguration"
  127524. */
  127525. getClassName(): string;
  127526. /**
  127527. * Add fallbacks to the effect fallbacks list.
  127528. * @param defines defines the Base texture to use.
  127529. * @param fallbacks defines the current fallback list.
  127530. * @param currentRank defines the current fallback rank.
  127531. * @returns the new fallback rank.
  127532. */
  127533. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127534. /**
  127535. * Add the required uniforms to the current list.
  127536. * @param uniforms defines the current uniform list.
  127537. */
  127538. static AddUniforms(uniforms: string[]): void;
  127539. /**
  127540. * Add the required samplers to the current list.
  127541. * @param samplers defines the current sampler list.
  127542. */
  127543. static AddSamplers(samplers: string[]): void;
  127544. /**
  127545. * Add the required uniforms to the current buffer.
  127546. * @param uniformBuffer defines the current uniform buffer.
  127547. */
  127548. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127549. /**
  127550. * Makes a duplicate of the current configuration into another one.
  127551. * @param configuration define the config where to copy the info
  127552. */
  127553. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  127554. /**
  127555. * Serializes this Sub Surface configuration.
  127556. * @returns - An object with the serialized config.
  127557. */
  127558. serialize(): any;
  127559. /**
  127560. * Parses a anisotropy Configuration from a serialized object.
  127561. * @param source - Serialized object.
  127562. * @param scene Defines the scene we are parsing for
  127563. * @param rootUrl Defines the rootUrl to load from
  127564. */
  127565. parse(source: any, scene: Scene, rootUrl: string): void;
  127566. }
  127567. }
  127568. declare module BABYLON {
  127569. /** @hidden */
  127570. export var pbrFragmentDeclaration: {
  127571. name: string;
  127572. shader: string;
  127573. };
  127574. }
  127575. declare module BABYLON {
  127576. /** @hidden */
  127577. export var pbrUboDeclaration: {
  127578. name: string;
  127579. shader: string;
  127580. };
  127581. }
  127582. declare module BABYLON {
  127583. /** @hidden */
  127584. export var pbrFragmentExtraDeclaration: {
  127585. name: string;
  127586. shader: string;
  127587. };
  127588. }
  127589. declare module BABYLON {
  127590. /** @hidden */
  127591. export var pbrFragmentSamplersDeclaration: {
  127592. name: string;
  127593. shader: string;
  127594. };
  127595. }
  127596. declare module BABYLON {
  127597. /** @hidden */
  127598. export var pbrHelperFunctions: {
  127599. name: string;
  127600. shader: string;
  127601. };
  127602. }
  127603. declare module BABYLON {
  127604. /** @hidden */
  127605. export var harmonicsFunctions: {
  127606. name: string;
  127607. shader: string;
  127608. };
  127609. }
  127610. declare module BABYLON {
  127611. /** @hidden */
  127612. export var pbrDirectLightingSetupFunctions: {
  127613. name: string;
  127614. shader: string;
  127615. };
  127616. }
  127617. declare module BABYLON {
  127618. /** @hidden */
  127619. export var pbrDirectLightingFalloffFunctions: {
  127620. name: string;
  127621. shader: string;
  127622. };
  127623. }
  127624. declare module BABYLON {
  127625. /** @hidden */
  127626. export var pbrBRDFFunctions: {
  127627. name: string;
  127628. shader: string;
  127629. };
  127630. }
  127631. declare module BABYLON {
  127632. /** @hidden */
  127633. export var pbrDirectLightingFunctions: {
  127634. name: string;
  127635. shader: string;
  127636. };
  127637. }
  127638. declare module BABYLON {
  127639. /** @hidden */
  127640. export var pbrIBLFunctions: {
  127641. name: string;
  127642. shader: string;
  127643. };
  127644. }
  127645. declare module BABYLON {
  127646. /** @hidden */
  127647. export var pbrBlockAlbedoOpacity: {
  127648. name: string;
  127649. shader: string;
  127650. };
  127651. }
  127652. declare module BABYLON {
  127653. /** @hidden */
  127654. export var pbrBlockReflectivity: {
  127655. name: string;
  127656. shader: string;
  127657. };
  127658. }
  127659. declare module BABYLON {
  127660. /** @hidden */
  127661. export var pbrBlockAmbientOcclusion: {
  127662. name: string;
  127663. shader: string;
  127664. };
  127665. }
  127666. declare module BABYLON {
  127667. /** @hidden */
  127668. export var pbrBlockAlphaFresnel: {
  127669. name: string;
  127670. shader: string;
  127671. };
  127672. }
  127673. declare module BABYLON {
  127674. /** @hidden */
  127675. export var pbrBlockAnisotropic: {
  127676. name: string;
  127677. shader: string;
  127678. };
  127679. }
  127680. declare module BABYLON {
  127681. /** @hidden */
  127682. export var pbrBlockReflection: {
  127683. name: string;
  127684. shader: string;
  127685. };
  127686. }
  127687. declare module BABYLON {
  127688. /** @hidden */
  127689. export var pbrBlockSheen: {
  127690. name: string;
  127691. shader: string;
  127692. };
  127693. }
  127694. declare module BABYLON {
  127695. /** @hidden */
  127696. export var pbrBlockClearcoat: {
  127697. name: string;
  127698. shader: string;
  127699. };
  127700. }
  127701. declare module BABYLON {
  127702. /** @hidden */
  127703. export var pbrBlockSubSurface: {
  127704. name: string;
  127705. shader: string;
  127706. };
  127707. }
  127708. declare module BABYLON {
  127709. /** @hidden */
  127710. export var pbrBlockNormalGeometric: {
  127711. name: string;
  127712. shader: string;
  127713. };
  127714. }
  127715. declare module BABYLON {
  127716. /** @hidden */
  127717. export var pbrBlockNormalFinal: {
  127718. name: string;
  127719. shader: string;
  127720. };
  127721. }
  127722. declare module BABYLON {
  127723. /** @hidden */
  127724. export var pbrBlockGeometryInfo: {
  127725. name: string;
  127726. shader: string;
  127727. };
  127728. }
  127729. declare module BABYLON {
  127730. /** @hidden */
  127731. export var pbrBlockReflectance0: {
  127732. name: string;
  127733. shader: string;
  127734. };
  127735. }
  127736. declare module BABYLON {
  127737. /** @hidden */
  127738. export var pbrBlockReflectance: {
  127739. name: string;
  127740. shader: string;
  127741. };
  127742. }
  127743. declare module BABYLON {
  127744. /** @hidden */
  127745. export var pbrBlockDirectLighting: {
  127746. name: string;
  127747. shader: string;
  127748. };
  127749. }
  127750. declare module BABYLON {
  127751. /** @hidden */
  127752. export var pbrBlockFinalLitComponents: {
  127753. name: string;
  127754. shader: string;
  127755. };
  127756. }
  127757. declare module BABYLON {
  127758. /** @hidden */
  127759. export var pbrBlockFinalUnlitComponents: {
  127760. name: string;
  127761. shader: string;
  127762. };
  127763. }
  127764. declare module BABYLON {
  127765. /** @hidden */
  127766. export var pbrBlockFinalColorComposition: {
  127767. name: string;
  127768. shader: string;
  127769. };
  127770. }
  127771. declare module BABYLON {
  127772. /** @hidden */
  127773. export var pbrBlockImageProcessing: {
  127774. name: string;
  127775. shader: string;
  127776. };
  127777. }
  127778. declare module BABYLON {
  127779. /** @hidden */
  127780. export var pbrDebug: {
  127781. name: string;
  127782. shader: string;
  127783. };
  127784. }
  127785. declare module BABYLON {
  127786. /** @hidden */
  127787. export var pbrPixelShader: {
  127788. name: string;
  127789. shader: string;
  127790. };
  127791. }
  127792. declare module BABYLON {
  127793. /** @hidden */
  127794. export var pbrVertexDeclaration: {
  127795. name: string;
  127796. shader: string;
  127797. };
  127798. }
  127799. declare module BABYLON {
  127800. /** @hidden */
  127801. export var pbrVertexShader: {
  127802. name: string;
  127803. shader: string;
  127804. };
  127805. }
  127806. declare module BABYLON {
  127807. /**
  127808. * Manages the defines for the PBR Material.
  127809. * @hidden
  127810. */
  127811. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  127812. PBR: boolean;
  127813. MAINUV1: boolean;
  127814. MAINUV2: boolean;
  127815. UV1: boolean;
  127816. UV2: boolean;
  127817. ALBEDO: boolean;
  127818. GAMMAALBEDO: boolean;
  127819. ALBEDODIRECTUV: number;
  127820. VERTEXCOLOR: boolean;
  127821. AMBIENT: boolean;
  127822. AMBIENTDIRECTUV: number;
  127823. AMBIENTINGRAYSCALE: boolean;
  127824. OPACITY: boolean;
  127825. VERTEXALPHA: boolean;
  127826. OPACITYDIRECTUV: number;
  127827. OPACITYRGB: boolean;
  127828. ALPHATEST: boolean;
  127829. DEPTHPREPASS: boolean;
  127830. ALPHABLEND: boolean;
  127831. ALPHAFROMALBEDO: boolean;
  127832. ALPHATESTVALUE: string;
  127833. SPECULAROVERALPHA: boolean;
  127834. RADIANCEOVERALPHA: boolean;
  127835. ALPHAFRESNEL: boolean;
  127836. LINEARALPHAFRESNEL: boolean;
  127837. PREMULTIPLYALPHA: boolean;
  127838. EMISSIVE: boolean;
  127839. EMISSIVEDIRECTUV: number;
  127840. REFLECTIVITY: boolean;
  127841. REFLECTIVITYDIRECTUV: number;
  127842. SPECULARTERM: boolean;
  127843. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  127844. MICROSURFACEAUTOMATIC: boolean;
  127845. LODBASEDMICROSFURACE: boolean;
  127846. MICROSURFACEMAP: boolean;
  127847. MICROSURFACEMAPDIRECTUV: number;
  127848. METALLICWORKFLOW: boolean;
  127849. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  127850. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  127851. METALLNESSSTOREINMETALMAPBLUE: boolean;
  127852. AOSTOREINMETALMAPRED: boolean;
  127853. METALLICF0FACTORFROMMETALLICMAP: boolean;
  127854. ENVIRONMENTBRDF: boolean;
  127855. ENVIRONMENTBRDF_RGBD: boolean;
  127856. NORMAL: boolean;
  127857. TANGENT: boolean;
  127858. BUMP: boolean;
  127859. BUMPDIRECTUV: number;
  127860. OBJECTSPACE_NORMALMAP: boolean;
  127861. PARALLAX: boolean;
  127862. PARALLAXOCCLUSION: boolean;
  127863. NORMALXYSCALE: boolean;
  127864. LIGHTMAP: boolean;
  127865. LIGHTMAPDIRECTUV: number;
  127866. USELIGHTMAPASSHADOWMAP: boolean;
  127867. GAMMALIGHTMAP: boolean;
  127868. RGBDLIGHTMAP: boolean;
  127869. REFLECTION: boolean;
  127870. REFLECTIONMAP_3D: boolean;
  127871. REFLECTIONMAP_SPHERICAL: boolean;
  127872. REFLECTIONMAP_PLANAR: boolean;
  127873. REFLECTIONMAP_CUBIC: boolean;
  127874. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  127875. REFLECTIONMAP_PROJECTION: boolean;
  127876. REFLECTIONMAP_SKYBOX: boolean;
  127877. REFLECTIONMAP_EXPLICIT: boolean;
  127878. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  127879. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  127880. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  127881. INVERTCUBICMAP: boolean;
  127882. USESPHERICALFROMREFLECTIONMAP: boolean;
  127883. USEIRRADIANCEMAP: boolean;
  127884. SPHERICAL_HARMONICS: boolean;
  127885. USESPHERICALINVERTEX: boolean;
  127886. REFLECTIONMAP_OPPOSITEZ: boolean;
  127887. LODINREFLECTIONALPHA: boolean;
  127888. GAMMAREFLECTION: boolean;
  127889. RGBDREFLECTION: boolean;
  127890. LINEARSPECULARREFLECTION: boolean;
  127891. RADIANCEOCCLUSION: boolean;
  127892. HORIZONOCCLUSION: boolean;
  127893. INSTANCES: boolean;
  127894. NUM_BONE_INFLUENCERS: number;
  127895. BonesPerMesh: number;
  127896. BONETEXTURE: boolean;
  127897. NONUNIFORMSCALING: boolean;
  127898. MORPHTARGETS: boolean;
  127899. MORPHTARGETS_NORMAL: boolean;
  127900. MORPHTARGETS_TANGENT: boolean;
  127901. MORPHTARGETS_UV: boolean;
  127902. NUM_MORPH_INFLUENCERS: number;
  127903. IMAGEPROCESSING: boolean;
  127904. VIGNETTE: boolean;
  127905. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127906. VIGNETTEBLENDMODEOPAQUE: boolean;
  127907. TONEMAPPING: boolean;
  127908. TONEMAPPING_ACES: boolean;
  127909. CONTRAST: boolean;
  127910. COLORCURVES: boolean;
  127911. COLORGRADING: boolean;
  127912. COLORGRADING3D: boolean;
  127913. SAMPLER3DGREENDEPTH: boolean;
  127914. SAMPLER3DBGRMAP: boolean;
  127915. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127916. EXPOSURE: boolean;
  127917. MULTIVIEW: boolean;
  127918. USEPHYSICALLIGHTFALLOFF: boolean;
  127919. USEGLTFLIGHTFALLOFF: boolean;
  127920. TWOSIDEDLIGHTING: boolean;
  127921. SHADOWFLOAT: boolean;
  127922. CLIPPLANE: boolean;
  127923. CLIPPLANE2: boolean;
  127924. CLIPPLANE3: boolean;
  127925. CLIPPLANE4: boolean;
  127926. CLIPPLANE5: boolean;
  127927. CLIPPLANE6: boolean;
  127928. POINTSIZE: boolean;
  127929. FOG: boolean;
  127930. LOGARITHMICDEPTH: boolean;
  127931. FORCENORMALFORWARD: boolean;
  127932. SPECULARAA: boolean;
  127933. CLEARCOAT: boolean;
  127934. CLEARCOAT_DEFAULTIOR: boolean;
  127935. CLEARCOAT_TEXTURE: boolean;
  127936. CLEARCOAT_TEXTUREDIRECTUV: number;
  127937. CLEARCOAT_BUMP: boolean;
  127938. CLEARCOAT_BUMPDIRECTUV: number;
  127939. CLEARCOAT_TINT: boolean;
  127940. CLEARCOAT_TINT_TEXTURE: boolean;
  127941. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  127942. ANISOTROPIC: boolean;
  127943. ANISOTROPIC_TEXTURE: boolean;
  127944. ANISOTROPIC_TEXTUREDIRECTUV: number;
  127945. BRDF_V_HEIGHT_CORRELATED: boolean;
  127946. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127947. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127948. SHEEN: boolean;
  127949. SHEEN_TEXTURE: boolean;
  127950. SHEEN_TEXTUREDIRECTUV: number;
  127951. SHEEN_LINKWITHALBEDO: boolean;
  127952. SHEEN_ROUGHNESS: boolean;
  127953. SHEEN_ALBEDOSCALING: boolean;
  127954. SUBSURFACE: boolean;
  127955. SS_REFRACTION: boolean;
  127956. SS_TRANSLUCENCY: boolean;
  127957. SS_SCATERRING: boolean;
  127958. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127959. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127960. SS_REFRACTIONMAP_3D: boolean;
  127961. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127962. SS_LODINREFRACTIONALPHA: boolean;
  127963. SS_GAMMAREFRACTION: boolean;
  127964. SS_RGBDREFRACTION: boolean;
  127965. SS_LINEARSPECULARREFRACTION: boolean;
  127966. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127967. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127968. UNLIT: boolean;
  127969. DEBUGMODE: number;
  127970. /**
  127971. * Initializes the PBR Material defines.
  127972. */
  127973. constructor();
  127974. /**
  127975. * Resets the PBR Material defines.
  127976. */
  127977. reset(): void;
  127978. }
  127979. /**
  127980. * The Physically based material base class of BJS.
  127981. *
  127982. * This offers the main features of a standard PBR material.
  127983. * For more information, please refer to the documentation :
  127984. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127985. */
  127986. export abstract class PBRBaseMaterial extends PushMaterial {
  127987. /**
  127988. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127989. */
  127990. static readonly PBRMATERIAL_OPAQUE: number;
  127991. /**
  127992. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127993. */
  127994. static readonly PBRMATERIAL_ALPHATEST: number;
  127995. /**
  127996. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127997. */
  127998. static readonly PBRMATERIAL_ALPHABLEND: number;
  127999. /**
  128000. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128001. * They are also discarded below the alpha cutoff threshold to improve performances.
  128002. */
  128003. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  128004. /**
  128005. * Defines the default value of how much AO map is occluding the analytical lights
  128006. * (point spot...).
  128007. */
  128008. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  128009. /**
  128010. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  128011. */
  128012. static readonly LIGHTFALLOFF_PHYSICAL: number;
  128013. /**
  128014. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  128015. * to enhance interoperability with other engines.
  128016. */
  128017. static readonly LIGHTFALLOFF_GLTF: number;
  128018. /**
  128019. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  128020. * to enhance interoperability with other materials.
  128021. */
  128022. static readonly LIGHTFALLOFF_STANDARD: number;
  128023. /**
  128024. * Intensity of the direct lights e.g. the four lights available in your scene.
  128025. * This impacts both the direct diffuse and specular highlights.
  128026. */
  128027. protected _directIntensity: number;
  128028. /**
  128029. * Intensity of the emissive part of the material.
  128030. * This helps controlling the emissive effect without modifying the emissive color.
  128031. */
  128032. protected _emissiveIntensity: number;
  128033. /**
  128034. * Intensity of the environment e.g. how much the environment will light the object
  128035. * either through harmonics for rough material or through the refelction for shiny ones.
  128036. */
  128037. protected _environmentIntensity: number;
  128038. /**
  128039. * This is a special control allowing the reduction of the specular highlights coming from the
  128040. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  128041. */
  128042. protected _specularIntensity: number;
  128043. /**
  128044. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  128045. */
  128046. private _lightingInfos;
  128047. /**
  128048. * Debug Control allowing disabling the bump map on this material.
  128049. */
  128050. protected _disableBumpMap: boolean;
  128051. /**
  128052. * AKA Diffuse Texture in standard nomenclature.
  128053. */
  128054. protected _albedoTexture: Nullable<BaseTexture>;
  128055. /**
  128056. * AKA Occlusion Texture in other nomenclature.
  128057. */
  128058. protected _ambientTexture: Nullable<BaseTexture>;
  128059. /**
  128060. * AKA Occlusion Texture Intensity in other nomenclature.
  128061. */
  128062. protected _ambientTextureStrength: number;
  128063. /**
  128064. * Defines how much the AO map is occluding the analytical lights (point spot...).
  128065. * 1 means it completely occludes it
  128066. * 0 mean it has no impact
  128067. */
  128068. protected _ambientTextureImpactOnAnalyticalLights: number;
  128069. /**
  128070. * Stores the alpha values in a texture.
  128071. */
  128072. protected _opacityTexture: Nullable<BaseTexture>;
  128073. /**
  128074. * Stores the reflection values in a texture.
  128075. */
  128076. protected _reflectionTexture: Nullable<BaseTexture>;
  128077. /**
  128078. * Stores the emissive values in a texture.
  128079. */
  128080. protected _emissiveTexture: Nullable<BaseTexture>;
  128081. /**
  128082. * AKA Specular texture in other nomenclature.
  128083. */
  128084. protected _reflectivityTexture: Nullable<BaseTexture>;
  128085. /**
  128086. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128087. */
  128088. protected _metallicTexture: Nullable<BaseTexture>;
  128089. /**
  128090. * Specifies the metallic scalar of the metallic/roughness workflow.
  128091. * Can also be used to scale the metalness values of the metallic texture.
  128092. */
  128093. protected _metallic: Nullable<number>;
  128094. /**
  128095. * Specifies the roughness scalar of the metallic/roughness workflow.
  128096. * Can also be used to scale the roughness values of the metallic texture.
  128097. */
  128098. protected _roughness: Nullable<number>;
  128099. /**
  128100. * Specifies the an F0 factor to help configuring the material F0.
  128101. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128102. * to 0.5 the previously hard coded value stays the same.
  128103. * Can also be used to scale the F0 values of the metallic texture.
  128104. */
  128105. protected _metallicF0Factor: number;
  128106. /**
  128107. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128108. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128109. * your expectation as it multiplies with the texture data.
  128110. */
  128111. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  128112. /**
  128113. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128114. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128115. */
  128116. protected _microSurfaceTexture: Nullable<BaseTexture>;
  128117. /**
  128118. * Stores surface normal data used to displace a mesh in a texture.
  128119. */
  128120. protected _bumpTexture: Nullable<BaseTexture>;
  128121. /**
  128122. * Stores the pre-calculated light information of a mesh in a texture.
  128123. */
  128124. protected _lightmapTexture: Nullable<BaseTexture>;
  128125. /**
  128126. * The color of a material in ambient lighting.
  128127. */
  128128. protected _ambientColor: Color3;
  128129. /**
  128130. * AKA Diffuse Color in other nomenclature.
  128131. */
  128132. protected _albedoColor: Color3;
  128133. /**
  128134. * AKA Specular Color in other nomenclature.
  128135. */
  128136. protected _reflectivityColor: Color3;
  128137. /**
  128138. * The color applied when light is reflected from a material.
  128139. */
  128140. protected _reflectionColor: Color3;
  128141. /**
  128142. * The color applied when light is emitted from a material.
  128143. */
  128144. protected _emissiveColor: Color3;
  128145. /**
  128146. * AKA Glossiness in other nomenclature.
  128147. */
  128148. protected _microSurface: number;
  128149. /**
  128150. * Specifies that the material will use the light map as a show map.
  128151. */
  128152. protected _useLightmapAsShadowmap: boolean;
  128153. /**
  128154. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128155. * makes the reflect vector face the model (under horizon).
  128156. */
  128157. protected _useHorizonOcclusion: boolean;
  128158. /**
  128159. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128160. * too much the area relying on ambient texture to define their ambient occlusion.
  128161. */
  128162. protected _useRadianceOcclusion: boolean;
  128163. /**
  128164. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128165. */
  128166. protected _useAlphaFromAlbedoTexture: boolean;
  128167. /**
  128168. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  128169. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128170. */
  128171. protected _useSpecularOverAlpha: boolean;
  128172. /**
  128173. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128174. */
  128175. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128176. /**
  128177. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128178. */
  128179. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  128180. /**
  128181. * Specifies if the metallic texture contains the roughness information in its green channel.
  128182. */
  128183. protected _useRoughnessFromMetallicTextureGreen: boolean;
  128184. /**
  128185. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128186. */
  128187. protected _useMetallnessFromMetallicTextureBlue: boolean;
  128188. /**
  128189. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128190. */
  128191. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  128192. /**
  128193. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128194. */
  128195. protected _useAmbientInGrayScale: boolean;
  128196. /**
  128197. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128198. * The material will try to infer what glossiness each pixel should be.
  128199. */
  128200. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  128201. /**
  128202. * Defines the falloff type used in this material.
  128203. * It by default is Physical.
  128204. */
  128205. protected _lightFalloff: number;
  128206. /**
  128207. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128208. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128209. */
  128210. protected _useRadianceOverAlpha: boolean;
  128211. /**
  128212. * Allows using an object space normal map (instead of tangent space).
  128213. */
  128214. protected _useObjectSpaceNormalMap: boolean;
  128215. /**
  128216. * Allows using the bump map in parallax mode.
  128217. */
  128218. protected _useParallax: boolean;
  128219. /**
  128220. * Allows using the bump map in parallax occlusion mode.
  128221. */
  128222. protected _useParallaxOcclusion: boolean;
  128223. /**
  128224. * Controls the scale bias of the parallax mode.
  128225. */
  128226. protected _parallaxScaleBias: number;
  128227. /**
  128228. * If sets to true, disables all the lights affecting the material.
  128229. */
  128230. protected _disableLighting: boolean;
  128231. /**
  128232. * Number of Simultaneous lights allowed on the material.
  128233. */
  128234. protected _maxSimultaneousLights: number;
  128235. /**
  128236. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  128237. */
  128238. protected _invertNormalMapX: boolean;
  128239. /**
  128240. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  128241. */
  128242. protected _invertNormalMapY: boolean;
  128243. /**
  128244. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128245. */
  128246. protected _twoSidedLighting: boolean;
  128247. /**
  128248. * Defines the alpha limits in alpha test mode.
  128249. */
  128250. protected _alphaCutOff: number;
  128251. /**
  128252. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128253. */
  128254. protected _forceAlphaTest: boolean;
  128255. /**
  128256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128257. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128258. */
  128259. protected _useAlphaFresnel: boolean;
  128260. /**
  128261. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128262. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128263. */
  128264. protected _useLinearAlphaFresnel: boolean;
  128265. /**
  128266. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  128267. * from cos thetav and roughness:
  128268. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  128269. */
  128270. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  128271. /**
  128272. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128273. */
  128274. protected _forceIrradianceInFragment: boolean;
  128275. /**
  128276. * Force normal to face away from face.
  128277. */
  128278. protected _forceNormalForward: boolean;
  128279. /**
  128280. * Enables specular anti aliasing in the PBR shader.
  128281. * It will both interacts on the Geometry for analytical and IBL lighting.
  128282. * It also prefilter the roughness map based on the bump values.
  128283. */
  128284. protected _enableSpecularAntiAliasing: boolean;
  128285. /**
  128286. * Default configuration related to image processing available in the PBR Material.
  128287. */
  128288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  128289. /**
  128290. * Keep track of the image processing observer to allow dispose and replace.
  128291. */
  128292. private _imageProcessingObserver;
  128293. /**
  128294. * Attaches a new image processing configuration to the PBR Material.
  128295. * @param configuration
  128296. */
  128297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  128298. /**
  128299. * Stores the available render targets.
  128300. */
  128301. private _renderTargets;
  128302. /**
  128303. * Sets the global ambient color for the material used in lighting calculations.
  128304. */
  128305. private _globalAmbientColor;
  128306. /**
  128307. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  128308. */
  128309. private _useLogarithmicDepth;
  128310. /**
  128311. * If set to true, no lighting calculations will be applied.
  128312. */
  128313. private _unlit;
  128314. private _debugMode;
  128315. /**
  128316. * @hidden
  128317. * This is reserved for the inspector.
  128318. * Defines the material debug mode.
  128319. * It helps seeing only some components of the material while troubleshooting.
  128320. */
  128321. debugMode: number;
  128322. /**
  128323. * @hidden
  128324. * This is reserved for the inspector.
  128325. * Specify from where on screen the debug mode should start.
  128326. * The value goes from -1 (full screen) to 1 (not visible)
  128327. * It helps with side by side comparison against the final render
  128328. * This defaults to -1
  128329. */
  128330. private debugLimit;
  128331. /**
  128332. * @hidden
  128333. * This is reserved for the inspector.
  128334. * As the default viewing range might not be enough (if the ambient is really small for instance)
  128335. * You can use the factor to better multiply the final value.
  128336. */
  128337. private debugFactor;
  128338. /**
  128339. * Defines the clear coat layer parameters for the material.
  128340. */
  128341. readonly clearCoat: PBRClearCoatConfiguration;
  128342. /**
  128343. * Defines the anisotropic parameters for the material.
  128344. */
  128345. readonly anisotropy: PBRAnisotropicConfiguration;
  128346. /**
  128347. * Defines the BRDF parameters for the material.
  128348. */
  128349. readonly brdf: PBRBRDFConfiguration;
  128350. /**
  128351. * Defines the Sheen parameters for the material.
  128352. */
  128353. readonly sheen: PBRSheenConfiguration;
  128354. /**
  128355. * Defines the SubSurface parameters for the material.
  128356. */
  128357. readonly subSurface: PBRSubSurfaceConfiguration;
  128358. protected _rebuildInParallel: boolean;
  128359. /**
  128360. * Instantiates a new PBRMaterial instance.
  128361. *
  128362. * @param name The material name
  128363. * @param scene The scene the material will be use in.
  128364. */
  128365. constructor(name: string, scene: Scene);
  128366. /**
  128367. * Gets a boolean indicating that current material needs to register RTT
  128368. */
  128369. get hasRenderTargetTextures(): boolean;
  128370. /**
  128371. * Gets the name of the material class.
  128372. */
  128373. getClassName(): string;
  128374. /**
  128375. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128376. */
  128377. get useLogarithmicDepth(): boolean;
  128378. /**
  128379. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128380. */
  128381. set useLogarithmicDepth(value: boolean);
  128382. /**
  128383. * Returns true if alpha blending should be disabled.
  128384. */
  128385. protected get _disableAlphaBlending(): boolean;
  128386. /**
  128387. * Specifies whether or not this material should be rendered in alpha blend mode.
  128388. */
  128389. needAlphaBlending(): boolean;
  128390. /**
  128391. * Specifies whether or not this material should be rendered in alpha test mode.
  128392. */
  128393. needAlphaTesting(): boolean;
  128394. /**
  128395. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  128396. */
  128397. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  128398. /**
  128399. * Gets the texture used for the alpha test.
  128400. */
  128401. getAlphaTestTexture(): Nullable<BaseTexture>;
  128402. /**
  128403. * Specifies that the submesh is ready to be used.
  128404. * @param mesh - BJS mesh.
  128405. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  128406. * @param useInstances - Specifies that instances should be used.
  128407. * @returns - boolean indicating that the submesh is ready or not.
  128408. */
  128409. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  128410. /**
  128411. * Specifies if the material uses metallic roughness workflow.
  128412. * @returns boolean specifiying if the material uses metallic roughness workflow.
  128413. */
  128414. isMetallicWorkflow(): boolean;
  128415. private _prepareEffect;
  128416. private _prepareDefines;
  128417. /**
  128418. * Force shader compilation
  128419. */
  128420. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  128421. /**
  128422. * Initializes the uniform buffer layout for the shader.
  128423. */
  128424. buildUniformLayout(): void;
  128425. /**
  128426. * Unbinds the material from the mesh
  128427. */
  128428. unbind(): void;
  128429. /**
  128430. * Binds the submesh data.
  128431. * @param world - The world matrix.
  128432. * @param mesh - The BJS mesh.
  128433. * @param subMesh - A submesh of the BJS mesh.
  128434. */
  128435. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  128436. /**
  128437. * Returns the animatable textures.
  128438. * @returns - Array of animatable textures.
  128439. */
  128440. getAnimatables(): IAnimatable[];
  128441. /**
  128442. * Returns the texture used for reflections.
  128443. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  128444. */
  128445. private _getReflectionTexture;
  128446. /**
  128447. * Returns an array of the actively used textures.
  128448. * @returns - Array of BaseTextures
  128449. */
  128450. getActiveTextures(): BaseTexture[];
  128451. /**
  128452. * Checks to see if a texture is used in the material.
  128453. * @param texture - Base texture to use.
  128454. * @returns - Boolean specifying if a texture is used in the material.
  128455. */
  128456. hasTexture(texture: BaseTexture): boolean;
  128457. /**
  128458. * Disposes the resources of the material.
  128459. * @param forceDisposeEffect - Forces the disposal of effects.
  128460. * @param forceDisposeTextures - Forces the disposal of all textures.
  128461. */
  128462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  128463. }
  128464. }
  128465. declare module BABYLON {
  128466. /**
  128467. * The Physically based material of BJS.
  128468. *
  128469. * This offers the main features of a standard PBR material.
  128470. * For more information, please refer to the documentation :
  128471. * https://doc.babylonjs.com/how_to/physically_based_rendering
  128472. */
  128473. export class PBRMaterial extends PBRBaseMaterial {
  128474. /**
  128475. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  128476. */
  128477. static readonly PBRMATERIAL_OPAQUE: number;
  128478. /**
  128479. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  128480. */
  128481. static readonly PBRMATERIAL_ALPHATEST: number;
  128482. /**
  128483. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128484. */
  128485. static readonly PBRMATERIAL_ALPHABLEND: number;
  128486. /**
  128487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128488. * They are also discarded below the alpha cutoff threshold to improve performances.
  128489. */
  128490. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  128491. /**
  128492. * Defines the default value of how much AO map is occluding the analytical lights
  128493. * (point spot...).
  128494. */
  128495. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  128496. /**
  128497. * Intensity of the direct lights e.g. the four lights available in your scene.
  128498. * This impacts both the direct diffuse and specular highlights.
  128499. */
  128500. directIntensity: number;
  128501. /**
  128502. * Intensity of the emissive part of the material.
  128503. * This helps controlling the emissive effect without modifying the emissive color.
  128504. */
  128505. emissiveIntensity: number;
  128506. /**
  128507. * Intensity of the environment e.g. how much the environment will light the object
  128508. * either through harmonics for rough material or through the refelction for shiny ones.
  128509. */
  128510. environmentIntensity: number;
  128511. /**
  128512. * This is a special control allowing the reduction of the specular highlights coming from the
  128513. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  128514. */
  128515. specularIntensity: number;
  128516. /**
  128517. * Debug Control allowing disabling the bump map on this material.
  128518. */
  128519. disableBumpMap: boolean;
  128520. /**
  128521. * AKA Diffuse Texture in standard nomenclature.
  128522. */
  128523. albedoTexture: BaseTexture;
  128524. /**
  128525. * AKA Occlusion Texture in other nomenclature.
  128526. */
  128527. ambientTexture: BaseTexture;
  128528. /**
  128529. * AKA Occlusion Texture Intensity in other nomenclature.
  128530. */
  128531. ambientTextureStrength: number;
  128532. /**
  128533. * Defines how much the AO map is occluding the analytical lights (point spot...).
  128534. * 1 means it completely occludes it
  128535. * 0 mean it has no impact
  128536. */
  128537. ambientTextureImpactOnAnalyticalLights: number;
  128538. /**
  128539. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  128540. */
  128541. opacityTexture: BaseTexture;
  128542. /**
  128543. * Stores the reflection values in a texture.
  128544. */
  128545. reflectionTexture: Nullable<BaseTexture>;
  128546. /**
  128547. * Stores the emissive values in a texture.
  128548. */
  128549. emissiveTexture: BaseTexture;
  128550. /**
  128551. * AKA Specular texture in other nomenclature.
  128552. */
  128553. reflectivityTexture: BaseTexture;
  128554. /**
  128555. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128556. */
  128557. metallicTexture: BaseTexture;
  128558. /**
  128559. * Specifies the metallic scalar of the metallic/roughness workflow.
  128560. * Can also be used to scale the metalness values of the metallic texture.
  128561. */
  128562. metallic: Nullable<number>;
  128563. /**
  128564. * Specifies the roughness scalar of the metallic/roughness workflow.
  128565. * Can also be used to scale the roughness values of the metallic texture.
  128566. */
  128567. roughness: Nullable<number>;
  128568. /**
  128569. * Specifies the an F0 factor to help configuring the material F0.
  128570. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128571. * to 0.5 the previously hard coded value stays the same.
  128572. * Can also be used to scale the F0 values of the metallic texture.
  128573. */
  128574. metallicF0Factor: number;
  128575. /**
  128576. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128577. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128578. * your expectation as it multiplies with the texture data.
  128579. */
  128580. useMetallicF0FactorFromMetallicTexture: boolean;
  128581. /**
  128582. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128583. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128584. */
  128585. microSurfaceTexture: BaseTexture;
  128586. /**
  128587. * Stores surface normal data used to displace a mesh in a texture.
  128588. */
  128589. bumpTexture: BaseTexture;
  128590. /**
  128591. * Stores the pre-calculated light information of a mesh in a texture.
  128592. */
  128593. lightmapTexture: BaseTexture;
  128594. /**
  128595. * Stores the refracted light information in a texture.
  128596. */
  128597. get refractionTexture(): Nullable<BaseTexture>;
  128598. set refractionTexture(value: Nullable<BaseTexture>);
  128599. /**
  128600. * The color of a material in ambient lighting.
  128601. */
  128602. ambientColor: Color3;
  128603. /**
  128604. * AKA Diffuse Color in other nomenclature.
  128605. */
  128606. albedoColor: Color3;
  128607. /**
  128608. * AKA Specular Color in other nomenclature.
  128609. */
  128610. reflectivityColor: Color3;
  128611. /**
  128612. * The color reflected from the material.
  128613. */
  128614. reflectionColor: Color3;
  128615. /**
  128616. * The color emitted from the material.
  128617. */
  128618. emissiveColor: Color3;
  128619. /**
  128620. * AKA Glossiness in other nomenclature.
  128621. */
  128622. microSurface: number;
  128623. /**
  128624. * source material index of refraction (IOR)' / 'destination material IOR.
  128625. */
  128626. get indexOfRefraction(): number;
  128627. set indexOfRefraction(value: number);
  128628. /**
  128629. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  128630. */
  128631. get invertRefractionY(): boolean;
  128632. set invertRefractionY(value: boolean);
  128633. /**
  128634. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  128635. * Materials half opaque for instance using refraction could benefit from this control.
  128636. */
  128637. get linkRefractionWithTransparency(): boolean;
  128638. set linkRefractionWithTransparency(value: boolean);
  128639. /**
  128640. * If true, the light map contains occlusion information instead of lighting info.
  128641. */
  128642. useLightmapAsShadowmap: boolean;
  128643. /**
  128644. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128645. */
  128646. useAlphaFromAlbedoTexture: boolean;
  128647. /**
  128648. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128649. */
  128650. forceAlphaTest: boolean;
  128651. /**
  128652. * Defines the alpha limits in alpha test mode.
  128653. */
  128654. alphaCutOff: number;
  128655. /**
  128656. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  128657. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128658. */
  128659. useSpecularOverAlpha: boolean;
  128660. /**
  128661. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128662. */
  128663. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128664. /**
  128665. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128666. */
  128667. useRoughnessFromMetallicTextureAlpha: boolean;
  128668. /**
  128669. * Specifies if the metallic texture contains the roughness information in its green channel.
  128670. */
  128671. useRoughnessFromMetallicTextureGreen: boolean;
  128672. /**
  128673. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128674. */
  128675. useMetallnessFromMetallicTextureBlue: boolean;
  128676. /**
  128677. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128678. */
  128679. useAmbientOcclusionFromMetallicTextureRed: boolean;
  128680. /**
  128681. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128682. */
  128683. useAmbientInGrayScale: boolean;
  128684. /**
  128685. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128686. * The material will try to infer what glossiness each pixel should be.
  128687. */
  128688. useAutoMicroSurfaceFromReflectivityMap: boolean;
  128689. /**
  128690. * BJS is using an harcoded light falloff based on a manually sets up range.
  128691. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128692. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128693. */
  128694. get usePhysicalLightFalloff(): boolean;
  128695. /**
  128696. * BJS is using an harcoded light falloff based on a manually sets up range.
  128697. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128698. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128699. */
  128700. set usePhysicalLightFalloff(value: boolean);
  128701. /**
  128702. * In order to support the falloff compatibility with gltf, a special mode has been added
  128703. * to reproduce the gltf light falloff.
  128704. */
  128705. get useGLTFLightFalloff(): boolean;
  128706. /**
  128707. * In order to support the falloff compatibility with gltf, a special mode has been added
  128708. * to reproduce the gltf light falloff.
  128709. */
  128710. set useGLTFLightFalloff(value: boolean);
  128711. /**
  128712. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128713. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128714. */
  128715. useRadianceOverAlpha: boolean;
  128716. /**
  128717. * Allows using an object space normal map (instead of tangent space).
  128718. */
  128719. useObjectSpaceNormalMap: boolean;
  128720. /**
  128721. * Allows using the bump map in parallax mode.
  128722. */
  128723. useParallax: boolean;
  128724. /**
  128725. * Allows using the bump map in parallax occlusion mode.
  128726. */
  128727. useParallaxOcclusion: boolean;
  128728. /**
  128729. * Controls the scale bias of the parallax mode.
  128730. */
  128731. parallaxScaleBias: number;
  128732. /**
  128733. * If sets to true, disables all the lights affecting the material.
  128734. */
  128735. disableLighting: boolean;
  128736. /**
  128737. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128738. */
  128739. forceIrradianceInFragment: boolean;
  128740. /**
  128741. * Number of Simultaneous lights allowed on the material.
  128742. */
  128743. maxSimultaneousLights: number;
  128744. /**
  128745. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128746. */
  128747. invertNormalMapX: boolean;
  128748. /**
  128749. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128750. */
  128751. invertNormalMapY: boolean;
  128752. /**
  128753. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128754. */
  128755. twoSidedLighting: boolean;
  128756. /**
  128757. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128758. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128759. */
  128760. useAlphaFresnel: boolean;
  128761. /**
  128762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128763. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128764. */
  128765. useLinearAlphaFresnel: boolean;
  128766. /**
  128767. * Let user defines the brdf lookup texture used for IBL.
  128768. * A default 8bit version is embedded but you could point at :
  128769. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  128770. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  128771. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  128772. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  128773. */
  128774. environmentBRDFTexture: Nullable<BaseTexture>;
  128775. /**
  128776. * Force normal to face away from face.
  128777. */
  128778. forceNormalForward: boolean;
  128779. /**
  128780. * Enables specular anti aliasing in the PBR shader.
  128781. * It will both interacts on the Geometry for analytical and IBL lighting.
  128782. * It also prefilter the roughness map based on the bump values.
  128783. */
  128784. enableSpecularAntiAliasing: boolean;
  128785. /**
  128786. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128787. * makes the reflect vector face the model (under horizon).
  128788. */
  128789. useHorizonOcclusion: boolean;
  128790. /**
  128791. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128792. * too much the area relying on ambient texture to define their ambient occlusion.
  128793. */
  128794. useRadianceOcclusion: boolean;
  128795. /**
  128796. * If set to true, no lighting calculations will be applied.
  128797. */
  128798. unlit: boolean;
  128799. /**
  128800. * Gets the image processing configuration used either in this material.
  128801. */
  128802. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  128803. /**
  128804. * Sets the Default image processing configuration used either in the this material.
  128805. *
  128806. * If sets to null, the scene one is in use.
  128807. */
  128808. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  128809. /**
  128810. * Gets wether the color curves effect is enabled.
  128811. */
  128812. get cameraColorCurvesEnabled(): boolean;
  128813. /**
  128814. * Sets wether the color curves effect is enabled.
  128815. */
  128816. set cameraColorCurvesEnabled(value: boolean);
  128817. /**
  128818. * Gets wether the color grading effect is enabled.
  128819. */
  128820. get cameraColorGradingEnabled(): boolean;
  128821. /**
  128822. * Gets wether the color grading effect is enabled.
  128823. */
  128824. set cameraColorGradingEnabled(value: boolean);
  128825. /**
  128826. * Gets wether tonemapping is enabled or not.
  128827. */
  128828. get cameraToneMappingEnabled(): boolean;
  128829. /**
  128830. * Sets wether tonemapping is enabled or not
  128831. */
  128832. set cameraToneMappingEnabled(value: boolean);
  128833. /**
  128834. * The camera exposure used on this material.
  128835. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128836. * This corresponds to a photographic exposure.
  128837. */
  128838. get cameraExposure(): number;
  128839. /**
  128840. * The camera exposure used on this material.
  128841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128842. * This corresponds to a photographic exposure.
  128843. */
  128844. set cameraExposure(value: number);
  128845. /**
  128846. * Gets The camera contrast used on this material.
  128847. */
  128848. get cameraContrast(): number;
  128849. /**
  128850. * Sets The camera contrast used on this material.
  128851. */
  128852. set cameraContrast(value: number);
  128853. /**
  128854. * Gets the Color Grading 2D Lookup Texture.
  128855. */
  128856. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  128857. /**
  128858. * Sets the Color Grading 2D Lookup Texture.
  128859. */
  128860. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  128861. /**
  128862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128864. * 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;
  128865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128866. */
  128867. get cameraColorCurves(): Nullable<ColorCurves>;
  128868. /**
  128869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128871. * 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;
  128872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128873. */
  128874. set cameraColorCurves(value: Nullable<ColorCurves>);
  128875. /**
  128876. * Instantiates a new PBRMaterial instance.
  128877. *
  128878. * @param name The material name
  128879. * @param scene The scene the material will be use in.
  128880. */
  128881. constructor(name: string, scene: Scene);
  128882. /**
  128883. * Returns the name of this material class.
  128884. */
  128885. getClassName(): string;
  128886. /**
  128887. * Makes a duplicate of the current material.
  128888. * @param name - name to use for the new material.
  128889. */
  128890. clone(name: string): PBRMaterial;
  128891. /**
  128892. * Serializes this PBR Material.
  128893. * @returns - An object with the serialized material.
  128894. */
  128895. serialize(): any;
  128896. /**
  128897. * Parses a PBR Material from a serialized object.
  128898. * @param source - Serialized object.
  128899. * @param scene - BJS scene instance.
  128900. * @param rootUrl - url for the scene object
  128901. * @returns - PBRMaterial
  128902. */
  128903. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  128904. }
  128905. }
  128906. declare module BABYLON {
  128907. /**
  128908. * Direct draw surface info
  128909. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  128910. */
  128911. export interface DDSInfo {
  128912. /**
  128913. * Width of the texture
  128914. */
  128915. width: number;
  128916. /**
  128917. * Width of the texture
  128918. */
  128919. height: number;
  128920. /**
  128921. * Number of Mipmaps for the texture
  128922. * @see https://en.wikipedia.org/wiki/Mipmap
  128923. */
  128924. mipmapCount: number;
  128925. /**
  128926. * If the textures format is a known fourCC format
  128927. * @see https://www.fourcc.org/
  128928. */
  128929. isFourCC: boolean;
  128930. /**
  128931. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  128932. */
  128933. isRGB: boolean;
  128934. /**
  128935. * If the texture is a lumincance format
  128936. */
  128937. isLuminance: boolean;
  128938. /**
  128939. * If this is a cube texture
  128940. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  128941. */
  128942. isCube: boolean;
  128943. /**
  128944. * If the texture is a compressed format eg. FOURCC_DXT1
  128945. */
  128946. isCompressed: boolean;
  128947. /**
  128948. * The dxgiFormat of the texture
  128949. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  128950. */
  128951. dxgiFormat: number;
  128952. /**
  128953. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  128954. */
  128955. textureType: number;
  128956. /**
  128957. * Sphericle polynomial created for the dds texture
  128958. */
  128959. sphericalPolynomial?: SphericalPolynomial;
  128960. }
  128961. /**
  128962. * Class used to provide DDS decompression tools
  128963. */
  128964. export class DDSTools {
  128965. /**
  128966. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  128967. */
  128968. static StoreLODInAlphaChannel: boolean;
  128969. /**
  128970. * Gets DDS information from an array buffer
  128971. * @param data defines the array buffer view to read data from
  128972. * @returns the DDS information
  128973. */
  128974. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  128975. private static _FloatView;
  128976. private static _Int32View;
  128977. private static _ToHalfFloat;
  128978. private static _FromHalfFloat;
  128979. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  128980. private static _GetHalfFloatRGBAArrayBuffer;
  128981. private static _GetFloatRGBAArrayBuffer;
  128982. private static _GetFloatAsUIntRGBAArrayBuffer;
  128983. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  128984. private static _GetRGBAArrayBuffer;
  128985. private static _ExtractLongWordOrder;
  128986. private static _GetRGBArrayBuffer;
  128987. private static _GetLuminanceArrayBuffer;
  128988. /**
  128989. * Uploads DDS Levels to a Babylon Texture
  128990. * @hidden
  128991. */
  128992. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  128993. }
  128994. interface ThinEngine {
  128995. /**
  128996. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  128997. * @param rootUrl defines the url where the file to load is located
  128998. * @param scene defines the current scene
  128999. * @param lodScale defines scale to apply to the mip map selection
  129000. * @param lodOffset defines offset to apply to the mip map selection
  129001. * @param onLoad defines an optional callback raised when the texture is loaded
  129002. * @param onError defines an optional callback raised if there is an issue to load the texture
  129003. * @param format defines the format of the data
  129004. * @param forcedExtension defines the extension to use to pick the right loader
  129005. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  129006. * @returns the cube texture as an InternalTexture
  129007. */
  129008. 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;
  129009. }
  129010. }
  129011. declare module BABYLON {
  129012. /**
  129013. * Implementation of the DDS Texture Loader.
  129014. * @hidden
  129015. */
  129016. export class _DDSTextureLoader implements IInternalTextureLoader {
  129017. /**
  129018. * Defines wether the loader supports cascade loading the different faces.
  129019. */
  129020. readonly supportCascades: boolean;
  129021. /**
  129022. * This returns if the loader support the current file information.
  129023. * @param extension defines the file extension of the file being loaded
  129024. * @returns true if the loader can load the specified file
  129025. */
  129026. canLoad(extension: string): boolean;
  129027. /**
  129028. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129029. * @param data contains the texture data
  129030. * @param texture defines the BabylonJS internal texture
  129031. * @param createPolynomials will be true if polynomials have been requested
  129032. * @param onLoad defines the callback to trigger once the texture is ready
  129033. * @param onError defines the callback to trigger in case of error
  129034. */
  129035. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129036. /**
  129037. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129038. * @param data contains the texture data
  129039. * @param texture defines the BabylonJS internal texture
  129040. * @param callback defines the method to call once ready to upload
  129041. */
  129042. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129043. }
  129044. }
  129045. declare module BABYLON {
  129046. /**
  129047. * Implementation of the ENV Texture Loader.
  129048. * @hidden
  129049. */
  129050. export class _ENVTextureLoader implements IInternalTextureLoader {
  129051. /**
  129052. * Defines wether the loader supports cascade loading the different faces.
  129053. */
  129054. readonly supportCascades: boolean;
  129055. /**
  129056. * This returns if the loader support the current file information.
  129057. * @param extension defines the file extension of the file being loaded
  129058. * @returns true if the loader can load the specified file
  129059. */
  129060. canLoad(extension: string): boolean;
  129061. /**
  129062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129063. * @param data contains the texture data
  129064. * @param texture defines the BabylonJS internal texture
  129065. * @param createPolynomials will be true if polynomials have been requested
  129066. * @param onLoad defines the callback to trigger once the texture is ready
  129067. * @param onError defines the callback to trigger in case of error
  129068. */
  129069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129070. /**
  129071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129072. * @param data contains the texture data
  129073. * @param texture defines the BabylonJS internal texture
  129074. * @param callback defines the method to call once ready to upload
  129075. */
  129076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129077. }
  129078. }
  129079. declare module BABYLON {
  129080. /**
  129081. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129082. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129083. */
  129084. export class KhronosTextureContainer {
  129085. /** contents of the KTX container file */
  129086. data: ArrayBufferView;
  129087. private static HEADER_LEN;
  129088. private static COMPRESSED_2D;
  129089. private static COMPRESSED_3D;
  129090. private static TEX_2D;
  129091. private static TEX_3D;
  129092. /**
  129093. * Gets the openGL type
  129094. */
  129095. glType: number;
  129096. /**
  129097. * Gets the openGL type size
  129098. */
  129099. glTypeSize: number;
  129100. /**
  129101. * Gets the openGL format
  129102. */
  129103. glFormat: number;
  129104. /**
  129105. * Gets the openGL internal format
  129106. */
  129107. glInternalFormat: number;
  129108. /**
  129109. * Gets the base internal format
  129110. */
  129111. glBaseInternalFormat: number;
  129112. /**
  129113. * Gets image width in pixel
  129114. */
  129115. pixelWidth: number;
  129116. /**
  129117. * Gets image height in pixel
  129118. */
  129119. pixelHeight: number;
  129120. /**
  129121. * Gets image depth in pixels
  129122. */
  129123. pixelDepth: number;
  129124. /**
  129125. * Gets the number of array elements
  129126. */
  129127. numberOfArrayElements: number;
  129128. /**
  129129. * Gets the number of faces
  129130. */
  129131. numberOfFaces: number;
  129132. /**
  129133. * Gets the number of mipmap levels
  129134. */
  129135. numberOfMipmapLevels: number;
  129136. /**
  129137. * Gets the bytes of key value data
  129138. */
  129139. bytesOfKeyValueData: number;
  129140. /**
  129141. * Gets the load type
  129142. */
  129143. loadType: number;
  129144. /**
  129145. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  129146. */
  129147. isInvalid: boolean;
  129148. /**
  129149. * Creates a new KhronosTextureContainer
  129150. * @param data contents of the KTX container file
  129151. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  129152. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  129153. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  129154. */
  129155. constructor(
  129156. /** contents of the KTX container file */
  129157. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  129158. /**
  129159. * Uploads KTX content to a Babylon Texture.
  129160. * It is assumed that the texture has already been created & is currently bound
  129161. * @hidden
  129162. */
  129163. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  129164. private _upload2DCompressedLevels;
  129165. /**
  129166. * Checks if the given data starts with a KTX file identifier.
  129167. * @param data the data to check
  129168. * @returns true if the data is a KTX file or false otherwise
  129169. */
  129170. static IsValid(data: ArrayBufferView): boolean;
  129171. }
  129172. }
  129173. declare module BABYLON {
  129174. /**
  129175. * Class for loading KTX2 files
  129176. * !!! Experimental Extension Subject to Changes !!!
  129177. * @hidden
  129178. */
  129179. export class KhronosTextureContainer2 {
  129180. private static _ModulePromise;
  129181. private static _TranscodeFormat;
  129182. constructor(engine: ThinEngine);
  129183. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  129184. private _determineTranscodeFormat;
  129185. /**
  129186. * Checks if the given data starts with a KTX2 file identifier.
  129187. * @param data the data to check
  129188. * @returns true if the data is a KTX2 file or false otherwise
  129189. */
  129190. static IsValid(data: ArrayBufferView): boolean;
  129191. }
  129192. }
  129193. declare module BABYLON {
  129194. /**
  129195. * Implementation of the KTX Texture Loader.
  129196. * @hidden
  129197. */
  129198. export class _KTXTextureLoader implements IInternalTextureLoader {
  129199. /**
  129200. * Defines wether the loader supports cascade loading the different faces.
  129201. */
  129202. readonly supportCascades: boolean;
  129203. /**
  129204. * This returns if the loader support the current file information.
  129205. * @param extension defines the file extension of the file being loaded
  129206. * @returns true if the loader can load the specified file
  129207. */
  129208. canLoad(extension: string): boolean;
  129209. /**
  129210. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129211. * @param data contains the texture data
  129212. * @param texture defines the BabylonJS internal texture
  129213. * @param createPolynomials will be true if polynomials have been requested
  129214. * @param onLoad defines the callback to trigger once the texture is ready
  129215. * @param onError defines the callback to trigger in case of error
  129216. */
  129217. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129218. /**
  129219. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129220. * @param data contains the texture data
  129221. * @param texture defines the BabylonJS internal texture
  129222. * @param callback defines the method to call once ready to upload
  129223. */
  129224. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  129225. }
  129226. }
  129227. declare module BABYLON {
  129228. /** @hidden */
  129229. export var _forceSceneHelpersToBundle: boolean;
  129230. interface Scene {
  129231. /**
  129232. * Creates a default light for the scene.
  129233. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  129234. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  129235. */
  129236. createDefaultLight(replace?: boolean): void;
  129237. /**
  129238. * Creates a default camera for the scene.
  129239. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  129240. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129241. * @param replace has default false, when true replaces the active camera in the scene
  129242. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  129243. */
  129244. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129245. /**
  129246. * Creates a default camera and a default light.
  129247. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  129248. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129249. * @param replace has the default false, when true replaces the active camera/light in the scene
  129250. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  129251. */
  129252. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129253. /**
  129254. * Creates a new sky box
  129255. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  129256. * @param environmentTexture defines the texture to use as environment texture
  129257. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  129258. * @param scale defines the overall scale of the skybox
  129259. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  129260. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  129261. * @returns a new mesh holding the sky box
  129262. */
  129263. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  129264. /**
  129265. * Creates a new environment
  129266. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  129267. * @param options defines the options you can use to configure the environment
  129268. * @returns the new EnvironmentHelper
  129269. */
  129270. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  129271. /**
  129272. * Creates a new VREXperienceHelper
  129273. * @see http://doc.babylonjs.com/how_to/webvr_helper
  129274. * @param webVROptions defines the options used to create the new VREXperienceHelper
  129275. * @returns a new VREXperienceHelper
  129276. */
  129277. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  129278. /**
  129279. * Creates a new WebXRDefaultExperience
  129280. * @see http://doc.babylonjs.com/how_to/webxr
  129281. * @param options experience options
  129282. * @returns a promise for a new WebXRDefaultExperience
  129283. */
  129284. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129285. }
  129286. }
  129287. declare module BABYLON {
  129288. /**
  129289. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  129290. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  129291. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  129292. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  129293. */
  129294. export class VideoDome extends TransformNode {
  129295. /**
  129296. * Define the video source as a Monoscopic panoramic 360 video.
  129297. */
  129298. static readonly MODE_MONOSCOPIC: number;
  129299. /**
  129300. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129301. */
  129302. static readonly MODE_TOPBOTTOM: number;
  129303. /**
  129304. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129305. */
  129306. static readonly MODE_SIDEBYSIDE: number;
  129307. private _halfDome;
  129308. private _useDirectMapping;
  129309. /**
  129310. * The video texture being displayed on the sphere
  129311. */
  129312. protected _videoTexture: VideoTexture;
  129313. /**
  129314. * Gets the video texture being displayed on the sphere
  129315. */
  129316. get videoTexture(): VideoTexture;
  129317. /**
  129318. * The skybox material
  129319. */
  129320. protected _material: BackgroundMaterial;
  129321. /**
  129322. * The surface used for the skybox
  129323. */
  129324. protected _mesh: Mesh;
  129325. /**
  129326. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  129327. */
  129328. private _halfDomeMask;
  129329. /**
  129330. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129331. * Also see the options.resolution property.
  129332. */
  129333. get fovMultiplier(): number;
  129334. set fovMultiplier(value: number);
  129335. private _videoMode;
  129336. /**
  129337. * Gets or set the current video mode for the video. It can be:
  129338. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  129339. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129340. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129341. */
  129342. get videoMode(): number;
  129343. set videoMode(value: number);
  129344. /**
  129345. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  129346. *
  129347. */
  129348. get halfDome(): boolean;
  129349. /**
  129350. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  129351. */
  129352. set halfDome(enabled: boolean);
  129353. /**
  129354. * Oberserver used in Stereoscopic VR Mode.
  129355. */
  129356. private _onBeforeCameraRenderObserver;
  129357. /**
  129358. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  129359. * @param name Element's name, child elements will append suffixes for their own names.
  129360. * @param urlsOrVideo defines the url(s) or the video element to use
  129361. * @param options An object containing optional or exposed sub element properties
  129362. */
  129363. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  129364. resolution?: number;
  129365. clickToPlay?: boolean;
  129366. autoPlay?: boolean;
  129367. loop?: boolean;
  129368. size?: number;
  129369. poster?: string;
  129370. faceForward?: boolean;
  129371. useDirectMapping?: boolean;
  129372. halfDomeMode?: boolean;
  129373. }, scene: Scene);
  129374. private _changeVideoMode;
  129375. /**
  129376. * Releases resources associated with this node.
  129377. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129378. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129379. */
  129380. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  129381. }
  129382. }
  129383. declare module BABYLON {
  129384. /**
  129385. * This class can be used to get instrumentation data from a Babylon engine
  129386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129387. */
  129388. export class EngineInstrumentation implements IDisposable {
  129389. /**
  129390. * Define the instrumented engine.
  129391. */
  129392. engine: Engine;
  129393. private _captureGPUFrameTime;
  129394. private _gpuFrameTimeToken;
  129395. private _gpuFrameTime;
  129396. private _captureShaderCompilationTime;
  129397. private _shaderCompilationTime;
  129398. private _onBeginFrameObserver;
  129399. private _onEndFrameObserver;
  129400. private _onBeforeShaderCompilationObserver;
  129401. private _onAfterShaderCompilationObserver;
  129402. /**
  129403. * Gets the perf counter used for GPU frame time
  129404. */
  129405. get gpuFrameTimeCounter(): PerfCounter;
  129406. /**
  129407. * Gets the GPU frame time capture status
  129408. */
  129409. get captureGPUFrameTime(): boolean;
  129410. /**
  129411. * Enable or disable the GPU frame time capture
  129412. */
  129413. set captureGPUFrameTime(value: boolean);
  129414. /**
  129415. * Gets the perf counter used for shader compilation time
  129416. */
  129417. get shaderCompilationTimeCounter(): PerfCounter;
  129418. /**
  129419. * Gets the shader compilation time capture status
  129420. */
  129421. get captureShaderCompilationTime(): boolean;
  129422. /**
  129423. * Enable or disable the shader compilation time capture
  129424. */
  129425. set captureShaderCompilationTime(value: boolean);
  129426. /**
  129427. * Instantiates a new engine instrumentation.
  129428. * This class can be used to get instrumentation data from a Babylon engine
  129429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129430. * @param engine Defines the engine to instrument
  129431. */
  129432. constructor(
  129433. /**
  129434. * Define the instrumented engine.
  129435. */
  129436. engine: Engine);
  129437. /**
  129438. * Dispose and release associated resources.
  129439. */
  129440. dispose(): void;
  129441. }
  129442. }
  129443. declare module BABYLON {
  129444. /**
  129445. * This class can be used to get instrumentation data from a Babylon engine
  129446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129447. */
  129448. export class SceneInstrumentation implements IDisposable {
  129449. /**
  129450. * Defines the scene to instrument
  129451. */
  129452. scene: Scene;
  129453. private _captureActiveMeshesEvaluationTime;
  129454. private _activeMeshesEvaluationTime;
  129455. private _captureRenderTargetsRenderTime;
  129456. private _renderTargetsRenderTime;
  129457. private _captureFrameTime;
  129458. private _frameTime;
  129459. private _captureRenderTime;
  129460. private _renderTime;
  129461. private _captureInterFrameTime;
  129462. private _interFrameTime;
  129463. private _captureParticlesRenderTime;
  129464. private _particlesRenderTime;
  129465. private _captureSpritesRenderTime;
  129466. private _spritesRenderTime;
  129467. private _capturePhysicsTime;
  129468. private _physicsTime;
  129469. private _captureAnimationsTime;
  129470. private _animationsTime;
  129471. private _captureCameraRenderTime;
  129472. private _cameraRenderTime;
  129473. private _onBeforeActiveMeshesEvaluationObserver;
  129474. private _onAfterActiveMeshesEvaluationObserver;
  129475. private _onBeforeRenderTargetsRenderObserver;
  129476. private _onAfterRenderTargetsRenderObserver;
  129477. private _onAfterRenderObserver;
  129478. private _onBeforeDrawPhaseObserver;
  129479. private _onAfterDrawPhaseObserver;
  129480. private _onBeforeAnimationsObserver;
  129481. private _onBeforeParticlesRenderingObserver;
  129482. private _onAfterParticlesRenderingObserver;
  129483. private _onBeforeSpritesRenderingObserver;
  129484. private _onAfterSpritesRenderingObserver;
  129485. private _onBeforePhysicsObserver;
  129486. private _onAfterPhysicsObserver;
  129487. private _onAfterAnimationsObserver;
  129488. private _onBeforeCameraRenderObserver;
  129489. private _onAfterCameraRenderObserver;
  129490. /**
  129491. * Gets the perf counter used for active meshes evaluation time
  129492. */
  129493. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  129494. /**
  129495. * Gets the active meshes evaluation time capture status
  129496. */
  129497. get captureActiveMeshesEvaluationTime(): boolean;
  129498. /**
  129499. * Enable or disable the active meshes evaluation time capture
  129500. */
  129501. set captureActiveMeshesEvaluationTime(value: boolean);
  129502. /**
  129503. * Gets the perf counter used for render targets render time
  129504. */
  129505. get renderTargetsRenderTimeCounter(): PerfCounter;
  129506. /**
  129507. * Gets the render targets render time capture status
  129508. */
  129509. get captureRenderTargetsRenderTime(): boolean;
  129510. /**
  129511. * Enable or disable the render targets render time capture
  129512. */
  129513. set captureRenderTargetsRenderTime(value: boolean);
  129514. /**
  129515. * Gets the perf counter used for particles render time
  129516. */
  129517. get particlesRenderTimeCounter(): PerfCounter;
  129518. /**
  129519. * Gets the particles render time capture status
  129520. */
  129521. get captureParticlesRenderTime(): boolean;
  129522. /**
  129523. * Enable or disable the particles render time capture
  129524. */
  129525. set captureParticlesRenderTime(value: boolean);
  129526. /**
  129527. * Gets the perf counter used for sprites render time
  129528. */
  129529. get spritesRenderTimeCounter(): PerfCounter;
  129530. /**
  129531. * Gets the sprites render time capture status
  129532. */
  129533. get captureSpritesRenderTime(): boolean;
  129534. /**
  129535. * Enable or disable the sprites render time capture
  129536. */
  129537. set captureSpritesRenderTime(value: boolean);
  129538. /**
  129539. * Gets the perf counter used for physics time
  129540. */
  129541. get physicsTimeCounter(): PerfCounter;
  129542. /**
  129543. * Gets the physics time capture status
  129544. */
  129545. get capturePhysicsTime(): boolean;
  129546. /**
  129547. * Enable or disable the physics time capture
  129548. */
  129549. set capturePhysicsTime(value: boolean);
  129550. /**
  129551. * Gets the perf counter used for animations time
  129552. */
  129553. get animationsTimeCounter(): PerfCounter;
  129554. /**
  129555. * Gets the animations time capture status
  129556. */
  129557. get captureAnimationsTime(): boolean;
  129558. /**
  129559. * Enable or disable the animations time capture
  129560. */
  129561. set captureAnimationsTime(value: boolean);
  129562. /**
  129563. * Gets the perf counter used for frame time capture
  129564. */
  129565. get frameTimeCounter(): PerfCounter;
  129566. /**
  129567. * Gets the frame time capture status
  129568. */
  129569. get captureFrameTime(): boolean;
  129570. /**
  129571. * Enable or disable the frame time capture
  129572. */
  129573. set captureFrameTime(value: boolean);
  129574. /**
  129575. * Gets the perf counter used for inter-frames time capture
  129576. */
  129577. get interFrameTimeCounter(): PerfCounter;
  129578. /**
  129579. * Gets the inter-frames time capture status
  129580. */
  129581. get captureInterFrameTime(): boolean;
  129582. /**
  129583. * Enable or disable the inter-frames time capture
  129584. */
  129585. set captureInterFrameTime(value: boolean);
  129586. /**
  129587. * Gets the perf counter used for render time capture
  129588. */
  129589. get renderTimeCounter(): PerfCounter;
  129590. /**
  129591. * Gets the render time capture status
  129592. */
  129593. get captureRenderTime(): boolean;
  129594. /**
  129595. * Enable or disable the render time capture
  129596. */
  129597. set captureRenderTime(value: boolean);
  129598. /**
  129599. * Gets the perf counter used for camera render time capture
  129600. */
  129601. get cameraRenderTimeCounter(): PerfCounter;
  129602. /**
  129603. * Gets the camera render time capture status
  129604. */
  129605. get captureCameraRenderTime(): boolean;
  129606. /**
  129607. * Enable or disable the camera render time capture
  129608. */
  129609. set captureCameraRenderTime(value: boolean);
  129610. /**
  129611. * Gets the perf counter used for draw calls
  129612. */
  129613. get drawCallsCounter(): PerfCounter;
  129614. /**
  129615. * Instantiates a new scene instrumentation.
  129616. * This class can be used to get instrumentation data from a Babylon engine
  129617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129618. * @param scene Defines the scene to instrument
  129619. */
  129620. constructor(
  129621. /**
  129622. * Defines the scene to instrument
  129623. */
  129624. scene: Scene);
  129625. /**
  129626. * Dispose and release associated resources.
  129627. */
  129628. dispose(): void;
  129629. }
  129630. }
  129631. declare module BABYLON {
  129632. /** @hidden */
  129633. export var glowMapGenerationPixelShader: {
  129634. name: string;
  129635. shader: string;
  129636. };
  129637. }
  129638. declare module BABYLON {
  129639. /** @hidden */
  129640. export var glowMapGenerationVertexShader: {
  129641. name: string;
  129642. shader: string;
  129643. };
  129644. }
  129645. declare module BABYLON {
  129646. /**
  129647. * Effect layer options. This helps customizing the behaviour
  129648. * of the effect layer.
  129649. */
  129650. export interface IEffectLayerOptions {
  129651. /**
  129652. * Multiplication factor apply to the canvas size to compute the render target size
  129653. * used to generated the objects (the smaller the faster).
  129654. */
  129655. mainTextureRatio: number;
  129656. /**
  129657. * Enforces a fixed size texture to ensure effect stability across devices.
  129658. */
  129659. mainTextureFixedSize?: number;
  129660. /**
  129661. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  129662. */
  129663. alphaBlendingMode: number;
  129664. /**
  129665. * The camera attached to the layer.
  129666. */
  129667. camera: Nullable<Camera>;
  129668. /**
  129669. * The rendering group to draw the layer in.
  129670. */
  129671. renderingGroupId: number;
  129672. }
  129673. /**
  129674. * The effect layer Helps adding post process effect blended with the main pass.
  129675. *
  129676. * This can be for instance use to generate glow or higlight effects on the scene.
  129677. *
  129678. * The effect layer class can not be used directly and is intented to inherited from to be
  129679. * customized per effects.
  129680. */
  129681. export abstract class EffectLayer {
  129682. private _vertexBuffers;
  129683. private _indexBuffer;
  129684. private _cachedDefines;
  129685. private _effectLayerMapGenerationEffect;
  129686. private _effectLayerOptions;
  129687. private _mergeEffect;
  129688. protected _scene: Scene;
  129689. protected _engine: Engine;
  129690. protected _maxSize: number;
  129691. protected _mainTextureDesiredSize: ISize;
  129692. protected _mainTexture: RenderTargetTexture;
  129693. protected _shouldRender: boolean;
  129694. protected _postProcesses: PostProcess[];
  129695. protected _textures: BaseTexture[];
  129696. protected _emissiveTextureAndColor: {
  129697. texture: Nullable<BaseTexture>;
  129698. color: Color4;
  129699. };
  129700. /**
  129701. * The name of the layer
  129702. */
  129703. name: string;
  129704. /**
  129705. * The clear color of the texture used to generate the glow map.
  129706. */
  129707. neutralColor: Color4;
  129708. /**
  129709. * Specifies whether the highlight layer is enabled or not.
  129710. */
  129711. isEnabled: boolean;
  129712. /**
  129713. * Gets the camera attached to the layer.
  129714. */
  129715. get camera(): Nullable<Camera>;
  129716. /**
  129717. * Gets the rendering group id the layer should render in.
  129718. */
  129719. get renderingGroupId(): number;
  129720. set renderingGroupId(renderingGroupId: number);
  129721. /**
  129722. * An event triggered when the effect layer has been disposed.
  129723. */
  129724. onDisposeObservable: Observable<EffectLayer>;
  129725. /**
  129726. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  129727. */
  129728. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  129729. /**
  129730. * An event triggered when the generated texture is being merged in the scene.
  129731. */
  129732. onBeforeComposeObservable: Observable<EffectLayer>;
  129733. /**
  129734. * An event triggered when the mesh is rendered into the effect render target.
  129735. */
  129736. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  129737. /**
  129738. * An event triggered after the mesh has been rendered into the effect render target.
  129739. */
  129740. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  129741. /**
  129742. * An event triggered when the generated texture has been merged in the scene.
  129743. */
  129744. onAfterComposeObservable: Observable<EffectLayer>;
  129745. /**
  129746. * An event triggered when the efffect layer changes its size.
  129747. */
  129748. onSizeChangedObservable: Observable<EffectLayer>;
  129749. /** @hidden */
  129750. static _SceneComponentInitialization: (scene: Scene) => void;
  129751. /**
  129752. * Instantiates a new effect Layer and references it in the scene.
  129753. * @param name The name of the layer
  129754. * @param scene The scene to use the layer in
  129755. */
  129756. constructor(
  129757. /** The Friendly of the effect in the scene */
  129758. name: string, scene: Scene);
  129759. /**
  129760. * Get the effect name of the layer.
  129761. * @return The effect name
  129762. */
  129763. abstract getEffectName(): string;
  129764. /**
  129765. * Checks for the readiness of the element composing the layer.
  129766. * @param subMesh the mesh to check for
  129767. * @param useInstances specify whether or not to use instances to render the mesh
  129768. * @return true if ready otherwise, false
  129769. */
  129770. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129771. /**
  129772. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129773. * @returns true if the effect requires stencil during the main canvas render pass.
  129774. */
  129775. abstract needStencil(): boolean;
  129776. /**
  129777. * Create the merge effect. This is the shader use to blit the information back
  129778. * to the main canvas at the end of the scene rendering.
  129779. * @returns The effect containing the shader used to merge the effect on the main canvas
  129780. */
  129781. protected abstract _createMergeEffect(): Effect;
  129782. /**
  129783. * Creates the render target textures and post processes used in the effect layer.
  129784. */
  129785. protected abstract _createTextureAndPostProcesses(): void;
  129786. /**
  129787. * Implementation specific of rendering the generating effect on the main canvas.
  129788. * @param effect The effect used to render through
  129789. */
  129790. protected abstract _internalRender(effect: Effect): void;
  129791. /**
  129792. * Sets the required values for both the emissive texture and and the main color.
  129793. */
  129794. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129795. /**
  129796. * Free any resources and references associated to a mesh.
  129797. * Internal use
  129798. * @param mesh The mesh to free.
  129799. */
  129800. abstract _disposeMesh(mesh: Mesh): void;
  129801. /**
  129802. * Serializes this layer (Glow or Highlight for example)
  129803. * @returns a serialized layer object
  129804. */
  129805. abstract serialize?(): any;
  129806. /**
  129807. * Initializes the effect layer with the required options.
  129808. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  129809. */
  129810. protected _init(options: Partial<IEffectLayerOptions>): void;
  129811. /**
  129812. * Generates the index buffer of the full screen quad blending to the main canvas.
  129813. */
  129814. private _generateIndexBuffer;
  129815. /**
  129816. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  129817. */
  129818. private _generateVertexBuffer;
  129819. /**
  129820. * Sets the main texture desired size which is the closest power of two
  129821. * of the engine canvas size.
  129822. */
  129823. private _setMainTextureSize;
  129824. /**
  129825. * Creates the main texture for the effect layer.
  129826. */
  129827. protected _createMainTexture(): void;
  129828. /**
  129829. * Adds specific effects defines.
  129830. * @param defines The defines to add specifics to.
  129831. */
  129832. protected _addCustomEffectDefines(defines: string[]): void;
  129833. /**
  129834. * Checks for the readiness of the element composing the layer.
  129835. * @param subMesh the mesh to check for
  129836. * @param useInstances specify whether or not to use instances to render the mesh
  129837. * @param emissiveTexture the associated emissive texture used to generate the glow
  129838. * @return true if ready otherwise, false
  129839. */
  129840. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  129841. /**
  129842. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  129843. */
  129844. render(): void;
  129845. /**
  129846. * Determine if a given mesh will be used in the current effect.
  129847. * @param mesh mesh to test
  129848. * @returns true if the mesh will be used
  129849. */
  129850. hasMesh(mesh: AbstractMesh): boolean;
  129851. /**
  129852. * Returns true if the layer contains information to display, otherwise false.
  129853. * @returns true if the glow layer should be rendered
  129854. */
  129855. shouldRender(): boolean;
  129856. /**
  129857. * Returns true if the mesh should render, otherwise false.
  129858. * @param mesh The mesh to render
  129859. * @returns true if it should render otherwise false
  129860. */
  129861. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  129862. /**
  129863. * Returns true if the mesh can be rendered, otherwise false.
  129864. * @param mesh The mesh to render
  129865. * @param material The material used on the mesh
  129866. * @returns true if it can be rendered otherwise false
  129867. */
  129868. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129869. /**
  129870. * Returns true if the mesh should render, otherwise false.
  129871. * @param mesh The mesh to render
  129872. * @returns true if it should render otherwise false
  129873. */
  129874. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  129875. /**
  129876. * Renders the submesh passed in parameter to the generation map.
  129877. */
  129878. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  129879. /**
  129880. * Defines whether the current material of the mesh should be use to render the effect.
  129881. * @param mesh defines the current mesh to render
  129882. */
  129883. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129884. /**
  129885. * Rebuild the required buffers.
  129886. * @hidden Internal use only.
  129887. */
  129888. _rebuild(): void;
  129889. /**
  129890. * Dispose only the render target textures and post process.
  129891. */
  129892. private _disposeTextureAndPostProcesses;
  129893. /**
  129894. * Dispose the highlight layer and free resources.
  129895. */
  129896. dispose(): void;
  129897. /**
  129898. * Gets the class name of the effect layer
  129899. * @returns the string with the class name of the effect layer
  129900. */
  129901. getClassName(): string;
  129902. /**
  129903. * Creates an effect layer from parsed effect layer data
  129904. * @param parsedEffectLayer defines effect layer data
  129905. * @param scene defines the current scene
  129906. * @param rootUrl defines the root URL containing the effect layer information
  129907. * @returns a parsed effect Layer
  129908. */
  129909. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  129910. }
  129911. }
  129912. declare module BABYLON {
  129913. interface AbstractScene {
  129914. /**
  129915. * The list of effect layers (highlights/glow) added to the scene
  129916. * @see http://doc.babylonjs.com/how_to/highlight_layer
  129917. * @see http://doc.babylonjs.com/how_to/glow_layer
  129918. */
  129919. effectLayers: Array<EffectLayer>;
  129920. /**
  129921. * Removes the given effect layer from this scene.
  129922. * @param toRemove defines the effect layer to remove
  129923. * @returns the index of the removed effect layer
  129924. */
  129925. removeEffectLayer(toRemove: EffectLayer): number;
  129926. /**
  129927. * Adds the given effect layer to this scene
  129928. * @param newEffectLayer defines the effect layer to add
  129929. */
  129930. addEffectLayer(newEffectLayer: EffectLayer): void;
  129931. }
  129932. /**
  129933. * Defines the layer scene component responsible to manage any effect layers
  129934. * in a given scene.
  129935. */
  129936. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  129937. /**
  129938. * The component name helpfull to identify the component in the list of scene components.
  129939. */
  129940. readonly name: string;
  129941. /**
  129942. * The scene the component belongs to.
  129943. */
  129944. scene: Scene;
  129945. private _engine;
  129946. private _renderEffects;
  129947. private _needStencil;
  129948. private _previousStencilState;
  129949. /**
  129950. * Creates a new instance of the component for the given scene
  129951. * @param scene Defines the scene to register the component in
  129952. */
  129953. constructor(scene: Scene);
  129954. /**
  129955. * Registers the component in a given scene
  129956. */
  129957. register(): void;
  129958. /**
  129959. * Rebuilds the elements related to this component in case of
  129960. * context lost for instance.
  129961. */
  129962. rebuild(): void;
  129963. /**
  129964. * Serializes the component data to the specified json object
  129965. * @param serializationObject The object to serialize to
  129966. */
  129967. serialize(serializationObject: any): void;
  129968. /**
  129969. * Adds all the elements from the container to the scene
  129970. * @param container the container holding the elements
  129971. */
  129972. addFromContainer(container: AbstractScene): void;
  129973. /**
  129974. * Removes all the elements in the container from the scene
  129975. * @param container contains the elements to remove
  129976. * @param dispose if the removed element should be disposed (default: false)
  129977. */
  129978. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129979. /**
  129980. * Disposes the component and the associated ressources.
  129981. */
  129982. dispose(): void;
  129983. private _isReadyForMesh;
  129984. private _renderMainTexture;
  129985. private _setStencil;
  129986. private _setStencilBack;
  129987. private _draw;
  129988. private _drawCamera;
  129989. private _drawRenderingGroup;
  129990. }
  129991. }
  129992. declare module BABYLON {
  129993. /** @hidden */
  129994. export var glowMapMergePixelShader: {
  129995. name: string;
  129996. shader: string;
  129997. };
  129998. }
  129999. declare module BABYLON {
  130000. /** @hidden */
  130001. export var glowMapMergeVertexShader: {
  130002. name: string;
  130003. shader: string;
  130004. };
  130005. }
  130006. declare module BABYLON {
  130007. interface AbstractScene {
  130008. /**
  130009. * Return a the first highlight layer of the scene with a given name.
  130010. * @param name The name of the highlight layer to look for.
  130011. * @return The highlight layer if found otherwise null.
  130012. */
  130013. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  130014. }
  130015. /**
  130016. * Glow layer options. This helps customizing the behaviour
  130017. * of the glow layer.
  130018. */
  130019. export interface IGlowLayerOptions {
  130020. /**
  130021. * Multiplication factor apply to the canvas size to compute the render target size
  130022. * used to generated the glowing objects (the smaller the faster).
  130023. */
  130024. mainTextureRatio: number;
  130025. /**
  130026. * Enforces a fixed size texture to ensure resize independant blur.
  130027. */
  130028. mainTextureFixedSize?: number;
  130029. /**
  130030. * How big is the kernel of the blur texture.
  130031. */
  130032. blurKernelSize: number;
  130033. /**
  130034. * The camera attached to the layer.
  130035. */
  130036. camera: Nullable<Camera>;
  130037. /**
  130038. * Enable MSAA by chosing the number of samples.
  130039. */
  130040. mainTextureSamples?: number;
  130041. /**
  130042. * The rendering group to draw the layer in.
  130043. */
  130044. renderingGroupId: number;
  130045. }
  130046. /**
  130047. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  130048. *
  130049. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  130050. *
  130051. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  130052. */
  130053. export class GlowLayer extends EffectLayer {
  130054. /**
  130055. * Effect Name of the layer.
  130056. */
  130057. static readonly EffectName: string;
  130058. /**
  130059. * The default blur kernel size used for the glow.
  130060. */
  130061. static DefaultBlurKernelSize: number;
  130062. /**
  130063. * The default texture size ratio used for the glow.
  130064. */
  130065. static DefaultTextureRatio: number;
  130066. /**
  130067. * Sets the kernel size of the blur.
  130068. */
  130069. set blurKernelSize(value: number);
  130070. /**
  130071. * Gets the kernel size of the blur.
  130072. */
  130073. get blurKernelSize(): number;
  130074. /**
  130075. * Sets the glow intensity.
  130076. */
  130077. set intensity(value: number);
  130078. /**
  130079. * Gets the glow intensity.
  130080. */
  130081. get intensity(): number;
  130082. private _options;
  130083. private _intensity;
  130084. private _horizontalBlurPostprocess1;
  130085. private _verticalBlurPostprocess1;
  130086. private _horizontalBlurPostprocess2;
  130087. private _verticalBlurPostprocess2;
  130088. private _blurTexture1;
  130089. private _blurTexture2;
  130090. private _postProcesses1;
  130091. private _postProcesses2;
  130092. private _includedOnlyMeshes;
  130093. private _excludedMeshes;
  130094. private _meshesUsingTheirOwnMaterials;
  130095. /**
  130096. * Callback used to let the user override the color selection on a per mesh basis
  130097. */
  130098. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  130099. /**
  130100. * Callback used to let the user override the texture selection on a per mesh basis
  130101. */
  130102. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  130103. /**
  130104. * Instantiates a new glow Layer and references it to the scene.
  130105. * @param name The name of the layer
  130106. * @param scene The scene to use the layer in
  130107. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  130108. */
  130109. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  130110. /**
  130111. * Get the effect name of the layer.
  130112. * @return The effect name
  130113. */
  130114. getEffectName(): string;
  130115. /**
  130116. * Create the merge effect. This is the shader use to blit the information back
  130117. * to the main canvas at the end of the scene rendering.
  130118. */
  130119. protected _createMergeEffect(): Effect;
  130120. /**
  130121. * Creates the render target textures and post processes used in the glow layer.
  130122. */
  130123. protected _createTextureAndPostProcesses(): void;
  130124. /**
  130125. * Checks for the readiness of the element composing the layer.
  130126. * @param subMesh the mesh to check for
  130127. * @param useInstances specify wether or not to use instances to render the mesh
  130128. * @param emissiveTexture the associated emissive texture used to generate the glow
  130129. * @return true if ready otherwise, false
  130130. */
  130131. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130132. /**
  130133. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  130134. */
  130135. needStencil(): boolean;
  130136. /**
  130137. * Returns true if the mesh can be rendered, otherwise false.
  130138. * @param mesh The mesh to render
  130139. * @param material The material used on the mesh
  130140. * @returns true if it can be rendered otherwise false
  130141. */
  130142. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  130143. /**
  130144. * Implementation specific of rendering the generating effect on the main canvas.
  130145. * @param effect The effect used to render through
  130146. */
  130147. protected _internalRender(effect: Effect): void;
  130148. /**
  130149. * Sets the required values for both the emissive texture and and the main color.
  130150. */
  130151. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130152. /**
  130153. * Returns true if the mesh should render, otherwise false.
  130154. * @param mesh The mesh to render
  130155. * @returns true if it should render otherwise false
  130156. */
  130157. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130158. /**
  130159. * Adds specific effects defines.
  130160. * @param defines The defines to add specifics to.
  130161. */
  130162. protected _addCustomEffectDefines(defines: string[]): void;
  130163. /**
  130164. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  130165. * @param mesh The mesh to exclude from the glow layer
  130166. */
  130167. addExcludedMesh(mesh: Mesh): void;
  130168. /**
  130169. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  130170. * @param mesh The mesh to remove
  130171. */
  130172. removeExcludedMesh(mesh: Mesh): void;
  130173. /**
  130174. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  130175. * @param mesh The mesh to include in the glow layer
  130176. */
  130177. addIncludedOnlyMesh(mesh: Mesh): void;
  130178. /**
  130179. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  130180. * @param mesh The mesh to remove
  130181. */
  130182. removeIncludedOnlyMesh(mesh: Mesh): void;
  130183. /**
  130184. * Determine if a given mesh will be used in the glow layer
  130185. * @param mesh The mesh to test
  130186. * @returns true if the mesh will be highlighted by the current glow layer
  130187. */
  130188. hasMesh(mesh: AbstractMesh): boolean;
  130189. /**
  130190. * Defines whether the current material of the mesh should be use to render the effect.
  130191. * @param mesh defines the current mesh to render
  130192. */
  130193. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  130194. /**
  130195. * Add a mesh to be rendered through its own material and not with emissive only.
  130196. * @param mesh The mesh for which we need to use its material
  130197. */
  130198. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  130199. /**
  130200. * Remove a mesh from being rendered through its own material and not with emissive only.
  130201. * @param mesh The mesh for which we need to not use its material
  130202. */
  130203. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  130204. /**
  130205. * Free any resources and references associated to a mesh.
  130206. * Internal use
  130207. * @param mesh The mesh to free.
  130208. * @hidden
  130209. */
  130210. _disposeMesh(mesh: Mesh): void;
  130211. /**
  130212. * Gets the class name of the effect layer
  130213. * @returns the string with the class name of the effect layer
  130214. */
  130215. getClassName(): string;
  130216. /**
  130217. * Serializes this glow layer
  130218. * @returns a serialized glow layer object
  130219. */
  130220. serialize(): any;
  130221. /**
  130222. * Creates a Glow Layer from parsed glow layer data
  130223. * @param parsedGlowLayer defines glow layer data
  130224. * @param scene defines the current scene
  130225. * @param rootUrl defines the root URL containing the glow layer information
  130226. * @returns a parsed Glow Layer
  130227. */
  130228. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  130229. }
  130230. }
  130231. declare module BABYLON {
  130232. /** @hidden */
  130233. export var glowBlurPostProcessPixelShader: {
  130234. name: string;
  130235. shader: string;
  130236. };
  130237. }
  130238. declare module BABYLON {
  130239. interface AbstractScene {
  130240. /**
  130241. * Return a the first highlight layer of the scene with a given name.
  130242. * @param name The name of the highlight layer to look for.
  130243. * @return The highlight layer if found otherwise null.
  130244. */
  130245. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  130246. }
  130247. /**
  130248. * Highlight layer options. This helps customizing the behaviour
  130249. * of the highlight layer.
  130250. */
  130251. export interface IHighlightLayerOptions {
  130252. /**
  130253. * Multiplication factor apply to the canvas size to compute the render target size
  130254. * used to generated the glowing objects (the smaller the faster).
  130255. */
  130256. mainTextureRatio: number;
  130257. /**
  130258. * Enforces a fixed size texture to ensure resize independant blur.
  130259. */
  130260. mainTextureFixedSize?: number;
  130261. /**
  130262. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  130263. * of the picture to blur (the smaller the faster).
  130264. */
  130265. blurTextureSizeRatio: number;
  130266. /**
  130267. * How big in texel of the blur texture is the vertical blur.
  130268. */
  130269. blurVerticalSize: number;
  130270. /**
  130271. * How big in texel of the blur texture is the horizontal blur.
  130272. */
  130273. blurHorizontalSize: number;
  130274. /**
  130275. * Alpha blending mode used to apply the blur. Default is combine.
  130276. */
  130277. alphaBlendingMode: number;
  130278. /**
  130279. * The camera attached to the layer.
  130280. */
  130281. camera: Nullable<Camera>;
  130282. /**
  130283. * Should we display highlight as a solid stroke?
  130284. */
  130285. isStroke?: boolean;
  130286. /**
  130287. * The rendering group to draw the layer in.
  130288. */
  130289. renderingGroupId: number;
  130290. }
  130291. /**
  130292. * The highlight layer Helps adding a glow effect around a mesh.
  130293. *
  130294. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  130295. * glowy meshes to your scene.
  130296. *
  130297. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  130298. */
  130299. export class HighlightLayer extends EffectLayer {
  130300. name: string;
  130301. /**
  130302. * Effect Name of the highlight layer.
  130303. */
  130304. static readonly EffectName: string;
  130305. /**
  130306. * The neutral color used during the preparation of the glow effect.
  130307. * This is black by default as the blend operation is a blend operation.
  130308. */
  130309. static NeutralColor: Color4;
  130310. /**
  130311. * Stencil value used for glowing meshes.
  130312. */
  130313. static GlowingMeshStencilReference: number;
  130314. /**
  130315. * Stencil value used for the other meshes in the scene.
  130316. */
  130317. static NormalMeshStencilReference: number;
  130318. /**
  130319. * Specifies whether or not the inner glow is ACTIVE in the layer.
  130320. */
  130321. innerGlow: boolean;
  130322. /**
  130323. * Specifies whether or not the outer glow is ACTIVE in the layer.
  130324. */
  130325. outerGlow: boolean;
  130326. /**
  130327. * Specifies the horizontal size of the blur.
  130328. */
  130329. set blurHorizontalSize(value: number);
  130330. /**
  130331. * Specifies the vertical size of the blur.
  130332. */
  130333. set blurVerticalSize(value: number);
  130334. /**
  130335. * Gets the horizontal size of the blur.
  130336. */
  130337. get blurHorizontalSize(): number;
  130338. /**
  130339. * Gets the vertical size of the blur.
  130340. */
  130341. get blurVerticalSize(): number;
  130342. /**
  130343. * An event triggered when the highlight layer is being blurred.
  130344. */
  130345. onBeforeBlurObservable: Observable<HighlightLayer>;
  130346. /**
  130347. * An event triggered when the highlight layer has been blurred.
  130348. */
  130349. onAfterBlurObservable: Observable<HighlightLayer>;
  130350. private _instanceGlowingMeshStencilReference;
  130351. private _options;
  130352. private _downSamplePostprocess;
  130353. private _horizontalBlurPostprocess;
  130354. private _verticalBlurPostprocess;
  130355. private _blurTexture;
  130356. private _meshes;
  130357. private _excludedMeshes;
  130358. /**
  130359. * Instantiates a new highlight Layer and references it to the scene..
  130360. * @param name The name of the layer
  130361. * @param scene The scene to use the layer in
  130362. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  130363. */
  130364. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  130365. /**
  130366. * Get the effect name of the layer.
  130367. * @return The effect name
  130368. */
  130369. getEffectName(): string;
  130370. /**
  130371. * Create the merge effect. This is the shader use to blit the information back
  130372. * to the main canvas at the end of the scene rendering.
  130373. */
  130374. protected _createMergeEffect(): Effect;
  130375. /**
  130376. * Creates the render target textures and post processes used in the highlight layer.
  130377. */
  130378. protected _createTextureAndPostProcesses(): void;
  130379. /**
  130380. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  130381. */
  130382. needStencil(): boolean;
  130383. /**
  130384. * Checks for the readiness of the element composing the layer.
  130385. * @param subMesh the mesh to check for
  130386. * @param useInstances specify wether or not to use instances to render the mesh
  130387. * @param emissiveTexture the associated emissive texture used to generate the glow
  130388. * @return true if ready otherwise, false
  130389. */
  130390. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130391. /**
  130392. * Implementation specific of rendering the generating effect on the main canvas.
  130393. * @param effect The effect used to render through
  130394. */
  130395. protected _internalRender(effect: Effect): void;
  130396. /**
  130397. * Returns true if the layer contains information to display, otherwise false.
  130398. */
  130399. shouldRender(): boolean;
  130400. /**
  130401. * Returns true if the mesh should render, otherwise false.
  130402. * @param mesh The mesh to render
  130403. * @returns true if it should render otherwise false
  130404. */
  130405. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130406. /**
  130407. * Adds specific effects defines.
  130408. * @param defines The defines to add specifics to.
  130409. */
  130410. protected _addCustomEffectDefines(defines: string[]): void;
  130411. /**
  130412. * Sets the required values for both the emissive texture and and the main color.
  130413. */
  130414. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130415. /**
  130416. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  130417. * @param mesh The mesh to exclude from the highlight layer
  130418. */
  130419. addExcludedMesh(mesh: Mesh): void;
  130420. /**
  130421. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  130422. * @param mesh The mesh to highlight
  130423. */
  130424. removeExcludedMesh(mesh: Mesh): void;
  130425. /**
  130426. * Determine if a given mesh will be highlighted by the current HighlightLayer
  130427. * @param mesh mesh to test
  130428. * @returns true if the mesh will be highlighted by the current HighlightLayer
  130429. */
  130430. hasMesh(mesh: AbstractMesh): boolean;
  130431. /**
  130432. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  130433. * @param mesh The mesh to highlight
  130434. * @param color The color of the highlight
  130435. * @param glowEmissiveOnly Extract the glow from the emissive texture
  130436. */
  130437. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  130438. /**
  130439. * Remove a mesh from the highlight layer in order to make it stop glowing.
  130440. * @param mesh The mesh to highlight
  130441. */
  130442. removeMesh(mesh: Mesh): void;
  130443. /**
  130444. * Remove all the meshes currently referenced in the highlight layer
  130445. */
  130446. removeAllMeshes(): void;
  130447. /**
  130448. * Force the stencil to the normal expected value for none glowing parts
  130449. */
  130450. private _defaultStencilReference;
  130451. /**
  130452. * Free any resources and references associated to a mesh.
  130453. * Internal use
  130454. * @param mesh The mesh to free.
  130455. * @hidden
  130456. */
  130457. _disposeMesh(mesh: Mesh): void;
  130458. /**
  130459. * Dispose the highlight layer and free resources.
  130460. */
  130461. dispose(): void;
  130462. /**
  130463. * Gets the class name of the effect layer
  130464. * @returns the string with the class name of the effect layer
  130465. */
  130466. getClassName(): string;
  130467. /**
  130468. * Serializes this Highlight layer
  130469. * @returns a serialized Highlight layer object
  130470. */
  130471. serialize(): any;
  130472. /**
  130473. * Creates a Highlight layer from parsed Highlight layer data
  130474. * @param parsedHightlightLayer defines the Highlight layer data
  130475. * @param scene defines the current scene
  130476. * @param rootUrl defines the root URL containing the Highlight layer information
  130477. * @returns a parsed Highlight layer
  130478. */
  130479. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  130480. }
  130481. }
  130482. declare module BABYLON {
  130483. interface AbstractScene {
  130484. /**
  130485. * The list of layers (background and foreground) of the scene
  130486. */
  130487. layers: Array<Layer>;
  130488. }
  130489. /**
  130490. * Defines the layer scene component responsible to manage any layers
  130491. * in a given scene.
  130492. */
  130493. export class LayerSceneComponent implements ISceneComponent {
  130494. /**
  130495. * The component name helpfull to identify the component in the list of scene components.
  130496. */
  130497. readonly name: string;
  130498. /**
  130499. * The scene the component belongs to.
  130500. */
  130501. scene: Scene;
  130502. private _engine;
  130503. /**
  130504. * Creates a new instance of the component for the given scene
  130505. * @param scene Defines the scene to register the component in
  130506. */
  130507. constructor(scene: Scene);
  130508. /**
  130509. * Registers the component in a given scene
  130510. */
  130511. register(): void;
  130512. /**
  130513. * Rebuilds the elements related to this component in case of
  130514. * context lost for instance.
  130515. */
  130516. rebuild(): void;
  130517. /**
  130518. * Disposes the component and the associated ressources.
  130519. */
  130520. dispose(): void;
  130521. private _draw;
  130522. private _drawCameraPredicate;
  130523. private _drawCameraBackground;
  130524. private _drawCameraForeground;
  130525. private _drawRenderTargetPredicate;
  130526. private _drawRenderTargetBackground;
  130527. private _drawRenderTargetForeground;
  130528. /**
  130529. * Adds all the elements from the container to the scene
  130530. * @param container the container holding the elements
  130531. */
  130532. addFromContainer(container: AbstractScene): void;
  130533. /**
  130534. * Removes all the elements in the container from the scene
  130535. * @param container contains the elements to remove
  130536. * @param dispose if the removed element should be disposed (default: false)
  130537. */
  130538. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130539. }
  130540. }
  130541. declare module BABYLON {
  130542. /** @hidden */
  130543. export var layerPixelShader: {
  130544. name: string;
  130545. shader: string;
  130546. };
  130547. }
  130548. declare module BABYLON {
  130549. /** @hidden */
  130550. export var layerVertexShader: {
  130551. name: string;
  130552. shader: string;
  130553. };
  130554. }
  130555. declare module BABYLON {
  130556. /**
  130557. * This represents a full screen 2d layer.
  130558. * This can be useful to display a picture in the background of your scene for instance.
  130559. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130560. */
  130561. export class Layer {
  130562. /**
  130563. * Define the name of the layer.
  130564. */
  130565. name: string;
  130566. /**
  130567. * Define the texture the layer should display.
  130568. */
  130569. texture: Nullable<Texture>;
  130570. /**
  130571. * Is the layer in background or foreground.
  130572. */
  130573. isBackground: boolean;
  130574. /**
  130575. * Define the color of the layer (instead of texture).
  130576. */
  130577. color: Color4;
  130578. /**
  130579. * Define the scale of the layer in order to zoom in out of the texture.
  130580. */
  130581. scale: Vector2;
  130582. /**
  130583. * Define an offset for the layer in order to shift the texture.
  130584. */
  130585. offset: Vector2;
  130586. /**
  130587. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  130588. */
  130589. alphaBlendingMode: number;
  130590. /**
  130591. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  130592. * Alpha test will not mix with the background color in case of transparency.
  130593. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  130594. */
  130595. alphaTest: boolean;
  130596. /**
  130597. * Define a mask to restrict the layer to only some of the scene cameras.
  130598. */
  130599. layerMask: number;
  130600. /**
  130601. * Define the list of render target the layer is visible into.
  130602. */
  130603. renderTargetTextures: RenderTargetTexture[];
  130604. /**
  130605. * Define if the layer is only used in renderTarget or if it also
  130606. * renders in the main frame buffer of the canvas.
  130607. */
  130608. renderOnlyInRenderTargetTextures: boolean;
  130609. private _scene;
  130610. private _vertexBuffers;
  130611. private _indexBuffer;
  130612. private _effect;
  130613. private _previousDefines;
  130614. /**
  130615. * An event triggered when the layer is disposed.
  130616. */
  130617. onDisposeObservable: Observable<Layer>;
  130618. private _onDisposeObserver;
  130619. /**
  130620. * Back compatibility with callback before the onDisposeObservable existed.
  130621. * The set callback will be triggered when the layer has been disposed.
  130622. */
  130623. set onDispose(callback: () => void);
  130624. /**
  130625. * An event triggered before rendering the scene
  130626. */
  130627. onBeforeRenderObservable: Observable<Layer>;
  130628. private _onBeforeRenderObserver;
  130629. /**
  130630. * Back compatibility with callback before the onBeforeRenderObservable existed.
  130631. * The set callback will be triggered just before rendering the layer.
  130632. */
  130633. set onBeforeRender(callback: () => void);
  130634. /**
  130635. * An event triggered after rendering the scene
  130636. */
  130637. onAfterRenderObservable: Observable<Layer>;
  130638. private _onAfterRenderObserver;
  130639. /**
  130640. * Back compatibility with callback before the onAfterRenderObservable existed.
  130641. * The set callback will be triggered just after rendering the layer.
  130642. */
  130643. set onAfterRender(callback: () => void);
  130644. /**
  130645. * Instantiates a new layer.
  130646. * This represents a full screen 2d layer.
  130647. * This can be useful to display a picture in the background of your scene for instance.
  130648. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130649. * @param name Define the name of the layer in the scene
  130650. * @param imgUrl Define the url of the texture to display in the layer
  130651. * @param scene Define the scene the layer belongs to
  130652. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  130653. * @param color Defines a color for the layer
  130654. */
  130655. constructor(
  130656. /**
  130657. * Define the name of the layer.
  130658. */
  130659. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  130660. private _createIndexBuffer;
  130661. /** @hidden */
  130662. _rebuild(): void;
  130663. /**
  130664. * Renders the layer in the scene.
  130665. */
  130666. render(): void;
  130667. /**
  130668. * Disposes and releases the associated ressources.
  130669. */
  130670. dispose(): void;
  130671. }
  130672. }
  130673. declare module BABYLON {
  130674. /** @hidden */
  130675. export var lensFlarePixelShader: {
  130676. name: string;
  130677. shader: string;
  130678. };
  130679. }
  130680. declare module BABYLON {
  130681. /** @hidden */
  130682. export var lensFlareVertexShader: {
  130683. name: string;
  130684. shader: string;
  130685. };
  130686. }
  130687. declare module BABYLON {
  130688. /**
  130689. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130690. * It is usually composed of several `lensFlare`.
  130691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130692. */
  130693. export class LensFlareSystem {
  130694. /**
  130695. * Define the name of the lens flare system
  130696. */
  130697. name: string;
  130698. /**
  130699. * List of lens flares used in this system.
  130700. */
  130701. lensFlares: LensFlare[];
  130702. /**
  130703. * Define a limit from the border the lens flare can be visible.
  130704. */
  130705. borderLimit: number;
  130706. /**
  130707. * Define a viewport border we do not want to see the lens flare in.
  130708. */
  130709. viewportBorder: number;
  130710. /**
  130711. * Define a predicate which could limit the list of meshes able to occlude the effect.
  130712. */
  130713. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130714. /**
  130715. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  130716. */
  130717. layerMask: number;
  130718. /**
  130719. * Define the id of the lens flare system in the scene.
  130720. * (equal to name by default)
  130721. */
  130722. id: string;
  130723. private _scene;
  130724. private _emitter;
  130725. private _vertexBuffers;
  130726. private _indexBuffer;
  130727. private _effect;
  130728. private _positionX;
  130729. private _positionY;
  130730. private _isEnabled;
  130731. /** @hidden */
  130732. static _SceneComponentInitialization: (scene: Scene) => void;
  130733. /**
  130734. * Instantiates a lens flare system.
  130735. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130736. * It is usually composed of several `lensFlare`.
  130737. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130738. * @param name Define the name of the lens flare system in the scene
  130739. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  130740. * @param scene Define the scene the lens flare system belongs to
  130741. */
  130742. constructor(
  130743. /**
  130744. * Define the name of the lens flare system
  130745. */
  130746. name: string, emitter: any, scene: Scene);
  130747. /**
  130748. * Define if the lens flare system is enabled.
  130749. */
  130750. get isEnabled(): boolean;
  130751. set isEnabled(value: boolean);
  130752. /**
  130753. * Get the scene the effects belongs to.
  130754. * @returns the scene holding the lens flare system
  130755. */
  130756. getScene(): Scene;
  130757. /**
  130758. * Get the emitter of the lens flare system.
  130759. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130760. * @returns the emitter of the lens flare system
  130761. */
  130762. getEmitter(): any;
  130763. /**
  130764. * Set the emitter of the lens flare system.
  130765. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130766. * @param newEmitter Define the new emitter of the system
  130767. */
  130768. setEmitter(newEmitter: any): void;
  130769. /**
  130770. * Get the lens flare system emitter position.
  130771. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  130772. * @returns the position
  130773. */
  130774. getEmitterPosition(): Vector3;
  130775. /**
  130776. * @hidden
  130777. */
  130778. computeEffectivePosition(globalViewport: Viewport): boolean;
  130779. /** @hidden */
  130780. _isVisible(): boolean;
  130781. /**
  130782. * @hidden
  130783. */
  130784. render(): boolean;
  130785. /**
  130786. * Dispose and release the lens flare with its associated resources.
  130787. */
  130788. dispose(): void;
  130789. /**
  130790. * Parse a lens flare system from a JSON repressentation
  130791. * @param parsedLensFlareSystem Define the JSON to parse
  130792. * @param scene Define the scene the parsed system should be instantiated in
  130793. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  130794. * @returns the parsed system
  130795. */
  130796. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  130797. /**
  130798. * Serialize the current Lens Flare System into a JSON representation.
  130799. * @returns the serialized JSON
  130800. */
  130801. serialize(): any;
  130802. }
  130803. }
  130804. declare module BABYLON {
  130805. /**
  130806. * This represents one of the lens effect in a `lensFlareSystem`.
  130807. * It controls one of the indiviual texture used in the effect.
  130808. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130809. */
  130810. export class LensFlare {
  130811. /**
  130812. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130813. */
  130814. size: number;
  130815. /**
  130816. * 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.
  130817. */
  130818. position: number;
  130819. /**
  130820. * Define the lens color.
  130821. */
  130822. color: Color3;
  130823. /**
  130824. * Define the lens texture.
  130825. */
  130826. texture: Nullable<Texture>;
  130827. /**
  130828. * Define the alpha mode to render this particular lens.
  130829. */
  130830. alphaMode: number;
  130831. private _system;
  130832. /**
  130833. * Creates a new Lens Flare.
  130834. * This represents one of the lens effect in a `lensFlareSystem`.
  130835. * It controls one of the indiviual texture used in the effect.
  130836. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130837. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  130838. * @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.
  130839. * @param color Define the lens color
  130840. * @param imgUrl Define the lens texture url
  130841. * @param system Define the `lensFlareSystem` this flare is part of
  130842. * @returns The newly created Lens Flare
  130843. */
  130844. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  130845. /**
  130846. * Instantiates a new Lens Flare.
  130847. * This represents one of the lens effect in a `lensFlareSystem`.
  130848. * It controls one of the indiviual texture used in the effect.
  130849. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130850. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  130851. * @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.
  130852. * @param color Define the lens color
  130853. * @param imgUrl Define the lens texture url
  130854. * @param system Define the `lensFlareSystem` this flare is part of
  130855. */
  130856. constructor(
  130857. /**
  130858. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130859. */
  130860. size: number,
  130861. /**
  130862. * 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.
  130863. */
  130864. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  130865. /**
  130866. * Dispose and release the lens flare with its associated resources.
  130867. */
  130868. dispose(): void;
  130869. }
  130870. }
  130871. declare module BABYLON {
  130872. interface AbstractScene {
  130873. /**
  130874. * The list of lens flare system added to the scene
  130875. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130876. */
  130877. lensFlareSystems: Array<LensFlareSystem>;
  130878. /**
  130879. * Removes the given lens flare system from this scene.
  130880. * @param toRemove The lens flare system to remove
  130881. * @returns The index of the removed lens flare system
  130882. */
  130883. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  130884. /**
  130885. * Adds the given lens flare system to this scene
  130886. * @param newLensFlareSystem The lens flare system to add
  130887. */
  130888. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  130889. /**
  130890. * Gets a lens flare system using its name
  130891. * @param name defines the name to look for
  130892. * @returns the lens flare system or null if not found
  130893. */
  130894. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  130895. /**
  130896. * Gets a lens flare system using its id
  130897. * @param id defines the id to look for
  130898. * @returns the lens flare system or null if not found
  130899. */
  130900. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  130901. }
  130902. /**
  130903. * Defines the lens flare scene component responsible to manage any lens flares
  130904. * in a given scene.
  130905. */
  130906. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  130907. /**
  130908. * The component name helpfull to identify the component in the list of scene components.
  130909. */
  130910. readonly name: string;
  130911. /**
  130912. * The scene the component belongs to.
  130913. */
  130914. scene: Scene;
  130915. /**
  130916. * Creates a new instance of the component for the given scene
  130917. * @param scene Defines the scene to register the component in
  130918. */
  130919. constructor(scene: Scene);
  130920. /**
  130921. * Registers the component in a given scene
  130922. */
  130923. register(): void;
  130924. /**
  130925. * Rebuilds the elements related to this component in case of
  130926. * context lost for instance.
  130927. */
  130928. rebuild(): void;
  130929. /**
  130930. * Adds all the elements from the container to the scene
  130931. * @param container the container holding the elements
  130932. */
  130933. addFromContainer(container: AbstractScene): void;
  130934. /**
  130935. * Removes all the elements in the container from the scene
  130936. * @param container contains the elements to remove
  130937. * @param dispose if the removed element should be disposed (default: false)
  130938. */
  130939. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130940. /**
  130941. * Serializes the component data to the specified json object
  130942. * @param serializationObject The object to serialize to
  130943. */
  130944. serialize(serializationObject: any): void;
  130945. /**
  130946. * Disposes the component and the associated ressources.
  130947. */
  130948. dispose(): void;
  130949. private _draw;
  130950. }
  130951. }
  130952. declare module BABYLON {
  130953. /** @hidden */
  130954. export var depthPixelShader: {
  130955. name: string;
  130956. shader: string;
  130957. };
  130958. }
  130959. declare module BABYLON {
  130960. /** @hidden */
  130961. export var depthVertexShader: {
  130962. name: string;
  130963. shader: string;
  130964. };
  130965. }
  130966. declare module BABYLON {
  130967. /**
  130968. * This represents a depth renderer in Babylon.
  130969. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130970. */
  130971. export class DepthRenderer {
  130972. private _scene;
  130973. private _depthMap;
  130974. private _effect;
  130975. private readonly _storeNonLinearDepth;
  130976. private readonly _clearColor;
  130977. /** Get if the depth renderer is using packed depth or not */
  130978. readonly isPacked: boolean;
  130979. private _cachedDefines;
  130980. private _camera;
  130981. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  130982. enabled: boolean;
  130983. /**
  130984. * Specifiess that the depth renderer will only be used within
  130985. * the camera it is created for.
  130986. * This can help forcing its rendering during the camera processing.
  130987. */
  130988. useOnlyInActiveCamera: boolean;
  130989. /** @hidden */
  130990. static _SceneComponentInitialization: (scene: Scene) => void;
  130991. /**
  130992. * Instantiates a depth renderer
  130993. * @param scene The scene the renderer belongs to
  130994. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130995. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130996. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130997. */
  130998. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130999. /**
  131000. * Creates the depth rendering effect and checks if the effect is ready.
  131001. * @param subMesh The submesh to be used to render the depth map of
  131002. * @param useInstances If multiple world instances should be used
  131003. * @returns if the depth renderer is ready to render the depth map
  131004. */
  131005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131006. /**
  131007. * Gets the texture which the depth map will be written to.
  131008. * @returns The depth map texture
  131009. */
  131010. getDepthMap(): RenderTargetTexture;
  131011. /**
  131012. * Disposes of the depth renderer.
  131013. */
  131014. dispose(): void;
  131015. }
  131016. }
  131017. declare module BABYLON {
  131018. /** @hidden */
  131019. export var minmaxReduxPixelShader: {
  131020. name: string;
  131021. shader: string;
  131022. };
  131023. }
  131024. declare module BABYLON {
  131025. /**
  131026. * This class computes a min/max reduction from a texture: it means it computes the minimum
  131027. * and maximum values from all values of the texture.
  131028. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  131029. * The source values are read from the red channel of the texture.
  131030. */
  131031. export class MinMaxReducer {
  131032. /**
  131033. * Observable triggered when the computation has been performed
  131034. */
  131035. onAfterReductionPerformed: Observable<{
  131036. min: number;
  131037. max: number;
  131038. }>;
  131039. protected _camera: Camera;
  131040. protected _sourceTexture: Nullable<RenderTargetTexture>;
  131041. protected _reductionSteps: Nullable<Array<PostProcess>>;
  131042. protected _postProcessManager: PostProcessManager;
  131043. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  131044. protected _forceFullscreenViewport: boolean;
  131045. /**
  131046. * Creates a min/max reducer
  131047. * @param camera The camera to use for the post processes
  131048. */
  131049. constructor(camera: Camera);
  131050. /**
  131051. * Gets the texture used to read the values from.
  131052. */
  131053. get sourceTexture(): Nullable<RenderTargetTexture>;
  131054. /**
  131055. * Sets the source texture to read the values from.
  131056. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  131057. * because in such textures '1' value must not be taken into account to compute the maximum
  131058. * as this value is used to clear the texture.
  131059. * Note that the computation is not activated by calling this function, you must call activate() for that!
  131060. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  131061. * @param depthRedux Indicates if the texture is a depth texture or not
  131062. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  131063. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  131064. */
  131065. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  131066. /**
  131067. * Defines the refresh rate of the computation.
  131068. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  131069. */
  131070. get refreshRate(): number;
  131071. set refreshRate(value: number);
  131072. protected _activated: boolean;
  131073. /**
  131074. * Gets the activation status of the reducer
  131075. */
  131076. get activated(): boolean;
  131077. /**
  131078. * Activates the reduction computation.
  131079. * When activated, the observers registered in onAfterReductionPerformed are
  131080. * called after the compuation is performed
  131081. */
  131082. activate(): void;
  131083. /**
  131084. * Deactivates the reduction computation.
  131085. */
  131086. deactivate(): void;
  131087. /**
  131088. * Disposes the min/max reducer
  131089. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  131090. */
  131091. dispose(disposeAll?: boolean): void;
  131092. }
  131093. }
  131094. declare module BABYLON {
  131095. /**
  131096. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  131097. */
  131098. export class DepthReducer extends MinMaxReducer {
  131099. private _depthRenderer;
  131100. private _depthRendererId;
  131101. /**
  131102. * Gets the depth renderer used for the computation.
  131103. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  131104. */
  131105. get depthRenderer(): Nullable<DepthRenderer>;
  131106. /**
  131107. * Creates a depth reducer
  131108. * @param camera The camera used to render the depth texture
  131109. */
  131110. constructor(camera: Camera);
  131111. /**
  131112. * Sets the depth renderer to use to generate the depth map
  131113. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  131114. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  131115. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  131116. */
  131117. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  131118. /** @hidden */
  131119. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  131120. /**
  131121. * Activates the reduction computation.
  131122. * When activated, the observers registered in onAfterReductionPerformed are
  131123. * called after the compuation is performed
  131124. */
  131125. activate(): void;
  131126. /**
  131127. * Deactivates the reduction computation.
  131128. */
  131129. deactivate(): void;
  131130. /**
  131131. * Disposes the depth reducer
  131132. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  131133. */
  131134. dispose(disposeAll?: boolean): void;
  131135. }
  131136. }
  131137. declare module BABYLON {
  131138. /**
  131139. * A CSM implementation allowing casting shadows on large scenes.
  131140. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131141. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  131142. */
  131143. export class CascadedShadowGenerator extends ShadowGenerator {
  131144. private static readonly frustumCornersNDCSpace;
  131145. /**
  131146. * Name of the CSM class
  131147. */
  131148. static CLASSNAME: string;
  131149. /**
  131150. * Defines the default number of cascades used by the CSM.
  131151. */
  131152. static readonly DEFAULT_CASCADES_COUNT: number;
  131153. /**
  131154. * Defines the minimum number of cascades used by the CSM.
  131155. */
  131156. static readonly MIN_CASCADES_COUNT: number;
  131157. /**
  131158. * Defines the maximum number of cascades used by the CSM.
  131159. */
  131160. static readonly MAX_CASCADES_COUNT: number;
  131161. protected _validateFilter(filter: number): number;
  131162. /**
  131163. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  131164. */
  131165. penumbraDarkness: number;
  131166. private _numCascades;
  131167. /**
  131168. * Gets or set the number of cascades used by the CSM.
  131169. */
  131170. get numCascades(): number;
  131171. set numCascades(value: number);
  131172. /**
  131173. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  131174. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  131175. */
  131176. stabilizeCascades: boolean;
  131177. private _freezeShadowCastersBoundingInfo;
  131178. private _freezeShadowCastersBoundingInfoObservable;
  131179. /**
  131180. * Enables or disables the shadow casters bounding info computation.
  131181. * If your shadow casters don't move, you can disable this feature.
  131182. * If it is enabled, the bounding box computation is done every frame.
  131183. */
  131184. get freezeShadowCastersBoundingInfo(): boolean;
  131185. set freezeShadowCastersBoundingInfo(freeze: boolean);
  131186. private _scbiMin;
  131187. private _scbiMax;
  131188. protected _computeShadowCastersBoundingInfo(): void;
  131189. protected _shadowCastersBoundingInfo: BoundingInfo;
  131190. /**
  131191. * Gets or sets the shadow casters bounding info.
  131192. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  131193. * so that the system won't overwrite the bounds you provide
  131194. */
  131195. get shadowCastersBoundingInfo(): BoundingInfo;
  131196. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  131197. protected _breaksAreDirty: boolean;
  131198. protected _minDistance: number;
  131199. protected _maxDistance: number;
  131200. /**
  131201. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  131202. *
  131203. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  131204. * If you don't know these values, simply leave them to their defaults and don't call this function.
  131205. * @param min minimal distance for the breaks (default to 0.)
  131206. * @param max maximal distance for the breaks (default to 1.)
  131207. */
  131208. setMinMaxDistance(min: number, max: number): void;
  131209. /** Gets the minimal distance used in the cascade break computation */
  131210. get minDistance(): number;
  131211. /** Gets the maximal distance used in the cascade break computation */
  131212. get maxDistance(): number;
  131213. /**
  131214. * Gets the class name of that object
  131215. * @returns "CascadedShadowGenerator"
  131216. */
  131217. getClassName(): string;
  131218. private _cascadeMinExtents;
  131219. private _cascadeMaxExtents;
  131220. /**
  131221. * Gets a cascade minimum extents
  131222. * @param cascadeIndex index of the cascade
  131223. * @returns the minimum cascade extents
  131224. */
  131225. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  131226. /**
  131227. * Gets a cascade maximum extents
  131228. * @param cascadeIndex index of the cascade
  131229. * @returns the maximum cascade extents
  131230. */
  131231. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  131232. private _cascades;
  131233. private _currentLayer;
  131234. private _viewSpaceFrustumsZ;
  131235. private _viewMatrices;
  131236. private _projectionMatrices;
  131237. private _transformMatrices;
  131238. private _transformMatricesAsArray;
  131239. private _frustumLengths;
  131240. private _lightSizeUVCorrection;
  131241. private _depthCorrection;
  131242. private _frustumCornersWorldSpace;
  131243. private _frustumCenter;
  131244. private _shadowCameraPos;
  131245. private _shadowMaxZ;
  131246. /**
  131247. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  131248. * It defaults to camera.maxZ
  131249. */
  131250. get shadowMaxZ(): number;
  131251. /**
  131252. * Sets the shadow max z distance.
  131253. */
  131254. set shadowMaxZ(value: number);
  131255. protected _debug: boolean;
  131256. /**
  131257. * Gets or sets the debug flag.
  131258. * When enabled, the cascades are materialized by different colors on the screen.
  131259. */
  131260. get debug(): boolean;
  131261. set debug(dbg: boolean);
  131262. private _depthClamp;
  131263. /**
  131264. * Gets or sets the depth clamping value.
  131265. *
  131266. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  131267. * to account for the shadow casters far away.
  131268. *
  131269. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  131270. */
  131271. get depthClamp(): boolean;
  131272. set depthClamp(value: boolean);
  131273. private _cascadeBlendPercentage;
  131274. /**
  131275. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  131276. * It defaults to 0.1 (10% blending).
  131277. */
  131278. get cascadeBlendPercentage(): number;
  131279. set cascadeBlendPercentage(value: number);
  131280. private _lambda;
  131281. /**
  131282. * Gets or set the lambda parameter.
  131283. * This parameter is used to split the camera frustum and create the cascades.
  131284. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  131285. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  131286. */
  131287. get lambda(): number;
  131288. set lambda(value: number);
  131289. /**
  131290. * Gets the view matrix corresponding to a given cascade
  131291. * @param cascadeNum cascade to retrieve the view matrix from
  131292. * @returns the cascade view matrix
  131293. */
  131294. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  131295. /**
  131296. * Gets the projection matrix corresponding to a given cascade
  131297. * @param cascadeNum cascade to retrieve the projection matrix from
  131298. * @returns the cascade projection matrix
  131299. */
  131300. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  131301. /**
  131302. * Gets the transformation matrix corresponding to a given cascade
  131303. * @param cascadeNum cascade to retrieve the transformation matrix from
  131304. * @returns the cascade transformation matrix
  131305. */
  131306. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  131307. private _depthRenderer;
  131308. /**
  131309. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  131310. *
  131311. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  131312. *
  131313. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  131314. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  131315. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  131316. */
  131317. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  131318. private _depthReducer;
  131319. private _autoCalcDepthBounds;
  131320. /**
  131321. * Gets or sets the autoCalcDepthBounds property.
  131322. *
  131323. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  131324. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  131325. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  131326. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  131327. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  131328. */
  131329. get autoCalcDepthBounds(): boolean;
  131330. set autoCalcDepthBounds(value: boolean);
  131331. /**
  131332. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  131333. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  131334. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  131335. * for setting the refresh rate on the renderer yourself!
  131336. */
  131337. get autoCalcDepthBoundsRefreshRate(): number;
  131338. set autoCalcDepthBoundsRefreshRate(value: number);
  131339. /**
  131340. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  131341. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  131342. * you change the camera near/far planes!
  131343. */
  131344. splitFrustum(): void;
  131345. private _splitFrustum;
  131346. private _computeMatrices;
  131347. private _computeFrustumInWorldSpace;
  131348. private _computeCascadeFrustum;
  131349. /**
  131350. * Support test.
  131351. */
  131352. static get IsSupported(): boolean;
  131353. /** @hidden */
  131354. static _SceneComponentInitialization: (scene: Scene) => void;
  131355. /**
  131356. * Creates a Cascaded Shadow Generator object.
  131357. * A ShadowGenerator is the required tool to use the shadows.
  131358. * Each directional light casting shadows needs to use its own ShadowGenerator.
  131359. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131360. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  131361. * @param light The directional light object generating the shadows.
  131362. * @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.
  131363. */
  131364. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  131365. protected _initializeGenerator(): void;
  131366. protected _createTargetRenderTexture(): void;
  131367. protected _initializeShadowMap(): void;
  131368. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  131369. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  131370. /**
  131371. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  131372. * @param defines Defines of the material we want to update
  131373. * @param lightIndex Index of the light in the enabled light list of the material
  131374. */
  131375. prepareDefines(defines: any, lightIndex: number): void;
  131376. /**
  131377. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  131378. * defined in the generator but impacting the effect).
  131379. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  131380. * @param effect The effect we are binfing the information for
  131381. */
  131382. bindShadowLight(lightIndex: string, effect: Effect): void;
  131383. /**
  131384. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  131385. * (eq to view projection * shadow projection matrices)
  131386. * @returns The transform matrix used to create the shadow map
  131387. */
  131388. getTransformMatrix(): Matrix;
  131389. /**
  131390. * Disposes the ShadowGenerator.
  131391. * Returns nothing.
  131392. */
  131393. dispose(): void;
  131394. /**
  131395. * Serializes the shadow generator setup to a json object.
  131396. * @returns The serialized JSON object
  131397. */
  131398. serialize(): any;
  131399. /**
  131400. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  131401. * @param parsedShadowGenerator The JSON object to parse
  131402. * @param scene The scene to create the shadow map for
  131403. * @returns The parsed shadow generator
  131404. */
  131405. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  131406. }
  131407. }
  131408. declare module BABYLON {
  131409. /**
  131410. * Defines the shadow generator component responsible to manage any shadow generators
  131411. * in a given scene.
  131412. */
  131413. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  131414. /**
  131415. * The component name helpfull to identify the component in the list of scene components.
  131416. */
  131417. readonly name: string;
  131418. /**
  131419. * The scene the component belongs to.
  131420. */
  131421. scene: Scene;
  131422. /**
  131423. * Creates a new instance of the component for the given scene
  131424. * @param scene Defines the scene to register the component in
  131425. */
  131426. constructor(scene: Scene);
  131427. /**
  131428. * Registers the component in a given scene
  131429. */
  131430. register(): void;
  131431. /**
  131432. * Rebuilds the elements related to this component in case of
  131433. * context lost for instance.
  131434. */
  131435. rebuild(): void;
  131436. /**
  131437. * Serializes the component data to the specified json object
  131438. * @param serializationObject The object to serialize to
  131439. */
  131440. serialize(serializationObject: any): void;
  131441. /**
  131442. * Adds all the elements from the container to the scene
  131443. * @param container the container holding the elements
  131444. */
  131445. addFromContainer(container: AbstractScene): void;
  131446. /**
  131447. * Removes all the elements in the container from the scene
  131448. * @param container contains the elements to remove
  131449. * @param dispose if the removed element should be disposed (default: false)
  131450. */
  131451. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  131452. /**
  131453. * Rebuilds the elements related to this component in case of
  131454. * context lost for instance.
  131455. */
  131456. dispose(): void;
  131457. private _gatherRenderTargets;
  131458. }
  131459. }
  131460. declare module BABYLON {
  131461. /**
  131462. * A point light is a light defined by an unique point in world space.
  131463. * The light is emitted in every direction from this point.
  131464. * A good example of a point light is a standard light bulb.
  131465. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131466. */
  131467. export class PointLight extends ShadowLight {
  131468. private _shadowAngle;
  131469. /**
  131470. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131471. * This specifies what angle the shadow will use to be created.
  131472. *
  131473. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131474. */
  131475. get shadowAngle(): number;
  131476. /**
  131477. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131478. * This specifies what angle the shadow will use to be created.
  131479. *
  131480. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131481. */
  131482. set shadowAngle(value: number);
  131483. /**
  131484. * Gets the direction if it has been set.
  131485. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131486. */
  131487. get direction(): Vector3;
  131488. /**
  131489. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131490. */
  131491. set direction(value: Vector3);
  131492. /**
  131493. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  131494. * A PointLight emits the light in every direction.
  131495. * It can cast shadows.
  131496. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  131497. * ```javascript
  131498. * var pointLight = new PointLight("pl", camera.position, scene);
  131499. * ```
  131500. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131501. * @param name The light friendly name
  131502. * @param position The position of the point light in the scene
  131503. * @param scene The scene the lights belongs to
  131504. */
  131505. constructor(name: string, position: Vector3, scene: Scene);
  131506. /**
  131507. * Returns the string "PointLight"
  131508. * @returns the class name
  131509. */
  131510. getClassName(): string;
  131511. /**
  131512. * Returns the integer 0.
  131513. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131514. */
  131515. getTypeID(): number;
  131516. /**
  131517. * Specifies wether or not the shadowmap should be a cube texture.
  131518. * @returns true if the shadowmap needs to be a cube texture.
  131519. */
  131520. needCube(): boolean;
  131521. /**
  131522. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  131523. * @param faceIndex The index of the face we are computed the direction to generate shadow
  131524. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  131525. */
  131526. getShadowDirection(faceIndex?: number): Vector3;
  131527. /**
  131528. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  131529. * - fov = PI / 2
  131530. * - aspect ratio : 1.0
  131531. * - z-near and far equal to the active camera minZ and maxZ.
  131532. * Returns the PointLight.
  131533. */
  131534. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131535. protected _buildUniformLayout(): void;
  131536. /**
  131537. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  131538. * @param effect The effect to update
  131539. * @param lightIndex The index of the light in the effect to update
  131540. * @returns The point light
  131541. */
  131542. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  131543. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131544. /**
  131545. * Prepares the list of defines specific to the light type.
  131546. * @param defines the list of defines
  131547. * @param lightIndex defines the index of the light for the effect
  131548. */
  131549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131550. }
  131551. }
  131552. declare module BABYLON {
  131553. /**
  131554. * Header information of HDR texture files.
  131555. */
  131556. export interface HDRInfo {
  131557. /**
  131558. * The height of the texture in pixels.
  131559. */
  131560. height: number;
  131561. /**
  131562. * The width of the texture in pixels.
  131563. */
  131564. width: number;
  131565. /**
  131566. * The index of the beginning of the data in the binary file.
  131567. */
  131568. dataPosition: number;
  131569. }
  131570. /**
  131571. * This groups tools to convert HDR texture to native colors array.
  131572. */
  131573. export class HDRTools {
  131574. private static Ldexp;
  131575. private static Rgbe2float;
  131576. private static readStringLine;
  131577. /**
  131578. * Reads header information from an RGBE texture stored in a native array.
  131579. * More information on this format are available here:
  131580. * https://en.wikipedia.org/wiki/RGBE_image_format
  131581. *
  131582. * @param uint8array The binary file stored in native array.
  131583. * @return The header information.
  131584. */
  131585. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  131586. /**
  131587. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  131588. * This RGBE texture needs to store the information as a panorama.
  131589. *
  131590. * More information on this format are available here:
  131591. * https://en.wikipedia.org/wiki/RGBE_image_format
  131592. *
  131593. * @param buffer The binary file stored in an array buffer.
  131594. * @param size The expected size of the extracted cubemap.
  131595. * @return The Cube Map information.
  131596. */
  131597. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  131598. /**
  131599. * Returns the pixels data extracted from an RGBE texture.
  131600. * This pixels will be stored left to right up to down in the R G B order in one array.
  131601. *
  131602. * More information on this format are available here:
  131603. * https://en.wikipedia.org/wiki/RGBE_image_format
  131604. *
  131605. * @param uint8array The binary file stored in an array buffer.
  131606. * @param hdrInfo The header information of the file.
  131607. * @return The pixels data in RGB right to left up to down order.
  131608. */
  131609. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  131610. private static RGBE_ReadPixels_RLE;
  131611. }
  131612. }
  131613. declare module BABYLON {
  131614. /**
  131615. * This represents a texture coming from an HDR input.
  131616. *
  131617. * The only supported format is currently panorama picture stored in RGBE format.
  131618. * Example of such files can be found on HDRLib: http://hdrlib.com/
  131619. */
  131620. export class HDRCubeTexture extends BaseTexture {
  131621. private static _facesMapping;
  131622. private _generateHarmonics;
  131623. private _noMipmap;
  131624. private _textureMatrix;
  131625. private _size;
  131626. private _onLoad;
  131627. private _onError;
  131628. /**
  131629. * The texture URL.
  131630. */
  131631. url: string;
  131632. /**
  131633. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  131634. */
  131635. coordinatesMode: number;
  131636. protected _isBlocking: boolean;
  131637. /**
  131638. * Sets wether or not the texture is blocking during loading.
  131639. */
  131640. set isBlocking(value: boolean);
  131641. /**
  131642. * Gets wether or not the texture is blocking during loading.
  131643. */
  131644. get isBlocking(): boolean;
  131645. protected _rotationY: number;
  131646. /**
  131647. * Sets texture matrix rotation angle around Y axis in radians.
  131648. */
  131649. set rotationY(value: number);
  131650. /**
  131651. * Gets texture matrix rotation angle around Y axis radians.
  131652. */
  131653. get rotationY(): number;
  131654. /**
  131655. * Gets or sets the center of the bounding box associated with the cube texture
  131656. * It must define where the camera used to render the texture was set
  131657. */
  131658. boundingBoxPosition: Vector3;
  131659. private _boundingBoxSize;
  131660. /**
  131661. * Gets or sets the size of the bounding box associated with the cube texture
  131662. * When defined, the cubemap will switch to local mode
  131663. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  131664. * @example https://www.babylonjs-playground.com/#RNASML
  131665. */
  131666. set boundingBoxSize(value: Vector3);
  131667. get boundingBoxSize(): Vector3;
  131668. /**
  131669. * Instantiates an HDRTexture from the following parameters.
  131670. *
  131671. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  131672. * @param sceneOrEngine The scene or engine the texture will be used in
  131673. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  131674. * @param noMipmap Forces to not generate the mipmap if true
  131675. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  131676. * @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)
  131677. * @param reserved Reserved flag for internal use.
  131678. */
  131679. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  131680. /**
  131681. * Get the current class name of the texture useful for serialization or dynamic coding.
  131682. * @returns "HDRCubeTexture"
  131683. */
  131684. getClassName(): string;
  131685. /**
  131686. * Occurs when the file is raw .hdr file.
  131687. */
  131688. private loadTexture;
  131689. clone(): HDRCubeTexture;
  131690. delayLoad(): void;
  131691. /**
  131692. * Get the texture reflection matrix used to rotate/transform the reflection.
  131693. * @returns the reflection matrix
  131694. */
  131695. getReflectionTextureMatrix(): Matrix;
  131696. /**
  131697. * Set the texture reflection matrix used to rotate/transform the reflection.
  131698. * @param value Define the reflection matrix to set
  131699. */
  131700. setReflectionTextureMatrix(value: Matrix): void;
  131701. /**
  131702. * Parses a JSON representation of an HDR Texture in order to create the texture
  131703. * @param parsedTexture Define the JSON representation
  131704. * @param scene Define the scene the texture should be created in
  131705. * @param rootUrl Define the root url in case we need to load relative dependencies
  131706. * @returns the newly created texture after parsing
  131707. */
  131708. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  131709. serialize(): any;
  131710. }
  131711. }
  131712. declare module BABYLON {
  131713. /**
  131714. * Class used to control physics engine
  131715. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  131716. */
  131717. export class PhysicsEngine implements IPhysicsEngine {
  131718. private _physicsPlugin;
  131719. /**
  131720. * Global value used to control the smallest number supported by the simulation
  131721. */
  131722. static Epsilon: number;
  131723. private _impostors;
  131724. private _joints;
  131725. private _subTimeStep;
  131726. /**
  131727. * Gets the gravity vector used by the simulation
  131728. */
  131729. gravity: Vector3;
  131730. /**
  131731. * Factory used to create the default physics plugin.
  131732. * @returns The default physics plugin
  131733. */
  131734. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  131735. /**
  131736. * Creates a new Physics Engine
  131737. * @param gravity defines the gravity vector used by the simulation
  131738. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  131739. */
  131740. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  131741. /**
  131742. * Sets the gravity vector used by the simulation
  131743. * @param gravity defines the gravity vector to use
  131744. */
  131745. setGravity(gravity: Vector3): void;
  131746. /**
  131747. * Set the time step of the physics engine.
  131748. * Default is 1/60.
  131749. * To slow it down, enter 1/600 for example.
  131750. * To speed it up, 1/30
  131751. * @param newTimeStep defines the new timestep to apply to this world.
  131752. */
  131753. setTimeStep(newTimeStep?: number): void;
  131754. /**
  131755. * Get the time step of the physics engine.
  131756. * @returns the current time step
  131757. */
  131758. getTimeStep(): number;
  131759. /**
  131760. * Set the sub time step of the physics engine.
  131761. * Default is 0 meaning there is no sub steps
  131762. * To increase physics resolution precision, set a small value (like 1 ms)
  131763. * @param subTimeStep defines the new sub timestep used for physics resolution.
  131764. */
  131765. setSubTimeStep(subTimeStep?: number): void;
  131766. /**
  131767. * Get the sub time step of the physics engine.
  131768. * @returns the current sub time step
  131769. */
  131770. getSubTimeStep(): number;
  131771. /**
  131772. * Release all resources
  131773. */
  131774. dispose(): void;
  131775. /**
  131776. * Gets the name of the current physics plugin
  131777. * @returns the name of the plugin
  131778. */
  131779. getPhysicsPluginName(): string;
  131780. /**
  131781. * Adding a new impostor for the impostor tracking.
  131782. * This will be done by the impostor itself.
  131783. * @param impostor the impostor to add
  131784. */
  131785. addImpostor(impostor: PhysicsImpostor): void;
  131786. /**
  131787. * Remove an impostor from the engine.
  131788. * This impostor and its mesh will not longer be updated by the physics engine.
  131789. * @param impostor the impostor to remove
  131790. */
  131791. removeImpostor(impostor: PhysicsImpostor): void;
  131792. /**
  131793. * Add a joint to the physics engine
  131794. * @param mainImpostor defines the main impostor to which the joint is added.
  131795. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  131796. * @param joint defines the joint that will connect both impostors.
  131797. */
  131798. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131799. /**
  131800. * Removes a joint from the simulation
  131801. * @param mainImpostor defines the impostor used with the joint
  131802. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  131803. * @param joint defines the joint to remove
  131804. */
  131805. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131806. /**
  131807. * Called by the scene. No need to call it.
  131808. * @param delta defines the timespam between frames
  131809. */
  131810. _step(delta: number): void;
  131811. /**
  131812. * Gets the current plugin used to run the simulation
  131813. * @returns current plugin
  131814. */
  131815. getPhysicsPlugin(): IPhysicsEnginePlugin;
  131816. /**
  131817. * Gets the list of physic impostors
  131818. * @returns an array of PhysicsImpostor
  131819. */
  131820. getImpostors(): Array<PhysicsImpostor>;
  131821. /**
  131822. * Gets the impostor for a physics enabled object
  131823. * @param object defines the object impersonated by the impostor
  131824. * @returns the PhysicsImpostor or null if not found
  131825. */
  131826. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  131827. /**
  131828. * Gets the impostor for a physics body object
  131829. * @param body defines physics body used by the impostor
  131830. * @returns the PhysicsImpostor or null if not found
  131831. */
  131832. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  131833. /**
  131834. * Does a raycast in the physics world
  131835. * @param from when should the ray start?
  131836. * @param to when should the ray end?
  131837. * @returns PhysicsRaycastResult
  131838. */
  131839. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131840. }
  131841. }
  131842. declare module BABYLON {
  131843. /** @hidden */
  131844. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  131845. private _useDeltaForWorldStep;
  131846. world: any;
  131847. name: string;
  131848. private _physicsMaterials;
  131849. private _fixedTimeStep;
  131850. private _cannonRaycastResult;
  131851. private _raycastResult;
  131852. private _physicsBodysToRemoveAfterStep;
  131853. BJSCANNON: any;
  131854. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  131855. setGravity(gravity: Vector3): void;
  131856. setTimeStep(timeStep: number): void;
  131857. getTimeStep(): number;
  131858. executeStep(delta: number): void;
  131859. private _removeMarkedPhysicsBodiesFromWorld;
  131860. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131861. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131862. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131863. private _processChildMeshes;
  131864. removePhysicsBody(impostor: PhysicsImpostor): void;
  131865. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131866. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131867. private _addMaterial;
  131868. private _checkWithEpsilon;
  131869. private _createShape;
  131870. private _createHeightmap;
  131871. private _minus90X;
  131872. private _plus90X;
  131873. private _tmpPosition;
  131874. private _tmpDeltaPosition;
  131875. private _tmpUnityRotation;
  131876. private _updatePhysicsBodyTransformation;
  131877. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131878. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131879. isSupported(): boolean;
  131880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131881. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131882. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131883. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131884. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131885. getBodyMass(impostor: PhysicsImpostor): number;
  131886. getBodyFriction(impostor: PhysicsImpostor): number;
  131887. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131888. getBodyRestitution(impostor: PhysicsImpostor): number;
  131889. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131890. sleepBody(impostor: PhysicsImpostor): void;
  131891. wakeUpBody(impostor: PhysicsImpostor): void;
  131892. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  131893. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131894. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131895. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131896. getRadius(impostor: PhysicsImpostor): number;
  131897. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131898. dispose(): void;
  131899. private _extendNamespace;
  131900. /**
  131901. * Does a raycast in the physics world
  131902. * @param from when should the ray start?
  131903. * @param to when should the ray end?
  131904. * @returns PhysicsRaycastResult
  131905. */
  131906. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131907. }
  131908. }
  131909. declare module BABYLON {
  131910. /** @hidden */
  131911. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  131912. private _useDeltaForWorldStep;
  131913. world: any;
  131914. name: string;
  131915. BJSOIMO: any;
  131916. private _raycastResult;
  131917. private _fixedTimeStep;
  131918. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  131919. setGravity(gravity: Vector3): void;
  131920. setTimeStep(timeStep: number): void;
  131921. getTimeStep(): number;
  131922. private _tmpImpostorsArray;
  131923. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131924. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131925. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131926. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131927. private _tmpPositionVector;
  131928. removePhysicsBody(impostor: PhysicsImpostor): void;
  131929. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131930. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131931. isSupported(): boolean;
  131932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131934. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131935. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131936. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131937. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131938. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131939. getBodyMass(impostor: PhysicsImpostor): number;
  131940. getBodyFriction(impostor: PhysicsImpostor): number;
  131941. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131942. getBodyRestitution(impostor: PhysicsImpostor): number;
  131943. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131944. sleepBody(impostor: PhysicsImpostor): void;
  131945. wakeUpBody(impostor: PhysicsImpostor): void;
  131946. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131947. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  131948. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  131949. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131950. getRadius(impostor: PhysicsImpostor): number;
  131951. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131952. dispose(): void;
  131953. /**
  131954. * Does a raycast in the physics world
  131955. * @param from when should the ray start?
  131956. * @param to when should the ray end?
  131957. * @returns PhysicsRaycastResult
  131958. */
  131959. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131960. }
  131961. }
  131962. declare module BABYLON {
  131963. /**
  131964. * Class containing static functions to help procedurally build meshes
  131965. */
  131966. export class RibbonBuilder {
  131967. /**
  131968. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131969. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131970. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131971. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131972. * * 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
  131973. * * 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
  131974. * * 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
  131975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131976. * * 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
  131977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131978. * * 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
  131979. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131980. * * 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
  131981. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131983. * @param name defines the name of the mesh
  131984. * @param options defines the options used to create the mesh
  131985. * @param scene defines the hosting scene
  131986. * @returns the ribbon mesh
  131987. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131988. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131989. */
  131990. static CreateRibbon(name: string, options: {
  131991. pathArray: Vector3[][];
  131992. closeArray?: boolean;
  131993. closePath?: boolean;
  131994. offset?: number;
  131995. updatable?: boolean;
  131996. sideOrientation?: number;
  131997. frontUVs?: Vector4;
  131998. backUVs?: Vector4;
  131999. instance?: Mesh;
  132000. invertUV?: boolean;
  132001. uvs?: Vector2[];
  132002. colors?: Color4[];
  132003. }, scene?: Nullable<Scene>): Mesh;
  132004. }
  132005. }
  132006. declare module BABYLON {
  132007. /**
  132008. * Class containing static functions to help procedurally build meshes
  132009. */
  132010. export class ShapeBuilder {
  132011. /**
  132012. * 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.
  132013. * * 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.
  132014. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  132015. * * 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.
  132016. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  132017. * * 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
  132018. * * 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
  132019. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  132020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132021. * * 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
  132022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  132023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132024. * @param name defines the name of the mesh
  132025. * @param options defines the options used to create the mesh
  132026. * @param scene defines the hosting scene
  132027. * @returns the extruded shape mesh
  132028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  132029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  132030. */
  132031. static ExtrudeShape(name: string, options: {
  132032. shape: Vector3[];
  132033. path: Vector3[];
  132034. scale?: number;
  132035. rotation?: number;
  132036. cap?: number;
  132037. updatable?: boolean;
  132038. sideOrientation?: number;
  132039. frontUVs?: Vector4;
  132040. backUVs?: Vector4;
  132041. instance?: Mesh;
  132042. invertUV?: boolean;
  132043. }, scene?: Nullable<Scene>): Mesh;
  132044. /**
  132045. * Creates an custom extruded shape mesh.
  132046. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  132047. * * 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.
  132048. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  132049. * * 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
  132050. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  132051. * * 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
  132052. * * It must returns a float value that will be the scale value applied to the shape on each path point
  132053. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  132054. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  132055. * * 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
  132056. * * 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
  132057. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  132058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132059. * * 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
  132060. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  132061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132062. * @param name defines the name of the mesh
  132063. * @param options defines the options used to create the mesh
  132064. * @param scene defines the hosting scene
  132065. * @returns the custom extruded shape mesh
  132066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  132067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  132068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  132069. */
  132070. static ExtrudeShapeCustom(name: string, options: {
  132071. shape: Vector3[];
  132072. path: Vector3[];
  132073. scaleFunction?: any;
  132074. rotationFunction?: any;
  132075. ribbonCloseArray?: boolean;
  132076. ribbonClosePath?: boolean;
  132077. cap?: number;
  132078. updatable?: boolean;
  132079. sideOrientation?: number;
  132080. frontUVs?: Vector4;
  132081. backUVs?: Vector4;
  132082. instance?: Mesh;
  132083. invertUV?: boolean;
  132084. }, scene?: Nullable<Scene>): Mesh;
  132085. private static _ExtrudeShapeGeneric;
  132086. }
  132087. }
  132088. declare module BABYLON {
  132089. /**
  132090. * AmmoJS Physics plugin
  132091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  132092. * @see https://github.com/kripken/ammo.js/
  132093. */
  132094. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  132095. private _useDeltaForWorldStep;
  132096. /**
  132097. * Reference to the Ammo library
  132098. */
  132099. bjsAMMO: any;
  132100. /**
  132101. * Created ammoJS world which physics bodies are added to
  132102. */
  132103. world: any;
  132104. /**
  132105. * Name of the plugin
  132106. */
  132107. name: string;
  132108. private _timeStep;
  132109. private _fixedTimeStep;
  132110. private _maxSteps;
  132111. private _tmpQuaternion;
  132112. private _tmpAmmoTransform;
  132113. private _tmpAmmoQuaternion;
  132114. private _tmpAmmoConcreteContactResultCallback;
  132115. private _collisionConfiguration;
  132116. private _dispatcher;
  132117. private _overlappingPairCache;
  132118. private _solver;
  132119. private _softBodySolver;
  132120. private _tmpAmmoVectorA;
  132121. private _tmpAmmoVectorB;
  132122. private _tmpAmmoVectorC;
  132123. private _tmpAmmoVectorD;
  132124. private _tmpContactCallbackResult;
  132125. private _tmpAmmoVectorRCA;
  132126. private _tmpAmmoVectorRCB;
  132127. private _raycastResult;
  132128. private static readonly DISABLE_COLLISION_FLAG;
  132129. private static readonly KINEMATIC_FLAG;
  132130. private static readonly DISABLE_DEACTIVATION_FLAG;
  132131. /**
  132132. * Initializes the ammoJS plugin
  132133. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  132134. * @param ammoInjection can be used to inject your own ammo reference
  132135. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  132136. */
  132137. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  132138. /**
  132139. * Sets the gravity of the physics world (m/(s^2))
  132140. * @param gravity Gravity to set
  132141. */
  132142. setGravity(gravity: Vector3): void;
  132143. /**
  132144. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  132145. * @param timeStep timestep to use in seconds
  132146. */
  132147. setTimeStep(timeStep: number): void;
  132148. /**
  132149. * 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)
  132150. * @param fixedTimeStep fixedTimeStep to use in seconds
  132151. */
  132152. setFixedTimeStep(fixedTimeStep: number): void;
  132153. /**
  132154. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  132155. * @param maxSteps the maximum number of steps by the physics engine per frame
  132156. */
  132157. setMaxSteps(maxSteps: number): void;
  132158. /**
  132159. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  132160. * @returns the current timestep in seconds
  132161. */
  132162. getTimeStep(): number;
  132163. /**
  132164. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  132165. */
  132166. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  132167. private _isImpostorInContact;
  132168. private _isImpostorPairInContact;
  132169. private _stepSimulation;
  132170. /**
  132171. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  132172. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  132173. * After the step the babylon meshes are set to the position of the physics imposters
  132174. * @param delta amount of time to step forward
  132175. * @param impostors array of imposters to update before/after the step
  132176. */
  132177. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  132178. /**
  132179. * Update babylon mesh to match physics world object
  132180. * @param impostor imposter to match
  132181. */
  132182. private _afterSoftStep;
  132183. /**
  132184. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132185. * @param impostor imposter to match
  132186. */
  132187. private _ropeStep;
  132188. /**
  132189. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132190. * @param impostor imposter to match
  132191. */
  132192. private _softbodyOrClothStep;
  132193. private _tmpMatrix;
  132194. /**
  132195. * Applies an impulse on the imposter
  132196. * @param impostor imposter to apply impulse to
  132197. * @param force amount of force to be applied to the imposter
  132198. * @param contactPoint the location to apply the impulse on the imposter
  132199. */
  132200. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132201. /**
  132202. * Applies a force on the imposter
  132203. * @param impostor imposter to apply force
  132204. * @param force amount of force to be applied to the imposter
  132205. * @param contactPoint the location to apply the force on the imposter
  132206. */
  132207. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132208. /**
  132209. * Creates a physics body using the plugin
  132210. * @param impostor the imposter to create the physics body on
  132211. */
  132212. generatePhysicsBody(impostor: PhysicsImpostor): void;
  132213. /**
  132214. * Removes the physics body from the imposter and disposes of the body's memory
  132215. * @param impostor imposter to remove the physics body from
  132216. */
  132217. removePhysicsBody(impostor: PhysicsImpostor): void;
  132218. /**
  132219. * Generates a joint
  132220. * @param impostorJoint the imposter joint to create the joint with
  132221. */
  132222. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  132223. /**
  132224. * Removes a joint
  132225. * @param impostorJoint the imposter joint to remove the joint from
  132226. */
  132227. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  132228. private _addMeshVerts;
  132229. /**
  132230. * Initialise the soft body vertices to match its object's (mesh) vertices
  132231. * Softbody vertices (nodes) are in world space and to match this
  132232. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  132233. * @param impostor to create the softbody for
  132234. */
  132235. private _softVertexData;
  132236. /**
  132237. * Create an impostor's soft body
  132238. * @param impostor to create the softbody for
  132239. */
  132240. private _createSoftbody;
  132241. /**
  132242. * Create cloth for an impostor
  132243. * @param impostor to create the softbody for
  132244. */
  132245. private _createCloth;
  132246. /**
  132247. * Create rope for an impostor
  132248. * @param impostor to create the softbody for
  132249. */
  132250. private _createRope;
  132251. /**
  132252. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  132253. * @param impostor to create the custom physics shape for
  132254. */
  132255. private _createCustom;
  132256. private _addHullVerts;
  132257. private _createShape;
  132258. /**
  132259. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  132260. * @param impostor imposter containing the physics body and babylon object
  132261. */
  132262. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  132263. /**
  132264. * Sets the babylon object's position/rotation from the physics body's position/rotation
  132265. * @param impostor imposter containing the physics body and babylon object
  132266. * @param newPosition new position
  132267. * @param newRotation new rotation
  132268. */
  132269. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  132270. /**
  132271. * If this plugin is supported
  132272. * @returns true if its supported
  132273. */
  132274. isSupported(): boolean;
  132275. /**
  132276. * Sets the linear velocity of the physics body
  132277. * @param impostor imposter to set the velocity on
  132278. * @param velocity velocity to set
  132279. */
  132280. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132281. /**
  132282. * Sets the angular velocity of the physics body
  132283. * @param impostor imposter to set the velocity on
  132284. * @param velocity velocity to set
  132285. */
  132286. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132287. /**
  132288. * gets the linear velocity
  132289. * @param impostor imposter to get linear velocity from
  132290. * @returns linear velocity
  132291. */
  132292. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132293. /**
  132294. * gets the angular velocity
  132295. * @param impostor imposter to get angular velocity from
  132296. * @returns angular velocity
  132297. */
  132298. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132299. /**
  132300. * Sets the mass of physics body
  132301. * @param impostor imposter to set the mass on
  132302. * @param mass mass to set
  132303. */
  132304. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  132305. /**
  132306. * Gets the mass of the physics body
  132307. * @param impostor imposter to get the mass from
  132308. * @returns mass
  132309. */
  132310. getBodyMass(impostor: PhysicsImpostor): number;
  132311. /**
  132312. * Gets friction of the impostor
  132313. * @param impostor impostor to get friction from
  132314. * @returns friction value
  132315. */
  132316. getBodyFriction(impostor: PhysicsImpostor): number;
  132317. /**
  132318. * Sets friction of the impostor
  132319. * @param impostor impostor to set friction on
  132320. * @param friction friction value
  132321. */
  132322. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  132323. /**
  132324. * Gets restitution of the impostor
  132325. * @param impostor impostor to get restitution from
  132326. * @returns restitution value
  132327. */
  132328. getBodyRestitution(impostor: PhysicsImpostor): number;
  132329. /**
  132330. * Sets resitution of the impostor
  132331. * @param impostor impostor to set resitution on
  132332. * @param restitution resitution value
  132333. */
  132334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  132335. /**
  132336. * Gets pressure inside the impostor
  132337. * @param impostor impostor to get pressure from
  132338. * @returns pressure value
  132339. */
  132340. getBodyPressure(impostor: PhysicsImpostor): number;
  132341. /**
  132342. * Sets pressure inside a soft body impostor
  132343. * Cloth and rope must remain 0 pressure
  132344. * @param impostor impostor to set pressure on
  132345. * @param pressure pressure value
  132346. */
  132347. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  132348. /**
  132349. * Gets stiffness of the impostor
  132350. * @param impostor impostor to get stiffness from
  132351. * @returns pressure value
  132352. */
  132353. getBodyStiffness(impostor: PhysicsImpostor): number;
  132354. /**
  132355. * Sets stiffness of the impostor
  132356. * @param impostor impostor to set stiffness on
  132357. * @param stiffness stiffness value from 0 to 1
  132358. */
  132359. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  132360. /**
  132361. * Gets velocityIterations of the impostor
  132362. * @param impostor impostor to get velocity iterations from
  132363. * @returns velocityIterations value
  132364. */
  132365. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  132366. /**
  132367. * Sets velocityIterations of the impostor
  132368. * @param impostor impostor to set velocity iterations on
  132369. * @param velocityIterations velocityIterations value
  132370. */
  132371. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  132372. /**
  132373. * Gets positionIterations of the impostor
  132374. * @param impostor impostor to get position iterations from
  132375. * @returns positionIterations value
  132376. */
  132377. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  132378. /**
  132379. * Sets positionIterations of the impostor
  132380. * @param impostor impostor to set position on
  132381. * @param positionIterations positionIterations value
  132382. */
  132383. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  132384. /**
  132385. * Append an anchor to a cloth object
  132386. * @param impostor is the cloth impostor to add anchor to
  132387. * @param otherImpostor is the rigid impostor to anchor to
  132388. * @param width ratio across width from 0 to 1
  132389. * @param height ratio up height from 0 to 1
  132390. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  132391. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132392. */
  132393. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132394. /**
  132395. * Append an hook to a rope object
  132396. * @param impostor is the rope impostor to add hook to
  132397. * @param otherImpostor is the rigid impostor to hook to
  132398. * @param length ratio along the rope from 0 to 1
  132399. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  132400. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132401. */
  132402. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132403. /**
  132404. * Sleeps the physics body and stops it from being active
  132405. * @param impostor impostor to sleep
  132406. */
  132407. sleepBody(impostor: PhysicsImpostor): void;
  132408. /**
  132409. * Activates the physics body
  132410. * @param impostor impostor to activate
  132411. */
  132412. wakeUpBody(impostor: PhysicsImpostor): void;
  132413. /**
  132414. * Updates the distance parameters of the joint
  132415. * @param joint joint to update
  132416. * @param maxDistance maximum distance of the joint
  132417. * @param minDistance minimum distance of the joint
  132418. */
  132419. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  132420. /**
  132421. * Sets a motor on the joint
  132422. * @param joint joint to set motor on
  132423. * @param speed speed of the motor
  132424. * @param maxForce maximum force of the motor
  132425. * @param motorIndex index of the motor
  132426. */
  132427. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  132428. /**
  132429. * Sets the motors limit
  132430. * @param joint joint to set limit on
  132431. * @param upperLimit upper limit
  132432. * @param lowerLimit lower limit
  132433. */
  132434. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  132435. /**
  132436. * Syncs the position and rotation of a mesh with the impostor
  132437. * @param mesh mesh to sync
  132438. * @param impostor impostor to update the mesh with
  132439. */
  132440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  132441. /**
  132442. * Gets the radius of the impostor
  132443. * @param impostor impostor to get radius from
  132444. * @returns the radius
  132445. */
  132446. getRadius(impostor: PhysicsImpostor): number;
  132447. /**
  132448. * Gets the box size of the impostor
  132449. * @param impostor impostor to get box size from
  132450. * @param result the resulting box size
  132451. */
  132452. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  132453. /**
  132454. * Disposes of the impostor
  132455. */
  132456. dispose(): void;
  132457. /**
  132458. * Does a raycast in the physics world
  132459. * @param from when should the ray start?
  132460. * @param to when should the ray end?
  132461. * @returns PhysicsRaycastResult
  132462. */
  132463. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  132464. }
  132465. }
  132466. declare module BABYLON {
  132467. interface AbstractScene {
  132468. /**
  132469. * The list of reflection probes added to the scene
  132470. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132471. */
  132472. reflectionProbes: Array<ReflectionProbe>;
  132473. /**
  132474. * Removes the given reflection probe from this scene.
  132475. * @param toRemove The reflection probe to remove
  132476. * @returns The index of the removed reflection probe
  132477. */
  132478. removeReflectionProbe(toRemove: ReflectionProbe): number;
  132479. /**
  132480. * Adds the given reflection probe to this scene.
  132481. * @param newReflectionProbe The reflection probe to add
  132482. */
  132483. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  132484. }
  132485. /**
  132486. * Class used to generate realtime reflection / refraction cube textures
  132487. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132488. */
  132489. export class ReflectionProbe {
  132490. /** defines the name of the probe */
  132491. name: string;
  132492. private _scene;
  132493. private _renderTargetTexture;
  132494. private _projectionMatrix;
  132495. private _viewMatrix;
  132496. private _target;
  132497. private _add;
  132498. private _attachedMesh;
  132499. private _invertYAxis;
  132500. /** Gets or sets probe position (center of the cube map) */
  132501. position: Vector3;
  132502. /**
  132503. * Creates a new reflection probe
  132504. * @param name defines the name of the probe
  132505. * @param size defines the texture resolution (for each face)
  132506. * @param scene defines the hosting scene
  132507. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  132508. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  132509. */
  132510. constructor(
  132511. /** defines the name of the probe */
  132512. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  132513. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  132514. get samples(): number;
  132515. set samples(value: number);
  132516. /** Gets or sets the refresh rate to use (on every frame by default) */
  132517. get refreshRate(): number;
  132518. set refreshRate(value: number);
  132519. /**
  132520. * Gets the hosting scene
  132521. * @returns a Scene
  132522. */
  132523. getScene(): Scene;
  132524. /** Gets the internal CubeTexture used to render to */
  132525. get cubeTexture(): RenderTargetTexture;
  132526. /** Gets the list of meshes to render */
  132527. get renderList(): Nullable<AbstractMesh[]>;
  132528. /**
  132529. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  132530. * @param mesh defines the mesh to attach to
  132531. */
  132532. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132533. /**
  132534. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  132535. * @param renderingGroupId The rendering group id corresponding to its index
  132536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132537. */
  132538. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  132539. /**
  132540. * Clean all associated resources
  132541. */
  132542. dispose(): void;
  132543. /**
  132544. * Converts the reflection probe information to a readable string for debug purpose.
  132545. * @param fullDetails Supports for multiple levels of logging within scene loading
  132546. * @returns the human readable reflection probe info
  132547. */
  132548. toString(fullDetails?: boolean): string;
  132549. /**
  132550. * Get the class name of the relfection probe.
  132551. * @returns "ReflectionProbe"
  132552. */
  132553. getClassName(): string;
  132554. /**
  132555. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  132556. * @returns The JSON representation of the texture
  132557. */
  132558. serialize(): any;
  132559. /**
  132560. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  132561. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  132562. * @param scene Define the scene the parsed reflection probe should be instantiated in
  132563. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  132564. * @returns The parsed reflection probe if successful
  132565. */
  132566. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  132567. }
  132568. }
  132569. declare module BABYLON {
  132570. /** @hidden */
  132571. export var _BabylonLoaderRegistered: boolean;
  132572. /**
  132573. * Helps setting up some configuration for the babylon file loader.
  132574. */
  132575. export class BabylonFileLoaderConfiguration {
  132576. /**
  132577. * The loader does not allow injecting custom physix engine into the plugins.
  132578. * Unfortunately in ES6, we need to manually inject them into the plugin.
  132579. * So you could set this variable to your engine import to make it work.
  132580. */
  132581. static LoaderInjectedPhysicsEngine: any;
  132582. }
  132583. }
  132584. declare module BABYLON {
  132585. /**
  132586. * The Physically based simple base material of BJS.
  132587. *
  132588. * This enables better naming and convention enforcements on top of the pbrMaterial.
  132589. * It is used as the base class for both the specGloss and metalRough conventions.
  132590. */
  132591. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  132592. /**
  132593. * Number of Simultaneous lights allowed on the material.
  132594. */
  132595. maxSimultaneousLights: number;
  132596. /**
  132597. * If sets to true, disables all the lights affecting the material.
  132598. */
  132599. disableLighting: boolean;
  132600. /**
  132601. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  132602. */
  132603. environmentTexture: BaseTexture;
  132604. /**
  132605. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132606. */
  132607. invertNormalMapX: boolean;
  132608. /**
  132609. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132610. */
  132611. invertNormalMapY: boolean;
  132612. /**
  132613. * Normal map used in the model.
  132614. */
  132615. normalTexture: BaseTexture;
  132616. /**
  132617. * Emissivie color used to self-illuminate the model.
  132618. */
  132619. emissiveColor: Color3;
  132620. /**
  132621. * Emissivie texture used to self-illuminate the model.
  132622. */
  132623. emissiveTexture: BaseTexture;
  132624. /**
  132625. * Occlusion Channel Strenght.
  132626. */
  132627. occlusionStrength: number;
  132628. /**
  132629. * Occlusion Texture of the material (adding extra occlusion effects).
  132630. */
  132631. occlusionTexture: BaseTexture;
  132632. /**
  132633. * Defines the alpha limits in alpha test mode.
  132634. */
  132635. alphaCutOff: number;
  132636. /**
  132637. * Gets the current double sided mode.
  132638. */
  132639. get doubleSided(): boolean;
  132640. /**
  132641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132642. */
  132643. set doubleSided(value: boolean);
  132644. /**
  132645. * Stores the pre-calculated light information of a mesh in a texture.
  132646. */
  132647. lightmapTexture: BaseTexture;
  132648. /**
  132649. * If true, the light map contains occlusion information instead of lighting info.
  132650. */
  132651. useLightmapAsShadowmap: boolean;
  132652. /**
  132653. * Instantiates a new PBRMaterial instance.
  132654. *
  132655. * @param name The material name
  132656. * @param scene The scene the material will be use in.
  132657. */
  132658. constructor(name: string, scene: Scene);
  132659. getClassName(): string;
  132660. }
  132661. }
  132662. declare module BABYLON {
  132663. /**
  132664. * The PBR material of BJS following the metal roughness convention.
  132665. *
  132666. * This fits to the PBR convention in the GLTF definition:
  132667. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  132668. */
  132669. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  132670. /**
  132671. * The base color has two different interpretations depending on the value of metalness.
  132672. * When the material is a metal, the base color is the specific measured reflectance value
  132673. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  132674. * of the material.
  132675. */
  132676. baseColor: Color3;
  132677. /**
  132678. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  132679. * well as opacity information in the alpha channel.
  132680. */
  132681. baseTexture: BaseTexture;
  132682. /**
  132683. * Specifies the metallic scalar value of the material.
  132684. * Can also be used to scale the metalness values of the metallic texture.
  132685. */
  132686. metallic: number;
  132687. /**
  132688. * Specifies the roughness scalar value of the material.
  132689. * Can also be used to scale the roughness values of the metallic texture.
  132690. */
  132691. roughness: number;
  132692. /**
  132693. * Texture containing both the metallic value in the B channel and the
  132694. * roughness value in the G channel to keep better precision.
  132695. */
  132696. metallicRoughnessTexture: BaseTexture;
  132697. /**
  132698. * Instantiates a new PBRMetalRoughnessMaterial instance.
  132699. *
  132700. * @param name The material name
  132701. * @param scene The scene the material will be use in.
  132702. */
  132703. constructor(name: string, scene: Scene);
  132704. /**
  132705. * Return the currrent class name of the material.
  132706. */
  132707. getClassName(): string;
  132708. /**
  132709. * Makes a duplicate of the current material.
  132710. * @param name - name to use for the new material.
  132711. */
  132712. clone(name: string): PBRMetallicRoughnessMaterial;
  132713. /**
  132714. * Serialize the material to a parsable JSON object.
  132715. */
  132716. serialize(): any;
  132717. /**
  132718. * Parses a JSON object correponding to the serialize function.
  132719. */
  132720. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  132721. }
  132722. }
  132723. declare module BABYLON {
  132724. /**
  132725. * The PBR material of BJS following the specular glossiness convention.
  132726. *
  132727. * This fits to the PBR convention in the GLTF definition:
  132728. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  132729. */
  132730. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  132731. /**
  132732. * Specifies the diffuse color of the material.
  132733. */
  132734. diffuseColor: Color3;
  132735. /**
  132736. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  132737. * channel.
  132738. */
  132739. diffuseTexture: BaseTexture;
  132740. /**
  132741. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  132742. */
  132743. specularColor: Color3;
  132744. /**
  132745. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  132746. */
  132747. glossiness: number;
  132748. /**
  132749. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  132750. */
  132751. specularGlossinessTexture: BaseTexture;
  132752. /**
  132753. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  132754. *
  132755. * @param name The material name
  132756. * @param scene The scene the material will be use in.
  132757. */
  132758. constructor(name: string, scene: Scene);
  132759. /**
  132760. * Return the currrent class name of the material.
  132761. */
  132762. getClassName(): string;
  132763. /**
  132764. * Makes a duplicate of the current material.
  132765. * @param name - name to use for the new material.
  132766. */
  132767. clone(name: string): PBRSpecularGlossinessMaterial;
  132768. /**
  132769. * Serialize the material to a parsable JSON object.
  132770. */
  132771. serialize(): any;
  132772. /**
  132773. * Parses a JSON object correponding to the serialize function.
  132774. */
  132775. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  132776. }
  132777. }
  132778. declare module BABYLON {
  132779. /**
  132780. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  132781. * It can help converting any input color in a desired output one. This can then be used to create effects
  132782. * from sepia, black and white to sixties or futuristic rendering...
  132783. *
  132784. * The only supported format is currently 3dl.
  132785. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  132786. */
  132787. export class ColorGradingTexture extends BaseTexture {
  132788. /**
  132789. * The texture URL.
  132790. */
  132791. url: string;
  132792. /**
  132793. * Empty line regex stored for GC.
  132794. */
  132795. private static _noneEmptyLineRegex;
  132796. private _textureMatrix;
  132797. private _onLoad;
  132798. /**
  132799. * Instantiates a ColorGradingTexture from the following parameters.
  132800. *
  132801. * @param url The location of the color gradind data (currently only supporting 3dl)
  132802. * @param sceneOrEngine The scene or engine the texture will be used in
  132803. * @param onLoad defines a callback triggered when the texture has been loaded
  132804. */
  132805. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  132806. /**
  132807. * Fires the onload event from the constructor if requested.
  132808. */
  132809. private _triggerOnLoad;
  132810. /**
  132811. * Returns the texture matrix used in most of the material.
  132812. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  132813. */
  132814. getTextureMatrix(): Matrix;
  132815. /**
  132816. * Occurs when the file being loaded is a .3dl LUT file.
  132817. */
  132818. private load3dlTexture;
  132819. /**
  132820. * Starts the loading process of the texture.
  132821. */
  132822. private loadTexture;
  132823. /**
  132824. * Clones the color gradind texture.
  132825. */
  132826. clone(): ColorGradingTexture;
  132827. /**
  132828. * Called during delayed load for textures.
  132829. */
  132830. delayLoad(): void;
  132831. /**
  132832. * Parses a color grading texture serialized by Babylon.
  132833. * @param parsedTexture The texture information being parsedTexture
  132834. * @param scene The scene to load the texture in
  132835. * @param rootUrl The root url of the data assets to load
  132836. * @return A color gradind texture
  132837. */
  132838. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  132839. /**
  132840. * Serializes the LUT texture to json format.
  132841. */
  132842. serialize(): any;
  132843. }
  132844. }
  132845. declare module BABYLON {
  132846. /**
  132847. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  132848. */
  132849. export class EquiRectangularCubeTexture extends BaseTexture {
  132850. /** The six faces of the cube. */
  132851. private static _FacesMapping;
  132852. private _noMipmap;
  132853. private _onLoad;
  132854. private _onError;
  132855. /** The size of the cubemap. */
  132856. private _size;
  132857. /** The buffer of the image. */
  132858. private _buffer;
  132859. /** The width of the input image. */
  132860. private _width;
  132861. /** The height of the input image. */
  132862. private _height;
  132863. /** The URL to the image. */
  132864. url: string;
  132865. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  132866. coordinatesMode: number;
  132867. /**
  132868. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  132869. * @param url The location of the image
  132870. * @param scene The scene the texture will be used in
  132871. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  132872. * @param noMipmap Forces to not generate the mipmap if true
  132873. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132874. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132875. * @param onLoad — defines a callback called when texture is loaded
  132876. * @param onError — defines a callback called if there is an error
  132877. */
  132878. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  132879. /**
  132880. * Load the image data, by putting the image on a canvas and extracting its buffer.
  132881. */
  132882. private loadImage;
  132883. /**
  132884. * Convert the image buffer into a cubemap and create a CubeTexture.
  132885. */
  132886. private loadTexture;
  132887. /**
  132888. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  132889. * @param buffer The ArrayBuffer that should be converted.
  132890. * @returns The buffer as Float32Array.
  132891. */
  132892. private getFloat32ArrayFromArrayBuffer;
  132893. /**
  132894. * Get the current class name of the texture useful for serialization or dynamic coding.
  132895. * @returns "EquiRectangularCubeTexture"
  132896. */
  132897. getClassName(): string;
  132898. /**
  132899. * Create a clone of the current EquiRectangularCubeTexture and return it.
  132900. * @returns A clone of the current EquiRectangularCubeTexture.
  132901. */
  132902. clone(): EquiRectangularCubeTexture;
  132903. }
  132904. }
  132905. declare module BABYLON {
  132906. /**
  132907. * Based on jsTGALoader - Javascript loader for TGA file
  132908. * By Vincent Thibault
  132909. * @see http://blog.robrowser.com/javascript-tga-loader.html
  132910. */
  132911. export class TGATools {
  132912. private static _TYPE_INDEXED;
  132913. private static _TYPE_RGB;
  132914. private static _TYPE_GREY;
  132915. private static _TYPE_RLE_INDEXED;
  132916. private static _TYPE_RLE_RGB;
  132917. private static _TYPE_RLE_GREY;
  132918. private static _ORIGIN_MASK;
  132919. private static _ORIGIN_SHIFT;
  132920. private static _ORIGIN_BL;
  132921. private static _ORIGIN_BR;
  132922. private static _ORIGIN_UL;
  132923. private static _ORIGIN_UR;
  132924. /**
  132925. * Gets the header of a TGA file
  132926. * @param data defines the TGA data
  132927. * @returns the header
  132928. */
  132929. static GetTGAHeader(data: Uint8Array): any;
  132930. /**
  132931. * Uploads TGA content to a Babylon Texture
  132932. * @hidden
  132933. */
  132934. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  132935. /** @hidden */
  132936. 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;
  132937. /** @hidden */
  132938. 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;
  132939. /** @hidden */
  132940. 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;
  132941. /** @hidden */
  132942. 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;
  132943. /** @hidden */
  132944. 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;
  132945. /** @hidden */
  132946. 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;
  132947. }
  132948. }
  132949. declare module BABYLON {
  132950. /**
  132951. * Implementation of the TGA Texture Loader.
  132952. * @hidden
  132953. */
  132954. export class _TGATextureLoader implements IInternalTextureLoader {
  132955. /**
  132956. * Defines wether the loader supports cascade loading the different faces.
  132957. */
  132958. readonly supportCascades: boolean;
  132959. /**
  132960. * This returns if the loader support the current file information.
  132961. * @param extension defines the file extension of the file being loaded
  132962. * @returns true if the loader can load the specified file
  132963. */
  132964. canLoad(extension: string): boolean;
  132965. /**
  132966. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132967. * @param data contains the texture data
  132968. * @param texture defines the BabylonJS internal texture
  132969. * @param createPolynomials will be true if polynomials have been requested
  132970. * @param onLoad defines the callback to trigger once the texture is ready
  132971. * @param onError defines the callback to trigger in case of error
  132972. */
  132973. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132974. /**
  132975. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132976. * @param data contains the texture data
  132977. * @param texture defines the BabylonJS internal texture
  132978. * @param callback defines the method to call once ready to upload
  132979. */
  132980. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132981. }
  132982. }
  132983. declare module BABYLON {
  132984. /**
  132985. * Info about the .basis files
  132986. */
  132987. class BasisFileInfo {
  132988. /**
  132989. * If the file has alpha
  132990. */
  132991. hasAlpha: boolean;
  132992. /**
  132993. * Info about each image of the basis file
  132994. */
  132995. images: Array<{
  132996. levels: Array<{
  132997. width: number;
  132998. height: number;
  132999. transcodedPixels: ArrayBufferView;
  133000. }>;
  133001. }>;
  133002. }
  133003. /**
  133004. * Result of transcoding a basis file
  133005. */
  133006. class TranscodeResult {
  133007. /**
  133008. * Info about the .basis file
  133009. */
  133010. fileInfo: BasisFileInfo;
  133011. /**
  133012. * Format to use when loading the file
  133013. */
  133014. format: number;
  133015. }
  133016. /**
  133017. * Configuration options for the Basis transcoder
  133018. */
  133019. export class BasisTranscodeConfiguration {
  133020. /**
  133021. * Supported compression formats used to determine the supported output format of the transcoder
  133022. */
  133023. supportedCompressionFormats?: {
  133024. /**
  133025. * etc1 compression format
  133026. */
  133027. etc1?: boolean;
  133028. /**
  133029. * s3tc compression format
  133030. */
  133031. s3tc?: boolean;
  133032. /**
  133033. * pvrtc compression format
  133034. */
  133035. pvrtc?: boolean;
  133036. /**
  133037. * etc2 compression format
  133038. */
  133039. etc2?: boolean;
  133040. };
  133041. /**
  133042. * If mipmap levels should be loaded for transcoded images (Default: true)
  133043. */
  133044. loadMipmapLevels?: boolean;
  133045. /**
  133046. * Index of a single image to load (Default: all images)
  133047. */
  133048. loadSingleImage?: number;
  133049. }
  133050. /**
  133051. * Used to load .Basis files
  133052. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  133053. */
  133054. export class BasisTools {
  133055. private static _IgnoreSupportedFormats;
  133056. /**
  133057. * URL to use when loading the basis transcoder
  133058. */
  133059. static JSModuleURL: string;
  133060. /**
  133061. * URL to use when loading the wasm module for the transcoder
  133062. */
  133063. static WasmModuleURL: string;
  133064. /**
  133065. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  133066. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  133067. * @returns internal format corresponding to the Basis format
  133068. */
  133069. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  133070. private static _WorkerPromise;
  133071. private static _Worker;
  133072. private static _actionId;
  133073. private static _CreateWorkerAsync;
  133074. /**
  133075. * Transcodes a loaded image file to compressed pixel data
  133076. * @param data image data to transcode
  133077. * @param config configuration options for the transcoding
  133078. * @returns a promise resulting in the transcoded image
  133079. */
  133080. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  133081. /**
  133082. * Loads a texture from the transcode result
  133083. * @param texture texture load to
  133084. * @param transcodeResult the result of transcoding the basis file to load from
  133085. */
  133086. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  133087. }
  133088. }
  133089. declare module BABYLON {
  133090. /**
  133091. * Loader for .basis file format
  133092. */
  133093. export class _BasisTextureLoader implements IInternalTextureLoader {
  133094. /**
  133095. * Defines whether the loader supports cascade loading the different faces.
  133096. */
  133097. readonly supportCascades: boolean;
  133098. /**
  133099. * This returns if the loader support the current file information.
  133100. * @param extension defines the file extension of the file being loaded
  133101. * @returns true if the loader can load the specified file
  133102. */
  133103. canLoad(extension: string): boolean;
  133104. /**
  133105. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133106. * @param data contains the texture data
  133107. * @param texture defines the BabylonJS internal texture
  133108. * @param createPolynomials will be true if polynomials have been requested
  133109. * @param onLoad defines the callback to trigger once the texture is ready
  133110. * @param onError defines the callback to trigger in case of error
  133111. */
  133112. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133113. /**
  133114. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133115. * @param data contains the texture data
  133116. * @param texture defines the BabylonJS internal texture
  133117. * @param callback defines the method to call once ready to upload
  133118. */
  133119. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133120. }
  133121. }
  133122. declare module BABYLON {
  133123. /**
  133124. * 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.
  133125. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  133126. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  133127. */
  133128. export class CustomProceduralTexture extends ProceduralTexture {
  133129. private _animate;
  133130. private _time;
  133131. private _config;
  133132. private _texturePath;
  133133. /**
  133134. * Instantiates a new Custom Procedural Texture.
  133135. * 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.
  133136. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  133137. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  133138. * @param name Define the name of the texture
  133139. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  133140. * @param size Define the size of the texture to create
  133141. * @param scene Define the scene the texture belongs to
  133142. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  133143. * @param generateMipMaps Define if the texture should creates mip maps or not
  133144. */
  133145. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133146. private _loadJson;
  133147. /**
  133148. * Is the texture ready to be used ? (rendered at least once)
  133149. * @returns true if ready, otherwise, false.
  133150. */
  133151. isReady(): boolean;
  133152. /**
  133153. * Render the texture to its associated render target.
  133154. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  133155. */
  133156. render(useCameraPostProcess?: boolean): void;
  133157. /**
  133158. * Update the list of dependant textures samplers in the shader.
  133159. */
  133160. updateTextures(): void;
  133161. /**
  133162. * Update the uniform values of the procedural texture in the shader.
  133163. */
  133164. updateShaderUniforms(): void;
  133165. /**
  133166. * Define if the texture animates or not.
  133167. */
  133168. get animate(): boolean;
  133169. set animate(value: boolean);
  133170. }
  133171. }
  133172. declare module BABYLON {
  133173. /** @hidden */
  133174. export var noisePixelShader: {
  133175. name: string;
  133176. shader: string;
  133177. };
  133178. }
  133179. declare module BABYLON {
  133180. /**
  133181. * Class used to generate noise procedural textures
  133182. */
  133183. export class NoiseProceduralTexture extends ProceduralTexture {
  133184. private _time;
  133185. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  133186. brightness: number;
  133187. /** Defines the number of octaves to process */
  133188. octaves: number;
  133189. /** Defines the level of persistence (0.8 by default) */
  133190. persistence: number;
  133191. /** Gets or sets animation speed factor (default is 1) */
  133192. animationSpeedFactor: number;
  133193. /**
  133194. * Creates a new NoiseProceduralTexture
  133195. * @param name defines the name fo the texture
  133196. * @param size defines the size of the texture (default is 256)
  133197. * @param scene defines the hosting scene
  133198. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  133199. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  133200. */
  133201. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133202. private _updateShaderUniforms;
  133203. protected _getDefines(): string;
  133204. /** Generate the current state of the procedural texture */
  133205. render(useCameraPostProcess?: boolean): void;
  133206. /**
  133207. * Serializes this noise procedural texture
  133208. * @returns a serialized noise procedural texture object
  133209. */
  133210. serialize(): any;
  133211. /**
  133212. * Clone the texture.
  133213. * @returns the cloned texture
  133214. */
  133215. clone(): NoiseProceduralTexture;
  133216. /**
  133217. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  133218. * @param parsedTexture defines parsed texture data
  133219. * @param scene defines the current scene
  133220. * @param rootUrl defines the root URL containing noise procedural texture information
  133221. * @returns a parsed NoiseProceduralTexture
  133222. */
  133223. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  133224. }
  133225. }
  133226. declare module BABYLON {
  133227. /**
  133228. * Raw cube texture where the raw buffers are passed in
  133229. */
  133230. export class RawCubeTexture extends CubeTexture {
  133231. /**
  133232. * Creates a cube texture where the raw buffers are passed in.
  133233. * @param scene defines the scene the texture is attached to
  133234. * @param data defines the array of data to use to create each face
  133235. * @param size defines the size of the textures
  133236. * @param format defines the format of the data
  133237. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  133238. * @param generateMipMaps defines if the engine should generate the mip levels
  133239. * @param invertY defines if data must be stored with Y axis inverted
  133240. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  133241. * @param compression defines the compression used (null by default)
  133242. */
  133243. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  133244. /**
  133245. * Updates the raw cube texture.
  133246. * @param data defines the data to store
  133247. * @param format defines the data format
  133248. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  133249. * @param invertY defines if data must be stored with Y axis inverted
  133250. * @param compression defines the compression used (null by default)
  133251. * @param level defines which level of the texture to update
  133252. */
  133253. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  133254. /**
  133255. * Updates a raw cube texture with RGBD encoded data.
  133256. * @param data defines the array of data [mipmap][face] to use to create each face
  133257. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  133258. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133259. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133260. * @returns a promsie that resolves when the operation is complete
  133261. */
  133262. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  133263. /**
  133264. * Clones the raw cube texture.
  133265. * @return a new cube texture
  133266. */
  133267. clone(): CubeTexture;
  133268. /** @hidden */
  133269. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133270. }
  133271. }
  133272. declare module BABYLON {
  133273. /**
  133274. * Class used to store 3D textures containing user data
  133275. */
  133276. export class RawTexture3D extends Texture {
  133277. /** Gets or sets the texture format to use */
  133278. format: number;
  133279. /**
  133280. * Create a new RawTexture3D
  133281. * @param data defines the data of the texture
  133282. * @param width defines the width of the texture
  133283. * @param height defines the height of the texture
  133284. * @param depth defines the depth of the texture
  133285. * @param format defines the texture format to use
  133286. * @param scene defines the hosting scene
  133287. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133288. * @param invertY defines if texture must be stored with Y axis inverted
  133289. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133290. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133291. */
  133292. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133293. /** Gets or sets the texture format to use */
  133294. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133295. /**
  133296. * Update the texture with new data
  133297. * @param data defines the data to store in the texture
  133298. */
  133299. update(data: ArrayBufferView): void;
  133300. }
  133301. }
  133302. declare module BABYLON {
  133303. /**
  133304. * Class used to store 2D array textures containing user data
  133305. */
  133306. export class RawTexture2DArray extends Texture {
  133307. /** Gets or sets the texture format to use */
  133308. format: number;
  133309. /**
  133310. * Create a new RawTexture2DArray
  133311. * @param data defines the data of the texture
  133312. * @param width defines the width of the texture
  133313. * @param height defines the height of the texture
  133314. * @param depth defines the number of layers of the texture
  133315. * @param format defines the texture format to use
  133316. * @param scene defines the hosting scene
  133317. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133318. * @param invertY defines if texture must be stored with Y axis inverted
  133319. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133320. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133321. */
  133322. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133323. /** Gets or sets the texture format to use */
  133324. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133325. /**
  133326. * Update the texture with new data
  133327. * @param data defines the data to store in the texture
  133328. */
  133329. update(data: ArrayBufferView): void;
  133330. }
  133331. }
  133332. declare module BABYLON {
  133333. /**
  133334. * Creates a refraction texture used by refraction channel of the standard material.
  133335. * It is like a mirror but to see through a material.
  133336. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133337. */
  133338. export class RefractionTexture extends RenderTargetTexture {
  133339. /**
  133340. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  133341. * 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.
  133342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133343. */
  133344. refractionPlane: Plane;
  133345. /**
  133346. * Define how deep under the surface we should see.
  133347. */
  133348. depth: number;
  133349. /**
  133350. * Creates a refraction texture used by refraction channel of the standard material.
  133351. * It is like a mirror but to see through a material.
  133352. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133353. * @param name Define the texture name
  133354. * @param size Define the size of the underlying texture
  133355. * @param scene Define the scene the refraction belongs to
  133356. * @param generateMipMaps Define if we need to generate mips level for the refraction
  133357. */
  133358. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  133359. /**
  133360. * Clone the refraction texture.
  133361. * @returns the cloned texture
  133362. */
  133363. clone(): RefractionTexture;
  133364. /**
  133365. * Serialize the texture to a JSON representation you could use in Parse later on
  133366. * @returns the serialized JSON representation
  133367. */
  133368. serialize(): any;
  133369. }
  133370. }
  133371. declare module BABYLON {
  133372. /**
  133373. * Defines the options related to the creation of an HtmlElementTexture
  133374. */
  133375. export interface IHtmlElementTextureOptions {
  133376. /**
  133377. * Defines wether mip maps should be created or not.
  133378. */
  133379. generateMipMaps?: boolean;
  133380. /**
  133381. * Defines the sampling mode of the texture.
  133382. */
  133383. samplingMode?: number;
  133384. /**
  133385. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  133386. */
  133387. engine: Nullable<ThinEngine>;
  133388. /**
  133389. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  133390. */
  133391. scene: Nullable<Scene>;
  133392. }
  133393. /**
  133394. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  133395. * To be as efficient as possible depending on your constraints nothing aside the first upload
  133396. * is automatically managed.
  133397. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  133398. * in your application.
  133399. *
  133400. * As the update is not automatic, you need to call them manually.
  133401. */
  133402. export class HtmlElementTexture extends BaseTexture {
  133403. /**
  133404. * The texture URL.
  133405. */
  133406. element: HTMLVideoElement | HTMLCanvasElement;
  133407. private static readonly DefaultOptions;
  133408. private _textureMatrix;
  133409. private _isVideo;
  133410. private _generateMipMaps;
  133411. private _samplingMode;
  133412. /**
  133413. * Instantiates a HtmlElementTexture from the following parameters.
  133414. *
  133415. * @param name Defines the name of the texture
  133416. * @param element Defines the video or canvas the texture is filled with
  133417. * @param options Defines the other none mandatory texture creation options
  133418. */
  133419. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  133420. private _createInternalTexture;
  133421. /**
  133422. * Returns the texture matrix used in most of the material.
  133423. */
  133424. getTextureMatrix(): Matrix;
  133425. /**
  133426. * Updates the content of the texture.
  133427. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  133428. */
  133429. update(invertY?: Nullable<boolean>): void;
  133430. }
  133431. }
  133432. declare module BABYLON {
  133433. /**
  133434. * Defines the basic options interface of a TexturePacker Frame
  133435. */
  133436. export interface ITexturePackerFrame {
  133437. /**
  133438. * The frame ID
  133439. */
  133440. id: number;
  133441. /**
  133442. * The frames Scale
  133443. */
  133444. scale: Vector2;
  133445. /**
  133446. * The Frames offset
  133447. */
  133448. offset: Vector2;
  133449. }
  133450. /**
  133451. * This is a support class for frame Data on texture packer sets.
  133452. */
  133453. export class TexturePackerFrame implements ITexturePackerFrame {
  133454. /**
  133455. * The frame ID
  133456. */
  133457. id: number;
  133458. /**
  133459. * The frames Scale
  133460. */
  133461. scale: Vector2;
  133462. /**
  133463. * The Frames offset
  133464. */
  133465. offset: Vector2;
  133466. /**
  133467. * Initializes a texture package frame.
  133468. * @param id The numerical frame identifier
  133469. * @param scale Scalar Vector2 for UV frame
  133470. * @param offset Vector2 for the frame position in UV units.
  133471. * @returns TexturePackerFrame
  133472. */
  133473. constructor(id: number, scale: Vector2, offset: Vector2);
  133474. }
  133475. }
  133476. declare module BABYLON {
  133477. /**
  133478. * Defines the basic options interface of a TexturePacker
  133479. */
  133480. export interface ITexturePackerOptions {
  133481. /**
  133482. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  133483. */
  133484. map?: string[];
  133485. /**
  133486. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133487. */
  133488. uvsIn?: string;
  133489. /**
  133490. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133491. */
  133492. uvsOut?: string;
  133493. /**
  133494. * number representing the layout style. Defaults to LAYOUT_STRIP
  133495. */
  133496. layout?: number;
  133497. /**
  133498. * number of columns if using custom column count layout(2). This defaults to 4.
  133499. */
  133500. colnum?: number;
  133501. /**
  133502. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  133503. */
  133504. updateInputMeshes?: boolean;
  133505. /**
  133506. * boolean flag to dispose all the source textures. Defaults to true.
  133507. */
  133508. disposeSources?: boolean;
  133509. /**
  133510. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  133511. */
  133512. fillBlanks?: boolean;
  133513. /**
  133514. * string value representing the context fill style color. Defaults to 'black'.
  133515. */
  133516. customFillColor?: string;
  133517. /**
  133518. * Width and Height Value of each Frame in the TexturePacker Sets
  133519. */
  133520. frameSize?: number;
  133521. /**
  133522. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  133523. */
  133524. paddingRatio?: number;
  133525. /**
  133526. * Number that declares the fill method for the padding gutter.
  133527. */
  133528. paddingMode?: number;
  133529. /**
  133530. * If in SUBUV_COLOR padding mode what color to use.
  133531. */
  133532. paddingColor?: Color3 | Color4;
  133533. }
  133534. /**
  133535. * Defines the basic interface of a TexturePacker JSON File
  133536. */
  133537. export interface ITexturePackerJSON {
  133538. /**
  133539. * The frame ID
  133540. */
  133541. name: string;
  133542. /**
  133543. * The base64 channel data
  133544. */
  133545. sets: any;
  133546. /**
  133547. * The options of the Packer
  133548. */
  133549. options: ITexturePackerOptions;
  133550. /**
  133551. * The frame data of the Packer
  133552. */
  133553. frames: Array<number>;
  133554. }
  133555. /**
  133556. * This is a support class that generates a series of packed texture sets.
  133557. * @see https://doc.babylonjs.com/babylon101/materials
  133558. */
  133559. export class TexturePacker {
  133560. /** Packer Layout Constant 0 */
  133561. static readonly LAYOUT_STRIP: number;
  133562. /** Packer Layout Constant 1 */
  133563. static readonly LAYOUT_POWER2: number;
  133564. /** Packer Layout Constant 2 */
  133565. static readonly LAYOUT_COLNUM: number;
  133566. /** Packer Layout Constant 0 */
  133567. static readonly SUBUV_WRAP: number;
  133568. /** Packer Layout Constant 1 */
  133569. static readonly SUBUV_EXTEND: number;
  133570. /** Packer Layout Constant 2 */
  133571. static readonly SUBUV_COLOR: number;
  133572. /** The Name of the Texture Package */
  133573. name: string;
  133574. /** The scene scope of the TexturePacker */
  133575. scene: Scene;
  133576. /** The Meshes to target */
  133577. meshes: AbstractMesh[];
  133578. /** Arguments passed with the Constructor */
  133579. options: ITexturePackerOptions;
  133580. /** The promise that is started upon initialization */
  133581. promise: Nullable<Promise<TexturePacker | string>>;
  133582. /** The Container object for the channel sets that are generated */
  133583. sets: object;
  133584. /** The Container array for the frames that are generated */
  133585. frames: TexturePackerFrame[];
  133586. /** The expected number of textures the system is parsing. */
  133587. private _expecting;
  133588. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  133589. private _paddingValue;
  133590. /**
  133591. * Initializes a texture package series from an array of meshes or a single mesh.
  133592. * @param name The name of the package
  133593. * @param meshes The target meshes to compose the package from
  133594. * @param options The arguments that texture packer should follow while building.
  133595. * @param scene The scene which the textures are scoped to.
  133596. * @returns TexturePacker
  133597. */
  133598. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  133599. /**
  133600. * Starts the package process
  133601. * @param resolve The promises resolution function
  133602. * @returns TexturePacker
  133603. */
  133604. private _createFrames;
  133605. /**
  133606. * Calculates the Size of the Channel Sets
  133607. * @returns Vector2
  133608. */
  133609. private _calculateSize;
  133610. /**
  133611. * Calculates the UV data for the frames.
  133612. * @param baseSize the base frameSize
  133613. * @param padding the base frame padding
  133614. * @param dtSize size of the Dynamic Texture for that channel
  133615. * @param dtUnits is 1/dtSize
  133616. * @param update flag to update the input meshes
  133617. */
  133618. private _calculateMeshUVFrames;
  133619. /**
  133620. * Calculates the frames Offset.
  133621. * @param index of the frame
  133622. * @returns Vector2
  133623. */
  133624. private _getFrameOffset;
  133625. /**
  133626. * Updates a Mesh to the frame data
  133627. * @param mesh that is the target
  133628. * @param frameID or the frame index
  133629. */
  133630. private _updateMeshUV;
  133631. /**
  133632. * Updates a Meshes materials to use the texture packer channels
  133633. * @param m is the mesh to target
  133634. * @param force all channels on the packer to be set.
  133635. */
  133636. private _updateTextureReferences;
  133637. /**
  133638. * Public method to set a Mesh to a frame
  133639. * @param m that is the target
  133640. * @param frameID or the frame index
  133641. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  133642. */
  133643. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  133644. /**
  133645. * Starts the async promise to compile the texture packer.
  133646. * @returns Promise<void>
  133647. */
  133648. processAsync(): Promise<void>;
  133649. /**
  133650. * Disposes all textures associated with this packer
  133651. */
  133652. dispose(): void;
  133653. /**
  133654. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  133655. * @param imageType is the image type to use.
  133656. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  133657. */
  133658. download(imageType?: string, quality?: number): void;
  133659. /**
  133660. * Public method to load a texturePacker JSON file.
  133661. * @param data of the JSON file in string format.
  133662. */
  133663. updateFromJSON(data: string): void;
  133664. }
  133665. }
  133666. declare module BABYLON {
  133667. /**
  133668. * Enum used to define the target of a block
  133669. */
  133670. export enum NodeMaterialBlockTargets {
  133671. /** Vertex shader */
  133672. Vertex = 1,
  133673. /** Fragment shader */
  133674. Fragment = 2,
  133675. /** Neutral */
  133676. Neutral = 4,
  133677. /** Vertex and Fragment */
  133678. VertexAndFragment = 3
  133679. }
  133680. }
  133681. declare module BABYLON {
  133682. /**
  133683. * Defines the kind of connection point for node based material
  133684. */
  133685. export enum NodeMaterialBlockConnectionPointTypes {
  133686. /** Float */
  133687. Float = 1,
  133688. /** Int */
  133689. Int = 2,
  133690. /** Vector2 */
  133691. Vector2 = 4,
  133692. /** Vector3 */
  133693. Vector3 = 8,
  133694. /** Vector4 */
  133695. Vector4 = 16,
  133696. /** Color3 */
  133697. Color3 = 32,
  133698. /** Color4 */
  133699. Color4 = 64,
  133700. /** Matrix */
  133701. Matrix = 128,
  133702. /** Custom object */
  133703. Object = 256,
  133704. /** Detect type based on connection */
  133705. AutoDetect = 1024,
  133706. /** Output type that will be defined by input type */
  133707. BasedOnInput = 2048
  133708. }
  133709. }
  133710. declare module BABYLON {
  133711. /**
  133712. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  133713. */
  133714. export enum NodeMaterialBlockConnectionPointMode {
  133715. /** Value is an uniform */
  133716. Uniform = 0,
  133717. /** Value is a mesh attribute */
  133718. Attribute = 1,
  133719. /** Value is a varying between vertex and fragment shaders */
  133720. Varying = 2,
  133721. /** Mode is undefined */
  133722. Undefined = 3
  133723. }
  133724. }
  133725. declare module BABYLON {
  133726. /**
  133727. * Enum used to define system values e.g. values automatically provided by the system
  133728. */
  133729. export enum NodeMaterialSystemValues {
  133730. /** World */
  133731. World = 1,
  133732. /** View */
  133733. View = 2,
  133734. /** Projection */
  133735. Projection = 3,
  133736. /** ViewProjection */
  133737. ViewProjection = 4,
  133738. /** WorldView */
  133739. WorldView = 5,
  133740. /** WorldViewProjection */
  133741. WorldViewProjection = 6,
  133742. /** CameraPosition */
  133743. CameraPosition = 7,
  133744. /** Fog Color */
  133745. FogColor = 8,
  133746. /** Delta time */
  133747. DeltaTime = 9
  133748. }
  133749. }
  133750. declare module BABYLON {
  133751. /**
  133752. * Enum used to define the material modes
  133753. */
  133754. export enum NodeMaterialModes {
  133755. /** Regular material */
  133756. Material = 0,
  133757. /** For post process */
  133758. PostProcess = 1
  133759. }
  133760. }
  133761. declare module BABYLON {
  133762. /**
  133763. * Root class for all node material optimizers
  133764. */
  133765. export class NodeMaterialOptimizer {
  133766. /**
  133767. * Function used to optimize a NodeMaterial graph
  133768. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  133769. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  133770. */
  133771. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  133772. }
  133773. }
  133774. declare module BABYLON {
  133775. /**
  133776. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  133777. */
  133778. export class TransformBlock extends NodeMaterialBlock {
  133779. /**
  133780. * Defines the value to use to complement W value to transform it to a Vector4
  133781. */
  133782. complementW: number;
  133783. /**
  133784. * Defines the value to use to complement z value to transform it to a Vector4
  133785. */
  133786. complementZ: number;
  133787. /**
  133788. * Creates a new TransformBlock
  133789. * @param name defines the block name
  133790. */
  133791. constructor(name: string);
  133792. /**
  133793. * Gets the current class name
  133794. * @returns the class name
  133795. */
  133796. getClassName(): string;
  133797. /**
  133798. * Gets the vector input
  133799. */
  133800. get vector(): NodeMaterialConnectionPoint;
  133801. /**
  133802. * Gets the output component
  133803. */
  133804. get output(): NodeMaterialConnectionPoint;
  133805. /**
  133806. * Gets the xyz output component
  133807. */
  133808. get xyz(): NodeMaterialConnectionPoint;
  133809. /**
  133810. * Gets the matrix transform input
  133811. */
  133812. get transform(): NodeMaterialConnectionPoint;
  133813. protected _buildBlock(state: NodeMaterialBuildState): this;
  133814. serialize(): any;
  133815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133816. protected _dumpPropertiesCode(): string;
  133817. }
  133818. }
  133819. declare module BABYLON {
  133820. /**
  133821. * Block used to output the vertex position
  133822. */
  133823. export class VertexOutputBlock extends NodeMaterialBlock {
  133824. /**
  133825. * Creates a new VertexOutputBlock
  133826. * @param name defines the block name
  133827. */
  133828. constructor(name: string);
  133829. /**
  133830. * Gets the current class name
  133831. * @returns the class name
  133832. */
  133833. getClassName(): string;
  133834. /**
  133835. * Gets the vector input component
  133836. */
  133837. get vector(): NodeMaterialConnectionPoint;
  133838. protected _buildBlock(state: NodeMaterialBuildState): this;
  133839. }
  133840. }
  133841. declare module BABYLON {
  133842. /**
  133843. * Block used to output the final color
  133844. */
  133845. export class FragmentOutputBlock extends NodeMaterialBlock {
  133846. /**
  133847. * Create a new FragmentOutputBlock
  133848. * @param name defines the block name
  133849. */
  133850. constructor(name: string);
  133851. /**
  133852. * Gets the current class name
  133853. * @returns the class name
  133854. */
  133855. getClassName(): string;
  133856. /**
  133857. * Gets the rgba input component
  133858. */
  133859. get rgba(): NodeMaterialConnectionPoint;
  133860. /**
  133861. * Gets the rgb input component
  133862. */
  133863. get rgb(): NodeMaterialConnectionPoint;
  133864. /**
  133865. * Gets the a input component
  133866. */
  133867. get a(): NodeMaterialConnectionPoint;
  133868. protected _buildBlock(state: NodeMaterialBuildState): this;
  133869. }
  133870. }
  133871. declare module BABYLON {
  133872. /**
  133873. * Base block used to read a reflection texture from a sampler
  133874. */
  133875. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  133876. /** @hidden */
  133877. _define3DName: string;
  133878. /** @hidden */
  133879. _defineCubicName: string;
  133880. /** @hidden */
  133881. _defineExplicitName: string;
  133882. /** @hidden */
  133883. _defineProjectionName: string;
  133884. /** @hidden */
  133885. _defineLocalCubicName: string;
  133886. /** @hidden */
  133887. _defineSphericalName: string;
  133888. /** @hidden */
  133889. _definePlanarName: string;
  133890. /** @hidden */
  133891. _defineEquirectangularName: string;
  133892. /** @hidden */
  133893. _defineMirroredEquirectangularFixedName: string;
  133894. /** @hidden */
  133895. _defineEquirectangularFixedName: string;
  133896. /** @hidden */
  133897. _defineSkyboxName: string;
  133898. /** @hidden */
  133899. _defineOppositeZ: string;
  133900. /** @hidden */
  133901. _cubeSamplerName: string;
  133902. /** @hidden */
  133903. _2DSamplerName: string;
  133904. protected _positionUVWName: string;
  133905. protected _directionWName: string;
  133906. protected _reflectionVectorName: string;
  133907. /** @hidden */
  133908. _reflectionCoordsName: string;
  133909. /** @hidden */
  133910. _reflectionMatrixName: string;
  133911. protected _reflectionColorName: string;
  133912. /**
  133913. * Gets or sets the texture associated with the node
  133914. */
  133915. texture: Nullable<BaseTexture>;
  133916. /**
  133917. * Create a new ReflectionTextureBaseBlock
  133918. * @param name defines the block name
  133919. */
  133920. constructor(name: string);
  133921. /**
  133922. * Gets the current class name
  133923. * @returns the class name
  133924. */
  133925. getClassName(): string;
  133926. /**
  133927. * Gets the world position input component
  133928. */
  133929. abstract get position(): NodeMaterialConnectionPoint;
  133930. /**
  133931. * Gets the world position input component
  133932. */
  133933. abstract get worldPosition(): NodeMaterialConnectionPoint;
  133934. /**
  133935. * Gets the world normal input component
  133936. */
  133937. abstract get worldNormal(): NodeMaterialConnectionPoint;
  133938. /**
  133939. * Gets the world input component
  133940. */
  133941. abstract get world(): NodeMaterialConnectionPoint;
  133942. /**
  133943. * Gets the camera (or eye) position component
  133944. */
  133945. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  133946. /**
  133947. * Gets the view input component
  133948. */
  133949. abstract get view(): NodeMaterialConnectionPoint;
  133950. protected _getTexture(): Nullable<BaseTexture>;
  133951. autoConfigure(material: NodeMaterial): void;
  133952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133953. isReady(): boolean;
  133954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133955. /**
  133956. * Gets the code to inject in the vertex shader
  133957. * @param state current state of the node material building
  133958. * @returns the shader code
  133959. */
  133960. handleVertexSide(state: NodeMaterialBuildState): string;
  133961. /**
  133962. * Handles the inits for the fragment code path
  133963. * @param state node material build state
  133964. */
  133965. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  133966. /**
  133967. * Generates the reflection coords code for the fragment code path
  133968. * @param worldNormalVarName name of the world normal variable
  133969. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  133970. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  133971. * @returns the shader code
  133972. */
  133973. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  133974. /**
  133975. * Generates the reflection color code for the fragment code path
  133976. * @param lodVarName name of the lod variable
  133977. * @param swizzleLookupTexture swizzle to use for the final color variable
  133978. * @returns the shader code
  133979. */
  133980. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  133981. /**
  133982. * Generates the code corresponding to the connected output points
  133983. * @param state node material build state
  133984. * @param varName name of the variable to output
  133985. * @returns the shader code
  133986. */
  133987. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  133988. protected _buildBlock(state: NodeMaterialBuildState): this;
  133989. protected _dumpPropertiesCode(): string;
  133990. serialize(): any;
  133991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133992. }
  133993. }
  133994. declare module BABYLON {
  133995. /**
  133996. * Defines a connection point to be used for points with a custom object type
  133997. */
  133998. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  133999. private _blockType;
  134000. private _blockName;
  134001. private _nameForCheking?;
  134002. /**
  134003. * Creates a new connection point
  134004. * @param name defines the connection point name
  134005. * @param ownerBlock defines the block hosting this connection point
  134006. * @param direction defines the direction of the connection point
  134007. */
  134008. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  134009. /**
  134010. * Gets a number indicating if the current point can be connected to another point
  134011. * @param connectionPoint defines the other connection point
  134012. * @returns a number defining the compatibility state
  134013. */
  134014. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  134015. /**
  134016. * Creates a block suitable to be used as an input for this input point.
  134017. * If null is returned, a block based on the point type will be created.
  134018. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  134019. */
  134020. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  134021. }
  134022. }
  134023. declare module BABYLON {
  134024. /**
  134025. * Enum defining the type of properties that can be edited in the property pages in the NME
  134026. */
  134027. export enum PropertyTypeForEdition {
  134028. /** property is a boolean */
  134029. Boolean = 0,
  134030. /** property is a float */
  134031. Float = 1,
  134032. /** property is a Vector2 */
  134033. Vector2 = 2,
  134034. /** property is a list of values */
  134035. List = 3
  134036. }
  134037. /**
  134038. * Interface that defines an option in a variable of type list
  134039. */
  134040. export interface IEditablePropertyListOption {
  134041. /** label of the option */
  134042. "label": string;
  134043. /** value of the option */
  134044. "value": number;
  134045. }
  134046. /**
  134047. * Interface that defines the options available for an editable property
  134048. */
  134049. export interface IEditablePropertyOption {
  134050. /** min value */
  134051. "min"?: number;
  134052. /** max value */
  134053. "max"?: number;
  134054. /** notifiers: indicates which actions to take when the property is changed */
  134055. "notifiers"?: {
  134056. /** the material should be rebuilt */
  134057. "rebuild"?: boolean;
  134058. /** the preview should be updated */
  134059. "update"?: boolean;
  134060. };
  134061. /** list of the options for a variable of type list */
  134062. "options"?: IEditablePropertyListOption[];
  134063. }
  134064. /**
  134065. * Interface that describes an editable property
  134066. */
  134067. export interface IPropertyDescriptionForEdition {
  134068. /** name of the property */
  134069. "propertyName": string;
  134070. /** display name of the property */
  134071. "displayName": string;
  134072. /** type of the property */
  134073. "type": PropertyTypeForEdition;
  134074. /** group of the property - all properties with the same group value will be displayed in a specific section */
  134075. "groupName": string;
  134076. /** options for the property */
  134077. "options": IEditablePropertyOption;
  134078. }
  134079. /**
  134080. * Decorator that flags a property in a node material block as being editable
  134081. */
  134082. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  134083. }
  134084. declare module BABYLON {
  134085. /**
  134086. * Block used to implement the refraction part of the sub surface module of the PBR material
  134087. */
  134088. export class RefractionBlock extends NodeMaterialBlock {
  134089. /** @hidden */
  134090. _define3DName: string;
  134091. /** @hidden */
  134092. _refractionMatrixName: string;
  134093. /** @hidden */
  134094. _defineLODRefractionAlpha: string;
  134095. /** @hidden */
  134096. _defineLinearSpecularRefraction: string;
  134097. /** @hidden */
  134098. _defineOppositeZ: string;
  134099. /** @hidden */
  134100. _cubeSamplerName: string;
  134101. /** @hidden */
  134102. _2DSamplerName: string;
  134103. /** @hidden */
  134104. _vRefractionMicrosurfaceInfosName: string;
  134105. /** @hidden */
  134106. _vRefractionInfosName: string;
  134107. private _scene;
  134108. /**
  134109. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134110. * Materials half opaque for instance using refraction could benefit from this control.
  134111. */
  134112. linkRefractionWithTransparency: boolean;
  134113. /**
  134114. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134115. */
  134116. invertRefractionY: boolean;
  134117. /**
  134118. * Gets or sets the texture associated with the node
  134119. */
  134120. texture: Nullable<BaseTexture>;
  134121. /**
  134122. * Create a new RefractionBlock
  134123. * @param name defines the block name
  134124. */
  134125. constructor(name: string);
  134126. /**
  134127. * Gets the current class name
  134128. * @returns the class name
  134129. */
  134130. getClassName(): string;
  134131. /**
  134132. * Gets the intensity input component
  134133. */
  134134. get intensity(): NodeMaterialConnectionPoint;
  134135. /**
  134136. * Gets the index of refraction input component
  134137. */
  134138. get indexOfRefraction(): NodeMaterialConnectionPoint;
  134139. /**
  134140. * Gets the tint at distance input component
  134141. */
  134142. get tintAtDistance(): NodeMaterialConnectionPoint;
  134143. /**
  134144. * Gets the view input component
  134145. */
  134146. get view(): NodeMaterialConnectionPoint;
  134147. /**
  134148. * Gets the refraction object output component
  134149. */
  134150. get refraction(): NodeMaterialConnectionPoint;
  134151. /**
  134152. * Returns true if the block has a texture
  134153. */
  134154. get hasTexture(): boolean;
  134155. protected _getTexture(): Nullable<BaseTexture>;
  134156. autoConfigure(material: NodeMaterial): void;
  134157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134158. isReady(): boolean;
  134159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  134160. /**
  134161. * Gets the main code of the block (fragment side)
  134162. * @param state current state of the node material building
  134163. * @returns the shader code
  134164. */
  134165. getCode(state: NodeMaterialBuildState): string;
  134166. protected _buildBlock(state: NodeMaterialBuildState): this;
  134167. protected _dumpPropertiesCode(): string;
  134168. serialize(): any;
  134169. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134170. }
  134171. }
  134172. declare module BABYLON {
  134173. /**
  134174. * Base block used as input for post process
  134175. */
  134176. export class CurrentScreenBlock extends NodeMaterialBlock {
  134177. private _samplerName;
  134178. private _linearDefineName;
  134179. private _gammaDefineName;
  134180. private _mainUVName;
  134181. private _tempTextureRead;
  134182. /**
  134183. * Gets or sets the texture associated with the node
  134184. */
  134185. texture: Nullable<BaseTexture>;
  134186. /**
  134187. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134188. */
  134189. convertToGammaSpace: boolean;
  134190. /**
  134191. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134192. */
  134193. convertToLinearSpace: boolean;
  134194. /**
  134195. * Create a new CurrentScreenBlock
  134196. * @param name defines the block name
  134197. */
  134198. constructor(name: string);
  134199. /**
  134200. * Gets the current class name
  134201. * @returns the class name
  134202. */
  134203. getClassName(): string;
  134204. /**
  134205. * Gets the uv input component
  134206. */
  134207. get uv(): NodeMaterialConnectionPoint;
  134208. /**
  134209. * Gets the rgba output component
  134210. */
  134211. get rgba(): NodeMaterialConnectionPoint;
  134212. /**
  134213. * Gets the rgb output component
  134214. */
  134215. get rgb(): NodeMaterialConnectionPoint;
  134216. /**
  134217. * Gets the r output component
  134218. */
  134219. get r(): NodeMaterialConnectionPoint;
  134220. /**
  134221. * Gets the g output component
  134222. */
  134223. get g(): NodeMaterialConnectionPoint;
  134224. /**
  134225. * Gets the b output component
  134226. */
  134227. get b(): NodeMaterialConnectionPoint;
  134228. /**
  134229. * Gets the a output component
  134230. */
  134231. get a(): NodeMaterialConnectionPoint;
  134232. /**
  134233. * Initialize the block and prepare the context for build
  134234. * @param state defines the state that will be used for the build
  134235. */
  134236. initialize(state: NodeMaterialBuildState): void;
  134237. get target(): NodeMaterialBlockTargets;
  134238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134239. isReady(): boolean;
  134240. private _injectVertexCode;
  134241. private _writeTextureRead;
  134242. private _writeOutput;
  134243. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134244. serialize(): any;
  134245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134246. }
  134247. }
  134248. declare module BABYLON {
  134249. /**
  134250. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  134251. */
  134252. export class VectorMergerBlock extends NodeMaterialBlock {
  134253. /**
  134254. * Create a new VectorMergerBlock
  134255. * @param name defines the block name
  134256. */
  134257. constructor(name: string);
  134258. /**
  134259. * Gets the current class name
  134260. * @returns the class name
  134261. */
  134262. getClassName(): string;
  134263. /**
  134264. * Gets the xyz component (input)
  134265. */
  134266. get xyzIn(): NodeMaterialConnectionPoint;
  134267. /**
  134268. * Gets the xy component (input)
  134269. */
  134270. get xyIn(): NodeMaterialConnectionPoint;
  134271. /**
  134272. * Gets the x component (input)
  134273. */
  134274. get x(): NodeMaterialConnectionPoint;
  134275. /**
  134276. * Gets the y component (input)
  134277. */
  134278. get y(): NodeMaterialConnectionPoint;
  134279. /**
  134280. * Gets the z component (input)
  134281. */
  134282. get z(): NodeMaterialConnectionPoint;
  134283. /**
  134284. * Gets the w component (input)
  134285. */
  134286. get w(): NodeMaterialConnectionPoint;
  134287. /**
  134288. * Gets the xyzw component (output)
  134289. */
  134290. get xyzw(): NodeMaterialConnectionPoint;
  134291. /**
  134292. * Gets the xyz component (output)
  134293. */
  134294. get xyzOut(): NodeMaterialConnectionPoint;
  134295. /**
  134296. * Gets the xy component (output)
  134297. */
  134298. get xyOut(): NodeMaterialConnectionPoint;
  134299. /**
  134300. * Gets the xy component (output)
  134301. * @deprecated Please use xyOut instead.
  134302. */
  134303. get xy(): NodeMaterialConnectionPoint;
  134304. /**
  134305. * Gets the xyz component (output)
  134306. * @deprecated Please use xyzOut instead.
  134307. */
  134308. get xyz(): NodeMaterialConnectionPoint;
  134309. protected _buildBlock(state: NodeMaterialBuildState): this;
  134310. }
  134311. }
  134312. declare module BABYLON {
  134313. /**
  134314. * Block used to remap a float from a range to a new one
  134315. */
  134316. export class RemapBlock extends NodeMaterialBlock {
  134317. /**
  134318. * Gets or sets the source range
  134319. */
  134320. sourceRange: Vector2;
  134321. /**
  134322. * Gets or sets the target range
  134323. */
  134324. targetRange: Vector2;
  134325. /**
  134326. * Creates a new RemapBlock
  134327. * @param name defines the block name
  134328. */
  134329. constructor(name: string);
  134330. /**
  134331. * Gets the current class name
  134332. * @returns the class name
  134333. */
  134334. getClassName(): string;
  134335. /**
  134336. * Gets the input component
  134337. */
  134338. get input(): NodeMaterialConnectionPoint;
  134339. /**
  134340. * Gets the source min input component
  134341. */
  134342. get sourceMin(): NodeMaterialConnectionPoint;
  134343. /**
  134344. * Gets the source max input component
  134345. */
  134346. get sourceMax(): NodeMaterialConnectionPoint;
  134347. /**
  134348. * Gets the target min input component
  134349. */
  134350. get targetMin(): NodeMaterialConnectionPoint;
  134351. /**
  134352. * Gets the target max input component
  134353. */
  134354. get targetMax(): NodeMaterialConnectionPoint;
  134355. /**
  134356. * Gets the output component
  134357. */
  134358. get output(): NodeMaterialConnectionPoint;
  134359. protected _buildBlock(state: NodeMaterialBuildState): this;
  134360. protected _dumpPropertiesCode(): string;
  134361. serialize(): any;
  134362. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134363. }
  134364. }
  134365. declare module BABYLON {
  134366. /**
  134367. * Block used to multiply 2 values
  134368. */
  134369. export class MultiplyBlock extends NodeMaterialBlock {
  134370. /**
  134371. * Creates a new MultiplyBlock
  134372. * @param name defines the block name
  134373. */
  134374. constructor(name: string);
  134375. /**
  134376. * Gets the current class name
  134377. * @returns the class name
  134378. */
  134379. getClassName(): string;
  134380. /**
  134381. * Gets the left operand input component
  134382. */
  134383. get left(): NodeMaterialConnectionPoint;
  134384. /**
  134385. * Gets the right operand input component
  134386. */
  134387. get right(): NodeMaterialConnectionPoint;
  134388. /**
  134389. * Gets the output component
  134390. */
  134391. get output(): NodeMaterialConnectionPoint;
  134392. protected _buildBlock(state: NodeMaterialBuildState): this;
  134393. }
  134394. }
  134395. declare module BABYLON {
  134396. /**
  134397. * Interface used to configure the node material editor
  134398. */
  134399. export interface INodeMaterialEditorOptions {
  134400. /** Define the URl to load node editor script */
  134401. editorURL?: string;
  134402. }
  134403. /** @hidden */
  134404. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  134405. NORMAL: boolean;
  134406. TANGENT: boolean;
  134407. UV1: boolean;
  134408. /** BONES */
  134409. NUM_BONE_INFLUENCERS: number;
  134410. BonesPerMesh: number;
  134411. BONETEXTURE: boolean;
  134412. /** MORPH TARGETS */
  134413. MORPHTARGETS: boolean;
  134414. MORPHTARGETS_NORMAL: boolean;
  134415. MORPHTARGETS_TANGENT: boolean;
  134416. MORPHTARGETS_UV: boolean;
  134417. NUM_MORPH_INFLUENCERS: number;
  134418. /** IMAGE PROCESSING */
  134419. IMAGEPROCESSING: boolean;
  134420. VIGNETTE: boolean;
  134421. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134422. VIGNETTEBLENDMODEOPAQUE: boolean;
  134423. TONEMAPPING: boolean;
  134424. TONEMAPPING_ACES: boolean;
  134425. CONTRAST: boolean;
  134426. EXPOSURE: boolean;
  134427. COLORCURVES: boolean;
  134428. COLORGRADING: boolean;
  134429. COLORGRADING3D: boolean;
  134430. SAMPLER3DGREENDEPTH: boolean;
  134431. SAMPLER3DBGRMAP: boolean;
  134432. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134433. /** MISC. */
  134434. BUMPDIRECTUV: number;
  134435. constructor();
  134436. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  134437. }
  134438. /**
  134439. * Class used to configure NodeMaterial
  134440. */
  134441. export interface INodeMaterialOptions {
  134442. /**
  134443. * Defines if blocks should emit comments
  134444. */
  134445. emitComments: boolean;
  134446. }
  134447. /**
  134448. * Class used to create a node based material built by assembling shader blocks
  134449. */
  134450. export class NodeMaterial extends PushMaterial {
  134451. private static _BuildIdGenerator;
  134452. private _options;
  134453. private _vertexCompilationState;
  134454. private _fragmentCompilationState;
  134455. private _sharedData;
  134456. private _buildId;
  134457. private _buildWasSuccessful;
  134458. private _cachedWorldViewMatrix;
  134459. private _cachedWorldViewProjectionMatrix;
  134460. private _optimizers;
  134461. private _animationFrame;
  134462. /** Define the Url to load node editor script */
  134463. static EditorURL: string;
  134464. /** Define the Url to load snippets */
  134465. static SnippetUrl: string;
  134466. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  134467. static IgnoreTexturesAtLoadTime: boolean;
  134468. private BJSNODEMATERIALEDITOR;
  134469. /** Get the inspector from bundle or global */
  134470. private _getGlobalNodeMaterialEditor;
  134471. /**
  134472. * Snippet ID if the material was created from the snippet server
  134473. */
  134474. snippetId: string;
  134475. /**
  134476. * Gets or sets data used by visual editor
  134477. * @see https://nme.babylonjs.com
  134478. */
  134479. editorData: any;
  134480. /**
  134481. * 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)
  134482. */
  134483. ignoreAlpha: boolean;
  134484. /**
  134485. * Defines the maximum number of lights that can be used in the material
  134486. */
  134487. maxSimultaneousLights: number;
  134488. /**
  134489. * Observable raised when the material is built
  134490. */
  134491. onBuildObservable: Observable<NodeMaterial>;
  134492. /**
  134493. * Gets or sets the root nodes of the material vertex shader
  134494. */
  134495. _vertexOutputNodes: NodeMaterialBlock[];
  134496. /**
  134497. * Gets or sets the root nodes of the material fragment (pixel) shader
  134498. */
  134499. _fragmentOutputNodes: NodeMaterialBlock[];
  134500. /** Gets or sets options to control the node material overall behavior */
  134501. get options(): INodeMaterialOptions;
  134502. set options(options: INodeMaterialOptions);
  134503. /**
  134504. * Default configuration related to image processing available in the standard Material.
  134505. */
  134506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134507. /**
  134508. * Gets the image processing configuration used either in this material.
  134509. */
  134510. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134511. /**
  134512. * Sets the Default image processing configuration used either in the this material.
  134513. *
  134514. * If sets to null, the scene one is in use.
  134515. */
  134516. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134517. /**
  134518. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  134519. */
  134520. attachedBlocks: NodeMaterialBlock[];
  134521. /**
  134522. * Specifies the mode of the node material
  134523. * @hidden
  134524. */
  134525. _mode: NodeMaterialModes;
  134526. /**
  134527. * Gets the mode property
  134528. */
  134529. get mode(): NodeMaterialModes;
  134530. /**
  134531. * Create a new node based material
  134532. * @param name defines the material name
  134533. * @param scene defines the hosting scene
  134534. * @param options defines creation option
  134535. */
  134536. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  134537. /**
  134538. * Gets the current class name of the material e.g. "NodeMaterial"
  134539. * @returns the class name
  134540. */
  134541. getClassName(): string;
  134542. /**
  134543. * Keep track of the image processing observer to allow dispose and replace.
  134544. */
  134545. private _imageProcessingObserver;
  134546. /**
  134547. * Attaches a new image processing configuration to the Standard Material.
  134548. * @param configuration
  134549. */
  134550. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134551. /**
  134552. * Get a block by its name
  134553. * @param name defines the name of the block to retrieve
  134554. * @returns the required block or null if not found
  134555. */
  134556. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  134557. /**
  134558. * Get a block by its name
  134559. * @param predicate defines the predicate used to find the good candidate
  134560. * @returns the required block or null if not found
  134561. */
  134562. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  134563. /**
  134564. * Get an input block by its name
  134565. * @param predicate defines the predicate used to find the good candidate
  134566. * @returns the required input block or null if not found
  134567. */
  134568. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  134569. /**
  134570. * Gets the list of input blocks attached to this material
  134571. * @returns an array of InputBlocks
  134572. */
  134573. getInputBlocks(): InputBlock[];
  134574. /**
  134575. * Adds a new optimizer to the list of optimizers
  134576. * @param optimizer defines the optimizers to add
  134577. * @returns the current material
  134578. */
  134579. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134580. /**
  134581. * Remove an optimizer from the list of optimizers
  134582. * @param optimizer defines the optimizers to remove
  134583. * @returns the current material
  134584. */
  134585. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134586. /**
  134587. * Add a new block to the list of output nodes
  134588. * @param node defines the node to add
  134589. * @returns the current material
  134590. */
  134591. addOutputNode(node: NodeMaterialBlock): this;
  134592. /**
  134593. * Remove a block from the list of root nodes
  134594. * @param node defines the node to remove
  134595. * @returns the current material
  134596. */
  134597. removeOutputNode(node: NodeMaterialBlock): this;
  134598. private _addVertexOutputNode;
  134599. private _removeVertexOutputNode;
  134600. private _addFragmentOutputNode;
  134601. private _removeFragmentOutputNode;
  134602. /**
  134603. * Specifies if the material will require alpha blending
  134604. * @returns a boolean specifying if alpha blending is needed
  134605. */
  134606. needAlphaBlending(): boolean;
  134607. /**
  134608. * Specifies if this material should be rendered in alpha test mode
  134609. * @returns a boolean specifying if an alpha test is needed.
  134610. */
  134611. needAlphaTesting(): boolean;
  134612. private _initializeBlock;
  134613. private _resetDualBlocks;
  134614. /**
  134615. * Remove a block from the current node material
  134616. * @param block defines the block to remove
  134617. */
  134618. removeBlock(block: NodeMaterialBlock): void;
  134619. /**
  134620. * Build the material and generates the inner effect
  134621. * @param verbose defines if the build should log activity
  134622. */
  134623. build(verbose?: boolean): void;
  134624. /**
  134625. * Runs an otpimization phase to try to improve the shader code
  134626. */
  134627. optimize(): void;
  134628. private _prepareDefinesForAttributes;
  134629. /**
  134630. * Create a post process from the material
  134631. * @param camera The camera to apply the render pass to.
  134632. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  134633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134634. * @param engine The engine which the post process will be applied. (default: current engine)
  134635. * @param reusable If the post process can be reused on the same frame. (default: false)
  134636. * @param textureType Type of textures used when performing the post process. (default: 0)
  134637. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  134638. * @returns the post process created
  134639. */
  134640. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  134641. private _processDefines;
  134642. /**
  134643. * Get if the submesh is ready to be used and all its information available.
  134644. * Child classes can use it to update shaders
  134645. * @param mesh defines the mesh to check
  134646. * @param subMesh defines which submesh to check
  134647. * @param useInstances specifies that instances should be used
  134648. * @returns a boolean indicating that the submesh is ready or not
  134649. */
  134650. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134651. /**
  134652. * Get a string representing the shaders built by the current node graph
  134653. */
  134654. get compiledShaders(): string;
  134655. /**
  134656. * Binds the world matrix to the material
  134657. * @param world defines the world transformation matrix
  134658. */
  134659. bindOnlyWorldMatrix(world: Matrix): void;
  134660. /**
  134661. * Binds the submesh to this material by preparing the effect and shader to draw
  134662. * @param world defines the world transformation matrix
  134663. * @param mesh defines the mesh containing the submesh
  134664. * @param subMesh defines the submesh to bind the material to
  134665. */
  134666. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134667. /**
  134668. * Gets the active textures from the material
  134669. * @returns an array of textures
  134670. */
  134671. getActiveTextures(): BaseTexture[];
  134672. /**
  134673. * Gets the list of texture blocks
  134674. * @returns an array of texture blocks
  134675. */
  134676. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  134677. /**
  134678. * Specifies if the material uses a texture
  134679. * @param texture defines the texture to check against the material
  134680. * @returns a boolean specifying if the material uses the texture
  134681. */
  134682. hasTexture(texture: BaseTexture): boolean;
  134683. /**
  134684. * Disposes the material
  134685. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  134686. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  134687. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  134688. */
  134689. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  134690. /** Creates the node editor window. */
  134691. private _createNodeEditor;
  134692. /**
  134693. * Launch the node material editor
  134694. * @param config Define the configuration of the editor
  134695. * @return a promise fulfilled when the node editor is visible
  134696. */
  134697. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  134698. /**
  134699. * Clear the current material
  134700. */
  134701. clear(): void;
  134702. /**
  134703. * Clear the current material and set it to a default state
  134704. */
  134705. setToDefault(): void;
  134706. /**
  134707. * Clear the current material and set it to a default state for post process
  134708. */
  134709. setToDefaultPostProcess(): void;
  134710. /**
  134711. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  134712. * @param url defines the url to load from
  134713. * @returns a promise that will fullfil when the material is fully loaded
  134714. */
  134715. loadAsync(url: string): Promise<void>;
  134716. private _gatherBlocks;
  134717. /**
  134718. * Generate a string containing the code declaration required to create an equivalent of this material
  134719. * @returns a string
  134720. */
  134721. generateCode(): string;
  134722. /**
  134723. * Serializes this material in a JSON representation
  134724. * @returns the serialized material object
  134725. */
  134726. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  134727. private _restoreConnections;
  134728. /**
  134729. * Clear the current graph and load a new one from a serialization object
  134730. * @param source defines the JSON representation of the material
  134731. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134732. */
  134733. loadFromSerialization(source: any, rootUrl?: string): void;
  134734. /**
  134735. * Makes a duplicate of the current material.
  134736. * @param name - name to use for the new material.
  134737. */
  134738. clone(name: string): NodeMaterial;
  134739. /**
  134740. * Creates a node material from parsed material data
  134741. * @param source defines the JSON representation of the material
  134742. * @param scene defines the hosting scene
  134743. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134744. * @returns a new node material
  134745. */
  134746. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  134747. /**
  134748. * Creates a node material from a snippet saved in a remote file
  134749. * @param name defines the name of the material to create
  134750. * @param url defines the url to load from
  134751. * @param scene defines the hosting scene
  134752. * @returns a promise that will resolve to the new node material
  134753. */
  134754. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  134755. /**
  134756. * Creates a node material from a snippet saved by the node material editor
  134757. * @param snippetId defines the snippet to load
  134758. * @param scene defines the hosting scene
  134759. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134760. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  134761. * @returns a promise that will resolve to the new node material
  134762. */
  134763. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  134764. /**
  134765. * Creates a new node material set to default basic configuration
  134766. * @param name defines the name of the material
  134767. * @param scene defines the hosting scene
  134768. * @returns a new NodeMaterial
  134769. */
  134770. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  134771. }
  134772. }
  134773. declare module BABYLON {
  134774. /**
  134775. * Block used to read a texture from a sampler
  134776. */
  134777. export class TextureBlock extends NodeMaterialBlock {
  134778. private _defineName;
  134779. private _linearDefineName;
  134780. private _gammaDefineName;
  134781. private _tempTextureRead;
  134782. private _samplerName;
  134783. private _transformedUVName;
  134784. private _textureTransformName;
  134785. private _textureInfoName;
  134786. private _mainUVName;
  134787. private _mainUVDefineName;
  134788. /**
  134789. * Gets or sets the texture associated with the node
  134790. */
  134791. texture: Nullable<Texture>;
  134792. /**
  134793. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134794. */
  134795. convertToGammaSpace: boolean;
  134796. /**
  134797. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134798. */
  134799. convertToLinearSpace: boolean;
  134800. /**
  134801. * Create a new TextureBlock
  134802. * @param name defines the block name
  134803. */
  134804. constructor(name: string);
  134805. /**
  134806. * Gets the current class name
  134807. * @returns the class name
  134808. */
  134809. getClassName(): string;
  134810. /**
  134811. * Gets the uv input component
  134812. */
  134813. get uv(): NodeMaterialConnectionPoint;
  134814. /**
  134815. * Gets the rgba output component
  134816. */
  134817. get rgba(): NodeMaterialConnectionPoint;
  134818. /**
  134819. * Gets the rgb output component
  134820. */
  134821. get rgb(): NodeMaterialConnectionPoint;
  134822. /**
  134823. * Gets the r output component
  134824. */
  134825. get r(): NodeMaterialConnectionPoint;
  134826. /**
  134827. * Gets the g output component
  134828. */
  134829. get g(): NodeMaterialConnectionPoint;
  134830. /**
  134831. * Gets the b output component
  134832. */
  134833. get b(): NodeMaterialConnectionPoint;
  134834. /**
  134835. * Gets the a output component
  134836. */
  134837. get a(): NodeMaterialConnectionPoint;
  134838. get target(): NodeMaterialBlockTargets;
  134839. autoConfigure(material: NodeMaterial): void;
  134840. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134842. isReady(): boolean;
  134843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134844. private get _isMixed();
  134845. private _injectVertexCode;
  134846. private _writeTextureRead;
  134847. private _writeOutput;
  134848. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134849. protected _dumpPropertiesCode(): string;
  134850. serialize(): any;
  134851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134852. }
  134853. }
  134854. declare module BABYLON {
  134855. /**
  134856. * Class used to store shared data between 2 NodeMaterialBuildState
  134857. */
  134858. export class NodeMaterialBuildStateSharedData {
  134859. /**
  134860. * Gets the list of emitted varyings
  134861. */
  134862. temps: string[];
  134863. /**
  134864. * Gets the list of emitted varyings
  134865. */
  134866. varyings: string[];
  134867. /**
  134868. * Gets the varying declaration string
  134869. */
  134870. varyingDeclaration: string;
  134871. /**
  134872. * Input blocks
  134873. */
  134874. inputBlocks: InputBlock[];
  134875. /**
  134876. * Input blocks
  134877. */
  134878. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  134879. /**
  134880. * Bindable blocks (Blocks that need to set data to the effect)
  134881. */
  134882. bindableBlocks: NodeMaterialBlock[];
  134883. /**
  134884. * List of blocks that can provide a compilation fallback
  134885. */
  134886. blocksWithFallbacks: NodeMaterialBlock[];
  134887. /**
  134888. * List of blocks that can provide a define update
  134889. */
  134890. blocksWithDefines: NodeMaterialBlock[];
  134891. /**
  134892. * List of blocks that can provide a repeatable content
  134893. */
  134894. repeatableContentBlocks: NodeMaterialBlock[];
  134895. /**
  134896. * List of blocks that can provide a dynamic list of uniforms
  134897. */
  134898. dynamicUniformBlocks: NodeMaterialBlock[];
  134899. /**
  134900. * List of blocks that can block the isReady function for the material
  134901. */
  134902. blockingBlocks: NodeMaterialBlock[];
  134903. /**
  134904. * Gets the list of animated inputs
  134905. */
  134906. animatedInputs: InputBlock[];
  134907. /**
  134908. * Build Id used to avoid multiple recompilations
  134909. */
  134910. buildId: number;
  134911. /** List of emitted variables */
  134912. variableNames: {
  134913. [key: string]: number;
  134914. };
  134915. /** List of emitted defines */
  134916. defineNames: {
  134917. [key: string]: number;
  134918. };
  134919. /** Should emit comments? */
  134920. emitComments: boolean;
  134921. /** Emit build activity */
  134922. verbose: boolean;
  134923. /** Gets or sets the hosting scene */
  134924. scene: Scene;
  134925. /**
  134926. * Gets the compilation hints emitted at compilation time
  134927. */
  134928. hints: {
  134929. needWorldViewMatrix: boolean;
  134930. needWorldViewProjectionMatrix: boolean;
  134931. needAlphaBlending: boolean;
  134932. needAlphaTesting: boolean;
  134933. };
  134934. /**
  134935. * List of compilation checks
  134936. */
  134937. checks: {
  134938. emitVertex: boolean;
  134939. emitFragment: boolean;
  134940. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  134941. };
  134942. /** Creates a new shared data */
  134943. constructor();
  134944. /**
  134945. * Emits console errors and exceptions if there is a failing check
  134946. */
  134947. emitErrors(): void;
  134948. }
  134949. }
  134950. declare module BABYLON {
  134951. /**
  134952. * Class used to store node based material build state
  134953. */
  134954. export class NodeMaterialBuildState {
  134955. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  134956. supportUniformBuffers: boolean;
  134957. /**
  134958. * Gets the list of emitted attributes
  134959. */
  134960. attributes: string[];
  134961. /**
  134962. * Gets the list of emitted uniforms
  134963. */
  134964. uniforms: string[];
  134965. /**
  134966. * Gets the list of emitted constants
  134967. */
  134968. constants: string[];
  134969. /**
  134970. * Gets the list of emitted samplers
  134971. */
  134972. samplers: string[];
  134973. /**
  134974. * Gets the list of emitted functions
  134975. */
  134976. functions: {
  134977. [key: string]: string;
  134978. };
  134979. /**
  134980. * Gets the list of emitted extensions
  134981. */
  134982. extensions: {
  134983. [key: string]: string;
  134984. };
  134985. /**
  134986. * Gets the target of the compilation state
  134987. */
  134988. target: NodeMaterialBlockTargets;
  134989. /**
  134990. * Gets the list of emitted counters
  134991. */
  134992. counters: {
  134993. [key: string]: number;
  134994. };
  134995. /**
  134996. * Shared data between multiple NodeMaterialBuildState instances
  134997. */
  134998. sharedData: NodeMaterialBuildStateSharedData;
  134999. /** @hidden */
  135000. _vertexState: NodeMaterialBuildState;
  135001. /** @hidden */
  135002. _attributeDeclaration: string;
  135003. /** @hidden */
  135004. _uniformDeclaration: string;
  135005. /** @hidden */
  135006. _constantDeclaration: string;
  135007. /** @hidden */
  135008. _samplerDeclaration: string;
  135009. /** @hidden */
  135010. _varyingTransfer: string;
  135011. /** @hidden */
  135012. _injectAtEnd: string;
  135013. private _repeatableContentAnchorIndex;
  135014. /** @hidden */
  135015. _builtCompilationString: string;
  135016. /**
  135017. * Gets the emitted compilation strings
  135018. */
  135019. compilationString: string;
  135020. /**
  135021. * Finalize the compilation strings
  135022. * @param state defines the current compilation state
  135023. */
  135024. finalize(state: NodeMaterialBuildState): void;
  135025. /** @hidden */
  135026. get _repeatableContentAnchor(): string;
  135027. /** @hidden */
  135028. _getFreeVariableName(prefix: string): string;
  135029. /** @hidden */
  135030. _getFreeDefineName(prefix: string): string;
  135031. /** @hidden */
  135032. _excludeVariableName(name: string): void;
  135033. /** @hidden */
  135034. _emit2DSampler(name: string): void;
  135035. /** @hidden */
  135036. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  135037. /** @hidden */
  135038. _emitExtension(name: string, extension: string, define?: string): void;
  135039. /** @hidden */
  135040. _emitFunction(name: string, code: string, comments: string): void;
  135041. /** @hidden */
  135042. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  135043. replaceStrings?: {
  135044. search: RegExp;
  135045. replace: string;
  135046. }[];
  135047. repeatKey?: string;
  135048. }): string;
  135049. /** @hidden */
  135050. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  135051. repeatKey?: string;
  135052. removeAttributes?: boolean;
  135053. removeUniforms?: boolean;
  135054. removeVaryings?: boolean;
  135055. removeIfDef?: boolean;
  135056. replaceStrings?: {
  135057. search: RegExp;
  135058. replace: string;
  135059. }[];
  135060. }, storeKey?: string): void;
  135061. /** @hidden */
  135062. _registerTempVariable(name: string): boolean;
  135063. /** @hidden */
  135064. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  135065. /** @hidden */
  135066. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  135067. /** @hidden */
  135068. _emitFloat(value: number): string;
  135069. }
  135070. }
  135071. declare module BABYLON {
  135072. /**
  135073. * Defines a block that can be used inside a node based material
  135074. */
  135075. export class NodeMaterialBlock {
  135076. private _buildId;
  135077. private _buildTarget;
  135078. private _target;
  135079. private _isFinalMerger;
  135080. private _isInput;
  135081. protected _isUnique: boolean;
  135082. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  135083. inputsAreExclusive: boolean;
  135084. /** @hidden */
  135085. _codeVariableName: string;
  135086. /** @hidden */
  135087. _inputs: NodeMaterialConnectionPoint[];
  135088. /** @hidden */
  135089. _outputs: NodeMaterialConnectionPoint[];
  135090. /** @hidden */
  135091. _preparationId: number;
  135092. /**
  135093. * Gets or sets the name of the block
  135094. */
  135095. name: string;
  135096. /**
  135097. * Gets or sets the unique id of the node
  135098. */
  135099. uniqueId: number;
  135100. /**
  135101. * Gets or sets the comments associated with this block
  135102. */
  135103. comments: string;
  135104. /**
  135105. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  135106. */
  135107. get isUnique(): boolean;
  135108. /**
  135109. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  135110. */
  135111. get isFinalMerger(): boolean;
  135112. /**
  135113. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  135114. */
  135115. get isInput(): boolean;
  135116. /**
  135117. * Gets or sets the build Id
  135118. */
  135119. get buildId(): number;
  135120. set buildId(value: number);
  135121. /**
  135122. * Gets or sets the target of the block
  135123. */
  135124. get target(): NodeMaterialBlockTargets;
  135125. set target(value: NodeMaterialBlockTargets);
  135126. /**
  135127. * Gets the list of input points
  135128. */
  135129. get inputs(): NodeMaterialConnectionPoint[];
  135130. /** Gets the list of output points */
  135131. get outputs(): NodeMaterialConnectionPoint[];
  135132. /**
  135133. * Find an input by its name
  135134. * @param name defines the name of the input to look for
  135135. * @returns the input or null if not found
  135136. */
  135137. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135138. /**
  135139. * Find an output by its name
  135140. * @param name defines the name of the outputto look for
  135141. * @returns the output or null if not found
  135142. */
  135143. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135144. /**
  135145. * Creates a new NodeMaterialBlock
  135146. * @param name defines the block name
  135147. * @param target defines the target of that block (Vertex by default)
  135148. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  135149. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  135150. */
  135151. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  135152. /**
  135153. * Initialize the block and prepare the context for build
  135154. * @param state defines the state that will be used for the build
  135155. */
  135156. initialize(state: NodeMaterialBuildState): void;
  135157. /**
  135158. * Bind data to effect. Will only be called for blocks with isBindable === true
  135159. * @param effect defines the effect to bind data to
  135160. * @param nodeMaterial defines the hosting NodeMaterial
  135161. * @param mesh defines the mesh that will be rendered
  135162. * @param subMesh defines the submesh that will be rendered
  135163. */
  135164. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  135165. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  135166. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  135167. protected _writeFloat(value: number): string;
  135168. /**
  135169. * Gets the current class name e.g. "NodeMaterialBlock"
  135170. * @returns the class name
  135171. */
  135172. getClassName(): string;
  135173. /**
  135174. * Register a new input. Must be called inside a block constructor
  135175. * @param name defines the connection point name
  135176. * @param type defines the connection point type
  135177. * @param isOptional defines a boolean indicating that this input can be omitted
  135178. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135179. * @param point an already created connection point. If not provided, create a new one
  135180. * @returns the current block
  135181. */
  135182. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135183. /**
  135184. * Register a new output. Must be called inside a block constructor
  135185. * @param name defines the connection point name
  135186. * @param type defines the connection point type
  135187. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135188. * @param point an already created connection point. If not provided, create a new one
  135189. * @returns the current block
  135190. */
  135191. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135192. /**
  135193. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  135194. * @param forOutput defines an optional connection point to check compatibility with
  135195. * @returns the first available input or null
  135196. */
  135197. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  135198. /**
  135199. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  135200. * @param forBlock defines an optional block to check compatibility with
  135201. * @returns the first available input or null
  135202. */
  135203. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  135204. /**
  135205. * Gets the sibling of the given output
  135206. * @param current defines the current output
  135207. * @returns the next output in the list or null
  135208. */
  135209. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  135210. /**
  135211. * Connect current block with another block
  135212. * @param other defines the block to connect with
  135213. * @param options define the various options to help pick the right connections
  135214. * @returns the current block
  135215. */
  135216. connectTo(other: NodeMaterialBlock, options?: {
  135217. input?: string;
  135218. output?: string;
  135219. outputSwizzle?: string;
  135220. }): this | undefined;
  135221. protected _buildBlock(state: NodeMaterialBuildState): void;
  135222. /**
  135223. * Add uniforms, samplers and uniform buffers at compilation time
  135224. * @param state defines the state to update
  135225. * @param nodeMaterial defines the node material requesting the update
  135226. * @param defines defines the material defines to update
  135227. * @param uniformBuffers defines the list of uniform buffer names
  135228. */
  135229. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135230. /**
  135231. * Add potential fallbacks if shader compilation fails
  135232. * @param mesh defines the mesh to be rendered
  135233. * @param fallbacks defines the current prioritized list of fallbacks
  135234. */
  135235. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135236. /**
  135237. * Initialize defines for shader compilation
  135238. * @param mesh defines the mesh to be rendered
  135239. * @param nodeMaterial defines the node material requesting the update
  135240. * @param defines defines the material defines to update
  135241. * @param useInstances specifies that instances should be used
  135242. */
  135243. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135244. /**
  135245. * Update defines for shader compilation
  135246. * @param mesh defines the mesh to be rendered
  135247. * @param nodeMaterial defines the node material requesting the update
  135248. * @param defines defines the material defines to update
  135249. * @param useInstances specifies that instances should be used
  135250. */
  135251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135252. /**
  135253. * Lets the block try to connect some inputs automatically
  135254. * @param material defines the hosting NodeMaterial
  135255. */
  135256. autoConfigure(material: NodeMaterial): void;
  135257. /**
  135258. * Function called when a block is declared as repeatable content generator
  135259. * @param vertexShaderState defines the current compilation state for the vertex shader
  135260. * @param fragmentShaderState defines the current compilation state for the fragment shader
  135261. * @param mesh defines the mesh to be rendered
  135262. * @param defines defines the material defines to update
  135263. */
  135264. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135265. /**
  135266. * Checks if the block is ready
  135267. * @param mesh defines the mesh to be rendered
  135268. * @param nodeMaterial defines the node material requesting the update
  135269. * @param defines defines the material defines to update
  135270. * @param useInstances specifies that instances should be used
  135271. * @returns true if the block is ready
  135272. */
  135273. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  135274. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  135275. private _processBuild;
  135276. /**
  135277. * Compile the current node and generate the shader code
  135278. * @param state defines the current compilation state (uniforms, samplers, current string)
  135279. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  135280. * @returns true if already built
  135281. */
  135282. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  135283. protected _inputRename(name: string): string;
  135284. protected _outputRename(name: string): string;
  135285. protected _dumpPropertiesCode(): string;
  135286. /** @hidden */
  135287. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  135288. /** @hidden */
  135289. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  135290. /**
  135291. * Clone the current block to a new identical block
  135292. * @param scene defines the hosting scene
  135293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  135294. * @returns a copy of the current block
  135295. */
  135296. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  135297. /**
  135298. * Serializes this block in a JSON representation
  135299. * @returns the serialized block object
  135300. */
  135301. serialize(): any;
  135302. /** @hidden */
  135303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135304. private _deserializePortDisplayNames;
  135305. /**
  135306. * Release resources
  135307. */
  135308. dispose(): void;
  135309. }
  135310. }
  135311. declare module BABYLON {
  135312. /**
  135313. * Enum defining the type of animations supported by InputBlock
  135314. */
  135315. export enum AnimatedInputBlockTypes {
  135316. /** No animation */
  135317. None = 0,
  135318. /** Time based animation. Will only work for floats */
  135319. Time = 1
  135320. }
  135321. }
  135322. declare module BABYLON {
  135323. /**
  135324. * Block used to expose an input value
  135325. */
  135326. export class InputBlock extends NodeMaterialBlock {
  135327. private _mode;
  135328. private _associatedVariableName;
  135329. private _storedValue;
  135330. private _valueCallback;
  135331. private _type;
  135332. private _animationType;
  135333. /** Gets or set a value used to limit the range of float values */
  135334. min: number;
  135335. /** Gets or set a value used to limit the range of float values */
  135336. max: number;
  135337. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  135338. isBoolean: boolean;
  135339. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  135340. matrixMode: number;
  135341. /** @hidden */
  135342. _systemValue: Nullable<NodeMaterialSystemValues>;
  135343. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  135344. visibleInInspector: boolean;
  135345. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  135346. isConstant: boolean;
  135347. /** Gets or sets the group to use to display this block in the Inspector */
  135348. groupInInspector: string;
  135349. /** Gets an observable raised when the value is changed */
  135350. onValueChangedObservable: Observable<InputBlock>;
  135351. /**
  135352. * Gets or sets the connection point type (default is float)
  135353. */
  135354. get type(): NodeMaterialBlockConnectionPointTypes;
  135355. /**
  135356. * Creates a new InputBlock
  135357. * @param name defines the block name
  135358. * @param target defines the target of that block (Vertex by default)
  135359. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  135360. */
  135361. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  135362. /**
  135363. * Gets the output component
  135364. */
  135365. get output(): NodeMaterialConnectionPoint;
  135366. /**
  135367. * Set the source of this connection point to a vertex attribute
  135368. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  135369. * @returns the current connection point
  135370. */
  135371. setAsAttribute(attributeName?: string): InputBlock;
  135372. /**
  135373. * Set the source of this connection point to a system value
  135374. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  135375. * @returns the current connection point
  135376. */
  135377. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  135378. /**
  135379. * Gets or sets the value of that point.
  135380. * Please note that this value will be ignored if valueCallback is defined
  135381. */
  135382. get value(): any;
  135383. set value(value: any);
  135384. /**
  135385. * Gets or sets a callback used to get the value of that point.
  135386. * Please note that setting this value will force the connection point to ignore the value property
  135387. */
  135388. get valueCallback(): () => any;
  135389. set valueCallback(value: () => any);
  135390. /**
  135391. * Gets or sets the associated variable name in the shader
  135392. */
  135393. get associatedVariableName(): string;
  135394. set associatedVariableName(value: string);
  135395. /** Gets or sets the type of animation applied to the input */
  135396. get animationType(): AnimatedInputBlockTypes;
  135397. set animationType(value: AnimatedInputBlockTypes);
  135398. /**
  135399. * Gets a boolean indicating that this connection point not defined yet
  135400. */
  135401. get isUndefined(): boolean;
  135402. /**
  135403. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  135404. * In this case the connection point name must be the name of the uniform to use.
  135405. * Can only be set on inputs
  135406. */
  135407. get isUniform(): boolean;
  135408. set isUniform(value: boolean);
  135409. /**
  135410. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  135411. * In this case the connection point name must be the name of the attribute to use
  135412. * Can only be set on inputs
  135413. */
  135414. get isAttribute(): boolean;
  135415. set isAttribute(value: boolean);
  135416. /**
  135417. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  135418. * Can only be set on exit points
  135419. */
  135420. get isVarying(): boolean;
  135421. set isVarying(value: boolean);
  135422. /**
  135423. * Gets a boolean indicating that the current connection point is a system value
  135424. */
  135425. get isSystemValue(): boolean;
  135426. /**
  135427. * Gets or sets the current well known value or null if not defined as a system value
  135428. */
  135429. get systemValue(): Nullable<NodeMaterialSystemValues>;
  135430. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  135431. /**
  135432. * Gets the current class name
  135433. * @returns the class name
  135434. */
  135435. getClassName(): string;
  135436. /**
  135437. * Animate the input if animationType !== None
  135438. * @param scene defines the rendering scene
  135439. */
  135440. animate(scene: Scene): void;
  135441. private _emitDefine;
  135442. initialize(state: NodeMaterialBuildState): void;
  135443. /**
  135444. * Set the input block to its default value (based on its type)
  135445. */
  135446. setDefaultValue(): void;
  135447. private _emitConstant;
  135448. private _emit;
  135449. /** @hidden */
  135450. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  135451. /** @hidden */
  135452. _transmit(effect: Effect, scene: Scene): void;
  135453. protected _buildBlock(state: NodeMaterialBuildState): void;
  135454. protected _dumpPropertiesCode(): string;
  135455. dispose(): void;
  135456. serialize(): any;
  135457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135458. }
  135459. }
  135460. declare module BABYLON {
  135461. /**
  135462. * Enum used to define the compatibility state between two connection points
  135463. */
  135464. export enum NodeMaterialConnectionPointCompatibilityStates {
  135465. /** Points are compatibles */
  135466. Compatible = 0,
  135467. /** Points are incompatible because of their types */
  135468. TypeIncompatible = 1,
  135469. /** Points are incompatible because of their targets (vertex vs fragment) */
  135470. TargetIncompatible = 2
  135471. }
  135472. /**
  135473. * Defines the direction of a connection point
  135474. */
  135475. export enum NodeMaterialConnectionPointDirection {
  135476. /** Input */
  135477. Input = 0,
  135478. /** Output */
  135479. Output = 1
  135480. }
  135481. /**
  135482. * Defines a connection point for a block
  135483. */
  135484. export class NodeMaterialConnectionPoint {
  135485. /** @hidden */
  135486. _ownerBlock: NodeMaterialBlock;
  135487. /** @hidden */
  135488. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  135489. private _endpoints;
  135490. private _associatedVariableName;
  135491. private _direction;
  135492. /** @hidden */
  135493. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135494. /** @hidden */
  135495. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135496. private _type;
  135497. /** @hidden */
  135498. _enforceAssociatedVariableName: boolean;
  135499. /** Gets the direction of the point */
  135500. get direction(): NodeMaterialConnectionPointDirection;
  135501. /** Indicates that this connection point needs dual validation before being connected to another point */
  135502. needDualDirectionValidation: boolean;
  135503. /**
  135504. * Gets or sets the additional types supported by this connection point
  135505. */
  135506. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135507. /**
  135508. * Gets or sets the additional types excluded by this connection point
  135509. */
  135510. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135511. /**
  135512. * Observable triggered when this point is connected
  135513. */
  135514. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  135515. /**
  135516. * Gets or sets the associated variable name in the shader
  135517. */
  135518. get associatedVariableName(): string;
  135519. set associatedVariableName(value: string);
  135520. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  135521. get innerType(): NodeMaterialBlockConnectionPointTypes;
  135522. /**
  135523. * Gets or sets the connection point type (default is float)
  135524. */
  135525. get type(): NodeMaterialBlockConnectionPointTypes;
  135526. set type(value: NodeMaterialBlockConnectionPointTypes);
  135527. /**
  135528. * Gets or sets the connection point name
  135529. */
  135530. name: string;
  135531. /**
  135532. * Gets or sets the connection point name
  135533. */
  135534. displayName: string;
  135535. /**
  135536. * Gets or sets a boolean indicating that this connection point can be omitted
  135537. */
  135538. isOptional: boolean;
  135539. /**
  135540. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  135541. */
  135542. define: string;
  135543. /** @hidden */
  135544. _prioritizeVertex: boolean;
  135545. private _target;
  135546. /** Gets or sets the target of that connection point */
  135547. get target(): NodeMaterialBlockTargets;
  135548. set target(value: NodeMaterialBlockTargets);
  135549. /**
  135550. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  135551. */
  135552. get isConnected(): boolean;
  135553. /**
  135554. * Gets a boolean indicating that the current point is connected to an input block
  135555. */
  135556. get isConnectedToInputBlock(): boolean;
  135557. /**
  135558. * Gets a the connected input block (if any)
  135559. */
  135560. get connectInputBlock(): Nullable<InputBlock>;
  135561. /** Get the other side of the connection (if any) */
  135562. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  135563. /** Get the block that owns this connection point */
  135564. get ownerBlock(): NodeMaterialBlock;
  135565. /** Get the block connected on the other side of this connection (if any) */
  135566. get sourceBlock(): Nullable<NodeMaterialBlock>;
  135567. /** Get the block connected on the endpoints of this connection (if any) */
  135568. get connectedBlocks(): Array<NodeMaterialBlock>;
  135569. /** Gets the list of connected endpoints */
  135570. get endpoints(): NodeMaterialConnectionPoint[];
  135571. /** Gets a boolean indicating if that output point is connected to at least one input */
  135572. get hasEndpoints(): boolean;
  135573. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  135574. get isConnectedInVertexShader(): boolean;
  135575. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  135576. get isConnectedInFragmentShader(): boolean;
  135577. /**
  135578. * Creates a block suitable to be used as an input for this input point.
  135579. * If null is returned, a block based on the point type will be created.
  135580. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  135581. */
  135582. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  135583. /**
  135584. * Creates a new connection point
  135585. * @param name defines the connection point name
  135586. * @param ownerBlock defines the block hosting this connection point
  135587. * @param direction defines the direction of the connection point
  135588. */
  135589. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  135590. /**
  135591. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  135592. * @returns the class name
  135593. */
  135594. getClassName(): string;
  135595. /**
  135596. * Gets a boolean indicating if the current point can be connected to another point
  135597. * @param connectionPoint defines the other connection point
  135598. * @returns a boolean
  135599. */
  135600. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  135601. /**
  135602. * Gets a number indicating if the current point can be connected to another point
  135603. * @param connectionPoint defines the other connection point
  135604. * @returns a number defining the compatibility state
  135605. */
  135606. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  135607. /**
  135608. * Connect this point to another connection point
  135609. * @param connectionPoint defines the other connection point
  135610. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  135611. * @returns the current connection point
  135612. */
  135613. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  135614. /**
  135615. * Disconnect this point from one of his endpoint
  135616. * @param endpoint defines the other connection point
  135617. * @returns the current connection point
  135618. */
  135619. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  135620. /**
  135621. * Serializes this point in a JSON representation
  135622. * @param isInput defines if the connection point is an input (default is true)
  135623. * @returns the serialized point object
  135624. */
  135625. serialize(isInput?: boolean): any;
  135626. /**
  135627. * Release resources
  135628. */
  135629. dispose(): void;
  135630. }
  135631. }
  135632. declare module BABYLON {
  135633. /**
  135634. * Block used to add support for vertex skinning (bones)
  135635. */
  135636. export class BonesBlock extends NodeMaterialBlock {
  135637. /**
  135638. * Creates a new BonesBlock
  135639. * @param name defines the block name
  135640. */
  135641. constructor(name: string);
  135642. /**
  135643. * Initialize the block and prepare the context for build
  135644. * @param state defines the state that will be used for the build
  135645. */
  135646. initialize(state: NodeMaterialBuildState): void;
  135647. /**
  135648. * Gets the current class name
  135649. * @returns the class name
  135650. */
  135651. getClassName(): string;
  135652. /**
  135653. * Gets the matrix indices input component
  135654. */
  135655. get matricesIndices(): NodeMaterialConnectionPoint;
  135656. /**
  135657. * Gets the matrix weights input component
  135658. */
  135659. get matricesWeights(): NodeMaterialConnectionPoint;
  135660. /**
  135661. * Gets the extra matrix indices input component
  135662. */
  135663. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  135664. /**
  135665. * Gets the extra matrix weights input component
  135666. */
  135667. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  135668. /**
  135669. * Gets the world input component
  135670. */
  135671. get world(): NodeMaterialConnectionPoint;
  135672. /**
  135673. * Gets the output component
  135674. */
  135675. get output(): NodeMaterialConnectionPoint;
  135676. autoConfigure(material: NodeMaterial): void;
  135677. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135680. protected _buildBlock(state: NodeMaterialBuildState): this;
  135681. }
  135682. }
  135683. declare module BABYLON {
  135684. /**
  135685. * Block used to add support for instances
  135686. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  135687. */
  135688. export class InstancesBlock extends NodeMaterialBlock {
  135689. /**
  135690. * Creates a new InstancesBlock
  135691. * @param name defines the block name
  135692. */
  135693. constructor(name: string);
  135694. /**
  135695. * Gets the current class name
  135696. * @returns the class name
  135697. */
  135698. getClassName(): string;
  135699. /**
  135700. * Gets the first world row input component
  135701. */
  135702. get world0(): NodeMaterialConnectionPoint;
  135703. /**
  135704. * Gets the second world row input component
  135705. */
  135706. get world1(): NodeMaterialConnectionPoint;
  135707. /**
  135708. * Gets the third world row input component
  135709. */
  135710. get world2(): NodeMaterialConnectionPoint;
  135711. /**
  135712. * Gets the forth world row input component
  135713. */
  135714. get world3(): NodeMaterialConnectionPoint;
  135715. /**
  135716. * Gets the world input component
  135717. */
  135718. get world(): NodeMaterialConnectionPoint;
  135719. /**
  135720. * Gets the output component
  135721. */
  135722. get output(): NodeMaterialConnectionPoint;
  135723. /**
  135724. * Gets the isntanceID component
  135725. */
  135726. get instanceID(): NodeMaterialConnectionPoint;
  135727. autoConfigure(material: NodeMaterial): void;
  135728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135729. protected _buildBlock(state: NodeMaterialBuildState): this;
  135730. }
  135731. }
  135732. declare module BABYLON {
  135733. /**
  135734. * Block used to add morph targets support to vertex shader
  135735. */
  135736. export class MorphTargetsBlock extends NodeMaterialBlock {
  135737. private _repeatableContentAnchor;
  135738. /**
  135739. * Create a new MorphTargetsBlock
  135740. * @param name defines the block name
  135741. */
  135742. constructor(name: string);
  135743. /**
  135744. * Gets the current class name
  135745. * @returns the class name
  135746. */
  135747. getClassName(): string;
  135748. /**
  135749. * Gets the position input component
  135750. */
  135751. get position(): NodeMaterialConnectionPoint;
  135752. /**
  135753. * Gets the normal input component
  135754. */
  135755. get normal(): NodeMaterialConnectionPoint;
  135756. /**
  135757. * Gets the tangent input component
  135758. */
  135759. get tangent(): NodeMaterialConnectionPoint;
  135760. /**
  135761. * Gets the tangent input component
  135762. */
  135763. get uv(): NodeMaterialConnectionPoint;
  135764. /**
  135765. * Gets the position output component
  135766. */
  135767. get positionOutput(): NodeMaterialConnectionPoint;
  135768. /**
  135769. * Gets the normal output component
  135770. */
  135771. get normalOutput(): NodeMaterialConnectionPoint;
  135772. /**
  135773. * Gets the tangent output component
  135774. */
  135775. get tangentOutput(): NodeMaterialConnectionPoint;
  135776. /**
  135777. * Gets the tangent output component
  135778. */
  135779. get uvOutput(): NodeMaterialConnectionPoint;
  135780. initialize(state: NodeMaterialBuildState): void;
  135781. autoConfigure(material: NodeMaterial): void;
  135782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135784. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135785. protected _buildBlock(state: NodeMaterialBuildState): this;
  135786. }
  135787. }
  135788. declare module BABYLON {
  135789. /**
  135790. * Block used to get data information from a light
  135791. */
  135792. export class LightInformationBlock extends NodeMaterialBlock {
  135793. private _lightDataUniformName;
  135794. private _lightColorUniformName;
  135795. private _lightTypeDefineName;
  135796. /**
  135797. * Gets or sets the light associated with this block
  135798. */
  135799. light: Nullable<Light>;
  135800. /**
  135801. * Creates a new LightInformationBlock
  135802. * @param name defines the block name
  135803. */
  135804. constructor(name: string);
  135805. /**
  135806. * Gets the current class name
  135807. * @returns the class name
  135808. */
  135809. getClassName(): string;
  135810. /**
  135811. * Gets the world position input component
  135812. */
  135813. get worldPosition(): NodeMaterialConnectionPoint;
  135814. /**
  135815. * Gets the direction output component
  135816. */
  135817. get direction(): NodeMaterialConnectionPoint;
  135818. /**
  135819. * Gets the direction output component
  135820. */
  135821. get color(): NodeMaterialConnectionPoint;
  135822. /**
  135823. * Gets the direction output component
  135824. */
  135825. get intensity(): NodeMaterialConnectionPoint;
  135826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135828. protected _buildBlock(state: NodeMaterialBuildState): this;
  135829. serialize(): any;
  135830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135831. }
  135832. }
  135833. declare module BABYLON {
  135834. /**
  135835. * Block used to add image processing support to fragment shader
  135836. */
  135837. export class ImageProcessingBlock extends NodeMaterialBlock {
  135838. /**
  135839. * Create a new ImageProcessingBlock
  135840. * @param name defines the block name
  135841. */
  135842. constructor(name: string);
  135843. /**
  135844. * Gets the current class name
  135845. * @returns the class name
  135846. */
  135847. getClassName(): string;
  135848. /**
  135849. * Gets the color input component
  135850. */
  135851. get color(): NodeMaterialConnectionPoint;
  135852. /**
  135853. * Gets the output component
  135854. */
  135855. get output(): NodeMaterialConnectionPoint;
  135856. /**
  135857. * Initialize the block and prepare the context for build
  135858. * @param state defines the state that will be used for the build
  135859. */
  135860. initialize(state: NodeMaterialBuildState): void;
  135861. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  135862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135863. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135864. protected _buildBlock(state: NodeMaterialBuildState): this;
  135865. }
  135866. }
  135867. declare module BABYLON {
  135868. /**
  135869. * Block used to pertub normals based on a normal map
  135870. */
  135871. export class PerturbNormalBlock extends NodeMaterialBlock {
  135872. private _tangentSpaceParameterName;
  135873. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  135874. invertX: boolean;
  135875. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  135876. invertY: boolean;
  135877. /**
  135878. * Create a new PerturbNormalBlock
  135879. * @param name defines the block name
  135880. */
  135881. constructor(name: string);
  135882. /**
  135883. * Gets the current class name
  135884. * @returns the class name
  135885. */
  135886. getClassName(): string;
  135887. /**
  135888. * Gets the world position input component
  135889. */
  135890. get worldPosition(): NodeMaterialConnectionPoint;
  135891. /**
  135892. * Gets the world normal input component
  135893. */
  135894. get worldNormal(): NodeMaterialConnectionPoint;
  135895. /**
  135896. * Gets the world tangent input component
  135897. */
  135898. get worldTangent(): NodeMaterialConnectionPoint;
  135899. /**
  135900. * Gets the uv input component
  135901. */
  135902. get uv(): NodeMaterialConnectionPoint;
  135903. /**
  135904. * Gets the normal map color input component
  135905. */
  135906. get normalMapColor(): NodeMaterialConnectionPoint;
  135907. /**
  135908. * Gets the strength input component
  135909. */
  135910. get strength(): NodeMaterialConnectionPoint;
  135911. /**
  135912. * Gets the output component
  135913. */
  135914. get output(): NodeMaterialConnectionPoint;
  135915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135917. autoConfigure(material: NodeMaterial): void;
  135918. protected _buildBlock(state: NodeMaterialBuildState): this;
  135919. protected _dumpPropertiesCode(): string;
  135920. serialize(): any;
  135921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135922. }
  135923. }
  135924. declare module BABYLON {
  135925. /**
  135926. * Block used to discard a pixel if a value is smaller than a cutoff
  135927. */
  135928. export class DiscardBlock extends NodeMaterialBlock {
  135929. /**
  135930. * Create a new DiscardBlock
  135931. * @param name defines the block name
  135932. */
  135933. constructor(name: string);
  135934. /**
  135935. * Gets the current class name
  135936. * @returns the class name
  135937. */
  135938. getClassName(): string;
  135939. /**
  135940. * Gets the color input component
  135941. */
  135942. get value(): NodeMaterialConnectionPoint;
  135943. /**
  135944. * Gets the cutoff input component
  135945. */
  135946. get cutoff(): NodeMaterialConnectionPoint;
  135947. protected _buildBlock(state: NodeMaterialBuildState): this;
  135948. }
  135949. }
  135950. declare module BABYLON {
  135951. /**
  135952. * Block used to test if the fragment shader is front facing
  135953. */
  135954. export class FrontFacingBlock extends NodeMaterialBlock {
  135955. /**
  135956. * Creates a new FrontFacingBlock
  135957. * @param name defines the block name
  135958. */
  135959. constructor(name: string);
  135960. /**
  135961. * Gets the current class name
  135962. * @returns the class name
  135963. */
  135964. getClassName(): string;
  135965. /**
  135966. * Gets the output component
  135967. */
  135968. get output(): NodeMaterialConnectionPoint;
  135969. protected _buildBlock(state: NodeMaterialBuildState): this;
  135970. }
  135971. }
  135972. declare module BABYLON {
  135973. /**
  135974. * Block used to get the derivative value on x and y of a given input
  135975. */
  135976. export class DerivativeBlock extends NodeMaterialBlock {
  135977. /**
  135978. * Create a new DerivativeBlock
  135979. * @param name defines the block name
  135980. */
  135981. constructor(name: string);
  135982. /**
  135983. * Gets the current class name
  135984. * @returns the class name
  135985. */
  135986. getClassName(): string;
  135987. /**
  135988. * Gets the input component
  135989. */
  135990. get input(): NodeMaterialConnectionPoint;
  135991. /**
  135992. * Gets the derivative output on x
  135993. */
  135994. get dx(): NodeMaterialConnectionPoint;
  135995. /**
  135996. * Gets the derivative output on y
  135997. */
  135998. get dy(): NodeMaterialConnectionPoint;
  135999. protected _buildBlock(state: NodeMaterialBuildState): this;
  136000. }
  136001. }
  136002. declare module BABYLON {
  136003. /**
  136004. * Block used to add support for scene fog
  136005. */
  136006. export class FogBlock extends NodeMaterialBlock {
  136007. private _fogDistanceName;
  136008. private _fogParameters;
  136009. /**
  136010. * Create a new FogBlock
  136011. * @param name defines the block name
  136012. */
  136013. constructor(name: string);
  136014. /**
  136015. * Gets the current class name
  136016. * @returns the class name
  136017. */
  136018. getClassName(): string;
  136019. /**
  136020. * Gets the world position input component
  136021. */
  136022. get worldPosition(): NodeMaterialConnectionPoint;
  136023. /**
  136024. * Gets the view input component
  136025. */
  136026. get view(): NodeMaterialConnectionPoint;
  136027. /**
  136028. * Gets the color input component
  136029. */
  136030. get input(): NodeMaterialConnectionPoint;
  136031. /**
  136032. * Gets the fog color input component
  136033. */
  136034. get fogColor(): NodeMaterialConnectionPoint;
  136035. /**
  136036. * Gets the output component
  136037. */
  136038. get output(): NodeMaterialConnectionPoint;
  136039. autoConfigure(material: NodeMaterial): void;
  136040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  136042. protected _buildBlock(state: NodeMaterialBuildState): this;
  136043. }
  136044. }
  136045. declare module BABYLON {
  136046. /**
  136047. * Block used to add light in the fragment shader
  136048. */
  136049. export class LightBlock extends NodeMaterialBlock {
  136050. private _lightId;
  136051. /**
  136052. * Gets or sets the light associated with this block
  136053. */
  136054. light: Nullable<Light>;
  136055. /**
  136056. * Create a new LightBlock
  136057. * @param name defines the block name
  136058. */
  136059. constructor(name: string);
  136060. /**
  136061. * Gets the current class name
  136062. * @returns the class name
  136063. */
  136064. getClassName(): string;
  136065. /**
  136066. * Gets the world position input component
  136067. */
  136068. get worldPosition(): NodeMaterialConnectionPoint;
  136069. /**
  136070. * Gets the world normal input component
  136071. */
  136072. get worldNormal(): NodeMaterialConnectionPoint;
  136073. /**
  136074. * Gets the camera (or eye) position component
  136075. */
  136076. get cameraPosition(): NodeMaterialConnectionPoint;
  136077. /**
  136078. * Gets the glossiness component
  136079. */
  136080. get glossiness(): NodeMaterialConnectionPoint;
  136081. /**
  136082. * Gets the glossinness power component
  136083. */
  136084. get glossPower(): NodeMaterialConnectionPoint;
  136085. /**
  136086. * Gets the diffuse color component
  136087. */
  136088. get diffuseColor(): NodeMaterialConnectionPoint;
  136089. /**
  136090. * Gets the specular color component
  136091. */
  136092. get specularColor(): NodeMaterialConnectionPoint;
  136093. /**
  136094. * Gets the diffuse output component
  136095. */
  136096. get diffuseOutput(): NodeMaterialConnectionPoint;
  136097. /**
  136098. * Gets the specular output component
  136099. */
  136100. get specularOutput(): NodeMaterialConnectionPoint;
  136101. /**
  136102. * Gets the shadow output component
  136103. */
  136104. get shadow(): NodeMaterialConnectionPoint;
  136105. autoConfigure(material: NodeMaterial): void;
  136106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136107. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  136108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  136109. private _injectVertexCode;
  136110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136111. serialize(): any;
  136112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136113. }
  136114. }
  136115. declare module BABYLON {
  136116. /**
  136117. * Block used to read a reflection texture from a sampler
  136118. */
  136119. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  136120. /**
  136121. * Create a new ReflectionTextureBlock
  136122. * @param name defines the block name
  136123. */
  136124. constructor(name: string);
  136125. /**
  136126. * Gets the current class name
  136127. * @returns the class name
  136128. */
  136129. getClassName(): string;
  136130. /**
  136131. * Gets the world position input component
  136132. */
  136133. get position(): NodeMaterialConnectionPoint;
  136134. /**
  136135. * Gets the world position input component
  136136. */
  136137. get worldPosition(): NodeMaterialConnectionPoint;
  136138. /**
  136139. * Gets the world normal input component
  136140. */
  136141. get worldNormal(): NodeMaterialConnectionPoint;
  136142. /**
  136143. * Gets the world input component
  136144. */
  136145. get world(): NodeMaterialConnectionPoint;
  136146. /**
  136147. * Gets the camera (or eye) position component
  136148. */
  136149. get cameraPosition(): NodeMaterialConnectionPoint;
  136150. /**
  136151. * Gets the view input component
  136152. */
  136153. get view(): NodeMaterialConnectionPoint;
  136154. /**
  136155. * Gets the rgb output component
  136156. */
  136157. get rgb(): NodeMaterialConnectionPoint;
  136158. /**
  136159. * Gets the r output component
  136160. */
  136161. get r(): NodeMaterialConnectionPoint;
  136162. /**
  136163. * Gets the g output component
  136164. */
  136165. get g(): NodeMaterialConnectionPoint;
  136166. /**
  136167. * Gets the b output component
  136168. */
  136169. get b(): NodeMaterialConnectionPoint;
  136170. autoConfigure(material: NodeMaterial): void;
  136171. protected _buildBlock(state: NodeMaterialBuildState): this;
  136172. }
  136173. }
  136174. declare module BABYLON {
  136175. /**
  136176. * Block used to add 2 vectors
  136177. */
  136178. export class AddBlock extends NodeMaterialBlock {
  136179. /**
  136180. * Creates a new AddBlock
  136181. * @param name defines the block name
  136182. */
  136183. constructor(name: string);
  136184. /**
  136185. * Gets the current class name
  136186. * @returns the class name
  136187. */
  136188. getClassName(): string;
  136189. /**
  136190. * Gets the left operand input component
  136191. */
  136192. get left(): NodeMaterialConnectionPoint;
  136193. /**
  136194. * Gets the right operand input component
  136195. */
  136196. get right(): NodeMaterialConnectionPoint;
  136197. /**
  136198. * Gets the output component
  136199. */
  136200. get output(): NodeMaterialConnectionPoint;
  136201. protected _buildBlock(state: NodeMaterialBuildState): this;
  136202. }
  136203. }
  136204. declare module BABYLON {
  136205. /**
  136206. * Block used to scale a vector by a float
  136207. */
  136208. export class ScaleBlock extends NodeMaterialBlock {
  136209. /**
  136210. * Creates a new ScaleBlock
  136211. * @param name defines the block name
  136212. */
  136213. constructor(name: string);
  136214. /**
  136215. * Gets the current class name
  136216. * @returns the class name
  136217. */
  136218. getClassName(): string;
  136219. /**
  136220. * Gets the input component
  136221. */
  136222. get input(): NodeMaterialConnectionPoint;
  136223. /**
  136224. * Gets the factor input component
  136225. */
  136226. get factor(): NodeMaterialConnectionPoint;
  136227. /**
  136228. * Gets the output component
  136229. */
  136230. get output(): NodeMaterialConnectionPoint;
  136231. protected _buildBlock(state: NodeMaterialBuildState): this;
  136232. }
  136233. }
  136234. declare module BABYLON {
  136235. /**
  136236. * Block used to clamp a float
  136237. */
  136238. export class ClampBlock extends NodeMaterialBlock {
  136239. /** Gets or sets the minimum range */
  136240. minimum: number;
  136241. /** Gets or sets the maximum range */
  136242. maximum: number;
  136243. /**
  136244. * Creates a new ClampBlock
  136245. * @param name defines the block name
  136246. */
  136247. constructor(name: string);
  136248. /**
  136249. * Gets the current class name
  136250. * @returns the class name
  136251. */
  136252. getClassName(): string;
  136253. /**
  136254. * Gets the value input component
  136255. */
  136256. get value(): NodeMaterialConnectionPoint;
  136257. /**
  136258. * Gets the output component
  136259. */
  136260. get output(): NodeMaterialConnectionPoint;
  136261. protected _buildBlock(state: NodeMaterialBuildState): this;
  136262. protected _dumpPropertiesCode(): string;
  136263. serialize(): any;
  136264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136265. }
  136266. }
  136267. declare module BABYLON {
  136268. /**
  136269. * Block used to apply a cross product between 2 vectors
  136270. */
  136271. export class CrossBlock extends NodeMaterialBlock {
  136272. /**
  136273. * Creates a new CrossBlock
  136274. * @param name defines the block name
  136275. */
  136276. constructor(name: string);
  136277. /**
  136278. * Gets the current class name
  136279. * @returns the class name
  136280. */
  136281. getClassName(): string;
  136282. /**
  136283. * Gets the left operand input component
  136284. */
  136285. get left(): NodeMaterialConnectionPoint;
  136286. /**
  136287. * Gets the right operand input component
  136288. */
  136289. get right(): NodeMaterialConnectionPoint;
  136290. /**
  136291. * Gets the output component
  136292. */
  136293. get output(): NodeMaterialConnectionPoint;
  136294. protected _buildBlock(state: NodeMaterialBuildState): this;
  136295. }
  136296. }
  136297. declare module BABYLON {
  136298. /**
  136299. * Block used to apply a dot product between 2 vectors
  136300. */
  136301. export class DotBlock extends NodeMaterialBlock {
  136302. /**
  136303. * Creates a new DotBlock
  136304. * @param name defines the block name
  136305. */
  136306. constructor(name: string);
  136307. /**
  136308. * Gets the current class name
  136309. * @returns the class name
  136310. */
  136311. getClassName(): string;
  136312. /**
  136313. * Gets the left operand input component
  136314. */
  136315. get left(): NodeMaterialConnectionPoint;
  136316. /**
  136317. * Gets the right operand input component
  136318. */
  136319. get right(): NodeMaterialConnectionPoint;
  136320. /**
  136321. * Gets the output component
  136322. */
  136323. get output(): NodeMaterialConnectionPoint;
  136324. protected _buildBlock(state: NodeMaterialBuildState): this;
  136325. }
  136326. }
  136327. declare module BABYLON {
  136328. /**
  136329. * Block used to normalize a vector
  136330. */
  136331. export class NormalizeBlock extends NodeMaterialBlock {
  136332. /**
  136333. * Creates a new NormalizeBlock
  136334. * @param name defines the block name
  136335. */
  136336. constructor(name: string);
  136337. /**
  136338. * Gets the current class name
  136339. * @returns the class name
  136340. */
  136341. getClassName(): string;
  136342. /**
  136343. * Gets the input component
  136344. */
  136345. get input(): NodeMaterialConnectionPoint;
  136346. /**
  136347. * Gets the output component
  136348. */
  136349. get output(): NodeMaterialConnectionPoint;
  136350. protected _buildBlock(state: NodeMaterialBuildState): this;
  136351. }
  136352. }
  136353. declare module BABYLON {
  136354. /**
  136355. * Operations supported by the Trigonometry block
  136356. */
  136357. export enum TrigonometryBlockOperations {
  136358. /** Cos */
  136359. Cos = 0,
  136360. /** Sin */
  136361. Sin = 1,
  136362. /** Abs */
  136363. Abs = 2,
  136364. /** Exp */
  136365. Exp = 3,
  136366. /** Exp2 */
  136367. Exp2 = 4,
  136368. /** Round */
  136369. Round = 5,
  136370. /** Floor */
  136371. Floor = 6,
  136372. /** Ceiling */
  136373. Ceiling = 7,
  136374. /** Square root */
  136375. Sqrt = 8,
  136376. /** Log */
  136377. Log = 9,
  136378. /** Tangent */
  136379. Tan = 10,
  136380. /** Arc tangent */
  136381. ArcTan = 11,
  136382. /** Arc cosinus */
  136383. ArcCos = 12,
  136384. /** Arc sinus */
  136385. ArcSin = 13,
  136386. /** Fraction */
  136387. Fract = 14,
  136388. /** Sign */
  136389. Sign = 15,
  136390. /** To radians (from degrees) */
  136391. Radians = 16,
  136392. /** To degrees (from radians) */
  136393. Degrees = 17
  136394. }
  136395. /**
  136396. * Block used to apply trigonometry operation to floats
  136397. */
  136398. export class TrigonometryBlock extends NodeMaterialBlock {
  136399. /**
  136400. * Gets or sets the operation applied by the block
  136401. */
  136402. operation: TrigonometryBlockOperations;
  136403. /**
  136404. * Creates a new TrigonometryBlock
  136405. * @param name defines the block name
  136406. */
  136407. constructor(name: string);
  136408. /**
  136409. * Gets the current class name
  136410. * @returns the class name
  136411. */
  136412. getClassName(): string;
  136413. /**
  136414. * Gets the input component
  136415. */
  136416. get input(): NodeMaterialConnectionPoint;
  136417. /**
  136418. * Gets the output component
  136419. */
  136420. get output(): NodeMaterialConnectionPoint;
  136421. protected _buildBlock(state: NodeMaterialBuildState): this;
  136422. serialize(): any;
  136423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136424. protected _dumpPropertiesCode(): string;
  136425. }
  136426. }
  136427. declare module BABYLON {
  136428. /**
  136429. * Block used to create a Color3/4 out of individual inputs (one for each component)
  136430. */
  136431. export class ColorMergerBlock extends NodeMaterialBlock {
  136432. /**
  136433. * Create a new ColorMergerBlock
  136434. * @param name defines the block name
  136435. */
  136436. constructor(name: string);
  136437. /**
  136438. * Gets the current class name
  136439. * @returns the class name
  136440. */
  136441. getClassName(): string;
  136442. /**
  136443. * Gets the rgb component (input)
  136444. */
  136445. get rgbIn(): NodeMaterialConnectionPoint;
  136446. /**
  136447. * Gets the r component (input)
  136448. */
  136449. get r(): NodeMaterialConnectionPoint;
  136450. /**
  136451. * Gets the g component (input)
  136452. */
  136453. get g(): NodeMaterialConnectionPoint;
  136454. /**
  136455. * Gets the b component (input)
  136456. */
  136457. get b(): NodeMaterialConnectionPoint;
  136458. /**
  136459. * Gets the a component (input)
  136460. */
  136461. get a(): NodeMaterialConnectionPoint;
  136462. /**
  136463. * Gets the rgba component (output)
  136464. */
  136465. get rgba(): NodeMaterialConnectionPoint;
  136466. /**
  136467. * Gets the rgb component (output)
  136468. */
  136469. get rgbOut(): NodeMaterialConnectionPoint;
  136470. /**
  136471. * Gets the rgb component (output)
  136472. * @deprecated Please use rgbOut instead.
  136473. */
  136474. get rgb(): NodeMaterialConnectionPoint;
  136475. protected _buildBlock(state: NodeMaterialBuildState): this;
  136476. }
  136477. }
  136478. declare module BABYLON {
  136479. /**
  136480. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  136481. */
  136482. export class ColorSplitterBlock extends NodeMaterialBlock {
  136483. /**
  136484. * Create a new ColorSplitterBlock
  136485. * @param name defines the block name
  136486. */
  136487. constructor(name: string);
  136488. /**
  136489. * Gets the current class name
  136490. * @returns the class name
  136491. */
  136492. getClassName(): string;
  136493. /**
  136494. * Gets the rgba component (input)
  136495. */
  136496. get rgba(): NodeMaterialConnectionPoint;
  136497. /**
  136498. * Gets the rgb component (input)
  136499. */
  136500. get rgbIn(): NodeMaterialConnectionPoint;
  136501. /**
  136502. * Gets the rgb component (output)
  136503. */
  136504. get rgbOut(): NodeMaterialConnectionPoint;
  136505. /**
  136506. * Gets the r component (output)
  136507. */
  136508. get r(): NodeMaterialConnectionPoint;
  136509. /**
  136510. * Gets the g component (output)
  136511. */
  136512. get g(): NodeMaterialConnectionPoint;
  136513. /**
  136514. * Gets the b component (output)
  136515. */
  136516. get b(): NodeMaterialConnectionPoint;
  136517. /**
  136518. * Gets the a component (output)
  136519. */
  136520. get a(): NodeMaterialConnectionPoint;
  136521. protected _inputRename(name: string): string;
  136522. protected _outputRename(name: string): string;
  136523. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136524. }
  136525. }
  136526. declare module BABYLON {
  136527. /**
  136528. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  136529. */
  136530. export class VectorSplitterBlock extends NodeMaterialBlock {
  136531. /**
  136532. * Create a new VectorSplitterBlock
  136533. * @param name defines the block name
  136534. */
  136535. constructor(name: string);
  136536. /**
  136537. * Gets the current class name
  136538. * @returns the class name
  136539. */
  136540. getClassName(): string;
  136541. /**
  136542. * Gets the xyzw component (input)
  136543. */
  136544. get xyzw(): NodeMaterialConnectionPoint;
  136545. /**
  136546. * Gets the xyz component (input)
  136547. */
  136548. get xyzIn(): NodeMaterialConnectionPoint;
  136549. /**
  136550. * Gets the xy component (input)
  136551. */
  136552. get xyIn(): NodeMaterialConnectionPoint;
  136553. /**
  136554. * Gets the xyz component (output)
  136555. */
  136556. get xyzOut(): NodeMaterialConnectionPoint;
  136557. /**
  136558. * Gets the xy component (output)
  136559. */
  136560. get xyOut(): NodeMaterialConnectionPoint;
  136561. /**
  136562. * Gets the x component (output)
  136563. */
  136564. get x(): NodeMaterialConnectionPoint;
  136565. /**
  136566. * Gets the y component (output)
  136567. */
  136568. get y(): NodeMaterialConnectionPoint;
  136569. /**
  136570. * Gets the z component (output)
  136571. */
  136572. get z(): NodeMaterialConnectionPoint;
  136573. /**
  136574. * Gets the w component (output)
  136575. */
  136576. get w(): NodeMaterialConnectionPoint;
  136577. protected _inputRename(name: string): string;
  136578. protected _outputRename(name: string): string;
  136579. protected _buildBlock(state: NodeMaterialBuildState): this;
  136580. }
  136581. }
  136582. declare module BABYLON {
  136583. /**
  136584. * Block used to lerp between 2 values
  136585. */
  136586. export class LerpBlock extends NodeMaterialBlock {
  136587. /**
  136588. * Creates a new LerpBlock
  136589. * @param name defines the block name
  136590. */
  136591. constructor(name: string);
  136592. /**
  136593. * Gets the current class name
  136594. * @returns the class name
  136595. */
  136596. getClassName(): string;
  136597. /**
  136598. * Gets the left operand input component
  136599. */
  136600. get left(): NodeMaterialConnectionPoint;
  136601. /**
  136602. * Gets the right operand input component
  136603. */
  136604. get right(): NodeMaterialConnectionPoint;
  136605. /**
  136606. * Gets the gradient operand input component
  136607. */
  136608. get gradient(): NodeMaterialConnectionPoint;
  136609. /**
  136610. * Gets the output component
  136611. */
  136612. get output(): NodeMaterialConnectionPoint;
  136613. protected _buildBlock(state: NodeMaterialBuildState): this;
  136614. }
  136615. }
  136616. declare module BABYLON {
  136617. /**
  136618. * Block used to divide 2 vectors
  136619. */
  136620. export class DivideBlock extends NodeMaterialBlock {
  136621. /**
  136622. * Creates a new DivideBlock
  136623. * @param name defines the block name
  136624. */
  136625. constructor(name: string);
  136626. /**
  136627. * Gets the current class name
  136628. * @returns the class name
  136629. */
  136630. getClassName(): string;
  136631. /**
  136632. * Gets the left operand input component
  136633. */
  136634. get left(): NodeMaterialConnectionPoint;
  136635. /**
  136636. * Gets the right operand input component
  136637. */
  136638. get right(): NodeMaterialConnectionPoint;
  136639. /**
  136640. * Gets the output component
  136641. */
  136642. get output(): NodeMaterialConnectionPoint;
  136643. protected _buildBlock(state: NodeMaterialBuildState): this;
  136644. }
  136645. }
  136646. declare module BABYLON {
  136647. /**
  136648. * Block used to subtract 2 vectors
  136649. */
  136650. export class SubtractBlock extends NodeMaterialBlock {
  136651. /**
  136652. * Creates a new SubtractBlock
  136653. * @param name defines the block name
  136654. */
  136655. constructor(name: string);
  136656. /**
  136657. * Gets the current class name
  136658. * @returns the class name
  136659. */
  136660. getClassName(): string;
  136661. /**
  136662. * Gets the left operand input component
  136663. */
  136664. get left(): NodeMaterialConnectionPoint;
  136665. /**
  136666. * Gets the right operand input component
  136667. */
  136668. get right(): NodeMaterialConnectionPoint;
  136669. /**
  136670. * Gets the output component
  136671. */
  136672. get output(): NodeMaterialConnectionPoint;
  136673. protected _buildBlock(state: NodeMaterialBuildState): this;
  136674. }
  136675. }
  136676. declare module BABYLON {
  136677. /**
  136678. * Block used to step a value
  136679. */
  136680. export class StepBlock extends NodeMaterialBlock {
  136681. /**
  136682. * Creates a new StepBlock
  136683. * @param name defines the block name
  136684. */
  136685. constructor(name: string);
  136686. /**
  136687. * Gets the current class name
  136688. * @returns the class name
  136689. */
  136690. getClassName(): string;
  136691. /**
  136692. * Gets the value operand input component
  136693. */
  136694. get value(): NodeMaterialConnectionPoint;
  136695. /**
  136696. * Gets the edge operand input component
  136697. */
  136698. get edge(): NodeMaterialConnectionPoint;
  136699. /**
  136700. * Gets the output component
  136701. */
  136702. get output(): NodeMaterialConnectionPoint;
  136703. protected _buildBlock(state: NodeMaterialBuildState): this;
  136704. }
  136705. }
  136706. declare module BABYLON {
  136707. /**
  136708. * Block used to get the opposite (1 - x) of a value
  136709. */
  136710. export class OneMinusBlock extends NodeMaterialBlock {
  136711. /**
  136712. * Creates a new OneMinusBlock
  136713. * @param name defines the block name
  136714. */
  136715. constructor(name: string);
  136716. /**
  136717. * Gets the current class name
  136718. * @returns the class name
  136719. */
  136720. getClassName(): string;
  136721. /**
  136722. * Gets the input component
  136723. */
  136724. get input(): NodeMaterialConnectionPoint;
  136725. /**
  136726. * Gets the output component
  136727. */
  136728. get output(): NodeMaterialConnectionPoint;
  136729. protected _buildBlock(state: NodeMaterialBuildState): this;
  136730. }
  136731. }
  136732. declare module BABYLON {
  136733. /**
  136734. * Block used to get the view direction
  136735. */
  136736. export class ViewDirectionBlock extends NodeMaterialBlock {
  136737. /**
  136738. * Creates a new ViewDirectionBlock
  136739. * @param name defines the block name
  136740. */
  136741. constructor(name: string);
  136742. /**
  136743. * Gets the current class name
  136744. * @returns the class name
  136745. */
  136746. getClassName(): string;
  136747. /**
  136748. * Gets the world position component
  136749. */
  136750. get worldPosition(): NodeMaterialConnectionPoint;
  136751. /**
  136752. * Gets the camera position component
  136753. */
  136754. get cameraPosition(): NodeMaterialConnectionPoint;
  136755. /**
  136756. * Gets the output component
  136757. */
  136758. get output(): NodeMaterialConnectionPoint;
  136759. autoConfigure(material: NodeMaterial): void;
  136760. protected _buildBlock(state: NodeMaterialBuildState): this;
  136761. }
  136762. }
  136763. declare module BABYLON {
  136764. /**
  136765. * Block used to compute fresnel value
  136766. */
  136767. export class FresnelBlock extends NodeMaterialBlock {
  136768. /**
  136769. * Create a new FresnelBlock
  136770. * @param name defines the block name
  136771. */
  136772. constructor(name: string);
  136773. /**
  136774. * Gets the current class name
  136775. * @returns the class name
  136776. */
  136777. getClassName(): string;
  136778. /**
  136779. * Gets the world normal input component
  136780. */
  136781. get worldNormal(): NodeMaterialConnectionPoint;
  136782. /**
  136783. * Gets the view direction input component
  136784. */
  136785. get viewDirection(): NodeMaterialConnectionPoint;
  136786. /**
  136787. * Gets the bias input component
  136788. */
  136789. get bias(): NodeMaterialConnectionPoint;
  136790. /**
  136791. * Gets the camera (or eye) position component
  136792. */
  136793. get power(): NodeMaterialConnectionPoint;
  136794. /**
  136795. * Gets the fresnel output component
  136796. */
  136797. get fresnel(): NodeMaterialConnectionPoint;
  136798. autoConfigure(material: NodeMaterial): void;
  136799. protected _buildBlock(state: NodeMaterialBuildState): this;
  136800. }
  136801. }
  136802. declare module BABYLON {
  136803. /**
  136804. * Block used to get the max of 2 values
  136805. */
  136806. export class MaxBlock extends NodeMaterialBlock {
  136807. /**
  136808. * Creates a new MaxBlock
  136809. * @param name defines the block name
  136810. */
  136811. constructor(name: string);
  136812. /**
  136813. * Gets the current class name
  136814. * @returns the class name
  136815. */
  136816. getClassName(): string;
  136817. /**
  136818. * Gets the left operand input component
  136819. */
  136820. get left(): NodeMaterialConnectionPoint;
  136821. /**
  136822. * Gets the right operand input component
  136823. */
  136824. get right(): NodeMaterialConnectionPoint;
  136825. /**
  136826. * Gets the output component
  136827. */
  136828. get output(): NodeMaterialConnectionPoint;
  136829. protected _buildBlock(state: NodeMaterialBuildState): this;
  136830. }
  136831. }
  136832. declare module BABYLON {
  136833. /**
  136834. * Block used to get the min of 2 values
  136835. */
  136836. export class MinBlock extends NodeMaterialBlock {
  136837. /**
  136838. * Creates a new MinBlock
  136839. * @param name defines the block name
  136840. */
  136841. constructor(name: string);
  136842. /**
  136843. * Gets the current class name
  136844. * @returns the class name
  136845. */
  136846. getClassName(): string;
  136847. /**
  136848. * Gets the left operand input component
  136849. */
  136850. get left(): NodeMaterialConnectionPoint;
  136851. /**
  136852. * Gets the right operand input component
  136853. */
  136854. get right(): NodeMaterialConnectionPoint;
  136855. /**
  136856. * Gets the output component
  136857. */
  136858. get output(): NodeMaterialConnectionPoint;
  136859. protected _buildBlock(state: NodeMaterialBuildState): this;
  136860. }
  136861. }
  136862. declare module BABYLON {
  136863. /**
  136864. * Block used to get the distance between 2 values
  136865. */
  136866. export class DistanceBlock extends NodeMaterialBlock {
  136867. /**
  136868. * Creates a new DistanceBlock
  136869. * @param name defines the block name
  136870. */
  136871. constructor(name: string);
  136872. /**
  136873. * Gets the current class name
  136874. * @returns the class name
  136875. */
  136876. getClassName(): string;
  136877. /**
  136878. * Gets the left operand input component
  136879. */
  136880. get left(): NodeMaterialConnectionPoint;
  136881. /**
  136882. * Gets the right operand input component
  136883. */
  136884. get right(): NodeMaterialConnectionPoint;
  136885. /**
  136886. * Gets the output component
  136887. */
  136888. get output(): NodeMaterialConnectionPoint;
  136889. protected _buildBlock(state: NodeMaterialBuildState): this;
  136890. }
  136891. }
  136892. declare module BABYLON {
  136893. /**
  136894. * Block used to get the length of a vector
  136895. */
  136896. export class LengthBlock extends NodeMaterialBlock {
  136897. /**
  136898. * Creates a new LengthBlock
  136899. * @param name defines the block name
  136900. */
  136901. constructor(name: string);
  136902. /**
  136903. * Gets the current class name
  136904. * @returns the class name
  136905. */
  136906. getClassName(): string;
  136907. /**
  136908. * Gets the value input component
  136909. */
  136910. get value(): NodeMaterialConnectionPoint;
  136911. /**
  136912. * Gets the output component
  136913. */
  136914. get output(): NodeMaterialConnectionPoint;
  136915. protected _buildBlock(state: NodeMaterialBuildState): this;
  136916. }
  136917. }
  136918. declare module BABYLON {
  136919. /**
  136920. * Block used to get negative version of a value (i.e. x * -1)
  136921. */
  136922. export class NegateBlock extends NodeMaterialBlock {
  136923. /**
  136924. * Creates a new NegateBlock
  136925. * @param name defines the block name
  136926. */
  136927. constructor(name: string);
  136928. /**
  136929. * Gets the current class name
  136930. * @returns the class name
  136931. */
  136932. getClassName(): string;
  136933. /**
  136934. * Gets the value input component
  136935. */
  136936. get value(): NodeMaterialConnectionPoint;
  136937. /**
  136938. * Gets the output component
  136939. */
  136940. get output(): NodeMaterialConnectionPoint;
  136941. protected _buildBlock(state: NodeMaterialBuildState): this;
  136942. }
  136943. }
  136944. declare module BABYLON {
  136945. /**
  136946. * Block used to get the value of the first parameter raised to the power of the second
  136947. */
  136948. export class PowBlock extends NodeMaterialBlock {
  136949. /**
  136950. * Creates a new PowBlock
  136951. * @param name defines the block name
  136952. */
  136953. constructor(name: string);
  136954. /**
  136955. * Gets the current class name
  136956. * @returns the class name
  136957. */
  136958. getClassName(): string;
  136959. /**
  136960. * Gets the value operand input component
  136961. */
  136962. get value(): NodeMaterialConnectionPoint;
  136963. /**
  136964. * Gets the power operand input component
  136965. */
  136966. get power(): NodeMaterialConnectionPoint;
  136967. /**
  136968. * Gets the output component
  136969. */
  136970. get output(): NodeMaterialConnectionPoint;
  136971. protected _buildBlock(state: NodeMaterialBuildState): this;
  136972. }
  136973. }
  136974. declare module BABYLON {
  136975. /**
  136976. * Block used to get a random number
  136977. */
  136978. export class RandomNumberBlock extends NodeMaterialBlock {
  136979. /**
  136980. * Creates a new RandomNumberBlock
  136981. * @param name defines the block name
  136982. */
  136983. constructor(name: string);
  136984. /**
  136985. * Gets the current class name
  136986. * @returns the class name
  136987. */
  136988. getClassName(): string;
  136989. /**
  136990. * Gets the seed input component
  136991. */
  136992. get seed(): NodeMaterialConnectionPoint;
  136993. /**
  136994. * Gets the output component
  136995. */
  136996. get output(): NodeMaterialConnectionPoint;
  136997. protected _buildBlock(state: NodeMaterialBuildState): this;
  136998. }
  136999. }
  137000. declare module BABYLON {
  137001. /**
  137002. * Block used to compute arc tangent of 2 values
  137003. */
  137004. export class ArcTan2Block extends NodeMaterialBlock {
  137005. /**
  137006. * Creates a new ArcTan2Block
  137007. * @param name defines the block name
  137008. */
  137009. constructor(name: string);
  137010. /**
  137011. * Gets the current class name
  137012. * @returns the class name
  137013. */
  137014. getClassName(): string;
  137015. /**
  137016. * Gets the x operand input component
  137017. */
  137018. get x(): NodeMaterialConnectionPoint;
  137019. /**
  137020. * Gets the y operand input component
  137021. */
  137022. get y(): NodeMaterialConnectionPoint;
  137023. /**
  137024. * Gets the output component
  137025. */
  137026. get output(): NodeMaterialConnectionPoint;
  137027. protected _buildBlock(state: NodeMaterialBuildState): this;
  137028. }
  137029. }
  137030. declare module BABYLON {
  137031. /**
  137032. * Block used to smooth step a value
  137033. */
  137034. export class SmoothStepBlock extends NodeMaterialBlock {
  137035. /**
  137036. * Creates a new SmoothStepBlock
  137037. * @param name defines the block name
  137038. */
  137039. constructor(name: string);
  137040. /**
  137041. * Gets the current class name
  137042. * @returns the class name
  137043. */
  137044. getClassName(): string;
  137045. /**
  137046. * Gets the value operand input component
  137047. */
  137048. get value(): NodeMaterialConnectionPoint;
  137049. /**
  137050. * Gets the first edge operand input component
  137051. */
  137052. get edge0(): NodeMaterialConnectionPoint;
  137053. /**
  137054. * Gets the second edge operand input component
  137055. */
  137056. get edge1(): NodeMaterialConnectionPoint;
  137057. /**
  137058. * Gets the output component
  137059. */
  137060. get output(): NodeMaterialConnectionPoint;
  137061. protected _buildBlock(state: NodeMaterialBuildState): this;
  137062. }
  137063. }
  137064. declare module BABYLON {
  137065. /**
  137066. * Block used to get the reciprocal (1 / x) of a value
  137067. */
  137068. export class ReciprocalBlock extends NodeMaterialBlock {
  137069. /**
  137070. * Creates a new ReciprocalBlock
  137071. * @param name defines the block name
  137072. */
  137073. constructor(name: string);
  137074. /**
  137075. * Gets the current class name
  137076. * @returns the class name
  137077. */
  137078. getClassName(): string;
  137079. /**
  137080. * Gets the input component
  137081. */
  137082. get input(): NodeMaterialConnectionPoint;
  137083. /**
  137084. * Gets the output component
  137085. */
  137086. get output(): NodeMaterialConnectionPoint;
  137087. protected _buildBlock(state: NodeMaterialBuildState): this;
  137088. }
  137089. }
  137090. declare module BABYLON {
  137091. /**
  137092. * Block used to replace a color by another one
  137093. */
  137094. export class ReplaceColorBlock extends NodeMaterialBlock {
  137095. /**
  137096. * Creates a new ReplaceColorBlock
  137097. * @param name defines the block name
  137098. */
  137099. constructor(name: string);
  137100. /**
  137101. * Gets the current class name
  137102. * @returns the class name
  137103. */
  137104. getClassName(): string;
  137105. /**
  137106. * Gets the value input component
  137107. */
  137108. get value(): NodeMaterialConnectionPoint;
  137109. /**
  137110. * Gets the reference input component
  137111. */
  137112. get reference(): NodeMaterialConnectionPoint;
  137113. /**
  137114. * Gets the distance input component
  137115. */
  137116. get distance(): NodeMaterialConnectionPoint;
  137117. /**
  137118. * Gets the replacement input component
  137119. */
  137120. get replacement(): NodeMaterialConnectionPoint;
  137121. /**
  137122. * Gets the output component
  137123. */
  137124. get output(): NodeMaterialConnectionPoint;
  137125. protected _buildBlock(state: NodeMaterialBuildState): this;
  137126. }
  137127. }
  137128. declare module BABYLON {
  137129. /**
  137130. * Block used to posterize a value
  137131. * @see https://en.wikipedia.org/wiki/Posterization
  137132. */
  137133. export class PosterizeBlock extends NodeMaterialBlock {
  137134. /**
  137135. * Creates a new PosterizeBlock
  137136. * @param name defines the block name
  137137. */
  137138. constructor(name: string);
  137139. /**
  137140. * Gets the current class name
  137141. * @returns the class name
  137142. */
  137143. getClassName(): string;
  137144. /**
  137145. * Gets the value input component
  137146. */
  137147. get value(): NodeMaterialConnectionPoint;
  137148. /**
  137149. * Gets the steps input component
  137150. */
  137151. get steps(): NodeMaterialConnectionPoint;
  137152. /**
  137153. * Gets the output component
  137154. */
  137155. get output(): NodeMaterialConnectionPoint;
  137156. protected _buildBlock(state: NodeMaterialBuildState): this;
  137157. }
  137158. }
  137159. declare module BABYLON {
  137160. /**
  137161. * Operations supported by the Wave block
  137162. */
  137163. export enum WaveBlockKind {
  137164. /** SawTooth */
  137165. SawTooth = 0,
  137166. /** Square */
  137167. Square = 1,
  137168. /** Triangle */
  137169. Triangle = 2
  137170. }
  137171. /**
  137172. * Block used to apply wave operation to floats
  137173. */
  137174. export class WaveBlock extends NodeMaterialBlock {
  137175. /**
  137176. * Gets or sets the kibnd of wave to be applied by the block
  137177. */
  137178. kind: WaveBlockKind;
  137179. /**
  137180. * Creates a new WaveBlock
  137181. * @param name defines the block name
  137182. */
  137183. constructor(name: string);
  137184. /**
  137185. * Gets the current class name
  137186. * @returns the class name
  137187. */
  137188. getClassName(): string;
  137189. /**
  137190. * Gets the input component
  137191. */
  137192. get input(): NodeMaterialConnectionPoint;
  137193. /**
  137194. * Gets the output component
  137195. */
  137196. get output(): NodeMaterialConnectionPoint;
  137197. protected _buildBlock(state: NodeMaterialBuildState): this;
  137198. serialize(): any;
  137199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137200. }
  137201. }
  137202. declare module BABYLON {
  137203. /**
  137204. * Class used to store a color step for the GradientBlock
  137205. */
  137206. export class GradientBlockColorStep {
  137207. /**
  137208. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137209. */
  137210. step: number;
  137211. /**
  137212. * Gets or sets the color associated with this step
  137213. */
  137214. color: Color3;
  137215. /**
  137216. * Creates a new GradientBlockColorStep
  137217. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  137218. * @param color defines the color associated with this step
  137219. */
  137220. constructor(
  137221. /**
  137222. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137223. */
  137224. step: number,
  137225. /**
  137226. * Gets or sets the color associated with this step
  137227. */
  137228. color: Color3);
  137229. }
  137230. /**
  137231. * Block used to return a color from a gradient based on an input value between 0 and 1
  137232. */
  137233. export class GradientBlock extends NodeMaterialBlock {
  137234. /**
  137235. * Gets or sets the list of color steps
  137236. */
  137237. colorSteps: GradientBlockColorStep[];
  137238. /**
  137239. * Creates a new GradientBlock
  137240. * @param name defines the block name
  137241. */
  137242. constructor(name: string);
  137243. /**
  137244. * Gets the current class name
  137245. * @returns the class name
  137246. */
  137247. getClassName(): string;
  137248. /**
  137249. * Gets the gradient input component
  137250. */
  137251. get gradient(): NodeMaterialConnectionPoint;
  137252. /**
  137253. * Gets the output component
  137254. */
  137255. get output(): NodeMaterialConnectionPoint;
  137256. private _writeColorConstant;
  137257. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137258. serialize(): any;
  137259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137260. protected _dumpPropertiesCode(): string;
  137261. }
  137262. }
  137263. declare module BABYLON {
  137264. /**
  137265. * Block used to normalize lerp between 2 values
  137266. */
  137267. export class NLerpBlock extends NodeMaterialBlock {
  137268. /**
  137269. * Creates a new NLerpBlock
  137270. * @param name defines the block name
  137271. */
  137272. constructor(name: string);
  137273. /**
  137274. * Gets the current class name
  137275. * @returns the class name
  137276. */
  137277. getClassName(): string;
  137278. /**
  137279. * Gets the left operand input component
  137280. */
  137281. get left(): NodeMaterialConnectionPoint;
  137282. /**
  137283. * Gets the right operand input component
  137284. */
  137285. get right(): NodeMaterialConnectionPoint;
  137286. /**
  137287. * Gets the gradient operand input component
  137288. */
  137289. get gradient(): NodeMaterialConnectionPoint;
  137290. /**
  137291. * Gets the output component
  137292. */
  137293. get output(): NodeMaterialConnectionPoint;
  137294. protected _buildBlock(state: NodeMaterialBuildState): this;
  137295. }
  137296. }
  137297. declare module BABYLON {
  137298. /**
  137299. * block used to Generate a Worley Noise 3D Noise Pattern
  137300. */
  137301. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  137302. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  137303. manhattanDistance: boolean;
  137304. /**
  137305. * Creates a new WorleyNoise3DBlock
  137306. * @param name defines the block name
  137307. */
  137308. constructor(name: string);
  137309. /**
  137310. * Gets the current class name
  137311. * @returns the class name
  137312. */
  137313. getClassName(): string;
  137314. /**
  137315. * Gets the seed input component
  137316. */
  137317. get seed(): NodeMaterialConnectionPoint;
  137318. /**
  137319. * Gets the jitter input component
  137320. */
  137321. get jitter(): NodeMaterialConnectionPoint;
  137322. /**
  137323. * Gets the output component
  137324. */
  137325. get output(): NodeMaterialConnectionPoint;
  137326. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137327. /**
  137328. * Exposes the properties to the UI?
  137329. */
  137330. protected _dumpPropertiesCode(): string;
  137331. /**
  137332. * Exposes the properties to the Seralize?
  137333. */
  137334. serialize(): any;
  137335. /**
  137336. * Exposes the properties to the deseralize?
  137337. */
  137338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137339. }
  137340. }
  137341. declare module BABYLON {
  137342. /**
  137343. * block used to Generate a Simplex Perlin 3d Noise Pattern
  137344. */
  137345. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  137346. /**
  137347. * Creates a new SimplexPerlin3DBlock
  137348. * @param name defines the block name
  137349. */
  137350. constructor(name: string);
  137351. /**
  137352. * Gets the current class name
  137353. * @returns the class name
  137354. */
  137355. getClassName(): string;
  137356. /**
  137357. * Gets the seed operand input component
  137358. */
  137359. get seed(): NodeMaterialConnectionPoint;
  137360. /**
  137361. * Gets the output component
  137362. */
  137363. get output(): NodeMaterialConnectionPoint;
  137364. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137365. }
  137366. }
  137367. declare module BABYLON {
  137368. /**
  137369. * Block used to blend normals
  137370. */
  137371. export class NormalBlendBlock extends NodeMaterialBlock {
  137372. /**
  137373. * Creates a new NormalBlendBlock
  137374. * @param name defines the block name
  137375. */
  137376. constructor(name: string);
  137377. /**
  137378. * Gets the current class name
  137379. * @returns the class name
  137380. */
  137381. getClassName(): string;
  137382. /**
  137383. * Gets the first input component
  137384. */
  137385. get normalMap0(): NodeMaterialConnectionPoint;
  137386. /**
  137387. * Gets the second input component
  137388. */
  137389. get normalMap1(): NodeMaterialConnectionPoint;
  137390. /**
  137391. * Gets the output component
  137392. */
  137393. get output(): NodeMaterialConnectionPoint;
  137394. protected _buildBlock(state: NodeMaterialBuildState): this;
  137395. }
  137396. }
  137397. declare module BABYLON {
  137398. /**
  137399. * Block used to rotate a 2d vector by a given angle
  137400. */
  137401. export class Rotate2dBlock extends NodeMaterialBlock {
  137402. /**
  137403. * Creates a new Rotate2dBlock
  137404. * @param name defines the block name
  137405. */
  137406. constructor(name: string);
  137407. /**
  137408. * Gets the current class name
  137409. * @returns the class name
  137410. */
  137411. getClassName(): string;
  137412. /**
  137413. * Gets the input vector
  137414. */
  137415. get input(): NodeMaterialConnectionPoint;
  137416. /**
  137417. * Gets the input angle
  137418. */
  137419. get angle(): NodeMaterialConnectionPoint;
  137420. /**
  137421. * Gets the output component
  137422. */
  137423. get output(): NodeMaterialConnectionPoint;
  137424. autoConfigure(material: NodeMaterial): void;
  137425. protected _buildBlock(state: NodeMaterialBuildState): this;
  137426. }
  137427. }
  137428. declare module BABYLON {
  137429. /**
  137430. * Block used to get the reflected vector from a direction and a normal
  137431. */
  137432. export class ReflectBlock extends NodeMaterialBlock {
  137433. /**
  137434. * Creates a new ReflectBlock
  137435. * @param name defines the block name
  137436. */
  137437. constructor(name: string);
  137438. /**
  137439. * Gets the current class name
  137440. * @returns the class name
  137441. */
  137442. getClassName(): string;
  137443. /**
  137444. * Gets the incident component
  137445. */
  137446. get incident(): NodeMaterialConnectionPoint;
  137447. /**
  137448. * Gets the normal component
  137449. */
  137450. get normal(): NodeMaterialConnectionPoint;
  137451. /**
  137452. * Gets the output component
  137453. */
  137454. get output(): NodeMaterialConnectionPoint;
  137455. protected _buildBlock(state: NodeMaterialBuildState): this;
  137456. }
  137457. }
  137458. declare module BABYLON {
  137459. /**
  137460. * Block used to get the refracted vector from a direction and a normal
  137461. */
  137462. export class RefractBlock extends NodeMaterialBlock {
  137463. /**
  137464. * Creates a new RefractBlock
  137465. * @param name defines the block name
  137466. */
  137467. constructor(name: string);
  137468. /**
  137469. * Gets the current class name
  137470. * @returns the class name
  137471. */
  137472. getClassName(): string;
  137473. /**
  137474. * Gets the incident component
  137475. */
  137476. get incident(): NodeMaterialConnectionPoint;
  137477. /**
  137478. * Gets the normal component
  137479. */
  137480. get normal(): NodeMaterialConnectionPoint;
  137481. /**
  137482. * Gets the index of refraction component
  137483. */
  137484. get ior(): NodeMaterialConnectionPoint;
  137485. /**
  137486. * Gets the output component
  137487. */
  137488. get output(): NodeMaterialConnectionPoint;
  137489. protected _buildBlock(state: NodeMaterialBuildState): this;
  137490. }
  137491. }
  137492. declare module BABYLON {
  137493. /**
  137494. * Block used to desaturate a color
  137495. */
  137496. export class DesaturateBlock extends NodeMaterialBlock {
  137497. /**
  137498. * Creates a new DesaturateBlock
  137499. * @param name defines the block name
  137500. */
  137501. constructor(name: string);
  137502. /**
  137503. * Gets the current class name
  137504. * @returns the class name
  137505. */
  137506. getClassName(): string;
  137507. /**
  137508. * Gets the color operand input component
  137509. */
  137510. get color(): NodeMaterialConnectionPoint;
  137511. /**
  137512. * Gets the level operand input component
  137513. */
  137514. get level(): NodeMaterialConnectionPoint;
  137515. /**
  137516. * Gets the output component
  137517. */
  137518. get output(): NodeMaterialConnectionPoint;
  137519. protected _buildBlock(state: NodeMaterialBuildState): this;
  137520. }
  137521. }
  137522. declare module BABYLON {
  137523. /**
  137524. * Block used to implement the ambient occlusion module of the PBR material
  137525. */
  137526. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  137527. /**
  137528. * Create a new AmbientOcclusionBlock
  137529. * @param name defines the block name
  137530. */
  137531. constructor(name: string);
  137532. /**
  137533. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137534. */
  137535. useAmbientInGrayScale: boolean;
  137536. /**
  137537. * Initialize the block and prepare the context for build
  137538. * @param state defines the state that will be used for the build
  137539. */
  137540. initialize(state: NodeMaterialBuildState): void;
  137541. /**
  137542. * Gets the current class name
  137543. * @returns the class name
  137544. */
  137545. getClassName(): string;
  137546. /**
  137547. * Gets the texture input component
  137548. */
  137549. get texture(): NodeMaterialConnectionPoint;
  137550. /**
  137551. * Gets the texture intensity component
  137552. */
  137553. get intensity(): NodeMaterialConnectionPoint;
  137554. /**
  137555. * Gets the direct light intensity input component
  137556. */
  137557. get directLightIntensity(): NodeMaterialConnectionPoint;
  137558. /**
  137559. * Gets the ambient occlusion object output component
  137560. */
  137561. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137562. /**
  137563. * Gets the main code of the block (fragment side)
  137564. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  137565. * @returns the shader code
  137566. */
  137567. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  137568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137569. protected _buildBlock(state: NodeMaterialBuildState): this;
  137570. protected _dumpPropertiesCode(): string;
  137571. serialize(): any;
  137572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137573. }
  137574. }
  137575. declare module BABYLON {
  137576. /**
  137577. * Block used to implement the reflection module of the PBR material
  137578. */
  137579. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  137580. /** @hidden */
  137581. _defineLODReflectionAlpha: string;
  137582. /** @hidden */
  137583. _defineLinearSpecularReflection: string;
  137584. private _vEnvironmentIrradianceName;
  137585. /** @hidden */
  137586. _vReflectionMicrosurfaceInfosName: string;
  137587. /** @hidden */
  137588. _vReflectionInfosName: string;
  137589. private _scene;
  137590. /**
  137591. * The three properties below are set by the main PBR block prior to calling methods of this class.
  137592. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137593. * It's less burden on the user side in the editor part.
  137594. */
  137595. /** @hidden */
  137596. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137597. /** @hidden */
  137598. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137599. /** @hidden */
  137600. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  137601. /**
  137602. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  137603. * diffuse part of the IBL.
  137604. */
  137605. useSphericalHarmonics: boolean;
  137606. /**
  137607. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137608. */
  137609. forceIrradianceInFragment: boolean;
  137610. /**
  137611. * Create a new ReflectionBlock
  137612. * @param name defines the block name
  137613. */
  137614. constructor(name: string);
  137615. /**
  137616. * Gets the current class name
  137617. * @returns the class name
  137618. */
  137619. getClassName(): string;
  137620. /**
  137621. * Gets the position input component
  137622. */
  137623. get position(): NodeMaterialConnectionPoint;
  137624. /**
  137625. * Gets the world position input component
  137626. */
  137627. get worldPosition(): NodeMaterialConnectionPoint;
  137628. /**
  137629. * Gets the world normal input component
  137630. */
  137631. get worldNormal(): NodeMaterialConnectionPoint;
  137632. /**
  137633. * Gets the world input component
  137634. */
  137635. get world(): NodeMaterialConnectionPoint;
  137636. /**
  137637. * Gets the camera (or eye) position component
  137638. */
  137639. get cameraPosition(): NodeMaterialConnectionPoint;
  137640. /**
  137641. * Gets the view input component
  137642. */
  137643. get view(): NodeMaterialConnectionPoint;
  137644. /**
  137645. * Gets the color input component
  137646. */
  137647. get color(): NodeMaterialConnectionPoint;
  137648. /**
  137649. * Gets the reflection object output component
  137650. */
  137651. get reflection(): NodeMaterialConnectionPoint;
  137652. /**
  137653. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  137654. */
  137655. get hasTexture(): boolean;
  137656. /**
  137657. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  137658. */
  137659. get reflectionColor(): string;
  137660. protected _getTexture(): Nullable<BaseTexture>;
  137661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137663. /**
  137664. * Gets the code to inject in the vertex shader
  137665. * @param state current state of the node material building
  137666. * @returns the shader code
  137667. */
  137668. handleVertexSide(state: NodeMaterialBuildState): string;
  137669. /**
  137670. * Gets the main code of the block (fragment side)
  137671. * @param state current state of the node material building
  137672. * @param normalVarName name of the existing variable corresponding to the normal
  137673. * @returns the shader code
  137674. */
  137675. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  137676. protected _buildBlock(state: NodeMaterialBuildState): this;
  137677. protected _dumpPropertiesCode(): string;
  137678. serialize(): any;
  137679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137680. }
  137681. }
  137682. declare module BABYLON {
  137683. /**
  137684. * Block used to implement the sheen module of the PBR material
  137685. */
  137686. export class SheenBlock extends NodeMaterialBlock {
  137687. /**
  137688. * Create a new SheenBlock
  137689. * @param name defines the block name
  137690. */
  137691. constructor(name: string);
  137692. /**
  137693. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  137694. * It allows the strength of the sheen effect to not depend on the base color of the material,
  137695. * making it easier to setup and tweak the effect
  137696. */
  137697. albedoScaling: boolean;
  137698. /**
  137699. * Defines if the sheen is linked to the sheen color.
  137700. */
  137701. linkSheenWithAlbedo: boolean;
  137702. /**
  137703. * Initialize the block and prepare the context for build
  137704. * @param state defines the state that will be used for the build
  137705. */
  137706. initialize(state: NodeMaterialBuildState): void;
  137707. /**
  137708. * Gets the current class name
  137709. * @returns the class name
  137710. */
  137711. getClassName(): string;
  137712. /**
  137713. * Gets the intensity input component
  137714. */
  137715. get intensity(): NodeMaterialConnectionPoint;
  137716. /**
  137717. * Gets the color input component
  137718. */
  137719. get color(): NodeMaterialConnectionPoint;
  137720. /**
  137721. * Gets the roughness input component
  137722. */
  137723. get roughness(): NodeMaterialConnectionPoint;
  137724. /**
  137725. * Gets the texture input component
  137726. */
  137727. get texture(): NodeMaterialConnectionPoint;
  137728. /**
  137729. * Gets the sheen object output component
  137730. */
  137731. get sheen(): NodeMaterialConnectionPoint;
  137732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137733. /**
  137734. * Gets the main code of the block (fragment side)
  137735. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137736. * @returns the shader code
  137737. */
  137738. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  137739. protected _buildBlock(state: NodeMaterialBuildState): this;
  137740. protected _dumpPropertiesCode(): string;
  137741. serialize(): any;
  137742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137743. }
  137744. }
  137745. declare module BABYLON {
  137746. /**
  137747. * Block used to implement the reflectivity module of the PBR material
  137748. */
  137749. export class ReflectivityBlock extends NodeMaterialBlock {
  137750. /**
  137751. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137752. */
  137753. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137754. /**
  137755. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137756. */
  137757. useMetallnessFromMetallicTextureBlue: boolean;
  137758. /**
  137759. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137760. */
  137761. useRoughnessFromMetallicTextureAlpha: boolean;
  137762. /**
  137763. * Specifies if the metallic texture contains the roughness information in its green channel.
  137764. */
  137765. useRoughnessFromMetallicTextureGreen: boolean;
  137766. /**
  137767. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  137768. */
  137769. useMetallicF0FactorFromMetallicTexture: boolean;
  137770. /**
  137771. * Create a new ReflectivityBlock
  137772. * @param name defines the block name
  137773. */
  137774. constructor(name: string);
  137775. /**
  137776. * Initialize the block and prepare the context for build
  137777. * @param state defines the state that will be used for the build
  137778. */
  137779. initialize(state: NodeMaterialBuildState): void;
  137780. /**
  137781. * Gets the current class name
  137782. * @returns the class name
  137783. */
  137784. getClassName(): string;
  137785. /**
  137786. * Gets the metallic input component
  137787. */
  137788. get metallic(): NodeMaterialConnectionPoint;
  137789. /**
  137790. * Gets the roughness input component
  137791. */
  137792. get roughness(): NodeMaterialConnectionPoint;
  137793. /**
  137794. * Gets the texture input component
  137795. */
  137796. get texture(): NodeMaterialConnectionPoint;
  137797. /**
  137798. * Gets the reflectivity object output component
  137799. */
  137800. get reflectivity(): NodeMaterialConnectionPoint;
  137801. /**
  137802. * Gets the main code of the block (fragment side)
  137803. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  137804. * @returns the shader code
  137805. */
  137806. getCode(aoIntensityVarName: string): string;
  137807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137808. protected _buildBlock(state: NodeMaterialBuildState): this;
  137809. protected _dumpPropertiesCode(): string;
  137810. serialize(): any;
  137811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137812. }
  137813. }
  137814. declare module BABYLON {
  137815. /**
  137816. * Block used to implement the anisotropy module of the PBR material
  137817. */
  137818. export class AnisotropyBlock extends NodeMaterialBlock {
  137819. /**
  137820. * The two properties below are set by the main PBR block prior to calling methods of this class.
  137821. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137822. * It's less burden on the user side in the editor part.
  137823. */
  137824. /** @hidden */
  137825. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137826. /** @hidden */
  137827. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137828. /**
  137829. * Create a new AnisotropyBlock
  137830. * @param name defines the block name
  137831. */
  137832. constructor(name: string);
  137833. /**
  137834. * Initialize the block and prepare the context for build
  137835. * @param state defines the state that will be used for the build
  137836. */
  137837. initialize(state: NodeMaterialBuildState): void;
  137838. /**
  137839. * Gets the current class name
  137840. * @returns the class name
  137841. */
  137842. getClassName(): string;
  137843. /**
  137844. * Gets the intensity input component
  137845. */
  137846. get intensity(): NodeMaterialConnectionPoint;
  137847. /**
  137848. * Gets the direction input component
  137849. */
  137850. get direction(): NodeMaterialConnectionPoint;
  137851. /**
  137852. * Gets the texture input component
  137853. */
  137854. get texture(): NodeMaterialConnectionPoint;
  137855. /**
  137856. * Gets the uv input component
  137857. */
  137858. get uv(): NodeMaterialConnectionPoint;
  137859. /**
  137860. * Gets the worldTangent input component
  137861. */
  137862. get worldTangent(): NodeMaterialConnectionPoint;
  137863. /**
  137864. * Gets the anisotropy object output component
  137865. */
  137866. get anisotropy(): NodeMaterialConnectionPoint;
  137867. private _generateTBNSpace;
  137868. /**
  137869. * Gets the main code of the block (fragment side)
  137870. * @param state current state of the node material building
  137871. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137872. * @returns the shader code
  137873. */
  137874. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  137875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137876. protected _buildBlock(state: NodeMaterialBuildState): this;
  137877. }
  137878. }
  137879. declare module BABYLON {
  137880. /**
  137881. * Block used to implement the clear coat module of the PBR material
  137882. */
  137883. export class ClearCoatBlock extends NodeMaterialBlock {
  137884. private _scene;
  137885. /**
  137886. * Create a new ClearCoatBlock
  137887. * @param name defines the block name
  137888. */
  137889. constructor(name: string);
  137890. /**
  137891. * Initialize the block and prepare the context for build
  137892. * @param state defines the state that will be used for the build
  137893. */
  137894. initialize(state: NodeMaterialBuildState): void;
  137895. /**
  137896. * Gets the current class name
  137897. * @returns the class name
  137898. */
  137899. getClassName(): string;
  137900. /**
  137901. * Gets the intensity input component
  137902. */
  137903. get intensity(): NodeMaterialConnectionPoint;
  137904. /**
  137905. * Gets the roughness input component
  137906. */
  137907. get roughness(): NodeMaterialConnectionPoint;
  137908. /**
  137909. * Gets the ior input component
  137910. */
  137911. get ior(): NodeMaterialConnectionPoint;
  137912. /**
  137913. * Gets the texture input component
  137914. */
  137915. get texture(): NodeMaterialConnectionPoint;
  137916. /**
  137917. * Gets the bump texture input component
  137918. */
  137919. get bumpTexture(): NodeMaterialConnectionPoint;
  137920. /**
  137921. * Gets the uv input component
  137922. */
  137923. get uv(): NodeMaterialConnectionPoint;
  137924. /**
  137925. * Gets the tint color input component
  137926. */
  137927. get tintColor(): NodeMaterialConnectionPoint;
  137928. /**
  137929. * Gets the tint "at distance" input component
  137930. */
  137931. get tintAtDistance(): NodeMaterialConnectionPoint;
  137932. /**
  137933. * Gets the tint thickness input component
  137934. */
  137935. get tintThickness(): NodeMaterialConnectionPoint;
  137936. /**
  137937. * Gets the tint texture input component
  137938. */
  137939. get tintTexture(): NodeMaterialConnectionPoint;
  137940. /**
  137941. * Gets the world tangent input component
  137942. */
  137943. get worldTangent(): NodeMaterialConnectionPoint;
  137944. /**
  137945. * Gets the clear coat object output component
  137946. */
  137947. get clearcoat(): NodeMaterialConnectionPoint;
  137948. autoConfigure(material: NodeMaterial): void;
  137949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137951. private _generateTBNSpace;
  137952. /**
  137953. * Gets the main code of the block (fragment side)
  137954. * @param state current state of the node material building
  137955. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  137956. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137957. * @param worldPosVarName name of the variable holding the world position
  137958. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137959. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  137960. * @param worldNormalVarName name of the variable holding the world normal
  137961. * @returns the shader code
  137962. */
  137963. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  137964. protected _buildBlock(state: NodeMaterialBuildState): this;
  137965. }
  137966. }
  137967. declare module BABYLON {
  137968. /**
  137969. * Block used to implement the sub surface module of the PBR material
  137970. */
  137971. export class SubSurfaceBlock extends NodeMaterialBlock {
  137972. /**
  137973. * Create a new SubSurfaceBlock
  137974. * @param name defines the block name
  137975. */
  137976. constructor(name: string);
  137977. /**
  137978. * Stores the intensity of the different subsurface effects in the thickness texture.
  137979. * * the green channel is the translucency intensity.
  137980. * * the blue channel is the scattering intensity.
  137981. * * the alpha channel is the refraction intensity.
  137982. */
  137983. useMaskFromThicknessTexture: boolean;
  137984. /**
  137985. * Initialize the block and prepare the context for build
  137986. * @param state defines the state that will be used for the build
  137987. */
  137988. initialize(state: NodeMaterialBuildState): void;
  137989. /**
  137990. * Gets the current class name
  137991. * @returns the class name
  137992. */
  137993. getClassName(): string;
  137994. /**
  137995. * Gets the min thickness input component
  137996. */
  137997. get minThickness(): NodeMaterialConnectionPoint;
  137998. /**
  137999. * Gets the max thickness input component
  138000. */
  138001. get maxThickness(): NodeMaterialConnectionPoint;
  138002. /**
  138003. * Gets the thickness texture component
  138004. */
  138005. get thicknessTexture(): NodeMaterialConnectionPoint;
  138006. /**
  138007. * Gets the tint color input component
  138008. */
  138009. get tintColor(): NodeMaterialConnectionPoint;
  138010. /**
  138011. * Gets the translucency intensity input component
  138012. */
  138013. get translucencyIntensity(): NodeMaterialConnectionPoint;
  138014. /**
  138015. * Gets the translucency diffusion distance input component
  138016. */
  138017. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  138018. /**
  138019. * Gets the refraction object parameters
  138020. */
  138021. get refraction(): NodeMaterialConnectionPoint;
  138022. /**
  138023. * Gets the sub surface object output component
  138024. */
  138025. get subsurface(): NodeMaterialConnectionPoint;
  138026. autoConfigure(material: NodeMaterial): void;
  138027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138028. /**
  138029. * Gets the main code of the block (fragment side)
  138030. * @param state current state of the node material building
  138031. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  138032. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  138033. * @param worldPosVarName name of the variable holding the world position
  138034. * @returns the shader code
  138035. */
  138036. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  138037. protected _buildBlock(state: NodeMaterialBuildState): this;
  138038. }
  138039. }
  138040. declare module BABYLON {
  138041. /**
  138042. * Block used to implement the PBR metallic/roughness model
  138043. */
  138044. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  138045. /**
  138046. * Gets or sets the light associated with this block
  138047. */
  138048. light: Nullable<Light>;
  138049. private _lightId;
  138050. private _scene;
  138051. private _environmentBRDFTexture;
  138052. private _environmentBrdfSamplerName;
  138053. private _vNormalWName;
  138054. private _invertNormalName;
  138055. /**
  138056. * Create a new ReflectionBlock
  138057. * @param name defines the block name
  138058. */
  138059. constructor(name: string);
  138060. /**
  138061. * Intensity of the direct lights e.g. the four lights available in your scene.
  138062. * This impacts both the direct diffuse and specular highlights.
  138063. */
  138064. directIntensity: number;
  138065. /**
  138066. * Intensity of the environment e.g. how much the environment will light the object
  138067. * either through harmonics for rough material or through the refelction for shiny ones.
  138068. */
  138069. environmentIntensity: number;
  138070. /**
  138071. * This is a special control allowing the reduction of the specular highlights coming from the
  138072. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  138073. */
  138074. specularIntensity: number;
  138075. /**
  138076. * Defines the falloff type used in this material.
  138077. * It by default is Physical.
  138078. */
  138079. lightFalloff: number;
  138080. /**
  138081. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  138082. */
  138083. useAlphaFromAlbedoTexture: boolean;
  138084. /**
  138085. * Specifies that alpha test should be used
  138086. */
  138087. useAlphaTest: boolean;
  138088. /**
  138089. * Defines the alpha limits in alpha test mode.
  138090. */
  138091. alphaTestCutoff: number;
  138092. /**
  138093. * Specifies that alpha blending should be used
  138094. */
  138095. useAlphaBlending: boolean;
  138096. /**
  138097. * Defines if the alpha value should be determined via the rgb values.
  138098. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  138099. */
  138100. opacityRGB: boolean;
  138101. /**
  138102. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  138103. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  138104. */
  138105. useRadianceOverAlpha: boolean;
  138106. /**
  138107. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  138108. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  138109. */
  138110. useSpecularOverAlpha: boolean;
  138111. /**
  138112. * Enables specular anti aliasing in the PBR shader.
  138113. * It will both interacts on the Geometry for analytical and IBL lighting.
  138114. * It also prefilter the roughness map based on the bump values.
  138115. */
  138116. enableSpecularAntiAliasing: boolean;
  138117. /**
  138118. * Defines if the material uses energy conservation.
  138119. */
  138120. useEnergyConservation: boolean;
  138121. /**
  138122. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  138123. * too much the area relying on ambient texture to define their ambient occlusion.
  138124. */
  138125. useRadianceOcclusion: boolean;
  138126. /**
  138127. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  138128. * makes the reflect vector face the model (under horizon).
  138129. */
  138130. useHorizonOcclusion: boolean;
  138131. /**
  138132. * If set to true, no lighting calculations will be applied.
  138133. */
  138134. unlit: boolean;
  138135. /**
  138136. * Force normal to face away from face.
  138137. */
  138138. forceNormalForward: boolean;
  138139. /**
  138140. * Defines the material debug mode.
  138141. * It helps seeing only some components of the material while troubleshooting.
  138142. */
  138143. debugMode: number;
  138144. /**
  138145. * Specify from where on screen the debug mode should start.
  138146. * The value goes from -1 (full screen) to 1 (not visible)
  138147. * It helps with side by side comparison against the final render
  138148. * This defaults to 0
  138149. */
  138150. debugLimit: number;
  138151. /**
  138152. * As the default viewing range might not be enough (if the ambient is really small for instance)
  138153. * You can use the factor to better multiply the final value.
  138154. */
  138155. debugFactor: number;
  138156. /**
  138157. * Initialize the block and prepare the context for build
  138158. * @param state defines the state that will be used for the build
  138159. */
  138160. initialize(state: NodeMaterialBuildState): void;
  138161. /**
  138162. * Gets the current class name
  138163. * @returns the class name
  138164. */
  138165. getClassName(): string;
  138166. /**
  138167. * Gets the world position input component
  138168. */
  138169. get worldPosition(): NodeMaterialConnectionPoint;
  138170. /**
  138171. * Gets the world normal input component
  138172. */
  138173. get worldNormal(): NodeMaterialConnectionPoint;
  138174. /**
  138175. * Gets the perturbed normal input component
  138176. */
  138177. get perturbedNormal(): NodeMaterialConnectionPoint;
  138178. /**
  138179. * Gets the camera position input component
  138180. */
  138181. get cameraPosition(): NodeMaterialConnectionPoint;
  138182. /**
  138183. * Gets the base color input component
  138184. */
  138185. get baseColor(): NodeMaterialConnectionPoint;
  138186. /**
  138187. * Gets the base texture input component
  138188. */
  138189. get baseTexture(): NodeMaterialConnectionPoint;
  138190. /**
  138191. * Gets the opacity texture input component
  138192. */
  138193. get opacityTexture(): NodeMaterialConnectionPoint;
  138194. /**
  138195. * Gets the ambient color input component
  138196. */
  138197. get ambientColor(): NodeMaterialConnectionPoint;
  138198. /**
  138199. * Gets the reflectivity object parameters
  138200. */
  138201. get reflectivity(): NodeMaterialConnectionPoint;
  138202. /**
  138203. * Gets the ambient occlusion object parameters
  138204. */
  138205. get ambientOcclusion(): NodeMaterialConnectionPoint;
  138206. /**
  138207. * Gets the reflection object parameters
  138208. */
  138209. get reflection(): NodeMaterialConnectionPoint;
  138210. /**
  138211. * Gets the sheen object parameters
  138212. */
  138213. get sheen(): NodeMaterialConnectionPoint;
  138214. /**
  138215. * Gets the clear coat object parameters
  138216. */
  138217. get clearcoat(): NodeMaterialConnectionPoint;
  138218. /**
  138219. * Gets the sub surface object parameters
  138220. */
  138221. get subsurface(): NodeMaterialConnectionPoint;
  138222. /**
  138223. * Gets the anisotropy object parameters
  138224. */
  138225. get anisotropy(): NodeMaterialConnectionPoint;
  138226. /**
  138227. * Gets the ambient output component
  138228. */
  138229. get ambient(): NodeMaterialConnectionPoint;
  138230. /**
  138231. * Gets the diffuse output component
  138232. */
  138233. get diffuse(): NodeMaterialConnectionPoint;
  138234. /**
  138235. * Gets the specular output component
  138236. */
  138237. get specular(): NodeMaterialConnectionPoint;
  138238. /**
  138239. * Gets the sheen output component
  138240. */
  138241. get sheenDir(): NodeMaterialConnectionPoint;
  138242. /**
  138243. * Gets the clear coat output component
  138244. */
  138245. get clearcoatDir(): NodeMaterialConnectionPoint;
  138246. /**
  138247. * Gets the indirect diffuse output component
  138248. */
  138249. get diffuseIndirect(): NodeMaterialConnectionPoint;
  138250. /**
  138251. * Gets the indirect specular output component
  138252. */
  138253. get specularIndirect(): NodeMaterialConnectionPoint;
  138254. /**
  138255. * Gets the indirect sheen output component
  138256. */
  138257. get sheenIndirect(): NodeMaterialConnectionPoint;
  138258. /**
  138259. * Gets the indirect clear coat output component
  138260. */
  138261. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  138262. /**
  138263. * Gets the refraction output component
  138264. */
  138265. get refraction(): NodeMaterialConnectionPoint;
  138266. /**
  138267. * Gets the global lighting output component
  138268. */
  138269. get lighting(): NodeMaterialConnectionPoint;
  138270. /**
  138271. * Gets the shadow output component
  138272. */
  138273. get shadow(): NodeMaterialConnectionPoint;
  138274. /**
  138275. * Gets the alpha output component
  138276. */
  138277. get alpha(): NodeMaterialConnectionPoint;
  138278. autoConfigure(material: NodeMaterial): void;
  138279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138280. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138281. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138282. private _injectVertexCode;
  138283. /**
  138284. * Gets the code corresponding to the albedo/opacity module
  138285. * @returns the shader code
  138286. */
  138287. getAlbedoOpacityCode(): string;
  138288. protected _buildBlock(state: NodeMaterialBuildState): this;
  138289. protected _dumpPropertiesCode(): string;
  138290. serialize(): any;
  138291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138292. }
  138293. }
  138294. declare module BABYLON {
  138295. /**
  138296. * Effect Render Options
  138297. */
  138298. export interface IEffectRendererOptions {
  138299. /**
  138300. * Defines the vertices positions.
  138301. */
  138302. positions?: number[];
  138303. /**
  138304. * Defines the indices.
  138305. */
  138306. indices?: number[];
  138307. }
  138308. /**
  138309. * Helper class to render one or more effects.
  138310. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138311. */
  138312. export class EffectRenderer {
  138313. private engine;
  138314. private static _DefaultOptions;
  138315. private _vertexBuffers;
  138316. private _indexBuffer;
  138317. private _fullscreenViewport;
  138318. /**
  138319. * Creates an effect renderer
  138320. * @param engine the engine to use for rendering
  138321. * @param options defines the options of the effect renderer
  138322. */
  138323. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138324. /**
  138325. * Sets the current viewport in normalized coordinates 0-1
  138326. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138327. */
  138328. setViewport(viewport?: Viewport): void;
  138329. /**
  138330. * Binds the embedded attributes buffer to the effect.
  138331. * @param effect Defines the effect to bind the attributes for
  138332. */
  138333. bindBuffers(effect: Effect): void;
  138334. /**
  138335. * Sets the current effect wrapper to use during draw.
  138336. * The effect needs to be ready before calling this api.
  138337. * This also sets the default full screen position attribute.
  138338. * @param effectWrapper Defines the effect to draw with
  138339. */
  138340. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138341. /**
  138342. * Draws a full screen quad.
  138343. */
  138344. draw(): void;
  138345. private isRenderTargetTexture;
  138346. /**
  138347. * renders one or more effects to a specified texture
  138348. * @param effectWrapper the effect to renderer
  138349. * @param outputTexture texture to draw to, if null it will render to the screen.
  138350. */
  138351. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138352. /**
  138353. * Disposes of the effect renderer
  138354. */
  138355. dispose(): void;
  138356. }
  138357. /**
  138358. * Options to create an EffectWrapper
  138359. */
  138360. interface EffectWrapperCreationOptions {
  138361. /**
  138362. * Engine to use to create the effect
  138363. */
  138364. engine: ThinEngine;
  138365. /**
  138366. * Fragment shader for the effect
  138367. */
  138368. fragmentShader: string;
  138369. /**
  138370. * Vertex shader for the effect
  138371. */
  138372. vertexShader?: string;
  138373. /**
  138374. * Attributes to use in the shader
  138375. */
  138376. attributeNames?: Array<string>;
  138377. /**
  138378. * Uniforms to use in the shader
  138379. */
  138380. uniformNames?: Array<string>;
  138381. /**
  138382. * Texture sampler names to use in the shader
  138383. */
  138384. samplerNames?: Array<string>;
  138385. /**
  138386. * The friendly name of the effect displayed in Spector.
  138387. */
  138388. name?: string;
  138389. }
  138390. /**
  138391. * Wraps an effect to be used for rendering
  138392. */
  138393. export class EffectWrapper {
  138394. /**
  138395. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138396. */
  138397. onApplyObservable: Observable<{}>;
  138398. /**
  138399. * The underlying effect
  138400. */
  138401. effect: Effect;
  138402. /**
  138403. * Creates an effect to be renderer
  138404. * @param creationOptions options to create the effect
  138405. */
  138406. constructor(creationOptions: EffectWrapperCreationOptions);
  138407. /**
  138408. * Disposes of the effect wrapper
  138409. */
  138410. dispose(): void;
  138411. }
  138412. }
  138413. declare module BABYLON {
  138414. /**
  138415. * Helper class to push actions to a pool of workers.
  138416. */
  138417. export class WorkerPool implements IDisposable {
  138418. private _workerInfos;
  138419. private _pendingActions;
  138420. /**
  138421. * Constructor
  138422. * @param workers Array of workers to use for actions
  138423. */
  138424. constructor(workers: Array<Worker>);
  138425. /**
  138426. * Terminates all workers and clears any pending actions.
  138427. */
  138428. dispose(): void;
  138429. /**
  138430. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138431. * pended until a worker has completed its action.
  138432. * @param action The action to perform. Call onComplete when the action is complete.
  138433. */
  138434. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138435. private _execute;
  138436. }
  138437. }
  138438. declare module BABYLON {
  138439. /**
  138440. * Configuration for Draco compression
  138441. */
  138442. export interface IDracoCompressionConfiguration {
  138443. /**
  138444. * Configuration for the decoder.
  138445. */
  138446. decoder: {
  138447. /**
  138448. * The url to the WebAssembly module.
  138449. */
  138450. wasmUrl?: string;
  138451. /**
  138452. * The url to the WebAssembly binary.
  138453. */
  138454. wasmBinaryUrl?: string;
  138455. /**
  138456. * The url to the fallback JavaScript module.
  138457. */
  138458. fallbackUrl?: string;
  138459. };
  138460. }
  138461. /**
  138462. * Draco compression (https://google.github.io/draco/)
  138463. *
  138464. * This class wraps the Draco module.
  138465. *
  138466. * **Encoder**
  138467. *
  138468. * The encoder is not currently implemented.
  138469. *
  138470. * **Decoder**
  138471. *
  138472. * 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.
  138473. *
  138474. * To update the configuration, use the following code:
  138475. * ```javascript
  138476. * DracoCompression.Configuration = {
  138477. * decoder: {
  138478. * wasmUrl: "<url to the WebAssembly library>",
  138479. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  138480. * fallbackUrl: "<url to the fallback JavaScript library>",
  138481. * }
  138482. * };
  138483. * ```
  138484. *
  138485. * 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.
  138486. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  138487. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  138488. *
  138489. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  138490. * ```javascript
  138491. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  138492. * ```
  138493. *
  138494. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  138495. */
  138496. export class DracoCompression implements IDisposable {
  138497. private _workerPoolPromise?;
  138498. private _decoderModulePromise?;
  138499. /**
  138500. * The configuration. Defaults to the following urls:
  138501. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  138502. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  138503. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  138504. */
  138505. static Configuration: IDracoCompressionConfiguration;
  138506. /**
  138507. * Returns true if the decoder configuration is available.
  138508. */
  138509. static get DecoderAvailable(): boolean;
  138510. /**
  138511. * Default number of workers to create when creating the draco compression object.
  138512. */
  138513. static DefaultNumWorkers: number;
  138514. private static GetDefaultNumWorkers;
  138515. private static _Default;
  138516. /**
  138517. * Default instance for the draco compression object.
  138518. */
  138519. static get Default(): DracoCompression;
  138520. /**
  138521. * Constructor
  138522. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138523. */
  138524. constructor(numWorkers?: number);
  138525. /**
  138526. * Stop all async operations and release resources.
  138527. */
  138528. dispose(): void;
  138529. /**
  138530. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  138531. * @returns a promise that resolves when ready
  138532. */
  138533. whenReadyAsync(): Promise<void>;
  138534. /**
  138535. * Decode Draco compressed mesh data to vertex data.
  138536. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  138537. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  138538. * @returns A promise that resolves with the decoded vertex data
  138539. */
  138540. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  138541. [kind: string]: number;
  138542. }): Promise<VertexData>;
  138543. }
  138544. }
  138545. declare module BABYLON {
  138546. /**
  138547. * Class for building Constructive Solid Geometry
  138548. */
  138549. export class CSG {
  138550. private polygons;
  138551. /**
  138552. * The world matrix
  138553. */
  138554. matrix: Matrix;
  138555. /**
  138556. * Stores the position
  138557. */
  138558. position: Vector3;
  138559. /**
  138560. * Stores the rotation
  138561. */
  138562. rotation: Vector3;
  138563. /**
  138564. * Stores the rotation quaternion
  138565. */
  138566. rotationQuaternion: Nullable<Quaternion>;
  138567. /**
  138568. * Stores the scaling vector
  138569. */
  138570. scaling: Vector3;
  138571. /**
  138572. * Convert the Mesh to CSG
  138573. * @param mesh The Mesh to convert to CSG
  138574. * @returns A new CSG from the Mesh
  138575. */
  138576. static FromMesh(mesh: Mesh): CSG;
  138577. /**
  138578. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  138579. * @param polygons Polygons used to construct a CSG solid
  138580. */
  138581. private static FromPolygons;
  138582. /**
  138583. * Clones, or makes a deep copy, of the CSG
  138584. * @returns A new CSG
  138585. */
  138586. clone(): CSG;
  138587. /**
  138588. * Unions this CSG with another CSG
  138589. * @param csg The CSG to union against this CSG
  138590. * @returns The unioned CSG
  138591. */
  138592. union(csg: CSG): CSG;
  138593. /**
  138594. * Unions this CSG with another CSG in place
  138595. * @param csg The CSG to union against this CSG
  138596. */
  138597. unionInPlace(csg: CSG): void;
  138598. /**
  138599. * Subtracts this CSG with another CSG
  138600. * @param csg The CSG to subtract against this CSG
  138601. * @returns A new CSG
  138602. */
  138603. subtract(csg: CSG): CSG;
  138604. /**
  138605. * Subtracts this CSG with another CSG in place
  138606. * @param csg The CSG to subtact against this CSG
  138607. */
  138608. subtractInPlace(csg: CSG): void;
  138609. /**
  138610. * Intersect this CSG with another CSG
  138611. * @param csg The CSG to intersect against this CSG
  138612. * @returns A new CSG
  138613. */
  138614. intersect(csg: CSG): CSG;
  138615. /**
  138616. * Intersects this CSG with another CSG in place
  138617. * @param csg The CSG to intersect against this CSG
  138618. */
  138619. intersectInPlace(csg: CSG): void;
  138620. /**
  138621. * Return a new CSG solid with solid and empty space switched. This solid is
  138622. * not modified.
  138623. * @returns A new CSG solid with solid and empty space switched
  138624. */
  138625. inverse(): CSG;
  138626. /**
  138627. * Inverses the CSG in place
  138628. */
  138629. inverseInPlace(): void;
  138630. /**
  138631. * This is used to keep meshes transformations so they can be restored
  138632. * when we build back a Babylon Mesh
  138633. * NB : All CSG operations are performed in world coordinates
  138634. * @param csg The CSG to copy the transform attributes from
  138635. * @returns This CSG
  138636. */
  138637. copyTransformAttributes(csg: CSG): CSG;
  138638. /**
  138639. * Build Raw mesh from CSG
  138640. * Coordinates here are in world space
  138641. * @param name The name of the mesh geometry
  138642. * @param scene The Scene
  138643. * @param keepSubMeshes Specifies if the submeshes should be kept
  138644. * @returns A new Mesh
  138645. */
  138646. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138647. /**
  138648. * Build Mesh from CSG taking material and transforms into account
  138649. * @param name The name of the Mesh
  138650. * @param material The material of the Mesh
  138651. * @param scene The Scene
  138652. * @param keepSubMeshes Specifies if submeshes should be kept
  138653. * @returns The new Mesh
  138654. */
  138655. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138656. }
  138657. }
  138658. declare module BABYLON {
  138659. /**
  138660. * Class used to create a trail following a mesh
  138661. */
  138662. export class TrailMesh extends Mesh {
  138663. private _generator;
  138664. private _autoStart;
  138665. private _running;
  138666. private _diameter;
  138667. private _length;
  138668. private _sectionPolygonPointsCount;
  138669. private _sectionVectors;
  138670. private _sectionNormalVectors;
  138671. private _beforeRenderObserver;
  138672. /**
  138673. * @constructor
  138674. * @param name The value used by scene.getMeshByName() to do a lookup.
  138675. * @param generator The mesh or transform node to generate a trail.
  138676. * @param scene The scene to add this mesh to.
  138677. * @param diameter Diameter of trailing mesh. Default is 1.
  138678. * @param length Length of trailing mesh. Default is 60.
  138679. * @param autoStart Automatically start trailing mesh. Default true.
  138680. */
  138681. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  138682. /**
  138683. * "TrailMesh"
  138684. * @returns "TrailMesh"
  138685. */
  138686. getClassName(): string;
  138687. private _createMesh;
  138688. /**
  138689. * Start trailing mesh.
  138690. */
  138691. start(): void;
  138692. /**
  138693. * Stop trailing mesh.
  138694. */
  138695. stop(): void;
  138696. /**
  138697. * Update trailing mesh geometry.
  138698. */
  138699. update(): void;
  138700. /**
  138701. * Returns a new TrailMesh object.
  138702. * @param name is a string, the name given to the new mesh
  138703. * @param newGenerator use new generator object for cloned trail mesh
  138704. * @returns a new mesh
  138705. */
  138706. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  138707. /**
  138708. * Serializes this trail mesh
  138709. * @param serializationObject object to write serialization to
  138710. */
  138711. serialize(serializationObject: any): void;
  138712. /**
  138713. * Parses a serialized trail mesh
  138714. * @param parsedMesh the serialized mesh
  138715. * @param scene the scene to create the trail mesh in
  138716. * @returns the created trail mesh
  138717. */
  138718. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  138719. }
  138720. }
  138721. declare module BABYLON {
  138722. /**
  138723. * Class containing static functions to help procedurally build meshes
  138724. */
  138725. export class TiledBoxBuilder {
  138726. /**
  138727. * Creates a box mesh
  138728. * 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)
  138729. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138731. * * 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
  138732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138733. * @param name defines the name of the mesh
  138734. * @param options defines the options used to create the mesh
  138735. * @param scene defines the hosting scene
  138736. * @returns the box mesh
  138737. */
  138738. static CreateTiledBox(name: string, options: {
  138739. pattern?: number;
  138740. width?: number;
  138741. height?: number;
  138742. depth?: number;
  138743. tileSize?: number;
  138744. tileWidth?: number;
  138745. tileHeight?: number;
  138746. alignHorizontal?: number;
  138747. alignVertical?: number;
  138748. faceUV?: Vector4[];
  138749. faceColors?: Color4[];
  138750. sideOrientation?: number;
  138751. updatable?: boolean;
  138752. }, scene?: Nullable<Scene>): Mesh;
  138753. }
  138754. }
  138755. declare module BABYLON {
  138756. /**
  138757. * Class containing static functions to help procedurally build meshes
  138758. */
  138759. export class TorusKnotBuilder {
  138760. /**
  138761. * Creates a torus knot mesh
  138762. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138763. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138764. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138765. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138767. * * 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
  138768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138769. * @param name defines the name of the mesh
  138770. * @param options defines the options used to create the mesh
  138771. * @param scene defines the hosting scene
  138772. * @returns the torus knot mesh
  138773. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138774. */
  138775. static CreateTorusKnot(name: string, options: {
  138776. radius?: number;
  138777. tube?: number;
  138778. radialSegments?: number;
  138779. tubularSegments?: number;
  138780. p?: number;
  138781. q?: number;
  138782. updatable?: boolean;
  138783. sideOrientation?: number;
  138784. frontUVs?: Vector4;
  138785. backUVs?: Vector4;
  138786. }, scene: any): Mesh;
  138787. }
  138788. }
  138789. declare module BABYLON {
  138790. /**
  138791. * Polygon
  138792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  138793. */
  138794. export class Polygon {
  138795. /**
  138796. * Creates a rectangle
  138797. * @param xmin bottom X coord
  138798. * @param ymin bottom Y coord
  138799. * @param xmax top X coord
  138800. * @param ymax top Y coord
  138801. * @returns points that make the resulting rectation
  138802. */
  138803. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  138804. /**
  138805. * Creates a circle
  138806. * @param radius radius of circle
  138807. * @param cx scale in x
  138808. * @param cy scale in y
  138809. * @param numberOfSides number of sides that make up the circle
  138810. * @returns points that make the resulting circle
  138811. */
  138812. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  138813. /**
  138814. * Creates a polygon from input string
  138815. * @param input Input polygon data
  138816. * @returns the parsed points
  138817. */
  138818. static Parse(input: string): Vector2[];
  138819. /**
  138820. * Starts building a polygon from x and y coordinates
  138821. * @param x x coordinate
  138822. * @param y y coordinate
  138823. * @returns the started path2
  138824. */
  138825. static StartingAt(x: number, y: number): Path2;
  138826. }
  138827. /**
  138828. * Builds a polygon
  138829. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  138830. */
  138831. export class PolygonMeshBuilder {
  138832. private _points;
  138833. private _outlinepoints;
  138834. private _holes;
  138835. private _name;
  138836. private _scene;
  138837. private _epoints;
  138838. private _eholes;
  138839. private _addToepoint;
  138840. /**
  138841. * Babylon reference to the earcut plugin.
  138842. */
  138843. bjsEarcut: any;
  138844. /**
  138845. * Creates a PolygonMeshBuilder
  138846. * @param name name of the builder
  138847. * @param contours Path of the polygon
  138848. * @param scene scene to add to when creating the mesh
  138849. * @param earcutInjection can be used to inject your own earcut reference
  138850. */
  138851. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  138852. /**
  138853. * Adds a whole within the polygon
  138854. * @param hole Array of points defining the hole
  138855. * @returns this
  138856. */
  138857. addHole(hole: Vector2[]): PolygonMeshBuilder;
  138858. /**
  138859. * Creates the polygon
  138860. * @param updatable If the mesh should be updatable
  138861. * @param depth The depth of the mesh created
  138862. * @returns the created mesh
  138863. */
  138864. build(updatable?: boolean, depth?: number): Mesh;
  138865. /**
  138866. * Creates the polygon
  138867. * @param depth The depth of the mesh created
  138868. * @returns the created VertexData
  138869. */
  138870. buildVertexData(depth?: number): VertexData;
  138871. /**
  138872. * Adds a side to the polygon
  138873. * @param positions points that make the polygon
  138874. * @param normals normals of the polygon
  138875. * @param uvs uvs of the polygon
  138876. * @param indices indices of the polygon
  138877. * @param bounds bounds of the polygon
  138878. * @param points points of the polygon
  138879. * @param depth depth of the polygon
  138880. * @param flip flip of the polygon
  138881. */
  138882. private addSide;
  138883. }
  138884. }
  138885. declare module BABYLON {
  138886. /**
  138887. * Class containing static functions to help procedurally build meshes
  138888. */
  138889. export class PolygonBuilder {
  138890. /**
  138891. * Creates a polygon mesh
  138892. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  138893. * * 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
  138894. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138896. * * 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)
  138897. * * Remember you can only change the shape positions, not their number when updating a polygon
  138898. * @param name defines the name of the mesh
  138899. * @param options defines the options used to create the mesh
  138900. * @param scene defines the hosting scene
  138901. * @param earcutInjection can be used to inject your own earcut reference
  138902. * @returns the polygon mesh
  138903. */
  138904. static CreatePolygon(name: string, options: {
  138905. shape: Vector3[];
  138906. holes?: Vector3[][];
  138907. depth?: number;
  138908. faceUV?: Vector4[];
  138909. faceColors?: Color4[];
  138910. updatable?: boolean;
  138911. sideOrientation?: number;
  138912. frontUVs?: Vector4;
  138913. backUVs?: Vector4;
  138914. wrap?: boolean;
  138915. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138916. /**
  138917. * Creates an extruded polygon mesh, with depth in the Y direction.
  138918. * * 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)
  138919. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138920. * @param name defines the name of the mesh
  138921. * @param options defines the options used to create the mesh
  138922. * @param scene defines the hosting scene
  138923. * @param earcutInjection can be used to inject your own earcut reference
  138924. * @returns the polygon mesh
  138925. */
  138926. static ExtrudePolygon(name: string, options: {
  138927. shape: Vector3[];
  138928. holes?: Vector3[][];
  138929. depth?: number;
  138930. faceUV?: Vector4[];
  138931. faceColors?: Color4[];
  138932. updatable?: boolean;
  138933. sideOrientation?: number;
  138934. frontUVs?: Vector4;
  138935. backUVs?: Vector4;
  138936. wrap?: boolean;
  138937. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138938. }
  138939. }
  138940. declare module BABYLON {
  138941. /**
  138942. * Class containing static functions to help procedurally build meshes
  138943. */
  138944. export class LatheBuilder {
  138945. /**
  138946. * Creates lathe mesh.
  138947. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  138948. * * 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
  138949. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  138950. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  138951. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  138952. * * 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
  138953. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  138954. * * 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
  138955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138956. * * 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
  138957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138959. * @param name defines the name of the mesh
  138960. * @param options defines the options used to create the mesh
  138961. * @param scene defines the hosting scene
  138962. * @returns the lathe mesh
  138963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  138964. */
  138965. static CreateLathe(name: string, options: {
  138966. shape: Vector3[];
  138967. radius?: number;
  138968. tessellation?: number;
  138969. clip?: number;
  138970. arc?: number;
  138971. closed?: boolean;
  138972. updatable?: boolean;
  138973. sideOrientation?: number;
  138974. frontUVs?: Vector4;
  138975. backUVs?: Vector4;
  138976. cap?: number;
  138977. invertUV?: boolean;
  138978. }, scene?: Nullable<Scene>): Mesh;
  138979. }
  138980. }
  138981. declare module BABYLON {
  138982. /**
  138983. * Class containing static functions to help procedurally build meshes
  138984. */
  138985. export class TiledPlaneBuilder {
  138986. /**
  138987. * Creates a tiled plane mesh
  138988. * * The parameter `pattern` will, depending on value, do nothing or
  138989. * * * flip (reflect about central vertical) alternate tiles across and up
  138990. * * * flip every tile on alternate rows
  138991. * * * rotate (180 degs) alternate tiles across and up
  138992. * * * rotate every tile on alternate rows
  138993. * * * flip and rotate alternate tiles across and up
  138994. * * * flip and rotate every tile on alternate rows
  138995. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  138996. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  138997. * * 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
  138998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138999. * * 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)
  139000. * * 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)
  139001. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  139002. * @param name defines the name of the mesh
  139003. * @param options defines the options used to create the mesh
  139004. * @param scene defines the hosting scene
  139005. * @returns the box mesh
  139006. */
  139007. static CreateTiledPlane(name: string, options: {
  139008. pattern?: number;
  139009. tileSize?: number;
  139010. tileWidth?: number;
  139011. tileHeight?: number;
  139012. size?: number;
  139013. width?: number;
  139014. height?: number;
  139015. alignHorizontal?: number;
  139016. alignVertical?: number;
  139017. sideOrientation?: number;
  139018. frontUVs?: Vector4;
  139019. backUVs?: Vector4;
  139020. updatable?: boolean;
  139021. }, scene?: Nullable<Scene>): Mesh;
  139022. }
  139023. }
  139024. declare module BABYLON {
  139025. /**
  139026. * Class containing static functions to help procedurally build meshes
  139027. */
  139028. export class TubeBuilder {
  139029. /**
  139030. * Creates a tube mesh.
  139031. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139032. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  139033. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  139034. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  139035. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  139036. * * 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)
  139037. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  139038. * * 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
  139039. * * 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
  139040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139041. * * 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
  139042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139044. * @param name defines the name of the mesh
  139045. * @param options defines the options used to create the mesh
  139046. * @param scene defines the hosting scene
  139047. * @returns the tube mesh
  139048. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139049. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  139050. */
  139051. static CreateTube(name: string, options: {
  139052. path: Vector3[];
  139053. radius?: number;
  139054. tessellation?: number;
  139055. radiusFunction?: {
  139056. (i: number, distance: number): number;
  139057. };
  139058. cap?: number;
  139059. arc?: number;
  139060. updatable?: boolean;
  139061. sideOrientation?: number;
  139062. frontUVs?: Vector4;
  139063. backUVs?: Vector4;
  139064. instance?: Mesh;
  139065. invertUV?: boolean;
  139066. }, scene?: Nullable<Scene>): Mesh;
  139067. }
  139068. }
  139069. declare module BABYLON {
  139070. /**
  139071. * Class containing static functions to help procedurally build meshes
  139072. */
  139073. export class IcoSphereBuilder {
  139074. /**
  139075. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  139076. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  139077. * * 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`)
  139078. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  139079. * * 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
  139080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139081. * * 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
  139082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139083. * @param name defines the name of the mesh
  139084. * @param options defines the options used to create the mesh
  139085. * @param scene defines the hosting scene
  139086. * @returns the icosahedron mesh
  139087. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  139088. */
  139089. static CreateIcoSphere(name: string, options: {
  139090. radius?: number;
  139091. radiusX?: number;
  139092. radiusY?: number;
  139093. radiusZ?: number;
  139094. flat?: boolean;
  139095. subdivisions?: number;
  139096. sideOrientation?: number;
  139097. frontUVs?: Vector4;
  139098. backUVs?: Vector4;
  139099. updatable?: boolean;
  139100. }, scene?: Nullable<Scene>): Mesh;
  139101. }
  139102. }
  139103. declare module BABYLON {
  139104. /**
  139105. * Class containing static functions to help procedurally build meshes
  139106. */
  139107. export class DecalBuilder {
  139108. /**
  139109. * Creates a decal mesh.
  139110. * 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
  139111. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139112. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139113. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139114. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139115. * @param name defines the name of the mesh
  139116. * @param sourceMesh defines the mesh where the decal must be applied
  139117. * @param options defines the options used to create the mesh
  139118. * @param scene defines the hosting scene
  139119. * @returns the decal mesh
  139120. * @see https://doc.babylonjs.com/how_to/decals
  139121. */
  139122. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139123. position?: Vector3;
  139124. normal?: Vector3;
  139125. size?: Vector3;
  139126. angle?: number;
  139127. }): Mesh;
  139128. }
  139129. }
  139130. declare module BABYLON {
  139131. /**
  139132. * Class containing static functions to help procedurally build meshes
  139133. */
  139134. export class MeshBuilder {
  139135. /**
  139136. * Creates a box mesh
  139137. * * The parameter `size` sets the size (float) of each box side (default 1)
  139138. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  139139. * * 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)
  139140. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139142. * * 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
  139143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139144. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  139145. * @param name defines the name of the mesh
  139146. * @param options defines the options used to create the mesh
  139147. * @param scene defines the hosting scene
  139148. * @returns the box mesh
  139149. */
  139150. static CreateBox(name: string, options: {
  139151. size?: number;
  139152. width?: number;
  139153. height?: number;
  139154. depth?: number;
  139155. faceUV?: Vector4[];
  139156. faceColors?: Color4[];
  139157. sideOrientation?: number;
  139158. frontUVs?: Vector4;
  139159. backUVs?: Vector4;
  139160. wrap?: boolean;
  139161. topBaseAt?: number;
  139162. bottomBaseAt?: number;
  139163. updatable?: boolean;
  139164. }, scene?: Nullable<Scene>): Mesh;
  139165. /**
  139166. * Creates a tiled box mesh
  139167. * * faceTiles sets the pattern, tile size and number of tiles for a face
  139168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139169. * @param name defines the name of the mesh
  139170. * @param options defines the options used to create the mesh
  139171. * @param scene defines the hosting scene
  139172. * @returns the tiled box mesh
  139173. */
  139174. static CreateTiledBox(name: string, options: {
  139175. pattern?: number;
  139176. size?: number;
  139177. width?: number;
  139178. height?: number;
  139179. depth: number;
  139180. tileSize?: number;
  139181. tileWidth?: number;
  139182. tileHeight?: number;
  139183. faceUV?: Vector4[];
  139184. faceColors?: Color4[];
  139185. alignHorizontal?: number;
  139186. alignVertical?: number;
  139187. sideOrientation?: number;
  139188. updatable?: boolean;
  139189. }, scene?: Nullable<Scene>): Mesh;
  139190. /**
  139191. * Creates a sphere mesh
  139192. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  139193. * * 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`)
  139194. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  139195. * * 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
  139196. * * 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)
  139197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139198. * * 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
  139199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139200. * @param name defines the name of the mesh
  139201. * @param options defines the options used to create the mesh
  139202. * @param scene defines the hosting scene
  139203. * @returns the sphere mesh
  139204. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  139205. */
  139206. static CreateSphere(name: string, options: {
  139207. segments?: number;
  139208. diameter?: number;
  139209. diameterX?: number;
  139210. diameterY?: number;
  139211. diameterZ?: number;
  139212. arc?: number;
  139213. slice?: number;
  139214. sideOrientation?: number;
  139215. frontUVs?: Vector4;
  139216. backUVs?: Vector4;
  139217. updatable?: boolean;
  139218. }, scene?: Nullable<Scene>): Mesh;
  139219. /**
  139220. * Creates a plane polygonal mesh. By default, this is a disc
  139221. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  139222. * * 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
  139223. * * 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
  139224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139225. * * 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
  139226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139227. * @param name defines the name of the mesh
  139228. * @param options defines the options used to create the mesh
  139229. * @param scene defines the hosting scene
  139230. * @returns the plane polygonal mesh
  139231. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  139232. */
  139233. static CreateDisc(name: string, options: {
  139234. radius?: number;
  139235. tessellation?: number;
  139236. arc?: number;
  139237. updatable?: boolean;
  139238. sideOrientation?: number;
  139239. frontUVs?: Vector4;
  139240. backUVs?: Vector4;
  139241. }, scene?: Nullable<Scene>): Mesh;
  139242. /**
  139243. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  139244. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  139245. * * 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`)
  139246. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  139247. * * 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
  139248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139249. * * 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
  139250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139251. * @param name defines the name of the mesh
  139252. * @param options defines the options used to create the mesh
  139253. * @param scene defines the hosting scene
  139254. * @returns the icosahedron mesh
  139255. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  139256. */
  139257. static CreateIcoSphere(name: string, options: {
  139258. radius?: number;
  139259. radiusX?: number;
  139260. radiusY?: number;
  139261. radiusZ?: number;
  139262. flat?: boolean;
  139263. subdivisions?: number;
  139264. sideOrientation?: number;
  139265. frontUVs?: Vector4;
  139266. backUVs?: Vector4;
  139267. updatable?: boolean;
  139268. }, scene?: Nullable<Scene>): Mesh;
  139269. /**
  139270. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139271. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  139272. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  139273. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  139274. * * 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
  139275. * * 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
  139276. * * 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
  139277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139278. * * 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
  139279. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139280. * * 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
  139281. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  139282. * * 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
  139283. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  139284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139285. * @param name defines the name of the mesh
  139286. * @param options defines the options used to create the mesh
  139287. * @param scene defines the hosting scene
  139288. * @returns the ribbon mesh
  139289. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  139290. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139291. */
  139292. static CreateRibbon(name: string, options: {
  139293. pathArray: Vector3[][];
  139294. closeArray?: boolean;
  139295. closePath?: boolean;
  139296. offset?: number;
  139297. updatable?: boolean;
  139298. sideOrientation?: number;
  139299. frontUVs?: Vector4;
  139300. backUVs?: Vector4;
  139301. instance?: Mesh;
  139302. invertUV?: boolean;
  139303. uvs?: Vector2[];
  139304. colors?: Color4[];
  139305. }, scene?: Nullable<Scene>): Mesh;
  139306. /**
  139307. * Creates a cylinder or a cone mesh
  139308. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  139309. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  139310. * * 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.
  139311. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  139312. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  139313. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  139314. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  139315. * * 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).
  139316. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  139317. * * 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).
  139318. * * 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
  139319. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  139320. * * 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
  139321. * * 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.
  139322. * * If `enclose` is false, a ring surface is one element.
  139323. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  139324. * * 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
  139325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139326. * * 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
  139327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139328. * @param name defines the name of the mesh
  139329. * @param options defines the options used to create the mesh
  139330. * @param scene defines the hosting scene
  139331. * @returns the cylinder mesh
  139332. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  139333. */
  139334. static CreateCylinder(name: string, options: {
  139335. height?: number;
  139336. diameterTop?: number;
  139337. diameterBottom?: number;
  139338. diameter?: number;
  139339. tessellation?: number;
  139340. subdivisions?: number;
  139341. arc?: number;
  139342. faceColors?: Color4[];
  139343. faceUV?: Vector4[];
  139344. updatable?: boolean;
  139345. hasRings?: boolean;
  139346. enclose?: boolean;
  139347. cap?: number;
  139348. sideOrientation?: number;
  139349. frontUVs?: Vector4;
  139350. backUVs?: Vector4;
  139351. }, scene?: Nullable<Scene>): Mesh;
  139352. /**
  139353. * Creates a torus mesh
  139354. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  139355. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  139356. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  139357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139358. * * 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
  139359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139360. * @param name defines the name of the mesh
  139361. * @param options defines the options used to create the mesh
  139362. * @param scene defines the hosting scene
  139363. * @returns the torus mesh
  139364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  139365. */
  139366. static CreateTorus(name: string, options: {
  139367. diameter?: number;
  139368. thickness?: number;
  139369. tessellation?: number;
  139370. updatable?: boolean;
  139371. sideOrientation?: number;
  139372. frontUVs?: Vector4;
  139373. backUVs?: Vector4;
  139374. }, scene?: Nullable<Scene>): Mesh;
  139375. /**
  139376. * Creates a torus knot mesh
  139377. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  139378. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  139379. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  139380. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  139381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139382. * * 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
  139383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139384. * @param name defines the name of the mesh
  139385. * @param options defines the options used to create the mesh
  139386. * @param scene defines the hosting scene
  139387. * @returns the torus knot mesh
  139388. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  139389. */
  139390. static CreateTorusKnot(name: string, options: {
  139391. radius?: number;
  139392. tube?: number;
  139393. radialSegments?: number;
  139394. tubularSegments?: number;
  139395. p?: number;
  139396. q?: number;
  139397. updatable?: boolean;
  139398. sideOrientation?: number;
  139399. frontUVs?: Vector4;
  139400. backUVs?: Vector4;
  139401. }, scene?: Nullable<Scene>): Mesh;
  139402. /**
  139403. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  139404. * * 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
  139405. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  139406. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  139407. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  139408. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  139409. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  139410. * * 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
  139411. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  139412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  139414. * @param name defines the name of the new line system
  139415. * @param options defines the options used to create the line system
  139416. * @param scene defines the hosting scene
  139417. * @returns a new line system mesh
  139418. */
  139419. static CreateLineSystem(name: string, options: {
  139420. lines: Vector3[][];
  139421. updatable?: boolean;
  139422. instance?: Nullable<LinesMesh>;
  139423. colors?: Nullable<Color4[][]>;
  139424. useVertexAlpha?: boolean;
  139425. }, scene: Nullable<Scene>): LinesMesh;
  139426. /**
  139427. * Creates a line mesh
  139428. * 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
  139429. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139430. * * The parameter `points` is an array successive Vector3
  139431. * * 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
  139432. * * The optional parameter `colors` is an array of successive Color4, one per line point
  139433. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  139434. * * When updating an instance, remember that only point positions can change, not the number of points
  139435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  139437. * @param name defines the name of the new line system
  139438. * @param options defines the options used to create the line system
  139439. * @param scene defines the hosting scene
  139440. * @returns a new line mesh
  139441. */
  139442. static CreateLines(name: string, options: {
  139443. points: Vector3[];
  139444. updatable?: boolean;
  139445. instance?: Nullable<LinesMesh>;
  139446. colors?: Color4[];
  139447. useVertexAlpha?: boolean;
  139448. }, scene?: Nullable<Scene>): LinesMesh;
  139449. /**
  139450. * Creates a dashed line mesh
  139451. * * 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
  139452. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139453. * * The parameter `points` is an array successive Vector3
  139454. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  139455. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  139456. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  139457. * * 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
  139458. * * When updating an instance, remember that only point positions can change, not the number of points
  139459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139460. * @param name defines the name of the mesh
  139461. * @param options defines the options used to create the mesh
  139462. * @param scene defines the hosting scene
  139463. * @returns the dashed line mesh
  139464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  139465. */
  139466. static CreateDashedLines(name: string, options: {
  139467. points: Vector3[];
  139468. dashSize?: number;
  139469. gapSize?: number;
  139470. dashNb?: number;
  139471. updatable?: boolean;
  139472. instance?: LinesMesh;
  139473. }, scene?: Nullable<Scene>): LinesMesh;
  139474. /**
  139475. * 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.
  139476. * * 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.
  139477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139478. * * 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.
  139479. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  139480. * * 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
  139481. * * 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
  139482. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  139483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139484. * * 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
  139485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  139486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139487. * @param name defines the name of the mesh
  139488. * @param options defines the options used to create the mesh
  139489. * @param scene defines the hosting scene
  139490. * @returns the extruded shape mesh
  139491. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139493. */
  139494. static ExtrudeShape(name: string, options: {
  139495. shape: Vector3[];
  139496. path: Vector3[];
  139497. scale?: number;
  139498. rotation?: number;
  139499. cap?: number;
  139500. updatable?: boolean;
  139501. sideOrientation?: number;
  139502. frontUVs?: Vector4;
  139503. backUVs?: Vector4;
  139504. instance?: Mesh;
  139505. invertUV?: boolean;
  139506. }, scene?: Nullable<Scene>): Mesh;
  139507. /**
  139508. * Creates an custom extruded shape mesh.
  139509. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  139510. * * 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.
  139511. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139512. * * 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
  139513. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  139514. * * 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
  139515. * * It must returns a float value that will be the scale value applied to the shape on each path point
  139516. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  139517. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  139518. * * 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
  139519. * * 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
  139520. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  139521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139522. * * 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
  139523. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139525. * @param name defines the name of the mesh
  139526. * @param options defines the options used to create the mesh
  139527. * @param scene defines the hosting scene
  139528. * @returns the custom extruded shape mesh
  139529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  139530. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139532. */
  139533. static ExtrudeShapeCustom(name: string, options: {
  139534. shape: Vector3[];
  139535. path: Vector3[];
  139536. scaleFunction?: any;
  139537. rotationFunction?: any;
  139538. ribbonCloseArray?: boolean;
  139539. ribbonClosePath?: boolean;
  139540. cap?: number;
  139541. updatable?: boolean;
  139542. sideOrientation?: number;
  139543. frontUVs?: Vector4;
  139544. backUVs?: Vector4;
  139545. instance?: Mesh;
  139546. invertUV?: boolean;
  139547. }, scene?: Nullable<Scene>): Mesh;
  139548. /**
  139549. * Creates lathe mesh.
  139550. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  139551. * * 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
  139552. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  139553. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  139554. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  139555. * * 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
  139556. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  139557. * * 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
  139558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139559. * * 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
  139560. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139562. * @param name defines the name of the mesh
  139563. * @param options defines the options used to create the mesh
  139564. * @param scene defines the hosting scene
  139565. * @returns the lathe mesh
  139566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  139567. */
  139568. static CreateLathe(name: string, options: {
  139569. shape: Vector3[];
  139570. radius?: number;
  139571. tessellation?: number;
  139572. clip?: number;
  139573. arc?: number;
  139574. closed?: boolean;
  139575. updatable?: boolean;
  139576. sideOrientation?: number;
  139577. frontUVs?: Vector4;
  139578. backUVs?: Vector4;
  139579. cap?: number;
  139580. invertUV?: boolean;
  139581. }, scene?: Nullable<Scene>): Mesh;
  139582. /**
  139583. * Creates a tiled plane mesh
  139584. * * You can set a limited pattern arrangement with the tiles
  139585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139586. * * 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
  139587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139588. * @param name defines the name of the mesh
  139589. * @param options defines the options used to create the mesh
  139590. * @param scene defines the hosting scene
  139591. * @returns the plane mesh
  139592. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139593. */
  139594. static CreateTiledPlane(name: string, options: {
  139595. pattern?: number;
  139596. tileSize?: number;
  139597. tileWidth?: number;
  139598. tileHeight?: number;
  139599. size?: number;
  139600. width?: number;
  139601. height?: number;
  139602. alignHorizontal?: number;
  139603. alignVertical?: number;
  139604. sideOrientation?: number;
  139605. frontUVs?: Vector4;
  139606. backUVs?: Vector4;
  139607. updatable?: boolean;
  139608. }, scene?: Nullable<Scene>): Mesh;
  139609. /**
  139610. * Creates a plane mesh
  139611. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  139612. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  139613. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  139614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139615. * * 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
  139616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139617. * @param name defines the name of the mesh
  139618. * @param options defines the options used to create the mesh
  139619. * @param scene defines the hosting scene
  139620. * @returns the plane mesh
  139621. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139622. */
  139623. static CreatePlane(name: string, options: {
  139624. size?: number;
  139625. width?: number;
  139626. height?: number;
  139627. sideOrientation?: number;
  139628. frontUVs?: Vector4;
  139629. backUVs?: Vector4;
  139630. updatable?: boolean;
  139631. sourcePlane?: Plane;
  139632. }, scene?: Nullable<Scene>): Mesh;
  139633. /**
  139634. * Creates a ground mesh
  139635. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  139636. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  139637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139638. * @param name defines the name of the mesh
  139639. * @param options defines the options used to create the mesh
  139640. * @param scene defines the hosting scene
  139641. * @returns the ground mesh
  139642. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  139643. */
  139644. static CreateGround(name: string, options: {
  139645. width?: number;
  139646. height?: number;
  139647. subdivisions?: number;
  139648. subdivisionsX?: number;
  139649. subdivisionsY?: number;
  139650. updatable?: boolean;
  139651. }, scene?: Nullable<Scene>): Mesh;
  139652. /**
  139653. * Creates a tiled ground mesh
  139654. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  139655. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  139656. * * 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
  139657. * * 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
  139658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139659. * @param name defines the name of the mesh
  139660. * @param options defines the options used to create the mesh
  139661. * @param scene defines the hosting scene
  139662. * @returns the tiled ground mesh
  139663. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  139664. */
  139665. static CreateTiledGround(name: string, options: {
  139666. xmin: number;
  139667. zmin: number;
  139668. xmax: number;
  139669. zmax: number;
  139670. subdivisions?: {
  139671. w: number;
  139672. h: number;
  139673. };
  139674. precision?: {
  139675. w: number;
  139676. h: number;
  139677. };
  139678. updatable?: boolean;
  139679. }, scene?: Nullable<Scene>): Mesh;
  139680. /**
  139681. * Creates a ground mesh from a height map
  139682. * * The parameter `url` sets the URL of the height map image resource.
  139683. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  139684. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  139685. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  139686. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  139687. * * 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.
  139688. * * 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).
  139689. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  139690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139691. * @param name defines the name of the mesh
  139692. * @param url defines the url to the height map
  139693. * @param options defines the options used to create the mesh
  139694. * @param scene defines the hosting scene
  139695. * @returns the ground mesh
  139696. * @see https://doc.babylonjs.com/babylon101/height_map
  139697. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  139698. */
  139699. static CreateGroundFromHeightMap(name: string, url: string, options: {
  139700. width?: number;
  139701. height?: number;
  139702. subdivisions?: number;
  139703. minHeight?: number;
  139704. maxHeight?: number;
  139705. colorFilter?: Color3;
  139706. alphaFilter?: number;
  139707. updatable?: boolean;
  139708. onReady?: (mesh: GroundMesh) => void;
  139709. }, scene?: Nullable<Scene>): GroundMesh;
  139710. /**
  139711. * Creates a polygon mesh
  139712. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  139713. * * 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
  139714. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  139715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139716. * * 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)
  139717. * * Remember you can only change the shape positions, not their number when updating a polygon
  139718. * @param name defines the name of the mesh
  139719. * @param options defines the options used to create the mesh
  139720. * @param scene defines the hosting scene
  139721. * @param earcutInjection can be used to inject your own earcut reference
  139722. * @returns the polygon mesh
  139723. */
  139724. static CreatePolygon(name: string, options: {
  139725. shape: Vector3[];
  139726. holes?: Vector3[][];
  139727. depth?: number;
  139728. faceUV?: Vector4[];
  139729. faceColors?: Color4[];
  139730. updatable?: boolean;
  139731. sideOrientation?: number;
  139732. frontUVs?: Vector4;
  139733. backUVs?: Vector4;
  139734. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139735. /**
  139736. * Creates an extruded polygon mesh, with depth in the Y direction.
  139737. * * 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)
  139738. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139739. * @param name defines the name of the mesh
  139740. * @param options defines the options used to create the mesh
  139741. * @param scene defines the hosting scene
  139742. * @param earcutInjection can be used to inject your own earcut reference
  139743. * @returns the polygon mesh
  139744. */
  139745. static ExtrudePolygon(name: string, options: {
  139746. shape: Vector3[];
  139747. holes?: Vector3[][];
  139748. depth?: number;
  139749. faceUV?: Vector4[];
  139750. faceColors?: Color4[];
  139751. updatable?: boolean;
  139752. sideOrientation?: number;
  139753. frontUVs?: Vector4;
  139754. backUVs?: Vector4;
  139755. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139756. /**
  139757. * Creates a tube mesh.
  139758. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139759. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  139760. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  139761. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  139762. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  139763. * * 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)
  139764. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  139765. * * 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
  139766. * * 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
  139767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139768. * * 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
  139769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139771. * @param name defines the name of the mesh
  139772. * @param options defines the options used to create the mesh
  139773. * @param scene defines the hosting scene
  139774. * @returns the tube mesh
  139775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139776. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  139777. */
  139778. static CreateTube(name: string, options: {
  139779. path: Vector3[];
  139780. radius?: number;
  139781. tessellation?: number;
  139782. radiusFunction?: {
  139783. (i: number, distance: number): number;
  139784. };
  139785. cap?: number;
  139786. arc?: number;
  139787. updatable?: boolean;
  139788. sideOrientation?: number;
  139789. frontUVs?: Vector4;
  139790. backUVs?: Vector4;
  139791. instance?: Mesh;
  139792. invertUV?: boolean;
  139793. }, scene?: Nullable<Scene>): Mesh;
  139794. /**
  139795. * Creates a polyhedron mesh
  139796. * * 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
  139797. * * The parameter `size` (positive float, default 1) sets the polygon size
  139798. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  139799. * * 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`
  139800. * * 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
  139801. * * 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)`)
  139802. * * 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
  139803. * * 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
  139804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139805. * * 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
  139806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139807. * @param name defines the name of the mesh
  139808. * @param options defines the options used to create the mesh
  139809. * @param scene defines the hosting scene
  139810. * @returns the polyhedron mesh
  139811. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  139812. */
  139813. static CreatePolyhedron(name: string, options: {
  139814. type?: number;
  139815. size?: number;
  139816. sizeX?: number;
  139817. sizeY?: number;
  139818. sizeZ?: number;
  139819. custom?: any;
  139820. faceUV?: Vector4[];
  139821. faceColors?: Color4[];
  139822. flat?: boolean;
  139823. updatable?: boolean;
  139824. sideOrientation?: number;
  139825. frontUVs?: Vector4;
  139826. backUVs?: Vector4;
  139827. }, scene?: Nullable<Scene>): Mesh;
  139828. /**
  139829. * Creates a decal mesh.
  139830. * 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
  139831. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139832. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139833. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139834. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139835. * @param name defines the name of the mesh
  139836. * @param sourceMesh defines the mesh where the decal must be applied
  139837. * @param options defines the options used to create the mesh
  139838. * @param scene defines the hosting scene
  139839. * @returns the decal mesh
  139840. * @see https://doc.babylonjs.com/how_to/decals
  139841. */
  139842. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139843. position?: Vector3;
  139844. normal?: Vector3;
  139845. size?: Vector3;
  139846. angle?: number;
  139847. }): Mesh;
  139848. }
  139849. }
  139850. declare module BABYLON {
  139851. /**
  139852. * A simplifier interface for future simplification implementations
  139853. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139854. */
  139855. export interface ISimplifier {
  139856. /**
  139857. * Simplification of a given mesh according to the given settings.
  139858. * Since this requires computation, it is assumed that the function runs async.
  139859. * @param settings The settings of the simplification, including quality and distance
  139860. * @param successCallback A callback that will be called after the mesh was simplified.
  139861. * @param errorCallback in case of an error, this callback will be called. optional.
  139862. */
  139863. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  139864. }
  139865. /**
  139866. * Expected simplification settings.
  139867. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  139868. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139869. */
  139870. export interface ISimplificationSettings {
  139871. /**
  139872. * Gets or sets the expected quality
  139873. */
  139874. quality: number;
  139875. /**
  139876. * Gets or sets the distance when this optimized version should be used
  139877. */
  139878. distance: number;
  139879. /**
  139880. * Gets an already optimized mesh
  139881. */
  139882. optimizeMesh?: boolean;
  139883. }
  139884. /**
  139885. * Class used to specify simplification options
  139886. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139887. */
  139888. export class SimplificationSettings implements ISimplificationSettings {
  139889. /** expected quality */
  139890. quality: number;
  139891. /** distance when this optimized version should be used */
  139892. distance: number;
  139893. /** already optimized mesh */
  139894. optimizeMesh?: boolean | undefined;
  139895. /**
  139896. * Creates a SimplificationSettings
  139897. * @param quality expected quality
  139898. * @param distance distance when this optimized version should be used
  139899. * @param optimizeMesh already optimized mesh
  139900. */
  139901. constructor(
  139902. /** expected quality */
  139903. quality: number,
  139904. /** distance when this optimized version should be used */
  139905. distance: number,
  139906. /** already optimized mesh */
  139907. optimizeMesh?: boolean | undefined);
  139908. }
  139909. /**
  139910. * Interface used to define a simplification task
  139911. */
  139912. export interface ISimplificationTask {
  139913. /**
  139914. * Array of settings
  139915. */
  139916. settings: Array<ISimplificationSettings>;
  139917. /**
  139918. * Simplification type
  139919. */
  139920. simplificationType: SimplificationType;
  139921. /**
  139922. * Mesh to simplify
  139923. */
  139924. mesh: Mesh;
  139925. /**
  139926. * Callback called on success
  139927. */
  139928. successCallback?: () => void;
  139929. /**
  139930. * Defines if parallel processing can be used
  139931. */
  139932. parallelProcessing: boolean;
  139933. }
  139934. /**
  139935. * Queue used to order the simplification tasks
  139936. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139937. */
  139938. export class SimplificationQueue {
  139939. private _simplificationArray;
  139940. /**
  139941. * Gets a boolean indicating that the process is still running
  139942. */
  139943. running: boolean;
  139944. /**
  139945. * Creates a new queue
  139946. */
  139947. constructor();
  139948. /**
  139949. * Adds a new simplification task
  139950. * @param task defines a task to add
  139951. */
  139952. addTask(task: ISimplificationTask): void;
  139953. /**
  139954. * Execute next task
  139955. */
  139956. executeNext(): void;
  139957. /**
  139958. * Execute a simplification task
  139959. * @param task defines the task to run
  139960. */
  139961. runSimplification(task: ISimplificationTask): void;
  139962. private getSimplifier;
  139963. }
  139964. /**
  139965. * The implemented types of simplification
  139966. * At the moment only Quadratic Error Decimation is implemented
  139967. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139968. */
  139969. export enum SimplificationType {
  139970. /** Quadratic error decimation */
  139971. QUADRATIC = 0
  139972. }
  139973. /**
  139974. * An implementation of the Quadratic Error simplification algorithm.
  139975. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  139976. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  139977. * @author RaananW
  139978. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139979. */
  139980. export class QuadraticErrorSimplification implements ISimplifier {
  139981. private _mesh;
  139982. private triangles;
  139983. private vertices;
  139984. private references;
  139985. private _reconstructedMesh;
  139986. /** Gets or sets the number pf sync interations */
  139987. syncIterations: number;
  139988. /** Gets or sets the aggressiveness of the simplifier */
  139989. aggressiveness: number;
  139990. /** Gets or sets the number of allowed iterations for decimation */
  139991. decimationIterations: number;
  139992. /** Gets or sets the espilon to use for bounding box computation */
  139993. boundingBoxEpsilon: number;
  139994. /**
  139995. * Creates a new QuadraticErrorSimplification
  139996. * @param _mesh defines the target mesh
  139997. */
  139998. constructor(_mesh: Mesh);
  139999. /**
  140000. * Simplification of a given mesh according to the given settings.
  140001. * Since this requires computation, it is assumed that the function runs async.
  140002. * @param settings The settings of the simplification, including quality and distance
  140003. * @param successCallback A callback that will be called after the mesh was simplified.
  140004. */
  140005. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  140006. private runDecimation;
  140007. private initWithMesh;
  140008. private init;
  140009. private reconstructMesh;
  140010. private initDecimatedMesh;
  140011. private isFlipped;
  140012. private updateTriangles;
  140013. private identifyBorder;
  140014. private updateMesh;
  140015. private vertexError;
  140016. private calculateError;
  140017. }
  140018. }
  140019. declare module BABYLON {
  140020. interface Scene {
  140021. /** @hidden (Backing field) */
  140022. _simplificationQueue: SimplificationQueue;
  140023. /**
  140024. * Gets or sets the simplification queue attached to the scene
  140025. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  140026. */
  140027. simplificationQueue: SimplificationQueue;
  140028. }
  140029. interface Mesh {
  140030. /**
  140031. * Simplify the mesh according to the given array of settings.
  140032. * Function will return immediately and will simplify async
  140033. * @param settings a collection of simplification settings
  140034. * @param parallelProcessing should all levels calculate parallel or one after the other
  140035. * @param simplificationType the type of simplification to run
  140036. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  140037. * @returns the current mesh
  140038. */
  140039. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  140040. }
  140041. /**
  140042. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  140043. * created in a scene
  140044. */
  140045. export class SimplicationQueueSceneComponent implements ISceneComponent {
  140046. /**
  140047. * The component name helpfull to identify the component in the list of scene components.
  140048. */
  140049. readonly name: string;
  140050. /**
  140051. * The scene the component belongs to.
  140052. */
  140053. scene: Scene;
  140054. /**
  140055. * Creates a new instance of the component for the given scene
  140056. * @param scene Defines the scene to register the component in
  140057. */
  140058. constructor(scene: Scene);
  140059. /**
  140060. * Registers the component in a given scene
  140061. */
  140062. register(): void;
  140063. /**
  140064. * Rebuilds the elements related to this component in case of
  140065. * context lost for instance.
  140066. */
  140067. rebuild(): void;
  140068. /**
  140069. * Disposes the component and the associated ressources
  140070. */
  140071. dispose(): void;
  140072. private _beforeCameraUpdate;
  140073. }
  140074. }
  140075. declare module BABYLON {
  140076. /**
  140077. * Navigation plugin interface to add navigation constrained by a navigation mesh
  140078. */
  140079. export interface INavigationEnginePlugin {
  140080. /**
  140081. * plugin name
  140082. */
  140083. name: string;
  140084. /**
  140085. * Creates a navigation mesh
  140086. * @param meshes array of all the geometry used to compute the navigatio mesh
  140087. * @param parameters bunch of parameters used to filter geometry
  140088. */
  140089. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  140090. /**
  140091. * Create a navigation mesh debug mesh
  140092. * @param scene is where the mesh will be added
  140093. * @returns debug display mesh
  140094. */
  140095. createDebugNavMesh(scene: Scene): Mesh;
  140096. /**
  140097. * Get a navigation mesh constrained position, closest to the parameter position
  140098. * @param position world position
  140099. * @returns the closest point to position constrained by the navigation mesh
  140100. */
  140101. getClosestPoint(position: Vector3): Vector3;
  140102. /**
  140103. * Get a navigation mesh constrained position, closest to the parameter position
  140104. * @param position world position
  140105. * @param result output the closest point to position constrained by the navigation mesh
  140106. */
  140107. getClosestPointToRef(position: Vector3, result: Vector3): void;
  140108. /**
  140109. * Get a navigation mesh constrained position, within a particular radius
  140110. * @param position world position
  140111. * @param maxRadius the maximum distance to the constrained world position
  140112. * @returns the closest point to position constrained by the navigation mesh
  140113. */
  140114. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  140115. /**
  140116. * Get a navigation mesh constrained position, within a particular radius
  140117. * @param position world position
  140118. * @param maxRadius the maximum distance to the constrained world position
  140119. * @param result output the closest point to position constrained by the navigation mesh
  140120. */
  140121. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  140122. /**
  140123. * Compute the final position from a segment made of destination-position
  140124. * @param position world position
  140125. * @param destination world position
  140126. * @returns the resulting point along the navmesh
  140127. */
  140128. moveAlong(position: Vector3, destination: Vector3): Vector3;
  140129. /**
  140130. * Compute the final position from a segment made of destination-position
  140131. * @param position world position
  140132. * @param destination world position
  140133. * @param result output the resulting point along the navmesh
  140134. */
  140135. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140136. /**
  140137. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140138. * @param start world position
  140139. * @param end world position
  140140. * @returns array containing world position composing the path
  140141. */
  140142. computePath(start: Vector3, end: Vector3): Vector3[];
  140143. /**
  140144. * If this plugin is supported
  140145. * @returns true if plugin is supported
  140146. */
  140147. isSupported(): boolean;
  140148. /**
  140149. * Create a new Crowd so you can add agents
  140150. * @param maxAgents the maximum agent count in the crowd
  140151. * @param maxAgentRadius the maximum radius an agent can have
  140152. * @param scene to attach the crowd to
  140153. * @returns the crowd you can add agents to
  140154. */
  140155. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140156. /**
  140157. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140158. * The queries will try to find a solution within those bounds
  140159. * default is (1,1,1)
  140160. * @param extent x,y,z value that define the extent around the queries point of reference
  140161. */
  140162. setDefaultQueryExtent(extent: Vector3): void;
  140163. /**
  140164. * Get the Bounding box extent specified by setDefaultQueryExtent
  140165. * @returns the box extent values
  140166. */
  140167. getDefaultQueryExtent(): Vector3;
  140168. /**
  140169. * build the navmesh from a previously saved state using getNavmeshData
  140170. * @param data the Uint8Array returned by getNavmeshData
  140171. */
  140172. buildFromNavmeshData(data: Uint8Array): void;
  140173. /**
  140174. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140175. * @returns data the Uint8Array that can be saved and reused
  140176. */
  140177. getNavmeshData(): Uint8Array;
  140178. /**
  140179. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140180. * @param result output the box extent values
  140181. */
  140182. getDefaultQueryExtentToRef(result: Vector3): void;
  140183. /**
  140184. * Release all resources
  140185. */
  140186. dispose(): void;
  140187. }
  140188. /**
  140189. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  140190. */
  140191. export interface ICrowd {
  140192. /**
  140193. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140194. * You can attach anything to that node. The node position is updated in the scene update tick.
  140195. * @param pos world position that will be constrained by the navigation mesh
  140196. * @param parameters agent parameters
  140197. * @param transform hooked to the agent that will be update by the scene
  140198. * @returns agent index
  140199. */
  140200. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140201. /**
  140202. * Returns the agent position in world space
  140203. * @param index agent index returned by addAgent
  140204. * @returns world space position
  140205. */
  140206. getAgentPosition(index: number): Vector3;
  140207. /**
  140208. * Gets the agent position result in world space
  140209. * @param index agent index returned by addAgent
  140210. * @param result output world space position
  140211. */
  140212. getAgentPositionToRef(index: number, result: Vector3): void;
  140213. /**
  140214. * Gets the agent velocity in world space
  140215. * @param index agent index returned by addAgent
  140216. * @returns world space velocity
  140217. */
  140218. getAgentVelocity(index: number): Vector3;
  140219. /**
  140220. * Gets the agent velocity result in world space
  140221. * @param index agent index returned by addAgent
  140222. * @param result output world space velocity
  140223. */
  140224. getAgentVelocityToRef(index: number, result: Vector3): void;
  140225. /**
  140226. * remove a particular agent previously created
  140227. * @param index agent index returned by addAgent
  140228. */
  140229. removeAgent(index: number): void;
  140230. /**
  140231. * get the list of all agents attached to this crowd
  140232. * @returns list of agent indices
  140233. */
  140234. getAgents(): number[];
  140235. /**
  140236. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140237. * @param deltaTime in seconds
  140238. */
  140239. update(deltaTime: number): void;
  140240. /**
  140241. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140242. * @param index agent index returned by addAgent
  140243. * @param destination targeted world position
  140244. */
  140245. agentGoto(index: number, destination: Vector3): void;
  140246. /**
  140247. * Teleport the agent to a new position
  140248. * @param index agent index returned by addAgent
  140249. * @param destination targeted world position
  140250. */
  140251. agentTeleport(index: number, destination: Vector3): void;
  140252. /**
  140253. * Update agent parameters
  140254. * @param index agent index returned by addAgent
  140255. * @param parameters agent parameters
  140256. */
  140257. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140258. /**
  140259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140260. * The queries will try to find a solution within those bounds
  140261. * default is (1,1,1)
  140262. * @param extent x,y,z value that define the extent around the queries point of reference
  140263. */
  140264. setDefaultQueryExtent(extent: Vector3): void;
  140265. /**
  140266. * Get the Bounding box extent specified by setDefaultQueryExtent
  140267. * @returns the box extent values
  140268. */
  140269. getDefaultQueryExtent(): Vector3;
  140270. /**
  140271. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140272. * @param result output the box extent values
  140273. */
  140274. getDefaultQueryExtentToRef(result: Vector3): void;
  140275. /**
  140276. * Release all resources
  140277. */
  140278. dispose(): void;
  140279. }
  140280. /**
  140281. * Configures an agent
  140282. */
  140283. export interface IAgentParameters {
  140284. /**
  140285. * Agent radius. [Limit: >= 0]
  140286. */
  140287. radius: number;
  140288. /**
  140289. * Agent height. [Limit: > 0]
  140290. */
  140291. height: number;
  140292. /**
  140293. * Maximum allowed acceleration. [Limit: >= 0]
  140294. */
  140295. maxAcceleration: number;
  140296. /**
  140297. * Maximum allowed speed. [Limit: >= 0]
  140298. */
  140299. maxSpeed: number;
  140300. /**
  140301. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  140302. */
  140303. collisionQueryRange: number;
  140304. /**
  140305. * The path visibility optimization range. [Limit: > 0]
  140306. */
  140307. pathOptimizationRange: number;
  140308. /**
  140309. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  140310. */
  140311. separationWeight: number;
  140312. }
  140313. /**
  140314. * Configures the navigation mesh creation
  140315. */
  140316. export interface INavMeshParameters {
  140317. /**
  140318. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  140319. */
  140320. cs: number;
  140321. /**
  140322. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  140323. */
  140324. ch: number;
  140325. /**
  140326. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  140327. */
  140328. walkableSlopeAngle: number;
  140329. /**
  140330. * Minimum floor to 'ceiling' height that will still allow the floor area to
  140331. * be considered walkable. [Limit: >= 3] [Units: vx]
  140332. */
  140333. walkableHeight: number;
  140334. /**
  140335. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  140336. */
  140337. walkableClimb: number;
  140338. /**
  140339. * The distance to erode/shrink the walkable area of the heightfield away from
  140340. * obstructions. [Limit: >=0] [Units: vx]
  140341. */
  140342. walkableRadius: number;
  140343. /**
  140344. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  140345. */
  140346. maxEdgeLen: number;
  140347. /**
  140348. * The maximum distance a simplfied contour's border edges should deviate
  140349. * the original raw contour. [Limit: >=0] [Units: vx]
  140350. */
  140351. maxSimplificationError: number;
  140352. /**
  140353. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  140354. */
  140355. minRegionArea: number;
  140356. /**
  140357. * Any regions with a span count smaller than this value will, if possible,
  140358. * be merged with larger regions. [Limit: >=0] [Units: vx]
  140359. */
  140360. mergeRegionArea: number;
  140361. /**
  140362. * The maximum number of vertices allowed for polygons generated during the
  140363. * contour to polygon conversion process. [Limit: >= 3]
  140364. */
  140365. maxVertsPerPoly: number;
  140366. /**
  140367. * Sets the sampling distance to use when generating the detail mesh.
  140368. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  140369. */
  140370. detailSampleDist: number;
  140371. /**
  140372. * The maximum distance the detail mesh surface should deviate from heightfield
  140373. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  140374. */
  140375. detailSampleMaxError: number;
  140376. }
  140377. }
  140378. declare module BABYLON {
  140379. /**
  140380. * RecastJS navigation plugin
  140381. */
  140382. export class RecastJSPlugin implements INavigationEnginePlugin {
  140383. /**
  140384. * Reference to the Recast library
  140385. */
  140386. bjsRECAST: any;
  140387. /**
  140388. * plugin name
  140389. */
  140390. name: string;
  140391. /**
  140392. * the first navmesh created. We might extend this to support multiple navmeshes
  140393. */
  140394. navMesh: any;
  140395. /**
  140396. * Initializes the recastJS plugin
  140397. * @param recastInjection can be used to inject your own recast reference
  140398. */
  140399. constructor(recastInjection?: any);
  140400. /**
  140401. * Creates a navigation mesh
  140402. * @param meshes array of all the geometry used to compute the navigatio mesh
  140403. * @param parameters bunch of parameters used to filter geometry
  140404. */
  140405. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  140406. /**
  140407. * Create a navigation mesh debug mesh
  140408. * @param scene is where the mesh will be added
  140409. * @returns debug display mesh
  140410. */
  140411. createDebugNavMesh(scene: Scene): Mesh;
  140412. /**
  140413. * Get a navigation mesh constrained position, closest to the parameter position
  140414. * @param position world position
  140415. * @returns the closest point to position constrained by the navigation mesh
  140416. */
  140417. getClosestPoint(position: Vector3): Vector3;
  140418. /**
  140419. * Get a navigation mesh constrained position, closest to the parameter position
  140420. * @param position world position
  140421. * @param result output the closest point to position constrained by the navigation mesh
  140422. */
  140423. getClosestPointToRef(position: Vector3, result: Vector3): void;
  140424. /**
  140425. * Get a navigation mesh constrained position, within a particular radius
  140426. * @param position world position
  140427. * @param maxRadius the maximum distance to the constrained world position
  140428. * @returns the closest point to position constrained by the navigation mesh
  140429. */
  140430. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  140431. /**
  140432. * Get a navigation mesh constrained position, within a particular radius
  140433. * @param position world position
  140434. * @param maxRadius the maximum distance to the constrained world position
  140435. * @param result output the closest point to position constrained by the navigation mesh
  140436. */
  140437. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  140438. /**
  140439. * Compute the final position from a segment made of destination-position
  140440. * @param position world position
  140441. * @param destination world position
  140442. * @returns the resulting point along the navmesh
  140443. */
  140444. moveAlong(position: Vector3, destination: Vector3): Vector3;
  140445. /**
  140446. * Compute the final position from a segment made of destination-position
  140447. * @param position world position
  140448. * @param destination world position
  140449. * @param result output the resulting point along the navmesh
  140450. */
  140451. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140452. /**
  140453. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140454. * @param start world position
  140455. * @param end world position
  140456. * @returns array containing world position composing the path
  140457. */
  140458. computePath(start: Vector3, end: Vector3): Vector3[];
  140459. /**
  140460. * Create a new Crowd so you can add agents
  140461. * @param maxAgents the maximum agent count in the crowd
  140462. * @param maxAgentRadius the maximum radius an agent can have
  140463. * @param scene to attach the crowd to
  140464. * @returns the crowd you can add agents to
  140465. */
  140466. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140467. /**
  140468. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140469. * The queries will try to find a solution within those bounds
  140470. * default is (1,1,1)
  140471. * @param extent x,y,z value that define the extent around the queries point of reference
  140472. */
  140473. setDefaultQueryExtent(extent: Vector3): void;
  140474. /**
  140475. * Get the Bounding box extent specified by setDefaultQueryExtent
  140476. * @returns the box extent values
  140477. */
  140478. getDefaultQueryExtent(): Vector3;
  140479. /**
  140480. * build the navmesh from a previously saved state using getNavmeshData
  140481. * @param data the Uint8Array returned by getNavmeshData
  140482. */
  140483. buildFromNavmeshData(data: Uint8Array): void;
  140484. /**
  140485. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140486. * @returns data the Uint8Array that can be saved and reused
  140487. */
  140488. getNavmeshData(): Uint8Array;
  140489. /**
  140490. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140491. * @param result output the box extent values
  140492. */
  140493. getDefaultQueryExtentToRef(result: Vector3): void;
  140494. /**
  140495. * Disposes
  140496. */
  140497. dispose(): void;
  140498. /**
  140499. * If this plugin is supported
  140500. * @returns true if plugin is supported
  140501. */
  140502. isSupported(): boolean;
  140503. }
  140504. /**
  140505. * Recast detour crowd implementation
  140506. */
  140507. export class RecastJSCrowd implements ICrowd {
  140508. /**
  140509. * Recast/detour plugin
  140510. */
  140511. bjsRECASTPlugin: RecastJSPlugin;
  140512. /**
  140513. * Link to the detour crowd
  140514. */
  140515. recastCrowd: any;
  140516. /**
  140517. * One transform per agent
  140518. */
  140519. transforms: TransformNode[];
  140520. /**
  140521. * All agents created
  140522. */
  140523. agents: number[];
  140524. /**
  140525. * Link to the scene is kept to unregister the crowd from the scene
  140526. */
  140527. private _scene;
  140528. /**
  140529. * Observer for crowd updates
  140530. */
  140531. private _onBeforeAnimationsObserver;
  140532. /**
  140533. * Constructor
  140534. * @param plugin recastJS plugin
  140535. * @param maxAgents the maximum agent count in the crowd
  140536. * @param maxAgentRadius the maximum radius an agent can have
  140537. * @param scene to attach the crowd to
  140538. * @returns the crowd you can add agents to
  140539. */
  140540. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  140541. /**
  140542. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140543. * You can attach anything to that node. The node position is updated in the scene update tick.
  140544. * @param pos world position that will be constrained by the navigation mesh
  140545. * @param parameters agent parameters
  140546. * @param transform hooked to the agent that will be update by the scene
  140547. * @returns agent index
  140548. */
  140549. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140550. /**
  140551. * Returns the agent position in world space
  140552. * @param index agent index returned by addAgent
  140553. * @returns world space position
  140554. */
  140555. getAgentPosition(index: number): Vector3;
  140556. /**
  140557. * Returns the agent position result in world space
  140558. * @param index agent index returned by addAgent
  140559. * @param result output world space position
  140560. */
  140561. getAgentPositionToRef(index: number, result: Vector3): void;
  140562. /**
  140563. * Returns the agent velocity in world space
  140564. * @param index agent index returned by addAgent
  140565. * @returns world space velocity
  140566. */
  140567. getAgentVelocity(index: number): Vector3;
  140568. /**
  140569. * Returns the agent velocity result in world space
  140570. * @param index agent index returned by addAgent
  140571. * @param result output world space velocity
  140572. */
  140573. getAgentVelocityToRef(index: number, result: Vector3): void;
  140574. /**
  140575. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140576. * @param index agent index returned by addAgent
  140577. * @param destination targeted world position
  140578. */
  140579. agentGoto(index: number, destination: Vector3): void;
  140580. /**
  140581. * Teleport the agent to a new position
  140582. * @param index agent index returned by addAgent
  140583. * @param destination targeted world position
  140584. */
  140585. agentTeleport(index: number, destination: Vector3): void;
  140586. /**
  140587. * Update agent parameters
  140588. * @param index agent index returned by addAgent
  140589. * @param parameters agent parameters
  140590. */
  140591. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140592. /**
  140593. * remove a particular agent previously created
  140594. * @param index agent index returned by addAgent
  140595. */
  140596. removeAgent(index: number): void;
  140597. /**
  140598. * get the list of all agents attached to this crowd
  140599. * @returns list of agent indices
  140600. */
  140601. getAgents(): number[];
  140602. /**
  140603. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140604. * @param deltaTime in seconds
  140605. */
  140606. update(deltaTime: number): void;
  140607. /**
  140608. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140609. * The queries will try to find a solution within those bounds
  140610. * default is (1,1,1)
  140611. * @param extent x,y,z value that define the extent around the queries point of reference
  140612. */
  140613. setDefaultQueryExtent(extent: Vector3): void;
  140614. /**
  140615. * Get the Bounding box extent specified by setDefaultQueryExtent
  140616. * @returns the box extent values
  140617. */
  140618. getDefaultQueryExtent(): Vector3;
  140619. /**
  140620. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140621. * @param result output the box extent values
  140622. */
  140623. getDefaultQueryExtentToRef(result: Vector3): void;
  140624. /**
  140625. * Release all resources
  140626. */
  140627. dispose(): void;
  140628. }
  140629. }
  140630. declare module BABYLON {
  140631. /**
  140632. * Class used to enable access to IndexedDB
  140633. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  140634. */
  140635. export class Database implements IOfflineProvider {
  140636. private _callbackManifestChecked;
  140637. private _currentSceneUrl;
  140638. private _db;
  140639. private _enableSceneOffline;
  140640. private _enableTexturesOffline;
  140641. private _manifestVersionFound;
  140642. private _mustUpdateRessources;
  140643. private _hasReachedQuota;
  140644. private _isSupported;
  140645. private _idbFactory;
  140646. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  140647. private static IsUASupportingBlobStorage;
  140648. /**
  140649. * Gets a boolean indicating if Database storate is enabled (off by default)
  140650. */
  140651. static IDBStorageEnabled: boolean;
  140652. /**
  140653. * Gets a boolean indicating if scene must be saved in the database
  140654. */
  140655. get enableSceneOffline(): boolean;
  140656. /**
  140657. * Gets a boolean indicating if textures must be saved in the database
  140658. */
  140659. get enableTexturesOffline(): boolean;
  140660. /**
  140661. * Creates a new Database
  140662. * @param urlToScene defines the url to load the scene
  140663. * @param callbackManifestChecked defines the callback to use when manifest is checked
  140664. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  140665. */
  140666. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  140667. private static _ParseURL;
  140668. private static _ReturnFullUrlLocation;
  140669. private _checkManifestFile;
  140670. /**
  140671. * Open the database and make it available
  140672. * @param successCallback defines the callback to call on success
  140673. * @param errorCallback defines the callback to call on error
  140674. */
  140675. open(successCallback: () => void, errorCallback: () => void): void;
  140676. /**
  140677. * Loads an image from the database
  140678. * @param url defines the url to load from
  140679. * @param image defines the target DOM image
  140680. */
  140681. loadImage(url: string, image: HTMLImageElement): void;
  140682. private _loadImageFromDBAsync;
  140683. private _saveImageIntoDBAsync;
  140684. private _checkVersionFromDB;
  140685. private _loadVersionFromDBAsync;
  140686. private _saveVersionIntoDBAsync;
  140687. /**
  140688. * Loads a file from database
  140689. * @param url defines the URL to load from
  140690. * @param sceneLoaded defines a callback to call on success
  140691. * @param progressCallBack defines a callback to call when progress changed
  140692. * @param errorCallback defines a callback to call on error
  140693. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  140694. */
  140695. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  140696. private _loadFileAsync;
  140697. private _saveFileAsync;
  140698. /**
  140699. * Validates if xhr data is correct
  140700. * @param xhr defines the request to validate
  140701. * @param dataType defines the expected data type
  140702. * @returns true if data is correct
  140703. */
  140704. private static _ValidateXHRData;
  140705. }
  140706. }
  140707. declare module BABYLON {
  140708. /** @hidden */
  140709. export var gpuUpdateParticlesPixelShader: {
  140710. name: string;
  140711. shader: string;
  140712. };
  140713. }
  140714. declare module BABYLON {
  140715. /** @hidden */
  140716. export var gpuUpdateParticlesVertexShader: {
  140717. name: string;
  140718. shader: string;
  140719. };
  140720. }
  140721. declare module BABYLON {
  140722. /** @hidden */
  140723. export var clipPlaneFragmentDeclaration2: {
  140724. name: string;
  140725. shader: string;
  140726. };
  140727. }
  140728. declare module BABYLON {
  140729. /** @hidden */
  140730. export var gpuRenderParticlesPixelShader: {
  140731. name: string;
  140732. shader: string;
  140733. };
  140734. }
  140735. declare module BABYLON {
  140736. /** @hidden */
  140737. export var clipPlaneVertexDeclaration2: {
  140738. name: string;
  140739. shader: string;
  140740. };
  140741. }
  140742. declare module BABYLON {
  140743. /** @hidden */
  140744. export var gpuRenderParticlesVertexShader: {
  140745. name: string;
  140746. shader: string;
  140747. };
  140748. }
  140749. declare module BABYLON {
  140750. /**
  140751. * This represents a GPU particle system in Babylon
  140752. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  140753. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  140754. */
  140755. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  140756. /**
  140757. * The layer mask we are rendering the particles through.
  140758. */
  140759. layerMask: number;
  140760. private _capacity;
  140761. private _activeCount;
  140762. private _currentActiveCount;
  140763. private _accumulatedCount;
  140764. private _renderEffect;
  140765. private _updateEffect;
  140766. private _buffer0;
  140767. private _buffer1;
  140768. private _spriteBuffer;
  140769. private _updateVAO;
  140770. private _renderVAO;
  140771. private _targetIndex;
  140772. private _sourceBuffer;
  140773. private _targetBuffer;
  140774. private _engine;
  140775. private _currentRenderId;
  140776. private _started;
  140777. private _stopped;
  140778. private _timeDelta;
  140779. private _randomTexture;
  140780. private _randomTexture2;
  140781. private _attributesStrideSize;
  140782. private _updateEffectOptions;
  140783. private _randomTextureSize;
  140784. private _actualFrame;
  140785. private readonly _rawTextureWidth;
  140786. /**
  140787. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  140788. */
  140789. static get IsSupported(): boolean;
  140790. /**
  140791. * An event triggered when the system is disposed.
  140792. */
  140793. onDisposeObservable: Observable<GPUParticleSystem>;
  140794. /**
  140795. * Gets the maximum number of particles active at the same time.
  140796. * @returns The max number of active particles.
  140797. */
  140798. getCapacity(): number;
  140799. /**
  140800. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  140801. * to override the particles.
  140802. */
  140803. forceDepthWrite: boolean;
  140804. /**
  140805. * Gets or set the number of active particles
  140806. */
  140807. get activeParticleCount(): number;
  140808. set activeParticleCount(value: number);
  140809. private _preWarmDone;
  140810. /**
  140811. * Specifies if the particles are updated in emitter local space or world space.
  140812. */
  140813. isLocal: boolean;
  140814. /**
  140815. * Is this system ready to be used/rendered
  140816. * @return true if the system is ready
  140817. */
  140818. isReady(): boolean;
  140819. /**
  140820. * Gets if the system has been started. (Note: this will still be true after stop is called)
  140821. * @returns True if it has been started, otherwise false.
  140822. */
  140823. isStarted(): boolean;
  140824. /**
  140825. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  140826. * @returns True if it has been stopped, otherwise false.
  140827. */
  140828. isStopped(): boolean;
  140829. /**
  140830. * Gets a boolean indicating that the system is stopping
  140831. * @returns true if the system is currently stopping
  140832. */
  140833. isStopping(): boolean;
  140834. /**
  140835. * Gets the number of particles active at the same time.
  140836. * @returns The number of active particles.
  140837. */
  140838. getActiveCount(): number;
  140839. /**
  140840. * Starts the particle system and begins to emit
  140841. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  140842. */
  140843. start(delay?: number): void;
  140844. /**
  140845. * Stops the particle system.
  140846. */
  140847. stop(): void;
  140848. /**
  140849. * Remove all active particles
  140850. */
  140851. reset(): void;
  140852. /**
  140853. * Returns the string "GPUParticleSystem"
  140854. * @returns a string containing the class name
  140855. */
  140856. getClassName(): string;
  140857. private _colorGradientsTexture;
  140858. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  140859. /**
  140860. * Adds a new color gradient
  140861. * @param gradient defines the gradient to use (between 0 and 1)
  140862. * @param color1 defines the color to affect to the specified gradient
  140863. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  140864. * @returns the current particle system
  140865. */
  140866. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  140867. private _refreshColorGradient;
  140868. /** Force the system to rebuild all gradients that need to be resync */
  140869. forceRefreshGradients(): void;
  140870. /**
  140871. * Remove a specific color gradient
  140872. * @param gradient defines the gradient to remove
  140873. * @returns the current particle system
  140874. */
  140875. removeColorGradient(gradient: number): GPUParticleSystem;
  140876. private _angularSpeedGradientsTexture;
  140877. private _sizeGradientsTexture;
  140878. private _velocityGradientsTexture;
  140879. private _limitVelocityGradientsTexture;
  140880. private _dragGradientsTexture;
  140881. private _addFactorGradient;
  140882. /**
  140883. * Adds a new size gradient
  140884. * @param gradient defines the gradient to use (between 0 and 1)
  140885. * @param factor defines the size factor to affect to the specified gradient
  140886. * @returns the current particle system
  140887. */
  140888. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  140889. /**
  140890. * Remove a specific size gradient
  140891. * @param gradient defines the gradient to remove
  140892. * @returns the current particle system
  140893. */
  140894. removeSizeGradient(gradient: number): GPUParticleSystem;
  140895. private _refreshFactorGradient;
  140896. /**
  140897. * Adds a new angular speed gradient
  140898. * @param gradient defines the gradient to use (between 0 and 1)
  140899. * @param factor defines the angular speed to affect to the specified gradient
  140900. * @returns the current particle system
  140901. */
  140902. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  140903. /**
  140904. * Remove a specific angular speed gradient
  140905. * @param gradient defines the gradient to remove
  140906. * @returns the current particle system
  140907. */
  140908. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  140909. /**
  140910. * Adds a new velocity gradient
  140911. * @param gradient defines the gradient to use (between 0 and 1)
  140912. * @param factor defines the velocity to affect to the specified gradient
  140913. * @returns the current particle system
  140914. */
  140915. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140916. /**
  140917. * Remove a specific velocity gradient
  140918. * @param gradient defines the gradient to remove
  140919. * @returns the current particle system
  140920. */
  140921. removeVelocityGradient(gradient: number): GPUParticleSystem;
  140922. /**
  140923. * Adds a new limit velocity gradient
  140924. * @param gradient defines the gradient to use (between 0 and 1)
  140925. * @param factor defines the limit velocity value to affect to the specified gradient
  140926. * @returns the current particle system
  140927. */
  140928. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140929. /**
  140930. * Remove a specific limit velocity gradient
  140931. * @param gradient defines the gradient to remove
  140932. * @returns the current particle system
  140933. */
  140934. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  140935. /**
  140936. * Adds a new drag gradient
  140937. * @param gradient defines the gradient to use (between 0 and 1)
  140938. * @param factor defines the drag value to affect to the specified gradient
  140939. * @returns the current particle system
  140940. */
  140941. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  140942. /**
  140943. * Remove a specific drag gradient
  140944. * @param gradient defines the gradient to remove
  140945. * @returns the current particle system
  140946. */
  140947. removeDragGradient(gradient: number): GPUParticleSystem;
  140948. /**
  140949. * Not supported by GPUParticleSystem
  140950. * @param gradient defines the gradient to use (between 0 and 1)
  140951. * @param factor defines the emit rate value to affect to the specified gradient
  140952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140953. * @returns the current particle system
  140954. */
  140955. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140956. /**
  140957. * Not supported by GPUParticleSystem
  140958. * @param gradient defines the gradient to remove
  140959. * @returns the current particle system
  140960. */
  140961. removeEmitRateGradient(gradient: number): IParticleSystem;
  140962. /**
  140963. * Not supported by GPUParticleSystem
  140964. * @param gradient defines the gradient to use (between 0 and 1)
  140965. * @param factor defines the start size value to affect to the specified gradient
  140966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140967. * @returns the current particle system
  140968. */
  140969. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140970. /**
  140971. * Not supported by GPUParticleSystem
  140972. * @param gradient defines the gradient to remove
  140973. * @returns the current particle system
  140974. */
  140975. removeStartSizeGradient(gradient: number): IParticleSystem;
  140976. /**
  140977. * Not supported by GPUParticleSystem
  140978. * @param gradient defines the gradient to use (between 0 and 1)
  140979. * @param min defines the color remap minimal range
  140980. * @param max defines the color remap maximal range
  140981. * @returns the current particle system
  140982. */
  140983. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140984. /**
  140985. * Not supported by GPUParticleSystem
  140986. * @param gradient defines the gradient to remove
  140987. * @returns the current particle system
  140988. */
  140989. removeColorRemapGradient(): IParticleSystem;
  140990. /**
  140991. * Not supported by GPUParticleSystem
  140992. * @param gradient defines the gradient to use (between 0 and 1)
  140993. * @param min defines the alpha remap minimal range
  140994. * @param max defines the alpha remap maximal range
  140995. * @returns the current particle system
  140996. */
  140997. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140998. /**
  140999. * Not supported by GPUParticleSystem
  141000. * @param gradient defines the gradient to remove
  141001. * @returns the current particle system
  141002. */
  141003. removeAlphaRemapGradient(): IParticleSystem;
  141004. /**
  141005. * Not supported by GPUParticleSystem
  141006. * @param gradient defines the gradient to use (between 0 and 1)
  141007. * @param color defines the color to affect to the specified gradient
  141008. * @returns the current particle system
  141009. */
  141010. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  141011. /**
  141012. * Not supported by GPUParticleSystem
  141013. * @param gradient defines the gradient to remove
  141014. * @returns the current particle system
  141015. */
  141016. removeRampGradient(): IParticleSystem;
  141017. /**
  141018. * Not supported by GPUParticleSystem
  141019. * @returns the list of ramp gradients
  141020. */
  141021. getRampGradients(): Nullable<Array<Color3Gradient>>;
  141022. /**
  141023. * Not supported by GPUParticleSystem
  141024. * Gets or sets a boolean indicating that ramp gradients must be used
  141025. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  141026. */
  141027. get useRampGradients(): boolean;
  141028. set useRampGradients(value: boolean);
  141029. /**
  141030. * Not supported by GPUParticleSystem
  141031. * @param gradient defines the gradient to use (between 0 and 1)
  141032. * @param factor defines the life time factor to affect to the specified gradient
  141033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  141034. * @returns the current particle system
  141035. */
  141036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  141037. /**
  141038. * Not supported by GPUParticleSystem
  141039. * @param gradient defines the gradient to remove
  141040. * @returns the current particle system
  141041. */
  141042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  141043. /**
  141044. * Instantiates a GPU particle system.
  141045. * 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.
  141046. * @param name The name of the particle system
  141047. * @param options The options used to create the system
  141048. * @param scene The scene the particle system belongs to
  141049. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  141050. */
  141051. constructor(name: string, options: Partial<{
  141052. capacity: number;
  141053. randomTextureSize: number;
  141054. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  141055. protected _reset(): void;
  141056. private _createUpdateVAO;
  141057. private _createRenderVAO;
  141058. private _initialize;
  141059. /** @hidden */
  141060. _recreateUpdateEffect(): void;
  141061. /** @hidden */
  141062. _recreateRenderEffect(): void;
  141063. /**
  141064. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  141065. * @param preWarm defines if we are in the pre-warmimg phase
  141066. */
  141067. animate(preWarm?: boolean): void;
  141068. private _createFactorGradientTexture;
  141069. private _createSizeGradientTexture;
  141070. private _createAngularSpeedGradientTexture;
  141071. private _createVelocityGradientTexture;
  141072. private _createLimitVelocityGradientTexture;
  141073. private _createDragGradientTexture;
  141074. private _createColorGradientTexture;
  141075. /**
  141076. * Renders the particle system in its current state
  141077. * @param preWarm defines if the system should only update the particles but not render them
  141078. * @returns the current number of particles
  141079. */
  141080. render(preWarm?: boolean): number;
  141081. /**
  141082. * Rebuilds the particle system
  141083. */
  141084. rebuild(): void;
  141085. private _releaseBuffers;
  141086. private _releaseVAOs;
  141087. /**
  141088. * Disposes the particle system and free the associated resources
  141089. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  141090. */
  141091. dispose(disposeTexture?: boolean): void;
  141092. /**
  141093. * Clones the particle system.
  141094. * @param name The name of the cloned object
  141095. * @param newEmitter The new emitter to use
  141096. * @returns the cloned particle system
  141097. */
  141098. clone(name: string, newEmitter: any): GPUParticleSystem;
  141099. /**
  141100. * Serializes the particle system to a JSON object
  141101. * @param serializeTexture defines if the texture must be serialized as well
  141102. * @returns the JSON object
  141103. */
  141104. serialize(serializeTexture?: boolean): any;
  141105. /**
  141106. * Parses a JSON object to create a GPU particle system.
  141107. * @param parsedParticleSystem The JSON object to parse
  141108. * @param scene The scene to create the particle system in
  141109. * @param rootUrl The root url to use to load external dependencies like texture
  141110. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  141111. * @returns the parsed GPU particle system
  141112. */
  141113. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  141114. }
  141115. }
  141116. declare module BABYLON {
  141117. /**
  141118. * Represents a set of particle systems working together to create a specific effect
  141119. */
  141120. export class ParticleSystemSet implements IDisposable {
  141121. /**
  141122. * Gets or sets base Assets URL
  141123. */
  141124. static BaseAssetsUrl: string;
  141125. private _emitterCreationOptions;
  141126. private _emitterNode;
  141127. /**
  141128. * Gets the particle system list
  141129. */
  141130. systems: IParticleSystem[];
  141131. /**
  141132. * Gets the emitter node used with this set
  141133. */
  141134. get emitterNode(): Nullable<TransformNode>;
  141135. /**
  141136. * Creates a new emitter mesh as a sphere
  141137. * @param options defines the options used to create the sphere
  141138. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  141139. * @param scene defines the hosting scene
  141140. */
  141141. setEmitterAsSphere(options: {
  141142. diameter: number;
  141143. segments: number;
  141144. color: Color3;
  141145. }, renderingGroupId: number, scene: Scene): void;
  141146. /**
  141147. * Starts all particle systems of the set
  141148. * @param emitter defines an optional mesh to use as emitter for the particle systems
  141149. */
  141150. start(emitter?: AbstractMesh): void;
  141151. /**
  141152. * Release all associated resources
  141153. */
  141154. dispose(): void;
  141155. /**
  141156. * Serialize the set into a JSON compatible object
  141157. * @param serializeTexture defines if the texture must be serialized as well
  141158. * @returns a JSON compatible representation of the set
  141159. */
  141160. serialize(serializeTexture?: boolean): any;
  141161. /**
  141162. * Parse a new ParticleSystemSet from a serialized source
  141163. * @param data defines a JSON compatible representation of the set
  141164. * @param scene defines the hosting scene
  141165. * @param gpu defines if we want GPU particles or CPU particles
  141166. * @returns a new ParticleSystemSet
  141167. */
  141168. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  141169. }
  141170. }
  141171. declare module BABYLON {
  141172. /**
  141173. * This class is made for on one-liner static method to help creating particle system set.
  141174. */
  141175. export class ParticleHelper {
  141176. /**
  141177. * Gets or sets base Assets URL
  141178. */
  141179. static BaseAssetsUrl: string;
  141180. /** Define the Url to load snippets */
  141181. static SnippetUrl: string;
  141182. /**
  141183. * Create a default particle system that you can tweak
  141184. * @param emitter defines the emitter to use
  141185. * @param capacity defines the system capacity (default is 500 particles)
  141186. * @param scene defines the hosting scene
  141187. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  141188. * @returns the new Particle system
  141189. */
  141190. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  141191. /**
  141192. * This is the main static method (one-liner) of this helper to create different particle systems
  141193. * @param type This string represents the type to the particle system to create
  141194. * @param scene The scene where the particle system should live
  141195. * @param gpu If the system will use gpu
  141196. * @returns the ParticleSystemSet created
  141197. */
  141198. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  141199. /**
  141200. * Static function used to export a particle system to a ParticleSystemSet variable.
  141201. * Please note that the emitter shape is not exported
  141202. * @param systems defines the particle systems to export
  141203. * @returns the created particle system set
  141204. */
  141205. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  141206. /**
  141207. * Creates a particle system from a snippet saved in a remote file
  141208. * @param name defines the name of the particle system to create
  141209. * @param url defines the url to load from
  141210. * @param scene defines the hosting scene
  141211. * @param gpu If the system will use gpu
  141212. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141213. * @returns a promise that will resolve to the new particle system
  141214. */
  141215. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141216. /**
  141217. * Creates a particle system from a snippet saved by the particle system editor
  141218. * @param snippetId defines the snippet to load
  141219. * @param scene defines the hosting scene
  141220. * @param gpu If the system will use gpu
  141221. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141222. * @returns a promise that will resolve to the new particle system
  141223. */
  141224. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141225. }
  141226. }
  141227. declare module BABYLON {
  141228. interface Engine {
  141229. /**
  141230. * Create an effect to use with particle systems.
  141231. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  141232. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  141233. * @param uniformsNames defines a list of attribute names
  141234. * @param samplers defines an array of string used to represent textures
  141235. * @param defines defines the string containing the defines to use to compile the shaders
  141236. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  141237. * @param onCompiled defines a function to call when the effect creation is successful
  141238. * @param onError defines a function to call when the effect creation has failed
  141239. * @returns the new Effect
  141240. */
  141241. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  141242. }
  141243. interface Mesh {
  141244. /**
  141245. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  141246. * @returns an array of IParticleSystem
  141247. */
  141248. getEmittedParticleSystems(): IParticleSystem[];
  141249. /**
  141250. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  141251. * @returns an array of IParticleSystem
  141252. */
  141253. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  141254. }
  141255. /**
  141256. * @hidden
  141257. */
  141258. export var _IDoNeedToBeInTheBuild: number;
  141259. }
  141260. declare module BABYLON {
  141261. /** Defines the 4 color options */
  141262. export enum PointColor {
  141263. /** color value */
  141264. Color = 2,
  141265. /** uv value */
  141266. UV = 1,
  141267. /** random value */
  141268. Random = 0,
  141269. /** stated value */
  141270. Stated = 3
  141271. }
  141272. /**
  141273. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  141274. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  141275. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  141276. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  141277. *
  141278. * Full documentation here : TO BE ENTERED
  141279. */
  141280. export class PointsCloudSystem implements IDisposable {
  141281. /**
  141282. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  141283. * Example : var p = SPS.particles[i];
  141284. */
  141285. particles: CloudPoint[];
  141286. /**
  141287. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  141288. */
  141289. nbParticles: number;
  141290. /**
  141291. * This a counter for your own usage. It's not set by any SPS functions.
  141292. */
  141293. counter: number;
  141294. /**
  141295. * The PCS name. This name is also given to the underlying mesh.
  141296. */
  141297. name: string;
  141298. /**
  141299. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  141300. */
  141301. mesh: Mesh;
  141302. /**
  141303. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  141304. * Please read :
  141305. */
  141306. vars: any;
  141307. /**
  141308. * @hidden
  141309. */
  141310. _size: number;
  141311. private _scene;
  141312. private _promises;
  141313. private _positions;
  141314. private _indices;
  141315. private _normals;
  141316. private _colors;
  141317. private _uvs;
  141318. private _indices32;
  141319. private _positions32;
  141320. private _colors32;
  141321. private _uvs32;
  141322. private _updatable;
  141323. private _isVisibilityBoxLocked;
  141324. private _alwaysVisible;
  141325. private _groups;
  141326. private _groupCounter;
  141327. private _computeParticleColor;
  141328. private _computeParticleTexture;
  141329. private _computeParticleRotation;
  141330. private _computeBoundingBox;
  141331. private _isReady;
  141332. /**
  141333. * Creates a PCS (Points Cloud System) object
  141334. * @param name (String) is the PCS name, this will be the underlying mesh name
  141335. * @param pointSize (number) is the size for each point
  141336. * @param scene (Scene) is the scene in which the PCS is added
  141337. * @param options defines the options of the PCS e.g.
  141338. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  141339. */
  141340. constructor(name: string, pointSize: number, scene: Scene, options?: {
  141341. updatable?: boolean;
  141342. });
  141343. /**
  141344. * Builds the PCS underlying mesh. Returns a standard Mesh.
  141345. * If no points were added to the PCS, the returned mesh is just a single point.
  141346. * @returns a promise for the created mesh
  141347. */
  141348. buildMeshAsync(): Promise<Mesh>;
  141349. /**
  141350. * @hidden
  141351. */
  141352. private _buildMesh;
  141353. private _addParticle;
  141354. private _randomUnitVector;
  141355. private _getColorIndicesForCoord;
  141356. private _setPointsColorOrUV;
  141357. private _colorFromTexture;
  141358. private _calculateDensity;
  141359. /**
  141360. * Adds points to the PCS in random positions within a unit sphere
  141361. * @param nb (positive integer) the number of particles to be created from this model
  141362. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  141363. * @returns the number of groups in the system
  141364. */
  141365. addPoints(nb: number, pointFunction?: any): number;
  141366. /**
  141367. * Adds points to the PCS from the surface of the model shape
  141368. * @param mesh is any Mesh object that will be used as a surface model for the points
  141369. * @param nb (positive integer) the number of particles to be created from this model
  141370. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141371. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141372. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141373. * @returns the number of groups in the system
  141374. */
  141375. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141376. /**
  141377. * Adds points to the PCS inside the model shape
  141378. * @param mesh is any Mesh object that will be used as a surface model for the points
  141379. * @param nb (positive integer) the number of particles to be created from this model
  141380. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141381. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141382. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141383. * @returns the number of groups in the system
  141384. */
  141385. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141386. /**
  141387. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  141388. * This method calls `updateParticle()` for each particle of the SPS.
  141389. * For an animated SPS, it is usually called within the render loop.
  141390. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  141391. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  141392. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  141393. * @returns the PCS.
  141394. */
  141395. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  141396. /**
  141397. * Disposes the PCS.
  141398. */
  141399. dispose(): void;
  141400. /**
  141401. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  141402. * doc :
  141403. * @returns the PCS.
  141404. */
  141405. refreshVisibleSize(): PointsCloudSystem;
  141406. /**
  141407. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  141408. * @param size the size (float) of the visibility box
  141409. * note : this doesn't lock the PCS mesh bounding box.
  141410. * doc :
  141411. */
  141412. setVisibilityBox(size: number): void;
  141413. /**
  141414. * Gets whether the PCS is always visible or not
  141415. * doc :
  141416. */
  141417. get isAlwaysVisible(): boolean;
  141418. /**
  141419. * Sets the PCS as always visible or not
  141420. * doc :
  141421. */
  141422. set isAlwaysVisible(val: boolean);
  141423. /**
  141424. * Tells to `setParticles()` to compute the particle rotations or not
  141425. * Default value : false. The PCS is faster when it's set to false
  141426. * Note : particle rotations are only applied to parent particles
  141427. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  141428. */
  141429. set computeParticleRotation(val: boolean);
  141430. /**
  141431. * Tells to `setParticles()` to compute the particle colors or not.
  141432. * Default value : true. The PCS is faster when it's set to false.
  141433. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141434. */
  141435. set computeParticleColor(val: boolean);
  141436. set computeParticleTexture(val: boolean);
  141437. /**
  141438. * Gets if `setParticles()` computes the particle colors or not.
  141439. * Default value : false. The PCS is faster when it's set to false.
  141440. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141441. */
  141442. get computeParticleColor(): boolean;
  141443. /**
  141444. * Gets if `setParticles()` computes the particle textures or not.
  141445. * Default value : false. The PCS is faster when it's set to false.
  141446. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  141447. */
  141448. get computeParticleTexture(): boolean;
  141449. /**
  141450. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  141451. */
  141452. set computeBoundingBox(val: boolean);
  141453. /**
  141454. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  141455. */
  141456. get computeBoundingBox(): boolean;
  141457. /**
  141458. * This function does nothing. It may be overwritten to set all the particle first values.
  141459. * The PCS doesn't call this function, you may have to call it by your own.
  141460. * doc :
  141461. */
  141462. initParticles(): void;
  141463. /**
  141464. * This function does nothing. It may be overwritten to recycle a particle
  141465. * The PCS doesn't call this function, you can to call it
  141466. * doc :
  141467. * @param particle The particle to recycle
  141468. * @returns the recycled particle
  141469. */
  141470. recycleParticle(particle: CloudPoint): CloudPoint;
  141471. /**
  141472. * Updates a particle : this function should be overwritten by the user.
  141473. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  141474. * doc :
  141475. * @example : just set a particle position or velocity and recycle conditions
  141476. * @param particle The particle to update
  141477. * @returns the updated particle
  141478. */
  141479. updateParticle(particle: CloudPoint): CloudPoint;
  141480. /**
  141481. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  141482. * This does nothing and may be overwritten by the user.
  141483. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141484. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141485. * @param update the boolean update value actually passed to setParticles()
  141486. */
  141487. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141488. /**
  141489. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  141490. * This will be passed three parameters.
  141491. * This does nothing and may be overwritten by the user.
  141492. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141493. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141494. * @param update the boolean update value actually passed to setParticles()
  141495. */
  141496. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141497. }
  141498. }
  141499. declare module BABYLON {
  141500. /**
  141501. * Represents one particle of a points cloud system.
  141502. */
  141503. export class CloudPoint {
  141504. /**
  141505. * particle global index
  141506. */
  141507. idx: number;
  141508. /**
  141509. * The color of the particle
  141510. */
  141511. color: Nullable<Color4>;
  141512. /**
  141513. * The world space position of the particle.
  141514. */
  141515. position: Vector3;
  141516. /**
  141517. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  141518. */
  141519. rotation: Vector3;
  141520. /**
  141521. * The world space rotation quaternion of the particle.
  141522. */
  141523. rotationQuaternion: Nullable<Quaternion>;
  141524. /**
  141525. * The uv of the particle.
  141526. */
  141527. uv: Nullable<Vector2>;
  141528. /**
  141529. * The current speed of the particle.
  141530. */
  141531. velocity: Vector3;
  141532. /**
  141533. * The pivot point in the particle local space.
  141534. */
  141535. pivot: Vector3;
  141536. /**
  141537. * Must the particle be translated from its pivot point in its local space ?
  141538. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  141539. * Default : false
  141540. */
  141541. translateFromPivot: boolean;
  141542. /**
  141543. * Index of this particle in the global "positions" array (Internal use)
  141544. * @hidden
  141545. */
  141546. _pos: number;
  141547. /**
  141548. * @hidden Index of this particle in the global "indices" array (Internal use)
  141549. */
  141550. _ind: number;
  141551. /**
  141552. * Group this particle belongs to
  141553. */
  141554. _group: PointsGroup;
  141555. /**
  141556. * Group id of this particle
  141557. */
  141558. groupId: number;
  141559. /**
  141560. * Index of the particle in its group id (Internal use)
  141561. */
  141562. idxInGroup: number;
  141563. /**
  141564. * @hidden Particle BoundingInfo object (Internal use)
  141565. */
  141566. _boundingInfo: BoundingInfo;
  141567. /**
  141568. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  141569. */
  141570. _pcs: PointsCloudSystem;
  141571. /**
  141572. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  141573. */
  141574. _stillInvisible: boolean;
  141575. /**
  141576. * @hidden Last computed particle rotation matrix
  141577. */
  141578. _rotationMatrix: number[];
  141579. /**
  141580. * Parent particle Id, if any.
  141581. * Default null.
  141582. */
  141583. parentId: Nullable<number>;
  141584. /**
  141585. * @hidden Internal global position in the PCS.
  141586. */
  141587. _globalPosition: Vector3;
  141588. /**
  141589. * Creates a Point Cloud object.
  141590. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  141591. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  141592. * @param group (PointsGroup) is the group the particle belongs to
  141593. * @param groupId (integer) is the group identifier in the PCS.
  141594. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  141595. * @param pcs defines the PCS it is associated to
  141596. */
  141597. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  141598. /**
  141599. * get point size
  141600. */
  141601. get size(): Vector3;
  141602. /**
  141603. * Set point size
  141604. */
  141605. set size(scale: Vector3);
  141606. /**
  141607. * Legacy support, changed quaternion to rotationQuaternion
  141608. */
  141609. get quaternion(): Nullable<Quaternion>;
  141610. /**
  141611. * Legacy support, changed quaternion to rotationQuaternion
  141612. */
  141613. set quaternion(q: Nullable<Quaternion>);
  141614. /**
  141615. * Returns a boolean. True if the particle intersects a mesh, else false
  141616. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  141617. * @param target is the object (point or mesh) what the intersection is computed against
  141618. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  141619. * @returns true if it intersects
  141620. */
  141621. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  141622. /**
  141623. * get the rotation matrix of the particle
  141624. * @hidden
  141625. */
  141626. getRotationMatrix(m: Matrix): void;
  141627. }
  141628. /**
  141629. * Represents a group of points in a points cloud system
  141630. * * PCS internal tool, don't use it manually.
  141631. */
  141632. export class PointsGroup {
  141633. /**
  141634. * The group id
  141635. * @hidden
  141636. */
  141637. groupID: number;
  141638. /**
  141639. * image data for group (internal use)
  141640. * @hidden
  141641. */
  141642. _groupImageData: Nullable<ArrayBufferView>;
  141643. /**
  141644. * Image Width (internal use)
  141645. * @hidden
  141646. */
  141647. _groupImgWidth: number;
  141648. /**
  141649. * Image Height (internal use)
  141650. * @hidden
  141651. */
  141652. _groupImgHeight: number;
  141653. /**
  141654. * Custom position function (internal use)
  141655. * @hidden
  141656. */
  141657. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  141658. /**
  141659. * density per facet for surface points
  141660. * @hidden
  141661. */
  141662. _groupDensity: number[];
  141663. /**
  141664. * Only when points are colored by texture carries pointer to texture list array
  141665. * @hidden
  141666. */
  141667. _textureNb: number;
  141668. /**
  141669. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  141670. * PCS internal tool, don't use it manually.
  141671. * @hidden
  141672. */
  141673. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  141674. }
  141675. }
  141676. declare module BABYLON {
  141677. interface Scene {
  141678. /** @hidden (Backing field) */
  141679. _physicsEngine: Nullable<IPhysicsEngine>;
  141680. /** @hidden */
  141681. _physicsTimeAccumulator: number;
  141682. /**
  141683. * Gets the current physics engine
  141684. * @returns a IPhysicsEngine or null if none attached
  141685. */
  141686. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  141687. /**
  141688. * Enables physics to the current scene
  141689. * @param gravity defines the scene's gravity for the physics engine
  141690. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  141691. * @return a boolean indicating if the physics engine was initialized
  141692. */
  141693. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  141694. /**
  141695. * Disables and disposes the physics engine associated with the scene
  141696. */
  141697. disablePhysicsEngine(): void;
  141698. /**
  141699. * Gets a boolean indicating if there is an active physics engine
  141700. * @returns a boolean indicating if there is an active physics engine
  141701. */
  141702. isPhysicsEnabled(): boolean;
  141703. /**
  141704. * Deletes a physics compound impostor
  141705. * @param compound defines the compound to delete
  141706. */
  141707. deleteCompoundImpostor(compound: any): void;
  141708. /**
  141709. * An event triggered when physic simulation is about to be run
  141710. */
  141711. onBeforePhysicsObservable: Observable<Scene>;
  141712. /**
  141713. * An event triggered when physic simulation has been done
  141714. */
  141715. onAfterPhysicsObservable: Observable<Scene>;
  141716. }
  141717. interface AbstractMesh {
  141718. /** @hidden */
  141719. _physicsImpostor: Nullable<PhysicsImpostor>;
  141720. /**
  141721. * Gets or sets impostor used for physic simulation
  141722. * @see http://doc.babylonjs.com/features/physics_engine
  141723. */
  141724. physicsImpostor: Nullable<PhysicsImpostor>;
  141725. /**
  141726. * Gets the current physics impostor
  141727. * @see http://doc.babylonjs.com/features/physics_engine
  141728. * @returns a physics impostor or null
  141729. */
  141730. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  141731. /** Apply a physic impulse to the mesh
  141732. * @param force defines the force to apply
  141733. * @param contactPoint defines where to apply the force
  141734. * @returns the current mesh
  141735. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  141736. */
  141737. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  141738. /**
  141739. * Creates a physic joint between two meshes
  141740. * @param otherMesh defines the other mesh to use
  141741. * @param pivot1 defines the pivot to use on this mesh
  141742. * @param pivot2 defines the pivot to use on the other mesh
  141743. * @param options defines additional options (can be plugin dependent)
  141744. * @returns the current mesh
  141745. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  141746. */
  141747. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  141748. /** @hidden */
  141749. _disposePhysicsObserver: Nullable<Observer<Node>>;
  141750. }
  141751. /**
  141752. * Defines the physics engine scene component responsible to manage a physics engine
  141753. */
  141754. export class PhysicsEngineSceneComponent implements ISceneComponent {
  141755. /**
  141756. * The component name helpful to identify the component in the list of scene components.
  141757. */
  141758. readonly name: string;
  141759. /**
  141760. * The scene the component belongs to.
  141761. */
  141762. scene: Scene;
  141763. /**
  141764. * Creates a new instance of the component for the given scene
  141765. * @param scene Defines the scene to register the component in
  141766. */
  141767. constructor(scene: Scene);
  141768. /**
  141769. * Registers the component in a given scene
  141770. */
  141771. register(): void;
  141772. /**
  141773. * Rebuilds the elements related to this component in case of
  141774. * context lost for instance.
  141775. */
  141776. rebuild(): void;
  141777. /**
  141778. * Disposes the component and the associated ressources
  141779. */
  141780. dispose(): void;
  141781. }
  141782. }
  141783. declare module BABYLON {
  141784. /**
  141785. * A helper for physics simulations
  141786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141787. */
  141788. export class PhysicsHelper {
  141789. private _scene;
  141790. private _physicsEngine;
  141791. /**
  141792. * Initializes the Physics helper
  141793. * @param scene Babylon.js scene
  141794. */
  141795. constructor(scene: Scene);
  141796. /**
  141797. * Applies a radial explosion impulse
  141798. * @param origin the origin of the explosion
  141799. * @param radiusOrEventOptions the radius or the options of radial explosion
  141800. * @param strength the explosion strength
  141801. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141802. * @returns A physics radial explosion event, or null
  141803. */
  141804. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141805. /**
  141806. * Applies a radial explosion force
  141807. * @param origin the origin of the explosion
  141808. * @param radiusOrEventOptions the radius or the options of radial explosion
  141809. * @param strength the explosion strength
  141810. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141811. * @returns A physics radial explosion event, or null
  141812. */
  141813. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141814. /**
  141815. * Creates a gravitational field
  141816. * @param origin the origin of the explosion
  141817. * @param radiusOrEventOptions the radius or the options of radial explosion
  141818. * @param strength the explosion strength
  141819. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141820. * @returns A physics gravitational field event, or null
  141821. */
  141822. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  141823. /**
  141824. * Creates a physics updraft event
  141825. * @param origin the origin of the updraft
  141826. * @param radiusOrEventOptions the radius or the options of the updraft
  141827. * @param strength the strength of the updraft
  141828. * @param height the height of the updraft
  141829. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  141830. * @returns A physics updraft event, or null
  141831. */
  141832. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  141833. /**
  141834. * Creates a physics vortex event
  141835. * @param origin the of the vortex
  141836. * @param radiusOrEventOptions the radius or the options of the vortex
  141837. * @param strength the strength of the vortex
  141838. * @param height the height of the vortex
  141839. * @returns a Physics vortex event, or null
  141840. * A physics vortex event or null
  141841. */
  141842. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  141843. }
  141844. /**
  141845. * Represents a physics radial explosion event
  141846. */
  141847. class PhysicsRadialExplosionEvent {
  141848. private _scene;
  141849. private _options;
  141850. private _sphere;
  141851. private _dataFetched;
  141852. /**
  141853. * Initializes a radial explosioin event
  141854. * @param _scene BabylonJS scene
  141855. * @param _options The options for the vortex event
  141856. */
  141857. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  141858. /**
  141859. * Returns the data related to the radial explosion event (sphere).
  141860. * @returns The radial explosion event data
  141861. */
  141862. getData(): PhysicsRadialExplosionEventData;
  141863. /**
  141864. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  141865. * @param impostor A physics imposter
  141866. * @param origin the origin of the explosion
  141867. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  141868. */
  141869. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  141870. /**
  141871. * Triggers affecterd impostors callbacks
  141872. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  141873. */
  141874. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  141875. /**
  141876. * Disposes the sphere.
  141877. * @param force Specifies if the sphere should be disposed by force
  141878. */
  141879. dispose(force?: boolean): void;
  141880. /*** Helpers ***/
  141881. private _prepareSphere;
  141882. private _intersectsWithSphere;
  141883. }
  141884. /**
  141885. * Represents a gravitational field event
  141886. */
  141887. class PhysicsGravitationalFieldEvent {
  141888. private _physicsHelper;
  141889. private _scene;
  141890. private _origin;
  141891. private _options;
  141892. private _tickCallback;
  141893. private _sphere;
  141894. private _dataFetched;
  141895. /**
  141896. * Initializes the physics gravitational field event
  141897. * @param _physicsHelper A physics helper
  141898. * @param _scene BabylonJS scene
  141899. * @param _origin The origin position of the gravitational field event
  141900. * @param _options The options for the vortex event
  141901. */
  141902. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  141903. /**
  141904. * Returns the data related to the gravitational field event (sphere).
  141905. * @returns A gravitational field event
  141906. */
  141907. getData(): PhysicsGravitationalFieldEventData;
  141908. /**
  141909. * Enables the gravitational field.
  141910. */
  141911. enable(): void;
  141912. /**
  141913. * Disables the gravitational field.
  141914. */
  141915. disable(): void;
  141916. /**
  141917. * Disposes the sphere.
  141918. * @param force The force to dispose from the gravitational field event
  141919. */
  141920. dispose(force?: boolean): void;
  141921. private _tick;
  141922. }
  141923. /**
  141924. * Represents a physics updraft event
  141925. */
  141926. class PhysicsUpdraftEvent {
  141927. private _scene;
  141928. private _origin;
  141929. private _options;
  141930. private _physicsEngine;
  141931. private _originTop;
  141932. private _originDirection;
  141933. private _tickCallback;
  141934. private _cylinder;
  141935. private _cylinderPosition;
  141936. private _dataFetched;
  141937. /**
  141938. * Initializes the physics updraft event
  141939. * @param _scene BabylonJS scene
  141940. * @param _origin The origin position of the updraft
  141941. * @param _options The options for the updraft event
  141942. */
  141943. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  141944. /**
  141945. * Returns the data related to the updraft event (cylinder).
  141946. * @returns A physics updraft event
  141947. */
  141948. getData(): PhysicsUpdraftEventData;
  141949. /**
  141950. * Enables the updraft.
  141951. */
  141952. enable(): void;
  141953. /**
  141954. * Disables the updraft.
  141955. */
  141956. disable(): void;
  141957. /**
  141958. * Disposes the cylinder.
  141959. * @param force Specifies if the updraft should be disposed by force
  141960. */
  141961. dispose(force?: boolean): void;
  141962. private getImpostorHitData;
  141963. private _tick;
  141964. /*** Helpers ***/
  141965. private _prepareCylinder;
  141966. private _intersectsWithCylinder;
  141967. }
  141968. /**
  141969. * Represents a physics vortex event
  141970. */
  141971. class PhysicsVortexEvent {
  141972. private _scene;
  141973. private _origin;
  141974. private _options;
  141975. private _physicsEngine;
  141976. private _originTop;
  141977. private _tickCallback;
  141978. private _cylinder;
  141979. private _cylinderPosition;
  141980. private _dataFetched;
  141981. /**
  141982. * Initializes the physics vortex event
  141983. * @param _scene The BabylonJS scene
  141984. * @param _origin The origin position of the vortex
  141985. * @param _options The options for the vortex event
  141986. */
  141987. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  141988. /**
  141989. * Returns the data related to the vortex event (cylinder).
  141990. * @returns The physics vortex event data
  141991. */
  141992. getData(): PhysicsVortexEventData;
  141993. /**
  141994. * Enables the vortex.
  141995. */
  141996. enable(): void;
  141997. /**
  141998. * Disables the cortex.
  141999. */
  142000. disable(): void;
  142001. /**
  142002. * Disposes the sphere.
  142003. * @param force
  142004. */
  142005. dispose(force?: boolean): void;
  142006. private getImpostorHitData;
  142007. private _tick;
  142008. /*** Helpers ***/
  142009. private _prepareCylinder;
  142010. private _intersectsWithCylinder;
  142011. }
  142012. /**
  142013. * Options fot the radial explosion event
  142014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142015. */
  142016. export class PhysicsRadialExplosionEventOptions {
  142017. /**
  142018. * The radius of the sphere for the radial explosion.
  142019. */
  142020. radius: number;
  142021. /**
  142022. * The strenth of the explosion.
  142023. */
  142024. strength: number;
  142025. /**
  142026. * The strenght of the force in correspondence to the distance of the affected object
  142027. */
  142028. falloff: PhysicsRadialImpulseFalloff;
  142029. /**
  142030. * Sphere options for the radial explosion.
  142031. */
  142032. sphere: {
  142033. segments: number;
  142034. diameter: number;
  142035. };
  142036. /**
  142037. * Sphere options for the radial explosion.
  142038. */
  142039. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  142040. }
  142041. /**
  142042. * Options fot the updraft event
  142043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142044. */
  142045. export class PhysicsUpdraftEventOptions {
  142046. /**
  142047. * The radius of the cylinder for the vortex
  142048. */
  142049. radius: number;
  142050. /**
  142051. * The strenth of the updraft.
  142052. */
  142053. strength: number;
  142054. /**
  142055. * The height of the cylinder for the updraft.
  142056. */
  142057. height: number;
  142058. /**
  142059. * The mode for the the updraft.
  142060. */
  142061. updraftMode: PhysicsUpdraftMode;
  142062. }
  142063. /**
  142064. * Options fot the vortex event
  142065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142066. */
  142067. export class PhysicsVortexEventOptions {
  142068. /**
  142069. * The radius of the cylinder for the vortex
  142070. */
  142071. radius: number;
  142072. /**
  142073. * The strenth of the vortex.
  142074. */
  142075. strength: number;
  142076. /**
  142077. * The height of the cylinder for the vortex.
  142078. */
  142079. height: number;
  142080. /**
  142081. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  142082. */
  142083. centripetalForceThreshold: number;
  142084. /**
  142085. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  142086. */
  142087. centripetalForceMultiplier: number;
  142088. /**
  142089. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  142090. */
  142091. centrifugalForceMultiplier: number;
  142092. /**
  142093. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  142094. */
  142095. updraftForceMultiplier: number;
  142096. }
  142097. /**
  142098. * The strenght of the force in correspondence to the distance of the affected object
  142099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142100. */
  142101. export enum PhysicsRadialImpulseFalloff {
  142102. /** Defines that impulse is constant in strength across it's whole radius */
  142103. Constant = 0,
  142104. /** Defines that impulse gets weaker if it's further from the origin */
  142105. Linear = 1
  142106. }
  142107. /**
  142108. * The strength of the force in correspondence to the distance of the affected object
  142109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142110. */
  142111. export enum PhysicsUpdraftMode {
  142112. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  142113. Center = 0,
  142114. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  142115. Perpendicular = 1
  142116. }
  142117. /**
  142118. * Interface for a physics hit data
  142119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142120. */
  142121. export interface PhysicsHitData {
  142122. /**
  142123. * The force applied at the contact point
  142124. */
  142125. force: Vector3;
  142126. /**
  142127. * The contact point
  142128. */
  142129. contactPoint: Vector3;
  142130. /**
  142131. * The distance from the origin to the contact point
  142132. */
  142133. distanceFromOrigin: number;
  142134. }
  142135. /**
  142136. * Interface for radial explosion event data
  142137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142138. */
  142139. export interface PhysicsRadialExplosionEventData {
  142140. /**
  142141. * A sphere used for the radial explosion event
  142142. */
  142143. sphere: Mesh;
  142144. }
  142145. /**
  142146. * Interface for gravitational field event data
  142147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142148. */
  142149. export interface PhysicsGravitationalFieldEventData {
  142150. /**
  142151. * A sphere mesh used for the gravitational field event
  142152. */
  142153. sphere: Mesh;
  142154. }
  142155. /**
  142156. * Interface for updraft event data
  142157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142158. */
  142159. export interface PhysicsUpdraftEventData {
  142160. /**
  142161. * A cylinder used for the updraft event
  142162. */
  142163. cylinder: Mesh;
  142164. }
  142165. /**
  142166. * Interface for vortex event data
  142167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142168. */
  142169. export interface PhysicsVortexEventData {
  142170. /**
  142171. * A cylinder used for the vortex event
  142172. */
  142173. cylinder: Mesh;
  142174. }
  142175. /**
  142176. * Interface for an affected physics impostor
  142177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142178. */
  142179. export interface PhysicsAffectedImpostorWithData {
  142180. /**
  142181. * The impostor affected by the effect
  142182. */
  142183. impostor: PhysicsImpostor;
  142184. /**
  142185. * The data about the hit/horce from the explosion
  142186. */
  142187. hitData: PhysicsHitData;
  142188. }
  142189. }
  142190. declare module BABYLON {
  142191. /** @hidden */
  142192. export var blackAndWhitePixelShader: {
  142193. name: string;
  142194. shader: string;
  142195. };
  142196. }
  142197. declare module BABYLON {
  142198. /**
  142199. * Post process used to render in black and white
  142200. */
  142201. export class BlackAndWhitePostProcess extends PostProcess {
  142202. /**
  142203. * Linear about to convert he result to black and white (default: 1)
  142204. */
  142205. degree: number;
  142206. /**
  142207. * Creates a black and white post process
  142208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  142209. * @param name The name of the effect.
  142210. * @param options The required width/height ratio to downsize to before computing the render pass.
  142211. * @param camera The camera to apply the render pass to.
  142212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142213. * @param engine The engine which the post process will be applied. (default: current engine)
  142214. * @param reusable If the post process can be reused on the same frame. (default: false)
  142215. */
  142216. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142217. }
  142218. }
  142219. declare module BABYLON {
  142220. /**
  142221. * This represents a set of one or more post processes in Babylon.
  142222. * A post process can be used to apply a shader to a texture after it is rendered.
  142223. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142224. */
  142225. export class PostProcessRenderEffect {
  142226. private _postProcesses;
  142227. private _getPostProcesses;
  142228. private _singleInstance;
  142229. private _cameras;
  142230. private _indicesForCamera;
  142231. /**
  142232. * Name of the effect
  142233. * @hidden
  142234. */
  142235. _name: string;
  142236. /**
  142237. * Instantiates a post process render effect.
  142238. * A post process can be used to apply a shader to a texture after it is rendered.
  142239. * @param engine The engine the effect is tied to
  142240. * @param name The name of the effect
  142241. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  142242. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  142243. */
  142244. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  142245. /**
  142246. * Checks if all the post processes in the effect are supported.
  142247. */
  142248. get isSupported(): boolean;
  142249. /**
  142250. * Updates the current state of the effect
  142251. * @hidden
  142252. */
  142253. _update(): void;
  142254. /**
  142255. * Attaches the effect on cameras
  142256. * @param cameras The camera to attach to.
  142257. * @hidden
  142258. */
  142259. _attachCameras(cameras: Camera): void;
  142260. /**
  142261. * Attaches the effect on cameras
  142262. * @param cameras The camera to attach to.
  142263. * @hidden
  142264. */
  142265. _attachCameras(cameras: Camera[]): void;
  142266. /**
  142267. * Detaches the effect on cameras
  142268. * @param cameras The camera to detatch from.
  142269. * @hidden
  142270. */
  142271. _detachCameras(cameras: Camera): void;
  142272. /**
  142273. * Detatches the effect on cameras
  142274. * @param cameras The camera to detatch from.
  142275. * @hidden
  142276. */
  142277. _detachCameras(cameras: Camera[]): void;
  142278. /**
  142279. * Enables the effect on given cameras
  142280. * @param cameras The camera to enable.
  142281. * @hidden
  142282. */
  142283. _enable(cameras: Camera): void;
  142284. /**
  142285. * Enables the effect on given cameras
  142286. * @param cameras The camera to enable.
  142287. * @hidden
  142288. */
  142289. _enable(cameras: Nullable<Camera[]>): void;
  142290. /**
  142291. * Disables the effect on the given cameras
  142292. * @param cameras The camera to disable.
  142293. * @hidden
  142294. */
  142295. _disable(cameras: Camera): void;
  142296. /**
  142297. * Disables the effect on the given cameras
  142298. * @param cameras The camera to disable.
  142299. * @hidden
  142300. */
  142301. _disable(cameras: Nullable<Camera[]>): void;
  142302. /**
  142303. * Gets a list of the post processes contained in the effect.
  142304. * @param camera The camera to get the post processes on.
  142305. * @returns The list of the post processes in the effect.
  142306. */
  142307. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  142308. }
  142309. }
  142310. declare module BABYLON {
  142311. /** @hidden */
  142312. export var extractHighlightsPixelShader: {
  142313. name: string;
  142314. shader: string;
  142315. };
  142316. }
  142317. declare module BABYLON {
  142318. /**
  142319. * 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.
  142320. */
  142321. export class ExtractHighlightsPostProcess extends PostProcess {
  142322. /**
  142323. * The luminance threshold, pixels below this value will be set to black.
  142324. */
  142325. threshold: number;
  142326. /** @hidden */
  142327. _exposure: number;
  142328. /**
  142329. * Post process which has the input texture to be used when performing highlight extraction
  142330. * @hidden
  142331. */
  142332. _inputPostProcess: Nullable<PostProcess>;
  142333. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142334. }
  142335. }
  142336. declare module BABYLON {
  142337. /** @hidden */
  142338. export var bloomMergePixelShader: {
  142339. name: string;
  142340. shader: string;
  142341. };
  142342. }
  142343. declare module BABYLON {
  142344. /**
  142345. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142346. */
  142347. export class BloomMergePostProcess extends PostProcess {
  142348. /** Weight of the bloom to be added to the original input. */
  142349. weight: number;
  142350. /**
  142351. * Creates a new instance of @see BloomMergePostProcess
  142352. * @param name The name of the effect.
  142353. * @param originalFromInput Post process which's input will be used for the merge.
  142354. * @param blurred Blurred highlights post process which's output will be used.
  142355. * @param weight Weight of the bloom to be added to the original input.
  142356. * @param options The required width/height ratio to downsize to before computing the render pass.
  142357. * @param camera The camera to apply the render pass to.
  142358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142359. * @param engine The engine which the post process will be applied. (default: current engine)
  142360. * @param reusable If the post process can be reused on the same frame. (default: false)
  142361. * @param textureType Type of textures used when performing the post process. (default: 0)
  142362. * @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)
  142363. */
  142364. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  142365. /** Weight of the bloom to be added to the original input. */
  142366. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142367. }
  142368. }
  142369. declare module BABYLON {
  142370. /**
  142371. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  142372. */
  142373. export class BloomEffect extends PostProcessRenderEffect {
  142374. private bloomScale;
  142375. /**
  142376. * @hidden Internal
  142377. */
  142378. _effects: Array<PostProcess>;
  142379. /**
  142380. * @hidden Internal
  142381. */
  142382. _downscale: ExtractHighlightsPostProcess;
  142383. private _blurX;
  142384. private _blurY;
  142385. private _merge;
  142386. /**
  142387. * The luminance threshold to find bright areas of the image to bloom.
  142388. */
  142389. get threshold(): number;
  142390. set threshold(value: number);
  142391. /**
  142392. * The strength of the bloom.
  142393. */
  142394. get weight(): number;
  142395. set weight(value: number);
  142396. /**
  142397. * Specifies the size of the bloom blur kernel, relative to the final output size
  142398. */
  142399. get kernel(): number;
  142400. set kernel(value: number);
  142401. /**
  142402. * Creates a new instance of @see BloomEffect
  142403. * @param scene The scene the effect belongs to.
  142404. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  142405. * @param bloomKernel The size of the kernel to be used when applying the blur.
  142406. * @param bloomWeight The the strength of bloom.
  142407. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142408. * @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)
  142409. */
  142410. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  142411. /**
  142412. * Disposes each of the internal effects for a given camera.
  142413. * @param camera The camera to dispose the effect on.
  142414. */
  142415. disposeEffects(camera: Camera): void;
  142416. /**
  142417. * @hidden Internal
  142418. */
  142419. _updateEffects(): void;
  142420. /**
  142421. * Internal
  142422. * @returns if all the contained post processes are ready.
  142423. * @hidden
  142424. */
  142425. _isReady(): boolean;
  142426. }
  142427. }
  142428. declare module BABYLON {
  142429. /** @hidden */
  142430. export var chromaticAberrationPixelShader: {
  142431. name: string;
  142432. shader: string;
  142433. };
  142434. }
  142435. declare module BABYLON {
  142436. /**
  142437. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  142438. */
  142439. export class ChromaticAberrationPostProcess extends PostProcess {
  142440. /**
  142441. * The amount of seperation of rgb channels (default: 30)
  142442. */
  142443. aberrationAmount: number;
  142444. /**
  142445. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  142446. */
  142447. radialIntensity: number;
  142448. /**
  142449. * 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))
  142450. */
  142451. direction: Vector2;
  142452. /**
  142453. * 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))
  142454. */
  142455. centerPosition: Vector2;
  142456. /**
  142457. * Creates a new instance ChromaticAberrationPostProcess
  142458. * @param name The name of the effect.
  142459. * @param screenWidth The width of the screen to apply the effect on.
  142460. * @param screenHeight The height of the screen to apply the effect on.
  142461. * @param options The required width/height ratio to downsize to before computing the render pass.
  142462. * @param camera The camera to apply the render pass to.
  142463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142464. * @param engine The engine which the post process will be applied. (default: current engine)
  142465. * @param reusable If the post process can be reused on the same frame. (default: false)
  142466. * @param textureType Type of textures used when performing the post process. (default: 0)
  142467. * @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)
  142468. */
  142469. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142470. }
  142471. }
  142472. declare module BABYLON {
  142473. /** @hidden */
  142474. export var circleOfConfusionPixelShader: {
  142475. name: string;
  142476. shader: string;
  142477. };
  142478. }
  142479. declare module BABYLON {
  142480. /**
  142481. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  142482. */
  142483. export class CircleOfConfusionPostProcess extends PostProcess {
  142484. /**
  142485. * 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.
  142486. */
  142487. lensSize: number;
  142488. /**
  142489. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142490. */
  142491. fStop: number;
  142492. /**
  142493. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142494. */
  142495. focusDistance: number;
  142496. /**
  142497. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  142498. */
  142499. focalLength: number;
  142500. private _depthTexture;
  142501. /**
  142502. * Creates a new instance CircleOfConfusionPostProcess
  142503. * @param name The name of the effect.
  142504. * @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.
  142505. * @param options The required width/height ratio to downsize to before computing the render pass.
  142506. * @param camera The camera to apply the render pass to.
  142507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142508. * @param engine The engine which the post process will be applied. (default: current engine)
  142509. * @param reusable If the post process can be reused on the same frame. (default: false)
  142510. * @param textureType Type of textures used when performing the post process. (default: 0)
  142511. * @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)
  142512. */
  142513. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142514. /**
  142515. * 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.
  142516. */
  142517. set depthTexture(value: RenderTargetTexture);
  142518. }
  142519. }
  142520. declare module BABYLON {
  142521. /** @hidden */
  142522. export var colorCorrectionPixelShader: {
  142523. name: string;
  142524. shader: string;
  142525. };
  142526. }
  142527. declare module BABYLON {
  142528. /**
  142529. *
  142530. * This post-process allows the modification of rendered colors by using
  142531. * a 'look-up table' (LUT). This effect is also called Color Grading.
  142532. *
  142533. * The object needs to be provided an url to a texture containing the color
  142534. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  142535. * Use an image editing software to tweak the LUT to match your needs.
  142536. *
  142537. * For an example of a color LUT, see here:
  142538. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  142539. * For explanations on color grading, see here:
  142540. * @see http://udn.epicgames.com/Three/ColorGrading.html
  142541. *
  142542. */
  142543. export class ColorCorrectionPostProcess extends PostProcess {
  142544. private _colorTableTexture;
  142545. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142546. }
  142547. }
  142548. declare module BABYLON {
  142549. /** @hidden */
  142550. export var convolutionPixelShader: {
  142551. name: string;
  142552. shader: string;
  142553. };
  142554. }
  142555. declare module BABYLON {
  142556. /**
  142557. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  142558. * input texture to perform effects such as edge detection or sharpening
  142559. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142560. */
  142561. export class ConvolutionPostProcess extends PostProcess {
  142562. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142563. kernel: number[];
  142564. /**
  142565. * Creates a new instance ConvolutionPostProcess
  142566. * @param name The name of the effect.
  142567. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  142568. * @param options The required width/height ratio to downsize to before computing the render pass.
  142569. * @param camera The camera to apply the render pass to.
  142570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142571. * @param engine The engine which the post process will be applied. (default: current engine)
  142572. * @param reusable If the post process can be reused on the same frame. (default: false)
  142573. * @param textureType Type of textures used when performing the post process. (default: 0)
  142574. */
  142575. constructor(name: string,
  142576. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142577. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142578. /**
  142579. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142580. */
  142581. static EdgeDetect0Kernel: number[];
  142582. /**
  142583. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142584. */
  142585. static EdgeDetect1Kernel: number[];
  142586. /**
  142587. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142588. */
  142589. static EdgeDetect2Kernel: number[];
  142590. /**
  142591. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142592. */
  142593. static SharpenKernel: number[];
  142594. /**
  142595. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142596. */
  142597. static EmbossKernel: number[];
  142598. /**
  142599. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142600. */
  142601. static GaussianKernel: number[];
  142602. }
  142603. }
  142604. declare module BABYLON {
  142605. /**
  142606. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  142607. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  142608. * based on samples that have a large difference in distance than the center pixel.
  142609. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  142610. */
  142611. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  142612. direction: Vector2;
  142613. /**
  142614. * Creates a new instance CircleOfConfusionPostProcess
  142615. * @param name The name of the effect.
  142616. * @param scene The scene the effect belongs to.
  142617. * @param direction The direction the blur should be applied.
  142618. * @param kernel The size of the kernel used to blur.
  142619. * @param options The required width/height ratio to downsize to before computing the render pass.
  142620. * @param camera The camera to apply the render pass to.
  142621. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  142622. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  142623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142624. * @param engine The engine which the post process will be applied. (default: current engine)
  142625. * @param reusable If the post process can be reused on the same frame. (default: false)
  142626. * @param textureType Type of textures used when performing the post process. (default: 0)
  142627. * @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)
  142628. */
  142629. 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);
  142630. }
  142631. }
  142632. declare module BABYLON {
  142633. /** @hidden */
  142634. export var depthOfFieldMergePixelShader: {
  142635. name: string;
  142636. shader: string;
  142637. };
  142638. }
  142639. declare module BABYLON {
  142640. /**
  142641. * Options to be set when merging outputs from the default pipeline.
  142642. */
  142643. export class DepthOfFieldMergePostProcessOptions {
  142644. /**
  142645. * The original image to merge on top of
  142646. */
  142647. originalFromInput: PostProcess;
  142648. /**
  142649. * Parameters to perform the merge of the depth of field effect
  142650. */
  142651. depthOfField?: {
  142652. circleOfConfusion: PostProcess;
  142653. blurSteps: Array<PostProcess>;
  142654. };
  142655. /**
  142656. * Parameters to perform the merge of bloom effect
  142657. */
  142658. bloom?: {
  142659. blurred: PostProcess;
  142660. weight: number;
  142661. };
  142662. }
  142663. /**
  142664. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142665. */
  142666. export class DepthOfFieldMergePostProcess extends PostProcess {
  142667. private blurSteps;
  142668. /**
  142669. * Creates a new instance of DepthOfFieldMergePostProcess
  142670. * @param name The name of the effect.
  142671. * @param originalFromInput Post process which's input will be used for the merge.
  142672. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  142673. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  142674. * @param options The required width/height ratio to downsize to before computing the render pass.
  142675. * @param camera The camera to apply the render pass to.
  142676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142677. * @param engine The engine which the post process will be applied. (default: current engine)
  142678. * @param reusable If the post process can be reused on the same frame. (default: false)
  142679. * @param textureType Type of textures used when performing the post process. (default: 0)
  142680. * @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)
  142681. */
  142682. 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);
  142683. /**
  142684. * Updates the effect with the current post process compile time values and recompiles the shader.
  142685. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  142686. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  142687. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  142688. * @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
  142689. * @param onCompiled Called when the shader has been compiled.
  142690. * @param onError Called if there is an error when compiling a shader.
  142691. */
  142692. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  142693. }
  142694. }
  142695. declare module BABYLON {
  142696. /**
  142697. * Specifies the level of max blur that should be applied when using the depth of field effect
  142698. */
  142699. export enum DepthOfFieldEffectBlurLevel {
  142700. /**
  142701. * Subtle blur
  142702. */
  142703. Low = 0,
  142704. /**
  142705. * Medium blur
  142706. */
  142707. Medium = 1,
  142708. /**
  142709. * Large blur
  142710. */
  142711. High = 2
  142712. }
  142713. /**
  142714. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  142715. */
  142716. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  142717. private _circleOfConfusion;
  142718. /**
  142719. * @hidden Internal, blurs from high to low
  142720. */
  142721. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  142722. private _depthOfFieldBlurY;
  142723. private _dofMerge;
  142724. /**
  142725. * @hidden Internal post processes in depth of field effect
  142726. */
  142727. _effects: Array<PostProcess>;
  142728. /**
  142729. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  142730. */
  142731. set focalLength(value: number);
  142732. get focalLength(): number;
  142733. /**
  142734. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142735. */
  142736. set fStop(value: number);
  142737. get fStop(): number;
  142738. /**
  142739. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142740. */
  142741. set focusDistance(value: number);
  142742. get focusDistance(): number;
  142743. /**
  142744. * 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.
  142745. */
  142746. set lensSize(value: number);
  142747. get lensSize(): number;
  142748. /**
  142749. * Creates a new instance DepthOfFieldEffect
  142750. * @param scene The scene the effect belongs to.
  142751. * @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.
  142752. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142753. * @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)
  142754. */
  142755. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  142756. /**
  142757. * Get the current class name of the current effet
  142758. * @returns "DepthOfFieldEffect"
  142759. */
  142760. getClassName(): string;
  142761. /**
  142762. * 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.
  142763. */
  142764. set depthTexture(value: RenderTargetTexture);
  142765. /**
  142766. * Disposes each of the internal effects for a given camera.
  142767. * @param camera The camera to dispose the effect on.
  142768. */
  142769. disposeEffects(camera: Camera): void;
  142770. /**
  142771. * @hidden Internal
  142772. */
  142773. _updateEffects(): void;
  142774. /**
  142775. * Internal
  142776. * @returns if all the contained post processes are ready.
  142777. * @hidden
  142778. */
  142779. _isReady(): boolean;
  142780. }
  142781. }
  142782. declare module BABYLON {
  142783. /** @hidden */
  142784. export var displayPassPixelShader: {
  142785. name: string;
  142786. shader: string;
  142787. };
  142788. }
  142789. declare module BABYLON {
  142790. /**
  142791. * DisplayPassPostProcess which produces an output the same as it's input
  142792. */
  142793. export class DisplayPassPostProcess extends PostProcess {
  142794. /**
  142795. * Creates the DisplayPassPostProcess
  142796. * @param name The name of the effect.
  142797. * @param options The required width/height ratio to downsize to before computing the render pass.
  142798. * @param camera The camera to apply the render pass to.
  142799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142800. * @param engine The engine which the post process will be applied. (default: current engine)
  142801. * @param reusable If the post process can be reused on the same frame. (default: false)
  142802. */
  142803. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142804. }
  142805. }
  142806. declare module BABYLON {
  142807. /** @hidden */
  142808. export var filterPixelShader: {
  142809. name: string;
  142810. shader: string;
  142811. };
  142812. }
  142813. declare module BABYLON {
  142814. /**
  142815. * Applies a kernel filter to the image
  142816. */
  142817. export class FilterPostProcess extends PostProcess {
  142818. /** The matrix to be applied to the image */
  142819. kernelMatrix: Matrix;
  142820. /**
  142821. *
  142822. * @param name The name of the effect.
  142823. * @param kernelMatrix The matrix to be applied to the image
  142824. * @param options The required width/height ratio to downsize to before computing the render pass.
  142825. * @param camera The camera to apply the render pass to.
  142826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142827. * @param engine The engine which the post process will be applied. (default: current engine)
  142828. * @param reusable If the post process can be reused on the same frame. (default: false)
  142829. */
  142830. constructor(name: string,
  142831. /** The matrix to be applied to the image */
  142832. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142833. }
  142834. }
  142835. declare module BABYLON {
  142836. /** @hidden */
  142837. export var fxaaPixelShader: {
  142838. name: string;
  142839. shader: string;
  142840. };
  142841. }
  142842. declare module BABYLON {
  142843. /** @hidden */
  142844. export var fxaaVertexShader: {
  142845. name: string;
  142846. shader: string;
  142847. };
  142848. }
  142849. declare module BABYLON {
  142850. /**
  142851. * Fxaa post process
  142852. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  142853. */
  142854. export class FxaaPostProcess extends PostProcess {
  142855. /** @hidden */
  142856. texelWidth: number;
  142857. /** @hidden */
  142858. texelHeight: number;
  142859. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142860. private _getDefines;
  142861. }
  142862. }
  142863. declare module BABYLON {
  142864. /** @hidden */
  142865. export var grainPixelShader: {
  142866. name: string;
  142867. shader: string;
  142868. };
  142869. }
  142870. declare module BABYLON {
  142871. /**
  142872. * The GrainPostProcess adds noise to the image at mid luminance levels
  142873. */
  142874. export class GrainPostProcess extends PostProcess {
  142875. /**
  142876. * The intensity of the grain added (default: 30)
  142877. */
  142878. intensity: number;
  142879. /**
  142880. * If the grain should be randomized on every frame
  142881. */
  142882. animated: boolean;
  142883. /**
  142884. * Creates a new instance of @see GrainPostProcess
  142885. * @param name The name of the effect.
  142886. * @param options The required width/height ratio to downsize to before computing the render pass.
  142887. * @param camera The camera to apply the render pass to.
  142888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142889. * @param engine The engine which the post process will be applied. (default: current engine)
  142890. * @param reusable If the post process can be reused on the same frame. (default: false)
  142891. * @param textureType Type of textures used when performing the post process. (default: 0)
  142892. * @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)
  142893. */
  142894. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142895. }
  142896. }
  142897. declare module BABYLON {
  142898. /** @hidden */
  142899. export var highlightsPixelShader: {
  142900. name: string;
  142901. shader: string;
  142902. };
  142903. }
  142904. declare module BABYLON {
  142905. /**
  142906. * Extracts highlights from the image
  142907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142908. */
  142909. export class HighlightsPostProcess extends PostProcess {
  142910. /**
  142911. * Extracts highlights from the image
  142912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142913. * @param name The name of the effect.
  142914. * @param options The required width/height ratio to downsize to before computing the render pass.
  142915. * @param camera The camera to apply the render pass to.
  142916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142917. * @param engine The engine which the post process will be applied. (default: current engine)
  142918. * @param reusable If the post process can be reused on the same frame. (default: false)
  142919. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  142920. */
  142921. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142922. }
  142923. }
  142924. declare module BABYLON {
  142925. /** @hidden */
  142926. export var mrtFragmentDeclaration: {
  142927. name: string;
  142928. shader: string;
  142929. };
  142930. }
  142931. declare module BABYLON {
  142932. /** @hidden */
  142933. export var geometryPixelShader: {
  142934. name: string;
  142935. shader: string;
  142936. };
  142937. }
  142938. declare module BABYLON {
  142939. /** @hidden */
  142940. export var geometryVertexShader: {
  142941. name: string;
  142942. shader: string;
  142943. };
  142944. }
  142945. declare module BABYLON {
  142946. /** @hidden */
  142947. interface ISavedTransformationMatrix {
  142948. world: Matrix;
  142949. viewProjection: Matrix;
  142950. }
  142951. /**
  142952. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  142953. */
  142954. export class GeometryBufferRenderer {
  142955. /**
  142956. * Constant used to retrieve the position texture index in the G-Buffer textures array
  142957. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  142958. */
  142959. static readonly POSITION_TEXTURE_TYPE: number;
  142960. /**
  142961. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  142962. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  142963. */
  142964. static readonly VELOCITY_TEXTURE_TYPE: number;
  142965. /**
  142966. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  142967. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  142968. */
  142969. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  142970. /**
  142971. * Dictionary used to store the previous transformation matrices of each rendered mesh
  142972. * in order to compute objects velocities when enableVelocity is set to "true"
  142973. * @hidden
  142974. */
  142975. _previousTransformationMatrices: {
  142976. [index: number]: ISavedTransformationMatrix;
  142977. };
  142978. /**
  142979. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  142980. * in order to compute objects velocities when enableVelocity is set to "true"
  142981. * @hidden
  142982. */
  142983. _previousBonesTransformationMatrices: {
  142984. [index: number]: Float32Array;
  142985. };
  142986. /**
  142987. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  142988. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  142989. */
  142990. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  142991. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  142992. renderTransparentMeshes: boolean;
  142993. private _scene;
  142994. private _multiRenderTarget;
  142995. private _ratio;
  142996. private _enablePosition;
  142997. private _enableVelocity;
  142998. private _enableReflectivity;
  142999. private _positionIndex;
  143000. private _velocityIndex;
  143001. private _reflectivityIndex;
  143002. protected _effect: Effect;
  143003. protected _cachedDefines: string;
  143004. /**
  143005. * Set the render list (meshes to be rendered) used in the G buffer.
  143006. */
  143007. set renderList(meshes: Mesh[]);
  143008. /**
  143009. * Gets wether or not G buffer are supported by the running hardware.
  143010. * This requires draw buffer supports
  143011. */
  143012. get isSupported(): boolean;
  143013. /**
  143014. * Returns the index of the given texture type in the G-Buffer textures array
  143015. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  143016. * @returns the index of the given texture type in the G-Buffer textures array
  143017. */
  143018. getTextureIndex(textureType: number): number;
  143019. /**
  143020. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  143021. */
  143022. get enablePosition(): boolean;
  143023. /**
  143024. * Sets whether or not objects positions are enabled for the G buffer.
  143025. */
  143026. set enablePosition(enable: boolean);
  143027. /**
  143028. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  143029. */
  143030. get enableVelocity(): boolean;
  143031. /**
  143032. * Sets wether or not objects velocities are enabled for the G buffer.
  143033. */
  143034. set enableVelocity(enable: boolean);
  143035. /**
  143036. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  143037. */
  143038. get enableReflectivity(): boolean;
  143039. /**
  143040. * Sets wether or not objects roughness are enabled for the G buffer.
  143041. */
  143042. set enableReflectivity(enable: boolean);
  143043. /**
  143044. * Gets the scene associated with the buffer.
  143045. */
  143046. get scene(): Scene;
  143047. /**
  143048. * Gets the ratio used by the buffer during its creation.
  143049. * How big is the buffer related to the main canvas.
  143050. */
  143051. get ratio(): number;
  143052. /** @hidden */
  143053. static _SceneComponentInitialization: (scene: Scene) => void;
  143054. /**
  143055. * Creates a new G Buffer for the scene
  143056. * @param scene The scene the buffer belongs to
  143057. * @param ratio How big is the buffer related to the main canvas.
  143058. */
  143059. constructor(scene: Scene, ratio?: number);
  143060. /**
  143061. * Checks wether everything is ready to render a submesh to the G buffer.
  143062. * @param subMesh the submesh to check readiness for
  143063. * @param useInstances is the mesh drawn using instance or not
  143064. * @returns true if ready otherwise false
  143065. */
  143066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  143067. /**
  143068. * Gets the current underlying G Buffer.
  143069. * @returns the buffer
  143070. */
  143071. getGBuffer(): MultiRenderTarget;
  143072. /**
  143073. * Gets the number of samples used to render the buffer (anti aliasing).
  143074. */
  143075. get samples(): number;
  143076. /**
  143077. * Sets the number of samples used to render the buffer (anti aliasing).
  143078. */
  143079. set samples(value: number);
  143080. /**
  143081. * Disposes the renderer and frees up associated resources.
  143082. */
  143083. dispose(): void;
  143084. protected _createRenderTargets(): void;
  143085. private _copyBonesTransformationMatrices;
  143086. }
  143087. }
  143088. declare module BABYLON {
  143089. interface Scene {
  143090. /** @hidden (Backing field) */
  143091. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  143092. /**
  143093. * Gets or Sets the current geometry buffer associated to the scene.
  143094. */
  143095. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  143096. /**
  143097. * Enables a GeometryBufferRender and associates it with the scene
  143098. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  143099. * @returns the GeometryBufferRenderer
  143100. */
  143101. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  143102. /**
  143103. * Disables the GeometryBufferRender associated with the scene
  143104. */
  143105. disableGeometryBufferRenderer(): void;
  143106. }
  143107. /**
  143108. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  143109. * in several rendering techniques.
  143110. */
  143111. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  143112. /**
  143113. * The component name helpful to identify the component in the list of scene components.
  143114. */
  143115. readonly name: string;
  143116. /**
  143117. * The scene the component belongs to.
  143118. */
  143119. scene: Scene;
  143120. /**
  143121. * Creates a new instance of the component for the given scene
  143122. * @param scene Defines the scene to register the component in
  143123. */
  143124. constructor(scene: Scene);
  143125. /**
  143126. * Registers the component in a given scene
  143127. */
  143128. register(): void;
  143129. /**
  143130. * Rebuilds the elements related to this component in case of
  143131. * context lost for instance.
  143132. */
  143133. rebuild(): void;
  143134. /**
  143135. * Disposes the component and the associated ressources
  143136. */
  143137. dispose(): void;
  143138. private _gatherRenderTargets;
  143139. }
  143140. }
  143141. declare module BABYLON {
  143142. /** @hidden */
  143143. export var motionBlurPixelShader: {
  143144. name: string;
  143145. shader: string;
  143146. };
  143147. }
  143148. declare module BABYLON {
  143149. /**
  143150. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  143151. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  143152. * As an example, all you have to do is to create the post-process:
  143153. * var mb = new BABYLON.MotionBlurPostProcess(
  143154. * 'mb', // The name of the effect.
  143155. * scene, // The scene containing the objects to blur according to their velocity.
  143156. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  143157. * camera // The camera to apply the render pass to.
  143158. * );
  143159. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  143160. */
  143161. export class MotionBlurPostProcess extends PostProcess {
  143162. /**
  143163. * Defines how much the image is blurred by the movement. Default value is equal to 1
  143164. */
  143165. motionStrength: number;
  143166. /**
  143167. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  143168. */
  143169. get motionBlurSamples(): number;
  143170. /**
  143171. * Sets the number of iterations to be used for motion blur quality
  143172. */
  143173. set motionBlurSamples(samples: number);
  143174. private _motionBlurSamples;
  143175. private _geometryBufferRenderer;
  143176. /**
  143177. * Creates a new instance MotionBlurPostProcess
  143178. * @param name The name of the effect.
  143179. * @param scene The scene containing the objects to blur according to their velocity.
  143180. * @param options The required width/height ratio to downsize to before computing the render pass.
  143181. * @param camera The camera to apply the render pass to.
  143182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143183. * @param engine The engine which the post process will be applied. (default: current engine)
  143184. * @param reusable If the post process can be reused on the same frame. (default: false)
  143185. * @param textureType Type of textures used when performing the post process. (default: 0)
  143186. * @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)
  143187. */
  143188. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143189. /**
  143190. * Excludes the given skinned mesh from computing bones velocities.
  143191. * 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.
  143192. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  143193. */
  143194. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143195. /**
  143196. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  143197. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  143198. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  143199. */
  143200. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143201. /**
  143202. * Disposes the post process.
  143203. * @param camera The camera to dispose the post process on.
  143204. */
  143205. dispose(camera?: Camera): void;
  143206. }
  143207. }
  143208. declare module BABYLON {
  143209. /** @hidden */
  143210. export var refractionPixelShader: {
  143211. name: string;
  143212. shader: string;
  143213. };
  143214. }
  143215. declare module BABYLON {
  143216. /**
  143217. * Post process which applies a refractin texture
  143218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143219. */
  143220. export class RefractionPostProcess extends PostProcess {
  143221. /** the base color of the refraction (used to taint the rendering) */
  143222. color: Color3;
  143223. /** simulated refraction depth */
  143224. depth: number;
  143225. /** the coefficient of the base color (0 to remove base color tainting) */
  143226. colorLevel: number;
  143227. private _refTexture;
  143228. private _ownRefractionTexture;
  143229. /**
  143230. * Gets or sets the refraction texture
  143231. * Please note that you are responsible for disposing the texture if you set it manually
  143232. */
  143233. get refractionTexture(): Texture;
  143234. set refractionTexture(value: Texture);
  143235. /**
  143236. * Initializes the RefractionPostProcess
  143237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143238. * @param name The name of the effect.
  143239. * @param refractionTextureUrl Url of the refraction texture to use
  143240. * @param color the base color of the refraction (used to taint the rendering)
  143241. * @param depth simulated refraction depth
  143242. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  143243. * @param camera The camera to apply the render pass to.
  143244. * @param options The required width/height ratio to downsize to before computing the render pass.
  143245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143246. * @param engine The engine which the post process will be applied. (default: current engine)
  143247. * @param reusable If the post process can be reused on the same frame. (default: false)
  143248. */
  143249. constructor(name: string, refractionTextureUrl: string,
  143250. /** the base color of the refraction (used to taint the rendering) */
  143251. color: Color3,
  143252. /** simulated refraction depth */
  143253. depth: number,
  143254. /** the coefficient of the base color (0 to remove base color tainting) */
  143255. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  143256. /**
  143257. * Disposes of the post process
  143258. * @param camera Camera to dispose post process on
  143259. */
  143260. dispose(camera: Camera): void;
  143261. }
  143262. }
  143263. declare module BABYLON {
  143264. /** @hidden */
  143265. export var sharpenPixelShader: {
  143266. name: string;
  143267. shader: string;
  143268. };
  143269. }
  143270. declare module BABYLON {
  143271. /**
  143272. * The SharpenPostProcess applies a sharpen kernel to every pixel
  143273. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  143274. */
  143275. export class SharpenPostProcess extends PostProcess {
  143276. /**
  143277. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  143278. */
  143279. colorAmount: number;
  143280. /**
  143281. * How much sharpness should be applied (default: 0.3)
  143282. */
  143283. edgeAmount: number;
  143284. /**
  143285. * Creates a new instance ConvolutionPostProcess
  143286. * @param name The name of the effect.
  143287. * @param options The required width/height ratio to downsize to before computing the render pass.
  143288. * @param camera The camera to apply the render pass to.
  143289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143290. * @param engine The engine which the post process will be applied. (default: current engine)
  143291. * @param reusable If the post process can be reused on the same frame. (default: false)
  143292. * @param textureType Type of textures used when performing the post process. (default: 0)
  143293. * @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)
  143294. */
  143295. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143296. }
  143297. }
  143298. declare module BABYLON {
  143299. /**
  143300. * PostProcessRenderPipeline
  143301. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143302. */
  143303. export class PostProcessRenderPipeline {
  143304. private engine;
  143305. private _renderEffects;
  143306. private _renderEffectsForIsolatedPass;
  143307. /**
  143308. * List of inspectable custom properties (used by the Inspector)
  143309. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  143310. */
  143311. inspectableCustomProperties: IInspectable[];
  143312. /**
  143313. * @hidden
  143314. */
  143315. protected _cameras: Camera[];
  143316. /** @hidden */
  143317. _name: string;
  143318. /**
  143319. * Gets pipeline name
  143320. */
  143321. get name(): string;
  143322. /** Gets the list of attached cameras */
  143323. get cameras(): Camera[];
  143324. /**
  143325. * Initializes a PostProcessRenderPipeline
  143326. * @param engine engine to add the pipeline to
  143327. * @param name name of the pipeline
  143328. */
  143329. constructor(engine: Engine, name: string);
  143330. /**
  143331. * Gets the class name
  143332. * @returns "PostProcessRenderPipeline"
  143333. */
  143334. getClassName(): string;
  143335. /**
  143336. * If all the render effects in the pipeline are supported
  143337. */
  143338. get isSupported(): boolean;
  143339. /**
  143340. * Adds an effect to the pipeline
  143341. * @param renderEffect the effect to add
  143342. */
  143343. addEffect(renderEffect: PostProcessRenderEffect): void;
  143344. /** @hidden */
  143345. _rebuild(): void;
  143346. /** @hidden */
  143347. _enableEffect(renderEffectName: string, cameras: Camera): void;
  143348. /** @hidden */
  143349. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  143350. /** @hidden */
  143351. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143352. /** @hidden */
  143353. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143354. /** @hidden */
  143355. _attachCameras(cameras: Camera, unique: boolean): void;
  143356. /** @hidden */
  143357. _attachCameras(cameras: Camera[], unique: boolean): void;
  143358. /** @hidden */
  143359. _detachCameras(cameras: Camera): void;
  143360. /** @hidden */
  143361. _detachCameras(cameras: Nullable<Camera[]>): void;
  143362. /** @hidden */
  143363. _update(): void;
  143364. /** @hidden */
  143365. _reset(): void;
  143366. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  143367. /**
  143368. * Disposes of the pipeline
  143369. */
  143370. dispose(): void;
  143371. }
  143372. }
  143373. declare module BABYLON {
  143374. /**
  143375. * PostProcessRenderPipelineManager class
  143376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143377. */
  143378. export class PostProcessRenderPipelineManager {
  143379. private _renderPipelines;
  143380. /**
  143381. * Initializes a PostProcessRenderPipelineManager
  143382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143383. */
  143384. constructor();
  143385. /**
  143386. * Gets the list of supported render pipelines
  143387. */
  143388. get supportedPipelines(): PostProcessRenderPipeline[];
  143389. /**
  143390. * Adds a pipeline to the manager
  143391. * @param renderPipeline The pipeline to add
  143392. */
  143393. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  143394. /**
  143395. * Attaches a camera to the pipeline
  143396. * @param renderPipelineName The name of the pipeline to attach to
  143397. * @param cameras the camera to attach
  143398. * @param unique if the camera can be attached multiple times to the pipeline
  143399. */
  143400. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  143401. /**
  143402. * Detaches a camera from the pipeline
  143403. * @param renderPipelineName The name of the pipeline to detach from
  143404. * @param cameras the camera to detach
  143405. */
  143406. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  143407. /**
  143408. * Enables an effect by name on a pipeline
  143409. * @param renderPipelineName the name of the pipeline to enable the effect in
  143410. * @param renderEffectName the name of the effect to enable
  143411. * @param cameras the cameras that the effect should be enabled on
  143412. */
  143413. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143414. /**
  143415. * Disables an effect by name on a pipeline
  143416. * @param renderPipelineName the name of the pipeline to disable the effect in
  143417. * @param renderEffectName the name of the effect to disable
  143418. * @param cameras the cameras that the effect should be disabled on
  143419. */
  143420. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143421. /**
  143422. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  143423. */
  143424. update(): void;
  143425. /** @hidden */
  143426. _rebuild(): void;
  143427. /**
  143428. * Disposes of the manager and pipelines
  143429. */
  143430. dispose(): void;
  143431. }
  143432. }
  143433. declare module BABYLON {
  143434. interface Scene {
  143435. /** @hidden (Backing field) */
  143436. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143437. /**
  143438. * Gets the postprocess render pipeline manager
  143439. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143440. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143441. */
  143442. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143443. }
  143444. /**
  143445. * Defines the Render Pipeline scene component responsible to rendering pipelines
  143446. */
  143447. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  143448. /**
  143449. * The component name helpfull to identify the component in the list of scene components.
  143450. */
  143451. readonly name: string;
  143452. /**
  143453. * The scene the component belongs to.
  143454. */
  143455. scene: Scene;
  143456. /**
  143457. * Creates a new instance of the component for the given scene
  143458. * @param scene Defines the scene to register the component in
  143459. */
  143460. constructor(scene: Scene);
  143461. /**
  143462. * Registers the component in a given scene
  143463. */
  143464. register(): void;
  143465. /**
  143466. * Rebuilds the elements related to this component in case of
  143467. * context lost for instance.
  143468. */
  143469. rebuild(): void;
  143470. /**
  143471. * Disposes the component and the associated ressources
  143472. */
  143473. dispose(): void;
  143474. private _gatherRenderTargets;
  143475. }
  143476. }
  143477. declare module BABYLON {
  143478. /**
  143479. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  143480. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143481. */
  143482. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143483. private _scene;
  143484. private _camerasToBeAttached;
  143485. /**
  143486. * ID of the sharpen post process,
  143487. */
  143488. private readonly SharpenPostProcessId;
  143489. /**
  143490. * @ignore
  143491. * ID of the image processing post process;
  143492. */
  143493. readonly ImageProcessingPostProcessId: string;
  143494. /**
  143495. * @ignore
  143496. * ID of the Fast Approximate Anti-Aliasing post process;
  143497. */
  143498. readonly FxaaPostProcessId: string;
  143499. /**
  143500. * ID of the chromatic aberration post process,
  143501. */
  143502. private readonly ChromaticAberrationPostProcessId;
  143503. /**
  143504. * ID of the grain post process
  143505. */
  143506. private readonly GrainPostProcessId;
  143507. /**
  143508. * Sharpen post process which will apply a sharpen convolution to enhance edges
  143509. */
  143510. sharpen: SharpenPostProcess;
  143511. private _sharpenEffect;
  143512. private bloom;
  143513. /**
  143514. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  143515. */
  143516. depthOfField: DepthOfFieldEffect;
  143517. /**
  143518. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143519. */
  143520. fxaa: FxaaPostProcess;
  143521. /**
  143522. * Image post processing pass used to perform operations such as tone mapping or color grading.
  143523. */
  143524. imageProcessing: ImageProcessingPostProcess;
  143525. /**
  143526. * Chromatic aberration post process which will shift rgb colors in the image
  143527. */
  143528. chromaticAberration: ChromaticAberrationPostProcess;
  143529. private _chromaticAberrationEffect;
  143530. /**
  143531. * Grain post process which add noise to the image
  143532. */
  143533. grain: GrainPostProcess;
  143534. private _grainEffect;
  143535. /**
  143536. * Glow post process which adds a glow to emissive areas of the image
  143537. */
  143538. private _glowLayer;
  143539. /**
  143540. * Animations which can be used to tweak settings over a period of time
  143541. */
  143542. animations: Animation[];
  143543. private _imageProcessingConfigurationObserver;
  143544. private _sharpenEnabled;
  143545. private _bloomEnabled;
  143546. private _depthOfFieldEnabled;
  143547. private _depthOfFieldBlurLevel;
  143548. private _fxaaEnabled;
  143549. private _imageProcessingEnabled;
  143550. private _defaultPipelineTextureType;
  143551. private _bloomScale;
  143552. private _chromaticAberrationEnabled;
  143553. private _grainEnabled;
  143554. private _buildAllowed;
  143555. /**
  143556. * Gets active scene
  143557. */
  143558. get scene(): Scene;
  143559. /**
  143560. * Enable or disable the sharpen process from the pipeline
  143561. */
  143562. set sharpenEnabled(enabled: boolean);
  143563. get sharpenEnabled(): boolean;
  143564. private _resizeObserver;
  143565. private _hardwareScaleLevel;
  143566. private _bloomKernel;
  143567. /**
  143568. * Specifies the size of the bloom blur kernel, relative to the final output size
  143569. */
  143570. get bloomKernel(): number;
  143571. set bloomKernel(value: number);
  143572. /**
  143573. * Specifies the weight of the bloom in the final rendering
  143574. */
  143575. private _bloomWeight;
  143576. /**
  143577. * Specifies the luma threshold for the area that will be blurred by the bloom
  143578. */
  143579. private _bloomThreshold;
  143580. private _hdr;
  143581. /**
  143582. * The strength of the bloom.
  143583. */
  143584. set bloomWeight(value: number);
  143585. get bloomWeight(): number;
  143586. /**
  143587. * The strength of the bloom.
  143588. */
  143589. set bloomThreshold(value: number);
  143590. get bloomThreshold(): number;
  143591. /**
  143592. * The scale of the bloom, lower value will provide better performance.
  143593. */
  143594. set bloomScale(value: number);
  143595. get bloomScale(): number;
  143596. /**
  143597. * Enable or disable the bloom from the pipeline
  143598. */
  143599. set bloomEnabled(enabled: boolean);
  143600. get bloomEnabled(): boolean;
  143601. private _rebuildBloom;
  143602. /**
  143603. * If the depth of field is enabled.
  143604. */
  143605. get depthOfFieldEnabled(): boolean;
  143606. set depthOfFieldEnabled(enabled: boolean);
  143607. /**
  143608. * Blur level of the depth of field effect. (Higher blur will effect performance)
  143609. */
  143610. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  143611. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  143612. /**
  143613. * If the anti aliasing is enabled.
  143614. */
  143615. set fxaaEnabled(enabled: boolean);
  143616. get fxaaEnabled(): boolean;
  143617. private _samples;
  143618. /**
  143619. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  143620. */
  143621. set samples(sampleCount: number);
  143622. get samples(): number;
  143623. /**
  143624. * If image processing is enabled.
  143625. */
  143626. set imageProcessingEnabled(enabled: boolean);
  143627. get imageProcessingEnabled(): boolean;
  143628. /**
  143629. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  143630. */
  143631. set glowLayerEnabled(enabled: boolean);
  143632. get glowLayerEnabled(): boolean;
  143633. /**
  143634. * Gets the glow layer (or null if not defined)
  143635. */
  143636. get glowLayer(): Nullable<GlowLayer>;
  143637. /**
  143638. * Enable or disable the chromaticAberration process from the pipeline
  143639. */
  143640. set chromaticAberrationEnabled(enabled: boolean);
  143641. get chromaticAberrationEnabled(): boolean;
  143642. /**
  143643. * Enable or disable the grain process from the pipeline
  143644. */
  143645. set grainEnabled(enabled: boolean);
  143646. get grainEnabled(): boolean;
  143647. /**
  143648. * @constructor
  143649. * @param name - The rendering pipeline name (default: "")
  143650. * @param hdr - If high dynamic range textures should be used (default: true)
  143651. * @param scene - The scene linked to this pipeline (default: the last created scene)
  143652. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  143653. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  143654. */
  143655. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  143656. /**
  143657. * Get the class name
  143658. * @returns "DefaultRenderingPipeline"
  143659. */
  143660. getClassName(): string;
  143661. /**
  143662. * Force the compilation of the entire pipeline.
  143663. */
  143664. prepare(): void;
  143665. private _hasCleared;
  143666. private _prevPostProcess;
  143667. private _prevPrevPostProcess;
  143668. private _setAutoClearAndTextureSharing;
  143669. private _depthOfFieldSceneObserver;
  143670. private _buildPipeline;
  143671. private _disposePostProcesses;
  143672. /**
  143673. * Adds a camera to the pipeline
  143674. * @param camera the camera to be added
  143675. */
  143676. addCamera(camera: Camera): void;
  143677. /**
  143678. * Removes a camera from the pipeline
  143679. * @param camera the camera to remove
  143680. */
  143681. removeCamera(camera: Camera): void;
  143682. /**
  143683. * Dispose of the pipeline and stop all post processes
  143684. */
  143685. dispose(): void;
  143686. /**
  143687. * Serialize the rendering pipeline (Used when exporting)
  143688. * @returns the serialized object
  143689. */
  143690. serialize(): any;
  143691. /**
  143692. * Parse the serialized pipeline
  143693. * @param source Source pipeline.
  143694. * @param scene The scene to load the pipeline to.
  143695. * @param rootUrl The URL of the serialized pipeline.
  143696. * @returns An instantiated pipeline from the serialized object.
  143697. */
  143698. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  143699. }
  143700. }
  143701. declare module BABYLON {
  143702. /** @hidden */
  143703. export var lensHighlightsPixelShader: {
  143704. name: string;
  143705. shader: string;
  143706. };
  143707. }
  143708. declare module BABYLON {
  143709. /** @hidden */
  143710. export var depthOfFieldPixelShader: {
  143711. name: string;
  143712. shader: string;
  143713. };
  143714. }
  143715. declare module BABYLON {
  143716. /**
  143717. * BABYLON.JS Chromatic Aberration GLSL Shader
  143718. * Author: Olivier Guyot
  143719. * Separates very slightly R, G and B colors on the edges of the screen
  143720. * Inspired by Francois Tarlier & Martins Upitis
  143721. */
  143722. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  143723. /**
  143724. * @ignore
  143725. * The chromatic aberration PostProcess id in the pipeline
  143726. */
  143727. LensChromaticAberrationEffect: string;
  143728. /**
  143729. * @ignore
  143730. * The highlights enhancing PostProcess id in the pipeline
  143731. */
  143732. HighlightsEnhancingEffect: string;
  143733. /**
  143734. * @ignore
  143735. * The depth-of-field PostProcess id in the pipeline
  143736. */
  143737. LensDepthOfFieldEffect: string;
  143738. private _scene;
  143739. private _depthTexture;
  143740. private _grainTexture;
  143741. private _chromaticAberrationPostProcess;
  143742. private _highlightsPostProcess;
  143743. private _depthOfFieldPostProcess;
  143744. private _edgeBlur;
  143745. private _grainAmount;
  143746. private _chromaticAberration;
  143747. private _distortion;
  143748. private _highlightsGain;
  143749. private _highlightsThreshold;
  143750. private _dofDistance;
  143751. private _dofAperture;
  143752. private _dofDarken;
  143753. private _dofPentagon;
  143754. private _blurNoise;
  143755. /**
  143756. * @constructor
  143757. *
  143758. * Effect parameters are as follow:
  143759. * {
  143760. * chromatic_aberration: number; // from 0 to x (1 for realism)
  143761. * edge_blur: number; // from 0 to x (1 for realism)
  143762. * distortion: number; // from 0 to x (1 for realism)
  143763. * grain_amount: number; // from 0 to 1
  143764. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  143765. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  143766. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  143767. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  143768. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  143769. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  143770. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  143771. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  143772. * }
  143773. * Note: if an effect parameter is unset, effect is disabled
  143774. *
  143775. * @param name The rendering pipeline name
  143776. * @param parameters - An object containing all parameters (see above)
  143777. * @param scene The scene linked to this pipeline
  143778. * @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)
  143779. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143780. */
  143781. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  143782. /**
  143783. * Get the class name
  143784. * @returns "LensRenderingPipeline"
  143785. */
  143786. getClassName(): string;
  143787. /**
  143788. * Gets associated scene
  143789. */
  143790. get scene(): Scene;
  143791. /**
  143792. * Gets or sets the edge blur
  143793. */
  143794. get edgeBlur(): number;
  143795. set edgeBlur(value: number);
  143796. /**
  143797. * Gets or sets the grain amount
  143798. */
  143799. get grainAmount(): number;
  143800. set grainAmount(value: number);
  143801. /**
  143802. * Gets or sets the chromatic aberration amount
  143803. */
  143804. get chromaticAberration(): number;
  143805. set chromaticAberration(value: number);
  143806. /**
  143807. * Gets or sets the depth of field aperture
  143808. */
  143809. get dofAperture(): number;
  143810. set dofAperture(value: number);
  143811. /**
  143812. * Gets or sets the edge distortion
  143813. */
  143814. get edgeDistortion(): number;
  143815. set edgeDistortion(value: number);
  143816. /**
  143817. * Gets or sets the depth of field distortion
  143818. */
  143819. get dofDistortion(): number;
  143820. set dofDistortion(value: number);
  143821. /**
  143822. * Gets or sets the darken out of focus amount
  143823. */
  143824. get darkenOutOfFocus(): number;
  143825. set darkenOutOfFocus(value: number);
  143826. /**
  143827. * Gets or sets a boolean indicating if blur noise is enabled
  143828. */
  143829. get blurNoise(): boolean;
  143830. set blurNoise(value: boolean);
  143831. /**
  143832. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  143833. */
  143834. get pentagonBokeh(): boolean;
  143835. set pentagonBokeh(value: boolean);
  143836. /**
  143837. * Gets or sets the highlight grain amount
  143838. */
  143839. get highlightsGain(): number;
  143840. set highlightsGain(value: number);
  143841. /**
  143842. * Gets or sets the highlight threshold
  143843. */
  143844. get highlightsThreshold(): number;
  143845. set highlightsThreshold(value: number);
  143846. /**
  143847. * Sets the amount of blur at the edges
  143848. * @param amount blur amount
  143849. */
  143850. setEdgeBlur(amount: number): void;
  143851. /**
  143852. * Sets edge blur to 0
  143853. */
  143854. disableEdgeBlur(): void;
  143855. /**
  143856. * Sets the amout of grain
  143857. * @param amount Amount of grain
  143858. */
  143859. setGrainAmount(amount: number): void;
  143860. /**
  143861. * Set grain amount to 0
  143862. */
  143863. disableGrain(): void;
  143864. /**
  143865. * Sets the chromatic aberration amount
  143866. * @param amount amount of chromatic aberration
  143867. */
  143868. setChromaticAberration(amount: number): void;
  143869. /**
  143870. * Sets chromatic aberration amount to 0
  143871. */
  143872. disableChromaticAberration(): void;
  143873. /**
  143874. * Sets the EdgeDistortion amount
  143875. * @param amount amount of EdgeDistortion
  143876. */
  143877. setEdgeDistortion(amount: number): void;
  143878. /**
  143879. * Sets edge distortion to 0
  143880. */
  143881. disableEdgeDistortion(): void;
  143882. /**
  143883. * Sets the FocusDistance amount
  143884. * @param amount amount of FocusDistance
  143885. */
  143886. setFocusDistance(amount: number): void;
  143887. /**
  143888. * Disables depth of field
  143889. */
  143890. disableDepthOfField(): void;
  143891. /**
  143892. * Sets the Aperture amount
  143893. * @param amount amount of Aperture
  143894. */
  143895. setAperture(amount: number): void;
  143896. /**
  143897. * Sets the DarkenOutOfFocus amount
  143898. * @param amount amount of DarkenOutOfFocus
  143899. */
  143900. setDarkenOutOfFocus(amount: number): void;
  143901. private _pentagonBokehIsEnabled;
  143902. /**
  143903. * Creates a pentagon bokeh effect
  143904. */
  143905. enablePentagonBokeh(): void;
  143906. /**
  143907. * Disables the pentagon bokeh effect
  143908. */
  143909. disablePentagonBokeh(): void;
  143910. /**
  143911. * Enables noise blur
  143912. */
  143913. enableNoiseBlur(): void;
  143914. /**
  143915. * Disables noise blur
  143916. */
  143917. disableNoiseBlur(): void;
  143918. /**
  143919. * Sets the HighlightsGain amount
  143920. * @param amount amount of HighlightsGain
  143921. */
  143922. setHighlightsGain(amount: number): void;
  143923. /**
  143924. * Sets the HighlightsThreshold amount
  143925. * @param amount amount of HighlightsThreshold
  143926. */
  143927. setHighlightsThreshold(amount: number): void;
  143928. /**
  143929. * Disables highlights
  143930. */
  143931. disableHighlights(): void;
  143932. /**
  143933. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  143934. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  143935. */
  143936. dispose(disableDepthRender?: boolean): void;
  143937. private _createChromaticAberrationPostProcess;
  143938. private _createHighlightsPostProcess;
  143939. private _createDepthOfFieldPostProcess;
  143940. private _createGrainTexture;
  143941. }
  143942. }
  143943. declare module BABYLON {
  143944. /** @hidden */
  143945. export var ssao2PixelShader: {
  143946. name: string;
  143947. shader: string;
  143948. };
  143949. }
  143950. declare module BABYLON {
  143951. /** @hidden */
  143952. export var ssaoCombinePixelShader: {
  143953. name: string;
  143954. shader: string;
  143955. };
  143956. }
  143957. declare module BABYLON {
  143958. /**
  143959. * Render pipeline to produce ssao effect
  143960. */
  143961. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  143962. /**
  143963. * @ignore
  143964. * The PassPostProcess id in the pipeline that contains the original scene color
  143965. */
  143966. SSAOOriginalSceneColorEffect: string;
  143967. /**
  143968. * @ignore
  143969. * The SSAO PostProcess id in the pipeline
  143970. */
  143971. SSAORenderEffect: string;
  143972. /**
  143973. * @ignore
  143974. * The horizontal blur PostProcess id in the pipeline
  143975. */
  143976. SSAOBlurHRenderEffect: string;
  143977. /**
  143978. * @ignore
  143979. * The vertical blur PostProcess id in the pipeline
  143980. */
  143981. SSAOBlurVRenderEffect: string;
  143982. /**
  143983. * @ignore
  143984. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143985. */
  143986. SSAOCombineRenderEffect: string;
  143987. /**
  143988. * The output strength of the SSAO post-process. Default value is 1.0.
  143989. */
  143990. totalStrength: number;
  143991. /**
  143992. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  143993. */
  143994. maxZ: number;
  143995. /**
  143996. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  143997. */
  143998. minZAspect: number;
  143999. private _samples;
  144000. /**
  144001. * Number of samples used for the SSAO calculations. Default value is 8
  144002. */
  144003. set samples(n: number);
  144004. get samples(): number;
  144005. private _textureSamples;
  144006. /**
  144007. * Number of samples to use for antialiasing
  144008. */
  144009. set textureSamples(n: number);
  144010. get textureSamples(): number;
  144011. /**
  144012. * Ratio object used for SSAO ratio and blur ratio
  144013. */
  144014. private _ratio;
  144015. /**
  144016. * Dynamically generated sphere sampler.
  144017. */
  144018. private _sampleSphere;
  144019. /**
  144020. * Blur filter offsets
  144021. */
  144022. private _samplerOffsets;
  144023. private _expensiveBlur;
  144024. /**
  144025. * If bilateral blur should be used
  144026. */
  144027. set expensiveBlur(b: boolean);
  144028. get expensiveBlur(): boolean;
  144029. /**
  144030. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  144031. */
  144032. radius: number;
  144033. /**
  144034. * The base color of the SSAO post-process
  144035. * The final result is "base + ssao" between [0, 1]
  144036. */
  144037. base: number;
  144038. /**
  144039. * Support test.
  144040. */
  144041. static get IsSupported(): boolean;
  144042. private _scene;
  144043. private _depthTexture;
  144044. private _normalTexture;
  144045. private _randomTexture;
  144046. private _originalColorPostProcess;
  144047. private _ssaoPostProcess;
  144048. private _blurHPostProcess;
  144049. private _blurVPostProcess;
  144050. private _ssaoCombinePostProcess;
  144051. /**
  144052. * Gets active scene
  144053. */
  144054. get scene(): Scene;
  144055. /**
  144056. * @constructor
  144057. * @param name The rendering pipeline name
  144058. * @param scene The scene linked to this pipeline
  144059. * @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 }
  144060. * @param cameras The array of cameras that the rendering pipeline will be attached to
  144061. */
  144062. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  144063. /**
  144064. * Get the class name
  144065. * @returns "SSAO2RenderingPipeline"
  144066. */
  144067. getClassName(): string;
  144068. /**
  144069. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  144070. */
  144071. dispose(disableGeometryBufferRenderer?: boolean): void;
  144072. private _createBlurPostProcess;
  144073. /** @hidden */
  144074. _rebuild(): void;
  144075. private _bits;
  144076. private _radicalInverse_VdC;
  144077. private _hammersley;
  144078. private _hemisphereSample_uniform;
  144079. private _generateHemisphere;
  144080. private _createSSAOPostProcess;
  144081. private _createSSAOCombinePostProcess;
  144082. private _createRandomTexture;
  144083. /**
  144084. * Serialize the rendering pipeline (Used when exporting)
  144085. * @returns the serialized object
  144086. */
  144087. serialize(): any;
  144088. /**
  144089. * Parse the serialized pipeline
  144090. * @param source Source pipeline.
  144091. * @param scene The scene to load the pipeline to.
  144092. * @param rootUrl The URL of the serialized pipeline.
  144093. * @returns An instantiated pipeline from the serialized object.
  144094. */
  144095. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  144096. }
  144097. }
  144098. declare module BABYLON {
  144099. /** @hidden */
  144100. export var ssaoPixelShader: {
  144101. name: string;
  144102. shader: string;
  144103. };
  144104. }
  144105. declare module BABYLON {
  144106. /**
  144107. * Render pipeline to produce ssao effect
  144108. */
  144109. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  144110. /**
  144111. * @ignore
  144112. * The PassPostProcess id in the pipeline that contains the original scene color
  144113. */
  144114. SSAOOriginalSceneColorEffect: string;
  144115. /**
  144116. * @ignore
  144117. * The SSAO PostProcess id in the pipeline
  144118. */
  144119. SSAORenderEffect: string;
  144120. /**
  144121. * @ignore
  144122. * The horizontal blur PostProcess id in the pipeline
  144123. */
  144124. SSAOBlurHRenderEffect: string;
  144125. /**
  144126. * @ignore
  144127. * The vertical blur PostProcess id in the pipeline
  144128. */
  144129. SSAOBlurVRenderEffect: string;
  144130. /**
  144131. * @ignore
  144132. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  144133. */
  144134. SSAOCombineRenderEffect: string;
  144135. /**
  144136. * The output strength of the SSAO post-process. Default value is 1.0.
  144137. */
  144138. totalStrength: number;
  144139. /**
  144140. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  144141. */
  144142. radius: number;
  144143. /**
  144144. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  144145. * Must not be equal to fallOff and superior to fallOff.
  144146. * Default value is 0.0075
  144147. */
  144148. area: number;
  144149. /**
  144150. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  144151. * Must not be equal to area and inferior to area.
  144152. * Default value is 0.000001
  144153. */
  144154. fallOff: number;
  144155. /**
  144156. * The base color of the SSAO post-process
  144157. * The final result is "base + ssao" between [0, 1]
  144158. */
  144159. base: number;
  144160. private _scene;
  144161. private _depthTexture;
  144162. private _randomTexture;
  144163. private _originalColorPostProcess;
  144164. private _ssaoPostProcess;
  144165. private _blurHPostProcess;
  144166. private _blurVPostProcess;
  144167. private _ssaoCombinePostProcess;
  144168. private _firstUpdate;
  144169. /**
  144170. * Gets active scene
  144171. */
  144172. get scene(): Scene;
  144173. /**
  144174. * @constructor
  144175. * @param name - The rendering pipeline name
  144176. * @param scene - The scene linked to this pipeline
  144177. * @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 }
  144178. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  144179. */
  144180. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  144181. /**
  144182. * Get the class name
  144183. * @returns "SSAORenderingPipeline"
  144184. */
  144185. getClassName(): string;
  144186. /**
  144187. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  144188. */
  144189. dispose(disableDepthRender?: boolean): void;
  144190. private _createBlurPostProcess;
  144191. /** @hidden */
  144192. _rebuild(): void;
  144193. private _createSSAOPostProcess;
  144194. private _createSSAOCombinePostProcess;
  144195. private _createRandomTexture;
  144196. }
  144197. }
  144198. declare module BABYLON {
  144199. /** @hidden */
  144200. export var screenSpaceReflectionPixelShader: {
  144201. name: string;
  144202. shader: string;
  144203. };
  144204. }
  144205. declare module BABYLON {
  144206. /**
  144207. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  144208. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  144209. */
  144210. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  144211. /**
  144212. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  144213. */
  144214. threshold: number;
  144215. /**
  144216. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  144217. */
  144218. strength: number;
  144219. /**
  144220. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  144221. */
  144222. reflectionSpecularFalloffExponent: number;
  144223. /**
  144224. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  144225. */
  144226. step: number;
  144227. /**
  144228. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  144229. */
  144230. roughnessFactor: number;
  144231. private _geometryBufferRenderer;
  144232. private _enableSmoothReflections;
  144233. private _reflectionSamples;
  144234. private _smoothSteps;
  144235. /**
  144236. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  144237. * @param name The name of the effect.
  144238. * @param scene The scene containing the objects to calculate reflections.
  144239. * @param options The required width/height ratio to downsize to before computing the render pass.
  144240. * @param camera The camera to apply the render pass to.
  144241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144242. * @param engine The engine which the post process will be applied. (default: current engine)
  144243. * @param reusable If the post process can be reused on the same frame. (default: false)
  144244. * @param textureType Type of textures used when performing the post process. (default: 0)
  144245. * @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)
  144246. */
  144247. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144248. /**
  144249. * Gets wether or not smoothing reflections is enabled.
  144250. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144251. */
  144252. get enableSmoothReflections(): boolean;
  144253. /**
  144254. * Sets wether or not smoothing reflections is enabled.
  144255. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144256. */
  144257. set enableSmoothReflections(enabled: boolean);
  144258. /**
  144259. * Gets the number of samples taken while computing reflections. More samples count is high,
  144260. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144261. */
  144262. get reflectionSamples(): number;
  144263. /**
  144264. * Sets the number of samples taken while computing reflections. More samples count is high,
  144265. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144266. */
  144267. set reflectionSamples(samples: number);
  144268. /**
  144269. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  144270. * more the post-process will require GPU power and can generate a drop in FPS.
  144271. * Default value (5.0) work pretty well in all cases but can be adjusted.
  144272. */
  144273. get smoothSteps(): number;
  144274. set smoothSteps(steps: number);
  144275. private _updateEffectDefines;
  144276. }
  144277. }
  144278. declare module BABYLON {
  144279. /** @hidden */
  144280. export var standardPixelShader: {
  144281. name: string;
  144282. shader: string;
  144283. };
  144284. }
  144285. declare module BABYLON {
  144286. /**
  144287. * Standard rendering pipeline
  144288. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144289. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  144290. */
  144291. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  144292. /**
  144293. * Public members
  144294. */
  144295. /**
  144296. * Post-process which contains the original scene color before the pipeline applies all the effects
  144297. */
  144298. originalPostProcess: Nullable<PostProcess>;
  144299. /**
  144300. * Post-process used to down scale an image x4
  144301. */
  144302. downSampleX4PostProcess: Nullable<PostProcess>;
  144303. /**
  144304. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  144305. */
  144306. brightPassPostProcess: Nullable<PostProcess>;
  144307. /**
  144308. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  144309. */
  144310. blurHPostProcesses: PostProcess[];
  144311. /**
  144312. * Post-process array storing all the vertical blur post-processes used by the pipeline
  144313. */
  144314. blurVPostProcesses: PostProcess[];
  144315. /**
  144316. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  144317. */
  144318. textureAdderPostProcess: Nullable<PostProcess>;
  144319. /**
  144320. * Post-process used to create volumetric lighting effect
  144321. */
  144322. volumetricLightPostProcess: Nullable<PostProcess>;
  144323. /**
  144324. * Post-process used to smooth the previous volumetric light post-process on the X axis
  144325. */
  144326. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  144327. /**
  144328. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  144329. */
  144330. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  144331. /**
  144332. * Post-process used to merge the volumetric light effect and the real scene color
  144333. */
  144334. volumetricLightMergePostProces: Nullable<PostProcess>;
  144335. /**
  144336. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  144337. */
  144338. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  144339. /**
  144340. * Base post-process used to calculate the average luminance of the final image for HDR
  144341. */
  144342. luminancePostProcess: Nullable<PostProcess>;
  144343. /**
  144344. * Post-processes used to create down sample post-processes in order to get
  144345. * the average luminance of the final image for HDR
  144346. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  144347. */
  144348. luminanceDownSamplePostProcesses: PostProcess[];
  144349. /**
  144350. * Post-process used to create a HDR effect (light adaptation)
  144351. */
  144352. hdrPostProcess: Nullable<PostProcess>;
  144353. /**
  144354. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  144355. */
  144356. textureAdderFinalPostProcess: Nullable<PostProcess>;
  144357. /**
  144358. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  144359. */
  144360. lensFlareFinalPostProcess: Nullable<PostProcess>;
  144361. /**
  144362. * Post-process used to merge the final HDR post-process and the real scene color
  144363. */
  144364. hdrFinalPostProcess: Nullable<PostProcess>;
  144365. /**
  144366. * Post-process used to create a lens flare effect
  144367. */
  144368. lensFlarePostProcess: Nullable<PostProcess>;
  144369. /**
  144370. * Post-process that merges the result of the lens flare post-process and the real scene color
  144371. */
  144372. lensFlareComposePostProcess: Nullable<PostProcess>;
  144373. /**
  144374. * Post-process used to create a motion blur effect
  144375. */
  144376. motionBlurPostProcess: Nullable<PostProcess>;
  144377. /**
  144378. * Post-process used to create a depth of field effect
  144379. */
  144380. depthOfFieldPostProcess: Nullable<PostProcess>;
  144381. /**
  144382. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  144383. */
  144384. fxaaPostProcess: Nullable<FxaaPostProcess>;
  144385. /**
  144386. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  144387. */
  144388. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  144389. /**
  144390. * Represents the brightness threshold in order to configure the illuminated surfaces
  144391. */
  144392. brightThreshold: number;
  144393. /**
  144394. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  144395. */
  144396. blurWidth: number;
  144397. /**
  144398. * Sets if the blur for highlighted surfaces must be only horizontal
  144399. */
  144400. horizontalBlur: boolean;
  144401. /**
  144402. * Gets the overall exposure used by the pipeline
  144403. */
  144404. get exposure(): number;
  144405. /**
  144406. * Sets the overall exposure used by the pipeline
  144407. */
  144408. set exposure(value: number);
  144409. /**
  144410. * Texture used typically to simulate "dirty" on camera lens
  144411. */
  144412. lensTexture: Nullable<Texture>;
  144413. /**
  144414. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  144415. */
  144416. volumetricLightCoefficient: number;
  144417. /**
  144418. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  144419. */
  144420. volumetricLightPower: number;
  144421. /**
  144422. * Used the set the blur intensity to smooth the volumetric lights
  144423. */
  144424. volumetricLightBlurScale: number;
  144425. /**
  144426. * Light (spot or directional) used to generate the volumetric lights rays
  144427. * The source light must have a shadow generate so the pipeline can get its
  144428. * depth map
  144429. */
  144430. sourceLight: Nullable<SpotLight | DirectionalLight>;
  144431. /**
  144432. * For eye adaptation, represents the minimum luminance the eye can see
  144433. */
  144434. hdrMinimumLuminance: number;
  144435. /**
  144436. * For eye adaptation, represents the decrease luminance speed
  144437. */
  144438. hdrDecreaseRate: number;
  144439. /**
  144440. * For eye adaptation, represents the increase luminance speed
  144441. */
  144442. hdrIncreaseRate: number;
  144443. /**
  144444. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144445. */
  144446. get hdrAutoExposure(): boolean;
  144447. /**
  144448. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144449. */
  144450. set hdrAutoExposure(value: boolean);
  144451. /**
  144452. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  144453. */
  144454. lensColorTexture: Nullable<Texture>;
  144455. /**
  144456. * The overall strengh for the lens flare effect
  144457. */
  144458. lensFlareStrength: number;
  144459. /**
  144460. * Dispersion coefficient for lens flare ghosts
  144461. */
  144462. lensFlareGhostDispersal: number;
  144463. /**
  144464. * Main lens flare halo width
  144465. */
  144466. lensFlareHaloWidth: number;
  144467. /**
  144468. * Based on the lens distortion effect, defines how much the lens flare result
  144469. * is distorted
  144470. */
  144471. lensFlareDistortionStrength: number;
  144472. /**
  144473. * Configures the blur intensity used for for lens flare (halo)
  144474. */
  144475. lensFlareBlurWidth: number;
  144476. /**
  144477. * Lens star texture must be used to simulate rays on the flares and is available
  144478. * in the documentation
  144479. */
  144480. lensStarTexture: Nullable<Texture>;
  144481. /**
  144482. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  144483. * flare effect by taking account of the dirt texture
  144484. */
  144485. lensFlareDirtTexture: Nullable<Texture>;
  144486. /**
  144487. * Represents the focal length for the depth of field effect
  144488. */
  144489. depthOfFieldDistance: number;
  144490. /**
  144491. * Represents the blur intensity for the blurred part of the depth of field effect
  144492. */
  144493. depthOfFieldBlurWidth: number;
  144494. /**
  144495. * Gets how much the image is blurred by the movement while using the motion blur post-process
  144496. */
  144497. get motionStrength(): number;
  144498. /**
  144499. * Sets how much the image is blurred by the movement while using the motion blur post-process
  144500. */
  144501. set motionStrength(strength: number);
  144502. /**
  144503. * Gets wether or not the motion blur post-process is object based or screen based.
  144504. */
  144505. get objectBasedMotionBlur(): boolean;
  144506. /**
  144507. * Sets wether or not the motion blur post-process should be object based or screen based
  144508. */
  144509. set objectBasedMotionBlur(value: boolean);
  144510. /**
  144511. * List of animations for the pipeline (IAnimatable implementation)
  144512. */
  144513. animations: Animation[];
  144514. /**
  144515. * Private members
  144516. */
  144517. private _scene;
  144518. private _currentDepthOfFieldSource;
  144519. private _basePostProcess;
  144520. private _fixedExposure;
  144521. private _currentExposure;
  144522. private _hdrAutoExposure;
  144523. private _hdrCurrentLuminance;
  144524. private _motionStrength;
  144525. private _isObjectBasedMotionBlur;
  144526. private _floatTextureType;
  144527. private _camerasToBeAttached;
  144528. private _ratio;
  144529. private _bloomEnabled;
  144530. private _depthOfFieldEnabled;
  144531. private _vlsEnabled;
  144532. private _lensFlareEnabled;
  144533. private _hdrEnabled;
  144534. private _motionBlurEnabled;
  144535. private _fxaaEnabled;
  144536. private _screenSpaceReflectionsEnabled;
  144537. private _motionBlurSamples;
  144538. private _volumetricLightStepsCount;
  144539. private _samples;
  144540. /**
  144541. * @ignore
  144542. * Specifies if the bloom pipeline is enabled
  144543. */
  144544. get BloomEnabled(): boolean;
  144545. set BloomEnabled(enabled: boolean);
  144546. /**
  144547. * @ignore
  144548. * Specifies if the depth of field pipeline is enabed
  144549. */
  144550. get DepthOfFieldEnabled(): boolean;
  144551. set DepthOfFieldEnabled(enabled: boolean);
  144552. /**
  144553. * @ignore
  144554. * Specifies if the lens flare pipeline is enabed
  144555. */
  144556. get LensFlareEnabled(): boolean;
  144557. set LensFlareEnabled(enabled: boolean);
  144558. /**
  144559. * @ignore
  144560. * Specifies if the HDR pipeline is enabled
  144561. */
  144562. get HDREnabled(): boolean;
  144563. set HDREnabled(enabled: boolean);
  144564. /**
  144565. * @ignore
  144566. * Specifies if the volumetric lights scattering effect is enabled
  144567. */
  144568. get VLSEnabled(): boolean;
  144569. set VLSEnabled(enabled: boolean);
  144570. /**
  144571. * @ignore
  144572. * Specifies if the motion blur effect is enabled
  144573. */
  144574. get MotionBlurEnabled(): boolean;
  144575. set MotionBlurEnabled(enabled: boolean);
  144576. /**
  144577. * Specifies if anti-aliasing is enabled
  144578. */
  144579. get fxaaEnabled(): boolean;
  144580. set fxaaEnabled(enabled: boolean);
  144581. /**
  144582. * Specifies if screen space reflections are enabled.
  144583. */
  144584. get screenSpaceReflectionsEnabled(): boolean;
  144585. set screenSpaceReflectionsEnabled(enabled: boolean);
  144586. /**
  144587. * Specifies the number of steps used to calculate the volumetric lights
  144588. * Typically in interval [50, 200]
  144589. */
  144590. get volumetricLightStepsCount(): number;
  144591. set volumetricLightStepsCount(count: number);
  144592. /**
  144593. * Specifies the number of samples used for the motion blur effect
  144594. * Typically in interval [16, 64]
  144595. */
  144596. get motionBlurSamples(): number;
  144597. set motionBlurSamples(samples: number);
  144598. /**
  144599. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  144600. */
  144601. get samples(): number;
  144602. set samples(sampleCount: number);
  144603. /**
  144604. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144605. * @constructor
  144606. * @param name The rendering pipeline name
  144607. * @param scene The scene linked to this pipeline
  144608. * @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)
  144609. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  144610. * @param cameras The array of cameras that the rendering pipeline will be attached to
  144611. */
  144612. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  144613. private _buildPipeline;
  144614. private _createDownSampleX4PostProcess;
  144615. private _createBrightPassPostProcess;
  144616. private _createBlurPostProcesses;
  144617. private _createTextureAdderPostProcess;
  144618. private _createVolumetricLightPostProcess;
  144619. private _createLuminancePostProcesses;
  144620. private _createHdrPostProcess;
  144621. private _createLensFlarePostProcess;
  144622. private _createDepthOfFieldPostProcess;
  144623. private _createMotionBlurPostProcess;
  144624. private _getDepthTexture;
  144625. private _disposePostProcesses;
  144626. /**
  144627. * Dispose of the pipeline and stop all post processes
  144628. */
  144629. dispose(): void;
  144630. /**
  144631. * Serialize the rendering pipeline (Used when exporting)
  144632. * @returns the serialized object
  144633. */
  144634. serialize(): any;
  144635. /**
  144636. * Parse the serialized pipeline
  144637. * @param source Source pipeline.
  144638. * @param scene The scene to load the pipeline to.
  144639. * @param rootUrl The URL of the serialized pipeline.
  144640. * @returns An instantiated pipeline from the serialized object.
  144641. */
  144642. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  144643. /**
  144644. * Luminance steps
  144645. */
  144646. static LuminanceSteps: number;
  144647. }
  144648. }
  144649. declare module BABYLON {
  144650. /** @hidden */
  144651. export var stereoscopicInterlacePixelShader: {
  144652. name: string;
  144653. shader: string;
  144654. };
  144655. }
  144656. declare module BABYLON {
  144657. /**
  144658. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  144659. */
  144660. export class StereoscopicInterlacePostProcessI extends PostProcess {
  144661. private _stepSize;
  144662. private _passedProcess;
  144663. /**
  144664. * Initializes a StereoscopicInterlacePostProcessI
  144665. * @param name The name of the effect.
  144666. * @param rigCameras The rig cameras to be appled to the post process
  144667. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  144668. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  144669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144670. * @param engine The engine which the post process will be applied. (default: current engine)
  144671. * @param reusable If the post process can be reused on the same frame. (default: false)
  144672. */
  144673. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144674. }
  144675. /**
  144676. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  144677. */
  144678. export class StereoscopicInterlacePostProcess extends PostProcess {
  144679. private _stepSize;
  144680. private _passedProcess;
  144681. /**
  144682. * Initializes a StereoscopicInterlacePostProcess
  144683. * @param name The name of the effect.
  144684. * @param rigCameras The rig cameras to be appled to the post process
  144685. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  144686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144687. * @param engine The engine which the post process will be applied. (default: current engine)
  144688. * @param reusable If the post process can be reused on the same frame. (default: false)
  144689. */
  144690. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144691. }
  144692. }
  144693. declare module BABYLON {
  144694. /** @hidden */
  144695. export var tonemapPixelShader: {
  144696. name: string;
  144697. shader: string;
  144698. };
  144699. }
  144700. declare module BABYLON {
  144701. /** Defines operator used for tonemapping */
  144702. export enum TonemappingOperator {
  144703. /** Hable */
  144704. Hable = 0,
  144705. /** Reinhard */
  144706. Reinhard = 1,
  144707. /** HejiDawson */
  144708. HejiDawson = 2,
  144709. /** Photographic */
  144710. Photographic = 3
  144711. }
  144712. /**
  144713. * Defines a post process to apply tone mapping
  144714. */
  144715. export class TonemapPostProcess extends PostProcess {
  144716. private _operator;
  144717. /** Defines the required exposure adjustement */
  144718. exposureAdjustment: number;
  144719. /**
  144720. * Creates a new TonemapPostProcess
  144721. * @param name defines the name of the postprocess
  144722. * @param _operator defines the operator to use
  144723. * @param exposureAdjustment defines the required exposure adjustement
  144724. * @param camera defines the camera to use (can be null)
  144725. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  144726. * @param engine defines the hosting engine (can be ignore if camera is set)
  144727. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144728. */
  144729. constructor(name: string, _operator: TonemappingOperator,
  144730. /** Defines the required exposure adjustement */
  144731. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  144732. }
  144733. }
  144734. declare module BABYLON {
  144735. /** @hidden */
  144736. export var volumetricLightScatteringPixelShader: {
  144737. name: string;
  144738. shader: string;
  144739. };
  144740. }
  144741. declare module BABYLON {
  144742. /** @hidden */
  144743. export var volumetricLightScatteringPassVertexShader: {
  144744. name: string;
  144745. shader: string;
  144746. };
  144747. }
  144748. declare module BABYLON {
  144749. /** @hidden */
  144750. export var volumetricLightScatteringPassPixelShader: {
  144751. name: string;
  144752. shader: string;
  144753. };
  144754. }
  144755. declare module BABYLON {
  144756. /**
  144757. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  144758. */
  144759. export class VolumetricLightScatteringPostProcess extends PostProcess {
  144760. private _volumetricLightScatteringPass;
  144761. private _volumetricLightScatteringRTT;
  144762. private _viewPort;
  144763. private _screenCoordinates;
  144764. private _cachedDefines;
  144765. /**
  144766. * If not undefined, the mesh position is computed from the attached node position
  144767. */
  144768. attachedNode: {
  144769. position: Vector3;
  144770. };
  144771. /**
  144772. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  144773. */
  144774. customMeshPosition: Vector3;
  144775. /**
  144776. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  144777. */
  144778. useCustomMeshPosition: boolean;
  144779. /**
  144780. * If the post-process should inverse the light scattering direction
  144781. */
  144782. invert: boolean;
  144783. /**
  144784. * The internal mesh used by the post-process
  144785. */
  144786. mesh: Mesh;
  144787. /**
  144788. * @hidden
  144789. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  144790. */
  144791. get useDiffuseColor(): boolean;
  144792. set useDiffuseColor(useDiffuseColor: boolean);
  144793. /**
  144794. * Array containing the excluded meshes not rendered in the internal pass
  144795. */
  144796. excludedMeshes: AbstractMesh[];
  144797. /**
  144798. * Controls the overall intensity of the post-process
  144799. */
  144800. exposure: number;
  144801. /**
  144802. * Dissipates each sample's contribution in range [0, 1]
  144803. */
  144804. decay: number;
  144805. /**
  144806. * Controls the overall intensity of each sample
  144807. */
  144808. weight: number;
  144809. /**
  144810. * Controls the density of each sample
  144811. */
  144812. density: number;
  144813. /**
  144814. * @constructor
  144815. * @param name The post-process name
  144816. * @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)
  144817. * @param camera The camera that the post-process will be attached to
  144818. * @param mesh The mesh used to create the light scattering
  144819. * @param samples The post-process quality, default 100
  144820. * @param samplingModeThe post-process filtering mode
  144821. * @param engine The babylon engine
  144822. * @param reusable If the post-process is reusable
  144823. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  144824. */
  144825. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  144826. /**
  144827. * Returns the string "VolumetricLightScatteringPostProcess"
  144828. * @returns "VolumetricLightScatteringPostProcess"
  144829. */
  144830. getClassName(): string;
  144831. private _isReady;
  144832. /**
  144833. * Sets the new light position for light scattering effect
  144834. * @param position The new custom light position
  144835. */
  144836. setCustomMeshPosition(position: Vector3): void;
  144837. /**
  144838. * Returns the light position for light scattering effect
  144839. * @return Vector3 The custom light position
  144840. */
  144841. getCustomMeshPosition(): Vector3;
  144842. /**
  144843. * Disposes the internal assets and detaches the post-process from the camera
  144844. */
  144845. dispose(camera: Camera): void;
  144846. /**
  144847. * Returns the render target texture used by the post-process
  144848. * @return the render target texture used by the post-process
  144849. */
  144850. getPass(): RenderTargetTexture;
  144851. private _meshExcluded;
  144852. private _createPass;
  144853. private _updateMeshScreenCoordinates;
  144854. /**
  144855. * Creates a default mesh for the Volumeric Light Scattering post-process
  144856. * @param name The mesh name
  144857. * @param scene The scene where to create the mesh
  144858. * @return the default mesh
  144859. */
  144860. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  144861. }
  144862. }
  144863. declare module BABYLON {
  144864. interface Scene {
  144865. /** @hidden (Backing field) */
  144866. _boundingBoxRenderer: BoundingBoxRenderer;
  144867. /** @hidden (Backing field) */
  144868. _forceShowBoundingBoxes: boolean;
  144869. /**
  144870. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  144871. */
  144872. forceShowBoundingBoxes: boolean;
  144873. /**
  144874. * Gets the bounding box renderer associated with the scene
  144875. * @returns a BoundingBoxRenderer
  144876. */
  144877. getBoundingBoxRenderer(): BoundingBoxRenderer;
  144878. }
  144879. interface AbstractMesh {
  144880. /** @hidden (Backing field) */
  144881. _showBoundingBox: boolean;
  144882. /**
  144883. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  144884. */
  144885. showBoundingBox: boolean;
  144886. }
  144887. /**
  144888. * Component responsible of rendering the bounding box of the meshes in a scene.
  144889. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  144890. */
  144891. export class BoundingBoxRenderer implements ISceneComponent {
  144892. /**
  144893. * The component name helpfull to identify the component in the list of scene components.
  144894. */
  144895. readonly name: string;
  144896. /**
  144897. * The scene the component belongs to.
  144898. */
  144899. scene: Scene;
  144900. /**
  144901. * Color of the bounding box lines placed in front of an object
  144902. */
  144903. frontColor: Color3;
  144904. /**
  144905. * Color of the bounding box lines placed behind an object
  144906. */
  144907. backColor: Color3;
  144908. /**
  144909. * Defines if the renderer should show the back lines or not
  144910. */
  144911. showBackLines: boolean;
  144912. /**
  144913. * @hidden
  144914. */
  144915. renderList: SmartArray<BoundingBox>;
  144916. private _colorShader;
  144917. private _vertexBuffers;
  144918. private _indexBuffer;
  144919. private _fillIndexBuffer;
  144920. private _fillIndexData;
  144921. /**
  144922. * Instantiates a new bounding box renderer in a scene.
  144923. * @param scene the scene the renderer renders in
  144924. */
  144925. constructor(scene: Scene);
  144926. /**
  144927. * Registers the component in a given scene
  144928. */
  144929. register(): void;
  144930. private _evaluateSubMesh;
  144931. private _activeMesh;
  144932. private _prepareRessources;
  144933. private _createIndexBuffer;
  144934. /**
  144935. * Rebuilds the elements related to this component in case of
  144936. * context lost for instance.
  144937. */
  144938. rebuild(): void;
  144939. /**
  144940. * @hidden
  144941. */
  144942. reset(): void;
  144943. /**
  144944. * Render the bounding boxes of a specific rendering group
  144945. * @param renderingGroupId defines the rendering group to render
  144946. */
  144947. render(renderingGroupId: number): void;
  144948. /**
  144949. * In case of occlusion queries, we can render the occlusion bounding box through this method
  144950. * @param mesh Define the mesh to render the occlusion bounding box for
  144951. */
  144952. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  144953. /**
  144954. * Dispose and release the resources attached to this renderer.
  144955. */
  144956. dispose(): void;
  144957. }
  144958. }
  144959. declare module BABYLON {
  144960. interface Scene {
  144961. /** @hidden (Backing field) */
  144962. _depthRenderer: {
  144963. [id: string]: DepthRenderer;
  144964. };
  144965. /**
  144966. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  144967. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  144968. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  144969. * @returns the created depth renderer
  144970. */
  144971. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  144972. /**
  144973. * Disables a depth renderer for a given camera
  144974. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  144975. */
  144976. disableDepthRenderer(camera?: Nullable<Camera>): void;
  144977. }
  144978. /**
  144979. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  144980. * in several rendering techniques.
  144981. */
  144982. export class DepthRendererSceneComponent implements ISceneComponent {
  144983. /**
  144984. * The component name helpfull to identify the component in the list of scene components.
  144985. */
  144986. readonly name: string;
  144987. /**
  144988. * The scene the component belongs to.
  144989. */
  144990. scene: Scene;
  144991. /**
  144992. * Creates a new instance of the component for the given scene
  144993. * @param scene Defines the scene to register the component in
  144994. */
  144995. constructor(scene: Scene);
  144996. /**
  144997. * Registers the component in a given scene
  144998. */
  144999. register(): void;
  145000. /**
  145001. * Rebuilds the elements related to this component in case of
  145002. * context lost for instance.
  145003. */
  145004. rebuild(): void;
  145005. /**
  145006. * Disposes the component and the associated ressources
  145007. */
  145008. dispose(): void;
  145009. private _gatherRenderTargets;
  145010. private _gatherActiveCameraRenderTargets;
  145011. }
  145012. }
  145013. declare module BABYLON {
  145014. /** @hidden */
  145015. export var outlinePixelShader: {
  145016. name: string;
  145017. shader: string;
  145018. };
  145019. }
  145020. declare module BABYLON {
  145021. /** @hidden */
  145022. export var outlineVertexShader: {
  145023. name: string;
  145024. shader: string;
  145025. };
  145026. }
  145027. declare module BABYLON {
  145028. interface Scene {
  145029. /** @hidden */
  145030. _outlineRenderer: OutlineRenderer;
  145031. /**
  145032. * Gets the outline renderer associated with the scene
  145033. * @returns a OutlineRenderer
  145034. */
  145035. getOutlineRenderer(): OutlineRenderer;
  145036. }
  145037. interface AbstractMesh {
  145038. /** @hidden (Backing field) */
  145039. _renderOutline: boolean;
  145040. /**
  145041. * Gets or sets a boolean indicating if the outline must be rendered as well
  145042. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  145043. */
  145044. renderOutline: boolean;
  145045. /** @hidden (Backing field) */
  145046. _renderOverlay: boolean;
  145047. /**
  145048. * Gets or sets a boolean indicating if the overlay must be rendered as well
  145049. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  145050. */
  145051. renderOverlay: boolean;
  145052. }
  145053. /**
  145054. * This class is responsible to draw bothe outline/overlay of meshes.
  145055. * It should not be used directly but through the available method on mesh.
  145056. */
  145057. export class OutlineRenderer implements ISceneComponent {
  145058. /**
  145059. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  145060. */
  145061. private static _StencilReference;
  145062. /**
  145063. * The name of the component. Each component must have a unique name.
  145064. */
  145065. name: string;
  145066. /**
  145067. * The scene the component belongs to.
  145068. */
  145069. scene: Scene;
  145070. /**
  145071. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  145072. */
  145073. zOffset: number;
  145074. private _engine;
  145075. private _effect;
  145076. private _cachedDefines;
  145077. private _savedDepthWrite;
  145078. /**
  145079. * Instantiates a new outline renderer. (There could be only one per scene).
  145080. * @param scene Defines the scene it belongs to
  145081. */
  145082. constructor(scene: Scene);
  145083. /**
  145084. * Register the component to one instance of a scene.
  145085. */
  145086. register(): void;
  145087. /**
  145088. * Rebuilds the elements related to this component in case of
  145089. * context lost for instance.
  145090. */
  145091. rebuild(): void;
  145092. /**
  145093. * Disposes the component and the associated ressources.
  145094. */
  145095. dispose(): void;
  145096. /**
  145097. * Renders the outline in the canvas.
  145098. * @param subMesh Defines the sumesh to render
  145099. * @param batch Defines the batch of meshes in case of instances
  145100. * @param useOverlay Defines if the rendering is for the overlay or the outline
  145101. */
  145102. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  145103. /**
  145104. * Returns whether or not the outline renderer is ready for a given submesh.
  145105. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  145106. * @param subMesh Defines the submesh to check readyness for
  145107. * @param useInstances Defines wheter wee are trying to render instances or not
  145108. * @returns true if ready otherwise false
  145109. */
  145110. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  145111. private _beforeRenderingMesh;
  145112. private _afterRenderingMesh;
  145113. }
  145114. }
  145115. declare module BABYLON {
  145116. /**
  145117. * Defines the basic options interface of a Sprite Frame Source Size.
  145118. */
  145119. export interface ISpriteJSONSpriteSourceSize {
  145120. /**
  145121. * number of the original width of the Frame
  145122. */
  145123. w: number;
  145124. /**
  145125. * number of the original height of the Frame
  145126. */
  145127. h: number;
  145128. }
  145129. /**
  145130. * Defines the basic options interface of a Sprite Frame Data.
  145131. */
  145132. export interface ISpriteJSONSpriteFrameData {
  145133. /**
  145134. * number of the x offset of the Frame
  145135. */
  145136. x: number;
  145137. /**
  145138. * number of the y offset of the Frame
  145139. */
  145140. y: number;
  145141. /**
  145142. * number of the width of the Frame
  145143. */
  145144. w: number;
  145145. /**
  145146. * number of the height of the Frame
  145147. */
  145148. h: number;
  145149. }
  145150. /**
  145151. * Defines the basic options interface of a JSON Sprite.
  145152. */
  145153. export interface ISpriteJSONSprite {
  145154. /**
  145155. * string name of the Frame
  145156. */
  145157. filename: string;
  145158. /**
  145159. * ISpriteJSONSpriteFrame basic object of the frame data
  145160. */
  145161. frame: ISpriteJSONSpriteFrameData;
  145162. /**
  145163. * boolean to flag is the frame was rotated.
  145164. */
  145165. rotated: boolean;
  145166. /**
  145167. * boolean to flag is the frame was trimmed.
  145168. */
  145169. trimmed: boolean;
  145170. /**
  145171. * ISpriteJSONSpriteFrame basic object of the source data
  145172. */
  145173. spriteSourceSize: ISpriteJSONSpriteFrameData;
  145174. /**
  145175. * ISpriteJSONSpriteFrame basic object of the source data
  145176. */
  145177. sourceSize: ISpriteJSONSpriteSourceSize;
  145178. }
  145179. /**
  145180. * Defines the basic options interface of a JSON atlas.
  145181. */
  145182. export interface ISpriteJSONAtlas {
  145183. /**
  145184. * Array of objects that contain the frame data.
  145185. */
  145186. frames: Array<ISpriteJSONSprite>;
  145187. /**
  145188. * object basic object containing the sprite meta data.
  145189. */
  145190. meta?: object;
  145191. }
  145192. }
  145193. declare module BABYLON {
  145194. /** @hidden */
  145195. export var spriteMapPixelShader: {
  145196. name: string;
  145197. shader: string;
  145198. };
  145199. }
  145200. declare module BABYLON {
  145201. /** @hidden */
  145202. export var spriteMapVertexShader: {
  145203. name: string;
  145204. shader: string;
  145205. };
  145206. }
  145207. declare module BABYLON {
  145208. /**
  145209. * Defines the basic options interface of a SpriteMap
  145210. */
  145211. export interface ISpriteMapOptions {
  145212. /**
  145213. * Vector2 of the number of cells in the grid.
  145214. */
  145215. stageSize?: Vector2;
  145216. /**
  145217. * Vector2 of the size of the output plane in World Units.
  145218. */
  145219. outputSize?: Vector2;
  145220. /**
  145221. * Vector3 of the position of the output plane in World Units.
  145222. */
  145223. outputPosition?: Vector3;
  145224. /**
  145225. * Vector3 of the rotation of the output plane.
  145226. */
  145227. outputRotation?: Vector3;
  145228. /**
  145229. * number of layers that the system will reserve in resources.
  145230. */
  145231. layerCount?: number;
  145232. /**
  145233. * number of max animation frames a single cell will reserve in resources.
  145234. */
  145235. maxAnimationFrames?: number;
  145236. /**
  145237. * number cell index of the base tile when the system compiles.
  145238. */
  145239. baseTile?: number;
  145240. /**
  145241. * boolean flip the sprite after its been repositioned by the framing data.
  145242. */
  145243. flipU?: boolean;
  145244. /**
  145245. * Vector3 scalar of the global RGB values of the SpriteMap.
  145246. */
  145247. colorMultiply?: Vector3;
  145248. }
  145249. /**
  145250. * Defines the IDisposable interface in order to be cleanable from resources.
  145251. */
  145252. export interface ISpriteMap extends IDisposable {
  145253. /**
  145254. * String name of the SpriteMap.
  145255. */
  145256. name: string;
  145257. /**
  145258. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  145259. */
  145260. atlasJSON: ISpriteJSONAtlas;
  145261. /**
  145262. * Texture of the SpriteMap.
  145263. */
  145264. spriteSheet: Texture;
  145265. /**
  145266. * The parameters to initialize the SpriteMap with.
  145267. */
  145268. options: ISpriteMapOptions;
  145269. }
  145270. /**
  145271. * Class used to manage a grid restricted sprite deployment on an Output plane.
  145272. */
  145273. export class SpriteMap implements ISpriteMap {
  145274. /** The Name of the spriteMap */
  145275. name: string;
  145276. /** The JSON file with the frame and meta data */
  145277. atlasJSON: ISpriteJSONAtlas;
  145278. /** The systems Sprite Sheet Texture */
  145279. spriteSheet: Texture;
  145280. /** Arguments passed with the Constructor */
  145281. options: ISpriteMapOptions;
  145282. /** Public Sprite Storage array, parsed from atlasJSON */
  145283. sprites: Array<ISpriteJSONSprite>;
  145284. /** Returns the Number of Sprites in the System */
  145285. get spriteCount(): number;
  145286. /** Returns the Position of Output Plane*/
  145287. get position(): Vector3;
  145288. /** Returns the Position of Output Plane*/
  145289. set position(v: Vector3);
  145290. /** Returns the Rotation of Output Plane*/
  145291. get rotation(): Vector3;
  145292. /** Returns the Rotation of Output Plane*/
  145293. set rotation(v: Vector3);
  145294. /** Sets the AnimationMap*/
  145295. get animationMap(): RawTexture;
  145296. /** Sets the AnimationMap*/
  145297. set animationMap(v: RawTexture);
  145298. /** Scene that the SpriteMap was created in */
  145299. private _scene;
  145300. /** Texture Buffer of Float32 that holds tile frame data*/
  145301. private _frameMap;
  145302. /** Texture Buffers of Float32 that holds tileMap data*/
  145303. private _tileMaps;
  145304. /** Texture Buffer of Float32 that holds Animation Data*/
  145305. private _animationMap;
  145306. /** Custom ShaderMaterial Central to the System*/
  145307. private _material;
  145308. /** Custom ShaderMaterial Central to the System*/
  145309. private _output;
  145310. /** Systems Time Ticker*/
  145311. private _time;
  145312. /**
  145313. * Creates a new SpriteMap
  145314. * @param name defines the SpriteMaps Name
  145315. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  145316. * @param spriteSheet is the Texture that the Sprites are on.
  145317. * @param options a basic deployment configuration
  145318. * @param scene The Scene that the map is deployed on
  145319. */
  145320. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  145321. /**
  145322. * Returns tileID location
  145323. * @returns Vector2 the cell position ID
  145324. */
  145325. getTileID(): Vector2;
  145326. /**
  145327. * Gets the UV location of the mouse over the SpriteMap.
  145328. * @returns Vector2 the UV position of the mouse interaction
  145329. */
  145330. getMousePosition(): Vector2;
  145331. /**
  145332. * Creates the "frame" texture Buffer
  145333. * -------------------------------------
  145334. * Structure of frames
  145335. * "filename": "Falling-Water-2.png",
  145336. * "frame": {"x":69,"y":103,"w":24,"h":32},
  145337. * "rotated": true,
  145338. * "trimmed": true,
  145339. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  145340. * "sourceSize": {"w":32,"h":32}
  145341. * @returns RawTexture of the frameMap
  145342. */
  145343. private _createFrameBuffer;
  145344. /**
  145345. * Creates the tileMap texture Buffer
  145346. * @param buffer normally and array of numbers, or a false to generate from scratch
  145347. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  145348. * @returns RawTexture of the tileMap
  145349. */
  145350. private _createTileBuffer;
  145351. /**
  145352. * Modifies the data of the tileMaps
  145353. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  145354. * @param pos is the iVector2 Coordinates of the Tile
  145355. * @param tile The SpriteIndex of the new Tile
  145356. */
  145357. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  145358. /**
  145359. * Creates the animationMap texture Buffer
  145360. * @param buffer normally and array of numbers, or a false to generate from scratch
  145361. * @returns RawTexture of the animationMap
  145362. */
  145363. private _createTileAnimationBuffer;
  145364. /**
  145365. * Modifies the data of the animationMap
  145366. * @param cellID is the Index of the Sprite
  145367. * @param _frame is the target Animation frame
  145368. * @param toCell is the Target Index of the next frame of the animation
  145369. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  145370. * @param speed is a global scalar of the time variable on the map.
  145371. */
  145372. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  145373. /**
  145374. * Exports the .tilemaps file
  145375. */
  145376. saveTileMaps(): void;
  145377. /**
  145378. * Imports the .tilemaps file
  145379. * @param url of the .tilemaps file
  145380. */
  145381. loadTileMaps(url: string): void;
  145382. /**
  145383. * Release associated resources
  145384. */
  145385. dispose(): void;
  145386. }
  145387. }
  145388. declare module BABYLON {
  145389. /**
  145390. * Class used to manage multiple sprites of different sizes on the same spritesheet
  145391. * @see http://doc.babylonjs.com/babylon101/sprites
  145392. */
  145393. export class SpritePackedManager extends SpriteManager {
  145394. /** defines the packed manager's name */
  145395. name: string;
  145396. /**
  145397. * Creates a new sprite manager from a packed sprite sheet
  145398. * @param name defines the manager's name
  145399. * @param imgUrl defines the sprite sheet url
  145400. * @param capacity defines the maximum allowed number of sprites
  145401. * @param scene defines the hosting scene
  145402. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  145403. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  145404. * @param samplingMode defines the smapling mode to use with spritesheet
  145405. * @param fromPacked set to true; do not alter
  145406. */
  145407. constructor(
  145408. /** defines the packed manager's name */
  145409. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  145410. }
  145411. }
  145412. declare module BABYLON {
  145413. /**
  145414. * Defines the list of states available for a task inside a AssetsManager
  145415. */
  145416. export enum AssetTaskState {
  145417. /**
  145418. * Initialization
  145419. */
  145420. INIT = 0,
  145421. /**
  145422. * Running
  145423. */
  145424. RUNNING = 1,
  145425. /**
  145426. * Done
  145427. */
  145428. DONE = 2,
  145429. /**
  145430. * Error
  145431. */
  145432. ERROR = 3
  145433. }
  145434. /**
  145435. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  145436. */
  145437. export abstract class AbstractAssetTask {
  145438. /**
  145439. * Task name
  145440. */ name: string;
  145441. /**
  145442. * Callback called when the task is successful
  145443. */
  145444. onSuccess: (task: any) => void;
  145445. /**
  145446. * Callback called when the task is not successful
  145447. */
  145448. onError: (task: any, message?: string, exception?: any) => void;
  145449. /**
  145450. * Creates a new AssetsManager
  145451. * @param name defines the name of the task
  145452. */
  145453. constructor(
  145454. /**
  145455. * Task name
  145456. */ name: string);
  145457. private _isCompleted;
  145458. private _taskState;
  145459. private _errorObject;
  145460. /**
  145461. * Get if the task is completed
  145462. */
  145463. get isCompleted(): boolean;
  145464. /**
  145465. * Gets the current state of the task
  145466. */
  145467. get taskState(): AssetTaskState;
  145468. /**
  145469. * Gets the current error object (if task is in error)
  145470. */
  145471. get errorObject(): {
  145472. message?: string;
  145473. exception?: any;
  145474. };
  145475. /**
  145476. * Internal only
  145477. * @hidden
  145478. */
  145479. _setErrorObject(message?: string, exception?: any): void;
  145480. /**
  145481. * Execute the current task
  145482. * @param scene defines the scene where you want your assets to be loaded
  145483. * @param onSuccess is a callback called when the task is successfully executed
  145484. * @param onError is a callback called if an error occurs
  145485. */
  145486. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145487. /**
  145488. * Execute the current task
  145489. * @param scene defines the scene where you want your assets to be loaded
  145490. * @param onSuccess is a callback called when the task is successfully executed
  145491. * @param onError is a callback called if an error occurs
  145492. */
  145493. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145494. /**
  145495. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  145496. * This can be used with failed tasks that have the reason for failure fixed.
  145497. */
  145498. reset(): void;
  145499. private onErrorCallback;
  145500. private onDoneCallback;
  145501. }
  145502. /**
  145503. * Define the interface used by progress events raised during assets loading
  145504. */
  145505. export interface IAssetsProgressEvent {
  145506. /**
  145507. * Defines the number of remaining tasks to process
  145508. */
  145509. remainingCount: number;
  145510. /**
  145511. * Defines the total number of tasks
  145512. */
  145513. totalCount: number;
  145514. /**
  145515. * Defines the task that was just processed
  145516. */
  145517. task: AbstractAssetTask;
  145518. }
  145519. /**
  145520. * Class used to share progress information about assets loading
  145521. */
  145522. export class AssetsProgressEvent implements IAssetsProgressEvent {
  145523. /**
  145524. * Defines the number of remaining tasks to process
  145525. */
  145526. remainingCount: number;
  145527. /**
  145528. * Defines the total number of tasks
  145529. */
  145530. totalCount: number;
  145531. /**
  145532. * Defines the task that was just processed
  145533. */
  145534. task: AbstractAssetTask;
  145535. /**
  145536. * Creates a AssetsProgressEvent
  145537. * @param remainingCount defines the number of remaining tasks to process
  145538. * @param totalCount defines the total number of tasks
  145539. * @param task defines the task that was just processed
  145540. */
  145541. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  145542. }
  145543. /**
  145544. * Define a task used by AssetsManager to load meshes
  145545. */
  145546. export class MeshAssetTask extends AbstractAssetTask {
  145547. /**
  145548. * Defines the name of the task
  145549. */
  145550. name: string;
  145551. /**
  145552. * Defines the list of mesh's names you want to load
  145553. */
  145554. meshesNames: any;
  145555. /**
  145556. * Defines the root url to use as a base to load your meshes and associated resources
  145557. */
  145558. rootUrl: string;
  145559. /**
  145560. * Defines the filename or File of the scene to load from
  145561. */
  145562. sceneFilename: string | File;
  145563. /**
  145564. * Gets the list of loaded meshes
  145565. */
  145566. loadedMeshes: Array<AbstractMesh>;
  145567. /**
  145568. * Gets the list of loaded particle systems
  145569. */
  145570. loadedParticleSystems: Array<IParticleSystem>;
  145571. /**
  145572. * Gets the list of loaded skeletons
  145573. */
  145574. loadedSkeletons: Array<Skeleton>;
  145575. /**
  145576. * Gets the list of loaded animation groups
  145577. */
  145578. loadedAnimationGroups: Array<AnimationGroup>;
  145579. /**
  145580. * Callback called when the task is successful
  145581. */
  145582. onSuccess: (task: MeshAssetTask) => void;
  145583. /**
  145584. * Callback called when the task is successful
  145585. */
  145586. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  145587. /**
  145588. * Creates a new MeshAssetTask
  145589. * @param name defines the name of the task
  145590. * @param meshesNames defines the list of mesh's names you want to load
  145591. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  145592. * @param sceneFilename defines the filename or File of the scene to load from
  145593. */
  145594. constructor(
  145595. /**
  145596. * Defines the name of the task
  145597. */
  145598. name: string,
  145599. /**
  145600. * Defines the list of mesh's names you want to load
  145601. */
  145602. meshesNames: any,
  145603. /**
  145604. * Defines the root url to use as a base to load your meshes and associated resources
  145605. */
  145606. rootUrl: string,
  145607. /**
  145608. * Defines the filename or File of the scene to load from
  145609. */
  145610. sceneFilename: string | File);
  145611. /**
  145612. * Execute the current task
  145613. * @param scene defines the scene where you want your assets to be loaded
  145614. * @param onSuccess is a callback called when the task is successfully executed
  145615. * @param onError is a callback called if an error occurs
  145616. */
  145617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145618. }
  145619. /**
  145620. * Define a task used by AssetsManager to load text content
  145621. */
  145622. export class TextFileAssetTask extends AbstractAssetTask {
  145623. /**
  145624. * Defines the name of the task
  145625. */
  145626. name: string;
  145627. /**
  145628. * Defines the location of the file to load
  145629. */
  145630. url: string;
  145631. /**
  145632. * Gets the loaded text string
  145633. */
  145634. text: string;
  145635. /**
  145636. * Callback called when the task is successful
  145637. */
  145638. onSuccess: (task: TextFileAssetTask) => void;
  145639. /**
  145640. * Callback called when the task is successful
  145641. */
  145642. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  145643. /**
  145644. * Creates a new TextFileAssetTask object
  145645. * @param name defines the name of the task
  145646. * @param url defines the location of the file to load
  145647. */
  145648. constructor(
  145649. /**
  145650. * Defines the name of the task
  145651. */
  145652. name: string,
  145653. /**
  145654. * Defines the location of the file to load
  145655. */
  145656. url: string);
  145657. /**
  145658. * Execute the current task
  145659. * @param scene defines the scene where you want your assets to be loaded
  145660. * @param onSuccess is a callback called when the task is successfully executed
  145661. * @param onError is a callback called if an error occurs
  145662. */
  145663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145664. }
  145665. /**
  145666. * Define a task used by AssetsManager to load binary data
  145667. */
  145668. export class BinaryFileAssetTask extends AbstractAssetTask {
  145669. /**
  145670. * Defines the name of the task
  145671. */
  145672. name: string;
  145673. /**
  145674. * Defines the location of the file to load
  145675. */
  145676. url: string;
  145677. /**
  145678. * Gets the lodaded data (as an array buffer)
  145679. */
  145680. data: ArrayBuffer;
  145681. /**
  145682. * Callback called when the task is successful
  145683. */
  145684. onSuccess: (task: BinaryFileAssetTask) => void;
  145685. /**
  145686. * Callback called when the task is successful
  145687. */
  145688. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  145689. /**
  145690. * Creates a new BinaryFileAssetTask object
  145691. * @param name defines the name of the new task
  145692. * @param url defines the location of the file to load
  145693. */
  145694. constructor(
  145695. /**
  145696. * Defines the name of the task
  145697. */
  145698. name: string,
  145699. /**
  145700. * Defines the location of the file to load
  145701. */
  145702. url: string);
  145703. /**
  145704. * Execute the current task
  145705. * @param scene defines the scene where you want your assets to be loaded
  145706. * @param onSuccess is a callback called when the task is successfully executed
  145707. * @param onError is a callback called if an error occurs
  145708. */
  145709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145710. }
  145711. /**
  145712. * Define a task used by AssetsManager to load images
  145713. */
  145714. export class ImageAssetTask extends AbstractAssetTask {
  145715. /**
  145716. * Defines the name of the task
  145717. */
  145718. name: string;
  145719. /**
  145720. * Defines the location of the image to load
  145721. */
  145722. url: string;
  145723. /**
  145724. * Gets the loaded images
  145725. */
  145726. image: HTMLImageElement;
  145727. /**
  145728. * Callback called when the task is successful
  145729. */
  145730. onSuccess: (task: ImageAssetTask) => void;
  145731. /**
  145732. * Callback called when the task is successful
  145733. */
  145734. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  145735. /**
  145736. * Creates a new ImageAssetTask
  145737. * @param name defines the name of the task
  145738. * @param url defines the location of the image to load
  145739. */
  145740. constructor(
  145741. /**
  145742. * Defines the name of the task
  145743. */
  145744. name: string,
  145745. /**
  145746. * Defines the location of the image to load
  145747. */
  145748. url: string);
  145749. /**
  145750. * Execute the current task
  145751. * @param scene defines the scene where you want your assets to be loaded
  145752. * @param onSuccess is a callback called when the task is successfully executed
  145753. * @param onError is a callback called if an error occurs
  145754. */
  145755. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145756. }
  145757. /**
  145758. * Defines the interface used by texture loading tasks
  145759. */
  145760. export interface ITextureAssetTask<TEX extends BaseTexture> {
  145761. /**
  145762. * Gets the loaded texture
  145763. */
  145764. texture: TEX;
  145765. }
  145766. /**
  145767. * Define a task used by AssetsManager to load 2D textures
  145768. */
  145769. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  145770. /**
  145771. * Defines the name of the task
  145772. */
  145773. name: string;
  145774. /**
  145775. * Defines the location of the file to load
  145776. */
  145777. url: string;
  145778. /**
  145779. * Defines if mipmap should not be generated (default is false)
  145780. */
  145781. noMipmap?: boolean | undefined;
  145782. /**
  145783. * Defines if texture must be inverted on Y axis (default is true)
  145784. */
  145785. invertY: boolean;
  145786. /**
  145787. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145788. */
  145789. samplingMode: number;
  145790. /**
  145791. * Gets the loaded texture
  145792. */
  145793. texture: Texture;
  145794. /**
  145795. * Callback called when the task is successful
  145796. */
  145797. onSuccess: (task: TextureAssetTask) => void;
  145798. /**
  145799. * Callback called when the task is successful
  145800. */
  145801. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  145802. /**
  145803. * Creates a new TextureAssetTask object
  145804. * @param name defines the name of the task
  145805. * @param url defines the location of the file to load
  145806. * @param noMipmap defines if mipmap should not be generated (default is false)
  145807. * @param invertY defines if texture must be inverted on Y axis (default is true)
  145808. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145809. */
  145810. constructor(
  145811. /**
  145812. * Defines the name of the task
  145813. */
  145814. name: string,
  145815. /**
  145816. * Defines the location of the file to load
  145817. */
  145818. url: string,
  145819. /**
  145820. * Defines if mipmap should not be generated (default is false)
  145821. */
  145822. noMipmap?: boolean | undefined,
  145823. /**
  145824. * Defines if texture must be inverted on Y axis (default is true)
  145825. */
  145826. invertY?: boolean,
  145827. /**
  145828. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145829. */
  145830. samplingMode?: number);
  145831. /**
  145832. * Execute the current task
  145833. * @param scene defines the scene where you want your assets to be loaded
  145834. * @param onSuccess is a callback called when the task is successfully executed
  145835. * @param onError is a callback called if an error occurs
  145836. */
  145837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145838. }
  145839. /**
  145840. * Define a task used by AssetsManager to load cube textures
  145841. */
  145842. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  145843. /**
  145844. * Defines the name of the task
  145845. */
  145846. name: string;
  145847. /**
  145848. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145849. */
  145850. url: string;
  145851. /**
  145852. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145853. */
  145854. extensions?: string[] | undefined;
  145855. /**
  145856. * Defines if mipmaps should not be generated (default is false)
  145857. */
  145858. noMipmap?: boolean | undefined;
  145859. /**
  145860. * Defines the explicit list of files (undefined by default)
  145861. */
  145862. files?: string[] | undefined;
  145863. /**
  145864. * Gets the loaded texture
  145865. */
  145866. texture: CubeTexture;
  145867. /**
  145868. * Callback called when the task is successful
  145869. */
  145870. onSuccess: (task: CubeTextureAssetTask) => void;
  145871. /**
  145872. * Callback called when the task is successful
  145873. */
  145874. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  145875. /**
  145876. * Creates a new CubeTextureAssetTask
  145877. * @param name defines the name of the task
  145878. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145879. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145880. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145881. * @param files defines the explicit list of files (undefined by default)
  145882. */
  145883. constructor(
  145884. /**
  145885. * Defines the name of the task
  145886. */
  145887. name: string,
  145888. /**
  145889. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145890. */
  145891. url: string,
  145892. /**
  145893. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145894. */
  145895. extensions?: string[] | undefined,
  145896. /**
  145897. * Defines if mipmaps should not be generated (default is false)
  145898. */
  145899. noMipmap?: boolean | undefined,
  145900. /**
  145901. * Defines the explicit list of files (undefined by default)
  145902. */
  145903. files?: string[] | undefined);
  145904. /**
  145905. * Execute the current task
  145906. * @param scene defines the scene where you want your assets to be loaded
  145907. * @param onSuccess is a callback called when the task is successfully executed
  145908. * @param onError is a callback called if an error occurs
  145909. */
  145910. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145911. }
  145912. /**
  145913. * Define a task used by AssetsManager to load HDR cube textures
  145914. */
  145915. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  145916. /**
  145917. * Defines the name of the task
  145918. */
  145919. name: string;
  145920. /**
  145921. * Defines the location of the file to load
  145922. */
  145923. url: string;
  145924. /**
  145925. * Defines the desired size (the more it increases the longer the generation will be)
  145926. */
  145927. size: number;
  145928. /**
  145929. * Defines if mipmaps should not be generated (default is false)
  145930. */
  145931. noMipmap: boolean;
  145932. /**
  145933. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145934. */
  145935. generateHarmonics: boolean;
  145936. /**
  145937. * 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)
  145938. */
  145939. gammaSpace: boolean;
  145940. /**
  145941. * Internal Use Only
  145942. */
  145943. reserved: boolean;
  145944. /**
  145945. * Gets the loaded texture
  145946. */
  145947. texture: HDRCubeTexture;
  145948. /**
  145949. * Callback called when the task is successful
  145950. */
  145951. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  145952. /**
  145953. * Callback called when the task is successful
  145954. */
  145955. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  145956. /**
  145957. * Creates a new HDRCubeTextureAssetTask object
  145958. * @param name defines the name of the task
  145959. * @param url defines the location of the file to load
  145960. * @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.
  145961. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145962. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145963. * @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)
  145964. * @param reserved Internal use only
  145965. */
  145966. constructor(
  145967. /**
  145968. * Defines the name of the task
  145969. */
  145970. name: string,
  145971. /**
  145972. * Defines the location of the file to load
  145973. */
  145974. url: string,
  145975. /**
  145976. * Defines the desired size (the more it increases the longer the generation will be)
  145977. */
  145978. size: number,
  145979. /**
  145980. * Defines if mipmaps should not be generated (default is false)
  145981. */
  145982. noMipmap?: boolean,
  145983. /**
  145984. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145985. */
  145986. generateHarmonics?: boolean,
  145987. /**
  145988. * 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)
  145989. */
  145990. gammaSpace?: boolean,
  145991. /**
  145992. * Internal Use Only
  145993. */
  145994. reserved?: boolean);
  145995. /**
  145996. * Execute the current task
  145997. * @param scene defines the scene where you want your assets to be loaded
  145998. * @param onSuccess is a callback called when the task is successfully executed
  145999. * @param onError is a callback called if an error occurs
  146000. */
  146001. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  146002. }
  146003. /**
  146004. * Define a task used by AssetsManager to load Equirectangular cube textures
  146005. */
  146006. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  146007. /**
  146008. * Defines the name of the task
  146009. */
  146010. name: string;
  146011. /**
  146012. * Defines the location of the file to load
  146013. */
  146014. url: string;
  146015. /**
  146016. * Defines the desired size (the more it increases the longer the generation will be)
  146017. */
  146018. size: number;
  146019. /**
  146020. * Defines if mipmaps should not be generated (default is false)
  146021. */
  146022. noMipmap: boolean;
  146023. /**
  146024. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  146025. * but the standard material would require them in Gamma space) (default is true)
  146026. */
  146027. gammaSpace: boolean;
  146028. /**
  146029. * Gets the loaded texture
  146030. */
  146031. texture: EquiRectangularCubeTexture;
  146032. /**
  146033. * Callback called when the task is successful
  146034. */
  146035. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  146036. /**
  146037. * Callback called when the task is successful
  146038. */
  146039. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  146040. /**
  146041. * Creates a new EquiRectangularCubeTextureAssetTask object
  146042. * @param name defines the name of the task
  146043. * @param url defines the location of the file to load
  146044. * @param size defines the desired size (the more it increases the longer the generation will be)
  146045. * If the size is omitted this implies you are using a preprocessed cubemap.
  146046. * @param noMipmap defines if mipmaps should not be generated (default is false)
  146047. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  146048. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  146049. * (default is true)
  146050. */
  146051. constructor(
  146052. /**
  146053. * Defines the name of the task
  146054. */
  146055. name: string,
  146056. /**
  146057. * Defines the location of the file to load
  146058. */
  146059. url: string,
  146060. /**
  146061. * Defines the desired size (the more it increases the longer the generation will be)
  146062. */
  146063. size: number,
  146064. /**
  146065. * Defines if mipmaps should not be generated (default is false)
  146066. */
  146067. noMipmap?: boolean,
  146068. /**
  146069. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  146070. * but the standard material would require them in Gamma space) (default is true)
  146071. */
  146072. gammaSpace?: boolean);
  146073. /**
  146074. * Execute the current task
  146075. * @param scene defines the scene where you want your assets to be loaded
  146076. * @param onSuccess is a callback called when the task is successfully executed
  146077. * @param onError is a callback called if an error occurs
  146078. */
  146079. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  146080. }
  146081. /**
  146082. * This class can be used to easily import assets into a scene
  146083. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  146084. */
  146085. export class AssetsManager {
  146086. private _scene;
  146087. private _isLoading;
  146088. protected _tasks: AbstractAssetTask[];
  146089. protected _waitingTasksCount: number;
  146090. protected _totalTasksCount: number;
  146091. /**
  146092. * Callback called when all tasks are processed
  146093. */
  146094. onFinish: (tasks: AbstractAssetTask[]) => void;
  146095. /**
  146096. * Callback called when a task is successful
  146097. */
  146098. onTaskSuccess: (task: AbstractAssetTask) => void;
  146099. /**
  146100. * Callback called when a task had an error
  146101. */
  146102. onTaskError: (task: AbstractAssetTask) => void;
  146103. /**
  146104. * Callback called when a task is done (whatever the result is)
  146105. */
  146106. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  146107. /**
  146108. * Observable called when all tasks are processed
  146109. */
  146110. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  146111. /**
  146112. * Observable called when a task had an error
  146113. */
  146114. onTaskErrorObservable: Observable<AbstractAssetTask>;
  146115. /**
  146116. * Observable called when all tasks were executed
  146117. */
  146118. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  146119. /**
  146120. * Observable called when a task is done (whatever the result is)
  146121. */
  146122. onProgressObservable: Observable<IAssetsProgressEvent>;
  146123. /**
  146124. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  146125. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  146126. */
  146127. useDefaultLoadingScreen: boolean;
  146128. /**
  146129. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  146130. * when all assets have been downloaded.
  146131. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  146132. */
  146133. autoHideLoadingUI: boolean;
  146134. /**
  146135. * Creates a new AssetsManager
  146136. * @param scene defines the scene to work on
  146137. */
  146138. constructor(scene: Scene);
  146139. /**
  146140. * Add a MeshAssetTask to the list of active tasks
  146141. * @param taskName defines the name of the new task
  146142. * @param meshesNames defines the name of meshes to load
  146143. * @param rootUrl defines the root url to use to locate files
  146144. * @param sceneFilename defines the filename of the scene file
  146145. * @returns a new MeshAssetTask object
  146146. */
  146147. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  146148. /**
  146149. * Add a TextFileAssetTask to the list of active tasks
  146150. * @param taskName defines the name of the new task
  146151. * @param url defines the url of the file to load
  146152. * @returns a new TextFileAssetTask object
  146153. */
  146154. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  146155. /**
  146156. * Add a BinaryFileAssetTask to the list of active tasks
  146157. * @param taskName defines the name of the new task
  146158. * @param url defines the url of the file to load
  146159. * @returns a new BinaryFileAssetTask object
  146160. */
  146161. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  146162. /**
  146163. * Add a ImageAssetTask to the list of active tasks
  146164. * @param taskName defines the name of the new task
  146165. * @param url defines the url of the file to load
  146166. * @returns a new ImageAssetTask object
  146167. */
  146168. addImageTask(taskName: string, url: string): ImageAssetTask;
  146169. /**
  146170. * Add a TextureAssetTask to the list of active tasks
  146171. * @param taskName defines the name of the new task
  146172. * @param url defines the url of the file to load
  146173. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146174. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  146175. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  146176. * @returns a new TextureAssetTask object
  146177. */
  146178. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  146179. /**
  146180. * Add a CubeTextureAssetTask to the list of active tasks
  146181. * @param taskName defines the name of the new task
  146182. * @param url defines the url of the file to load
  146183. * @param extensions defines the extension to use to load the cube map (can be null)
  146184. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146185. * @param files defines the list of files to load (can be null)
  146186. * @returns a new CubeTextureAssetTask object
  146187. */
  146188. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  146189. /**
  146190. *
  146191. * Add a HDRCubeTextureAssetTask to the list of active tasks
  146192. * @param taskName defines the name of the new task
  146193. * @param url defines the url of the file to load
  146194. * @param size defines the size you want for the cubemap (can be null)
  146195. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146196. * @param generateHarmonics defines if you want to automatically generate (true by default)
  146197. * @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)
  146198. * @param reserved Internal use only
  146199. * @returns a new HDRCubeTextureAssetTask object
  146200. */
  146201. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  146202. /**
  146203. *
  146204. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  146205. * @param taskName defines the name of the new task
  146206. * @param url defines the url of the file to load
  146207. * @param size defines the size you want for the cubemap (can be null)
  146208. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146209. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  146210. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  146211. * @returns a new EquiRectangularCubeTextureAssetTask object
  146212. */
  146213. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  146214. /**
  146215. * Remove a task from the assets manager.
  146216. * @param task the task to remove
  146217. */
  146218. removeTask(task: AbstractAssetTask): void;
  146219. private _decreaseWaitingTasksCount;
  146220. private _runTask;
  146221. /**
  146222. * Reset the AssetsManager and remove all tasks
  146223. * @return the current instance of the AssetsManager
  146224. */
  146225. reset(): AssetsManager;
  146226. /**
  146227. * Start the loading process
  146228. * @return the current instance of the AssetsManager
  146229. */
  146230. load(): AssetsManager;
  146231. /**
  146232. * Start the loading process as an async operation
  146233. * @return a promise returning the list of failed tasks
  146234. */
  146235. loadAsync(): Promise<void>;
  146236. }
  146237. }
  146238. declare module BABYLON {
  146239. /**
  146240. * Wrapper class for promise with external resolve and reject.
  146241. */
  146242. export class Deferred<T> {
  146243. /**
  146244. * The promise associated with this deferred object.
  146245. */
  146246. readonly promise: Promise<T>;
  146247. private _resolve;
  146248. private _reject;
  146249. /**
  146250. * The resolve method of the promise associated with this deferred object.
  146251. */
  146252. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  146253. /**
  146254. * The reject method of the promise associated with this deferred object.
  146255. */
  146256. get reject(): (reason?: any) => void;
  146257. /**
  146258. * Constructor for this deferred object.
  146259. */
  146260. constructor();
  146261. }
  146262. }
  146263. declare module BABYLON {
  146264. /**
  146265. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  146266. */
  146267. export class MeshExploder {
  146268. private _centerMesh;
  146269. private _meshes;
  146270. private _meshesOrigins;
  146271. private _toCenterVectors;
  146272. private _scaledDirection;
  146273. private _newPosition;
  146274. private _centerPosition;
  146275. /**
  146276. * Explodes meshes from a center mesh.
  146277. * @param meshes The meshes to explode.
  146278. * @param centerMesh The mesh to be center of explosion.
  146279. */
  146280. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  146281. private _setCenterMesh;
  146282. /**
  146283. * Get class name
  146284. * @returns "MeshExploder"
  146285. */
  146286. getClassName(): string;
  146287. /**
  146288. * "Exploded meshes"
  146289. * @returns Array of meshes with the centerMesh at index 0.
  146290. */
  146291. getMeshes(): Array<Mesh>;
  146292. /**
  146293. * Explodes meshes giving a specific direction
  146294. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  146295. */
  146296. explode(direction?: number): void;
  146297. }
  146298. }
  146299. declare module BABYLON {
  146300. /**
  146301. * Class used to help managing file picking and drag'n'drop
  146302. */
  146303. export class FilesInput {
  146304. /**
  146305. * List of files ready to be loaded
  146306. */
  146307. static get FilesToLoad(): {
  146308. [key: string]: File;
  146309. };
  146310. /**
  146311. * Callback called when a file is processed
  146312. */
  146313. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  146314. private _engine;
  146315. private _currentScene;
  146316. private _sceneLoadedCallback;
  146317. private _progressCallback;
  146318. private _additionalRenderLoopLogicCallback;
  146319. private _textureLoadingCallback;
  146320. private _startingProcessingFilesCallback;
  146321. private _onReloadCallback;
  146322. private _errorCallback;
  146323. private _elementToMonitor;
  146324. private _sceneFileToLoad;
  146325. private _filesToLoad;
  146326. /**
  146327. * Creates a new FilesInput
  146328. * @param engine defines the rendering engine
  146329. * @param scene defines the hosting scene
  146330. * @param sceneLoadedCallback callback called when scene is loaded
  146331. * @param progressCallback callback called to track progress
  146332. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  146333. * @param textureLoadingCallback callback called when a texture is loading
  146334. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  146335. * @param onReloadCallback callback called when a reload is requested
  146336. * @param errorCallback callback call if an error occurs
  146337. */
  146338. 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);
  146339. private _dragEnterHandler;
  146340. private _dragOverHandler;
  146341. private _dropHandler;
  146342. /**
  146343. * Calls this function to listen to drag'n'drop events on a specific DOM element
  146344. * @param elementToMonitor defines the DOM element to track
  146345. */
  146346. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  146347. /**
  146348. * Release all associated resources
  146349. */
  146350. dispose(): void;
  146351. private renderFunction;
  146352. private drag;
  146353. private drop;
  146354. private _traverseFolder;
  146355. private _processFiles;
  146356. /**
  146357. * Load files from a drop event
  146358. * @param event defines the drop event to use as source
  146359. */
  146360. loadFiles(event: any): void;
  146361. private _processReload;
  146362. /**
  146363. * Reload the current scene from the loaded files
  146364. */
  146365. reload(): void;
  146366. }
  146367. }
  146368. declare module BABYLON {
  146369. /**
  146370. * Defines the root class used to create scene optimization to use with SceneOptimizer
  146371. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146372. */
  146373. export class SceneOptimization {
  146374. /**
  146375. * Defines the priority of this optimization (0 by default which means first in the list)
  146376. */
  146377. priority: number;
  146378. /**
  146379. * Gets a string describing the action executed by the current optimization
  146380. * @returns description string
  146381. */
  146382. getDescription(): string;
  146383. /**
  146384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146385. * @param scene defines the current scene where to apply this optimization
  146386. * @param optimizer defines the current optimizer
  146387. * @returns true if everything that can be done was applied
  146388. */
  146389. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146390. /**
  146391. * Creates the SceneOptimization object
  146392. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146393. * @param desc defines the description associated with the optimization
  146394. */
  146395. constructor(
  146396. /**
  146397. * Defines the priority of this optimization (0 by default which means first in the list)
  146398. */
  146399. priority?: number);
  146400. }
  146401. /**
  146402. * Defines an optimization used to reduce the size of render target textures
  146403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146404. */
  146405. export class TextureOptimization extends SceneOptimization {
  146406. /**
  146407. * Defines the priority of this optimization (0 by default which means first in the list)
  146408. */
  146409. priority: number;
  146410. /**
  146411. * 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
  146412. */
  146413. maximumSize: number;
  146414. /**
  146415. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146416. */
  146417. step: number;
  146418. /**
  146419. * Gets a string describing the action executed by the current optimization
  146420. * @returns description string
  146421. */
  146422. getDescription(): string;
  146423. /**
  146424. * Creates the TextureOptimization object
  146425. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146426. * @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
  146427. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146428. */
  146429. constructor(
  146430. /**
  146431. * Defines the priority of this optimization (0 by default which means first in the list)
  146432. */
  146433. priority?: number,
  146434. /**
  146435. * 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
  146436. */
  146437. maximumSize?: number,
  146438. /**
  146439. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146440. */
  146441. step?: number);
  146442. /**
  146443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146444. * @param scene defines the current scene where to apply this optimization
  146445. * @param optimizer defines the current optimizer
  146446. * @returns true if everything that can be done was applied
  146447. */
  146448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146449. }
  146450. /**
  146451. * Defines an optimization used to increase or decrease the rendering resolution
  146452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146453. */
  146454. export class HardwareScalingOptimization extends SceneOptimization {
  146455. /**
  146456. * Defines the priority of this optimization (0 by default which means first in the list)
  146457. */
  146458. priority: number;
  146459. /**
  146460. * Defines the maximum scale to use (2 by default)
  146461. */
  146462. maximumScale: number;
  146463. /**
  146464. * Defines the step to use between two passes (0.5 by default)
  146465. */
  146466. step: number;
  146467. private _currentScale;
  146468. private _directionOffset;
  146469. /**
  146470. * Gets a string describing the action executed by the current optimization
  146471. * @return description string
  146472. */
  146473. getDescription(): string;
  146474. /**
  146475. * Creates the HardwareScalingOptimization object
  146476. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146477. * @param maximumScale defines the maximum scale to use (2 by default)
  146478. * @param step defines the step to use between two passes (0.5 by default)
  146479. */
  146480. constructor(
  146481. /**
  146482. * Defines the priority of this optimization (0 by default which means first in the list)
  146483. */
  146484. priority?: number,
  146485. /**
  146486. * Defines the maximum scale to use (2 by default)
  146487. */
  146488. maximumScale?: number,
  146489. /**
  146490. * Defines the step to use between two passes (0.5 by default)
  146491. */
  146492. step?: number);
  146493. /**
  146494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146495. * @param scene defines the current scene where to apply this optimization
  146496. * @param optimizer defines the current optimizer
  146497. * @returns true if everything that can be done was applied
  146498. */
  146499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146500. }
  146501. /**
  146502. * Defines an optimization used to remove shadows
  146503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146504. */
  146505. export class ShadowsOptimization extends SceneOptimization {
  146506. /**
  146507. * Gets a string describing the action executed by the current optimization
  146508. * @return description string
  146509. */
  146510. getDescription(): string;
  146511. /**
  146512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146513. * @param scene defines the current scene where to apply this optimization
  146514. * @param optimizer defines the current optimizer
  146515. * @returns true if everything that can be done was applied
  146516. */
  146517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146518. }
  146519. /**
  146520. * Defines an optimization used to turn post-processes off
  146521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146522. */
  146523. export class PostProcessesOptimization extends SceneOptimization {
  146524. /**
  146525. * Gets a string describing the action executed by the current optimization
  146526. * @return description string
  146527. */
  146528. getDescription(): string;
  146529. /**
  146530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146531. * @param scene defines the current scene where to apply this optimization
  146532. * @param optimizer defines the current optimizer
  146533. * @returns true if everything that can be done was applied
  146534. */
  146535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146536. }
  146537. /**
  146538. * Defines an optimization used to turn lens flares off
  146539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146540. */
  146541. export class LensFlaresOptimization extends SceneOptimization {
  146542. /**
  146543. * Gets a string describing the action executed by the current optimization
  146544. * @return description string
  146545. */
  146546. getDescription(): string;
  146547. /**
  146548. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146549. * @param scene defines the current scene where to apply this optimization
  146550. * @param optimizer defines the current optimizer
  146551. * @returns true if everything that can be done was applied
  146552. */
  146553. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146554. }
  146555. /**
  146556. * Defines an optimization based on user defined callback.
  146557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146558. */
  146559. export class CustomOptimization extends SceneOptimization {
  146560. /**
  146561. * Callback called to apply the custom optimization.
  146562. */
  146563. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  146564. /**
  146565. * Callback called to get custom description
  146566. */
  146567. onGetDescription: () => string;
  146568. /**
  146569. * Gets a string describing the action executed by the current optimization
  146570. * @returns description string
  146571. */
  146572. getDescription(): string;
  146573. /**
  146574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146575. * @param scene defines the current scene where to apply this optimization
  146576. * @param optimizer defines the current optimizer
  146577. * @returns true if everything that can be done was applied
  146578. */
  146579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146580. }
  146581. /**
  146582. * Defines an optimization used to turn particles off
  146583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146584. */
  146585. export class ParticlesOptimization extends SceneOptimization {
  146586. /**
  146587. * Gets a string describing the action executed by the current optimization
  146588. * @return description string
  146589. */
  146590. getDescription(): string;
  146591. /**
  146592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146593. * @param scene defines the current scene where to apply this optimization
  146594. * @param optimizer defines the current optimizer
  146595. * @returns true if everything that can be done was applied
  146596. */
  146597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146598. }
  146599. /**
  146600. * Defines an optimization used to turn render targets off
  146601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146602. */
  146603. export class RenderTargetsOptimization extends SceneOptimization {
  146604. /**
  146605. * Gets a string describing the action executed by the current optimization
  146606. * @return description string
  146607. */
  146608. getDescription(): string;
  146609. /**
  146610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146611. * @param scene defines the current scene where to apply this optimization
  146612. * @param optimizer defines the current optimizer
  146613. * @returns true if everything that can be done was applied
  146614. */
  146615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146616. }
  146617. /**
  146618. * Defines an optimization used to merge meshes with compatible materials
  146619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146620. */
  146621. export class MergeMeshesOptimization extends SceneOptimization {
  146622. private static _UpdateSelectionTree;
  146623. /**
  146624. * Gets or sets a boolean which defines if optimization octree has to be updated
  146625. */
  146626. static get UpdateSelectionTree(): boolean;
  146627. /**
  146628. * Gets or sets a boolean which defines if optimization octree has to be updated
  146629. */
  146630. static set UpdateSelectionTree(value: boolean);
  146631. /**
  146632. * Gets a string describing the action executed by the current optimization
  146633. * @return description string
  146634. */
  146635. getDescription(): string;
  146636. private _canBeMerged;
  146637. /**
  146638. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146639. * @param scene defines the current scene where to apply this optimization
  146640. * @param optimizer defines the current optimizer
  146641. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  146642. * @returns true if everything that can be done was applied
  146643. */
  146644. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  146645. }
  146646. /**
  146647. * Defines a list of options used by SceneOptimizer
  146648. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146649. */
  146650. export class SceneOptimizerOptions {
  146651. /**
  146652. * Defines the target frame rate to reach (60 by default)
  146653. */
  146654. targetFrameRate: number;
  146655. /**
  146656. * Defines the interval between two checkes (2000ms by default)
  146657. */
  146658. trackerDuration: number;
  146659. /**
  146660. * Gets the list of optimizations to apply
  146661. */
  146662. optimizations: SceneOptimization[];
  146663. /**
  146664. * Creates a new list of options used by SceneOptimizer
  146665. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  146666. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  146667. */
  146668. constructor(
  146669. /**
  146670. * Defines the target frame rate to reach (60 by default)
  146671. */
  146672. targetFrameRate?: number,
  146673. /**
  146674. * Defines the interval between two checkes (2000ms by default)
  146675. */
  146676. trackerDuration?: number);
  146677. /**
  146678. * Add a new optimization
  146679. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  146680. * @returns the current SceneOptimizerOptions
  146681. */
  146682. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  146683. /**
  146684. * Add a new custom optimization
  146685. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  146686. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  146687. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146688. * @returns the current SceneOptimizerOptions
  146689. */
  146690. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  146691. /**
  146692. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  146693. * @param targetFrameRate defines the target frame rate (60 by default)
  146694. * @returns a SceneOptimizerOptions object
  146695. */
  146696. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146697. /**
  146698. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  146699. * @param targetFrameRate defines the target frame rate (60 by default)
  146700. * @returns a SceneOptimizerOptions object
  146701. */
  146702. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146703. /**
  146704. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  146705. * @param targetFrameRate defines the target frame rate (60 by default)
  146706. * @returns a SceneOptimizerOptions object
  146707. */
  146708. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146709. }
  146710. /**
  146711. * Class used to run optimizations in order to reach a target frame rate
  146712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146713. */
  146714. export class SceneOptimizer implements IDisposable {
  146715. private _isRunning;
  146716. private _options;
  146717. private _scene;
  146718. private _currentPriorityLevel;
  146719. private _targetFrameRate;
  146720. private _trackerDuration;
  146721. private _currentFrameRate;
  146722. private _sceneDisposeObserver;
  146723. private _improvementMode;
  146724. /**
  146725. * Defines an observable called when the optimizer reaches the target frame rate
  146726. */
  146727. onSuccessObservable: Observable<SceneOptimizer>;
  146728. /**
  146729. * Defines an observable called when the optimizer enables an optimization
  146730. */
  146731. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  146732. /**
  146733. * Defines an observable called when the optimizer is not able to reach the target frame rate
  146734. */
  146735. onFailureObservable: Observable<SceneOptimizer>;
  146736. /**
  146737. * Gets a boolean indicating if the optimizer is in improvement mode
  146738. */
  146739. get isInImprovementMode(): boolean;
  146740. /**
  146741. * Gets the current priority level (0 at start)
  146742. */
  146743. get currentPriorityLevel(): number;
  146744. /**
  146745. * Gets the current frame rate checked by the SceneOptimizer
  146746. */
  146747. get currentFrameRate(): number;
  146748. /**
  146749. * Gets or sets the current target frame rate (60 by default)
  146750. */
  146751. get targetFrameRate(): number;
  146752. /**
  146753. * Gets or sets the current target frame rate (60 by default)
  146754. */
  146755. set targetFrameRate(value: number);
  146756. /**
  146757. * Gets or sets the current interval between two checks (every 2000ms by default)
  146758. */
  146759. get trackerDuration(): number;
  146760. /**
  146761. * Gets or sets the current interval between two checks (every 2000ms by default)
  146762. */
  146763. set trackerDuration(value: number);
  146764. /**
  146765. * Gets the list of active optimizations
  146766. */
  146767. get optimizations(): SceneOptimization[];
  146768. /**
  146769. * Creates a new SceneOptimizer
  146770. * @param scene defines the scene to work on
  146771. * @param options defines the options to use with the SceneOptimizer
  146772. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  146773. * @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)
  146774. */
  146775. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  146776. /**
  146777. * Stops the current optimizer
  146778. */
  146779. stop(): void;
  146780. /**
  146781. * Reset the optimizer to initial step (current priority level = 0)
  146782. */
  146783. reset(): void;
  146784. /**
  146785. * Start the optimizer. By default it will try to reach a specific framerate
  146786. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  146787. */
  146788. start(): void;
  146789. private _checkCurrentState;
  146790. /**
  146791. * Release all resources
  146792. */
  146793. dispose(): void;
  146794. /**
  146795. * Helper function to create a SceneOptimizer with one single line of code
  146796. * @param scene defines the scene to work on
  146797. * @param options defines the options to use with the SceneOptimizer
  146798. * @param onSuccess defines a callback to call on success
  146799. * @param onFailure defines a callback to call on failure
  146800. * @returns the new SceneOptimizer object
  146801. */
  146802. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  146803. }
  146804. }
  146805. declare module BABYLON {
  146806. /**
  146807. * Class used to serialize a scene into a string
  146808. */
  146809. export class SceneSerializer {
  146810. /**
  146811. * Clear cache used by a previous serialization
  146812. */
  146813. static ClearCache(): void;
  146814. /**
  146815. * Serialize a scene into a JSON compatible object
  146816. * @param scene defines the scene to serialize
  146817. * @returns a JSON compatible object
  146818. */
  146819. static Serialize(scene: Scene): any;
  146820. /**
  146821. * Serialize a mesh into a JSON compatible object
  146822. * @param toSerialize defines the mesh to serialize
  146823. * @param withParents defines if parents must be serialized as well
  146824. * @param withChildren defines if children must be serialized as well
  146825. * @returns a JSON compatible object
  146826. */
  146827. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  146828. }
  146829. }
  146830. declare module BABYLON {
  146831. /**
  146832. * Class used to host texture specific utilities
  146833. */
  146834. export class TextureTools {
  146835. /**
  146836. * Uses the GPU to create a copy texture rescaled at a given size
  146837. * @param texture Texture to copy from
  146838. * @param width defines the desired width
  146839. * @param height defines the desired height
  146840. * @param useBilinearMode defines if bilinear mode has to be used
  146841. * @return the generated texture
  146842. */
  146843. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  146844. }
  146845. }
  146846. declare module BABYLON {
  146847. /**
  146848. * This represents the different options available for the video capture.
  146849. */
  146850. export interface VideoRecorderOptions {
  146851. /** Defines the mime type of the video. */
  146852. mimeType: string;
  146853. /** Defines the FPS the video should be recorded at. */
  146854. fps: number;
  146855. /** Defines the chunk size for the recording data. */
  146856. recordChunckSize: number;
  146857. /** The audio tracks to attach to the recording. */
  146858. audioTracks?: MediaStreamTrack[];
  146859. }
  146860. /**
  146861. * This can help with recording videos from BabylonJS.
  146862. * This is based on the available WebRTC functionalities of the browser.
  146863. *
  146864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  146865. */
  146866. export class VideoRecorder {
  146867. private static readonly _defaultOptions;
  146868. /**
  146869. * Returns whether or not the VideoRecorder is available in your browser.
  146870. * @param engine Defines the Babylon Engine.
  146871. * @returns true if supported otherwise false.
  146872. */
  146873. static IsSupported(engine: Engine): boolean;
  146874. private readonly _options;
  146875. private _canvas;
  146876. private _mediaRecorder;
  146877. private _recordedChunks;
  146878. private _fileName;
  146879. private _resolve;
  146880. private _reject;
  146881. /**
  146882. * True when a recording is already in progress.
  146883. */
  146884. get isRecording(): boolean;
  146885. /**
  146886. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  146887. * @param engine Defines the BabylonJS Engine you wish to record.
  146888. * @param options Defines options that can be used to customize the capture.
  146889. */
  146890. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  146891. /**
  146892. * Stops the current recording before the default capture timeout passed in the startRecording function.
  146893. */
  146894. stopRecording(): void;
  146895. /**
  146896. * Starts recording the canvas for a max duration specified in parameters.
  146897. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  146898. * If null no automatic download will start and you can rely on the promise to get the data back.
  146899. * @param maxDuration Defines the maximum recording time in seconds.
  146900. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  146901. * @return A promise callback at the end of the recording with the video data in Blob.
  146902. */
  146903. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  146904. /**
  146905. * Releases internal resources used during the recording.
  146906. */
  146907. dispose(): void;
  146908. private _handleDataAvailable;
  146909. private _handleError;
  146910. private _handleStop;
  146911. }
  146912. }
  146913. declare module BABYLON {
  146914. /**
  146915. * Class containing a set of static utilities functions for screenshots
  146916. */
  146917. export class ScreenshotTools {
  146918. /**
  146919. * Captures a screenshot of the current rendering
  146920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146921. * @param engine defines the rendering engine
  146922. * @param camera defines the source camera
  146923. * @param size This parameter can be set to a single number or to an object with the
  146924. * following (optional) properties: precision, width, height. If a single number is passed,
  146925. * it will be used for both width and height. If an object is passed, the screenshot size
  146926. * will be derived from the parameters. The precision property is a multiplier allowing
  146927. * rendering at a higher or lower resolution
  146928. * @param successCallback defines the callback receives a single parameter which contains the
  146929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146930. * src parameter of an <img> to display it
  146931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146932. * Check your browser for supported MIME types
  146933. */
  146934. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  146935. /**
  146936. * Captures a screenshot of the current rendering
  146937. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146938. * @param engine defines the rendering engine
  146939. * @param camera defines the source camera
  146940. * @param size This parameter can be set to a single number or to an object with the
  146941. * following (optional) properties: precision, width, height. If a single number is passed,
  146942. * it will be used for both width and height. If an object is passed, the screenshot size
  146943. * will be derived from the parameters. The precision property is a multiplier allowing
  146944. * rendering at a higher or lower resolution
  146945. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146946. * Check your browser for supported MIME types
  146947. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146948. * to the src parameter of an <img> to display it
  146949. */
  146950. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  146951. /**
  146952. * Generates an image screenshot from the specified camera.
  146953. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146954. * @param engine The engine to use for rendering
  146955. * @param camera The camera to use for rendering
  146956. * @param size This parameter can be set to a single number or to an object with the
  146957. * following (optional) properties: precision, width, height. If a single number is passed,
  146958. * it will be used for both width and height. If an object is passed, the screenshot size
  146959. * will be derived from the parameters. The precision property is a multiplier allowing
  146960. * rendering at a higher or lower resolution
  146961. * @param successCallback The callback receives a single parameter which contains the
  146962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146963. * src parameter of an <img> to display it
  146964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146965. * Check your browser for supported MIME types
  146966. * @param samples Texture samples (default: 1)
  146967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146968. * @param fileName A name for for the downloaded file.
  146969. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146970. */
  146971. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  146972. /**
  146973. * Generates an image screenshot from the specified camera.
  146974. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146975. * @param engine The engine to use for rendering
  146976. * @param camera The camera to use for rendering
  146977. * @param size This parameter can be set to a single number or to an object with the
  146978. * following (optional) properties: precision, width, height. If a single number is passed,
  146979. * it will be used for both width and height. If an object is passed, the screenshot size
  146980. * will be derived from the parameters. The precision property is a multiplier allowing
  146981. * rendering at a higher or lower resolution
  146982. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146983. * Check your browser for supported MIME types
  146984. * @param samples Texture samples (default: 1)
  146985. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146986. * @param fileName A name for for the downloaded file.
  146987. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146988. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146989. * to the src parameter of an <img> to display it
  146990. */
  146991. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  146992. /**
  146993. * Gets height and width for screenshot size
  146994. * @private
  146995. */
  146996. private static _getScreenshotSize;
  146997. }
  146998. }
  146999. declare module BABYLON {
  147000. /**
  147001. * Interface for a data buffer
  147002. */
  147003. export interface IDataBuffer {
  147004. /**
  147005. * Reads bytes from the data buffer.
  147006. * @param byteOffset The byte offset to read
  147007. * @param byteLength The byte length to read
  147008. * @returns A promise that resolves when the bytes are read
  147009. */
  147010. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  147011. /**
  147012. * The byte length of the buffer.
  147013. */
  147014. readonly byteLength: number;
  147015. }
  147016. /**
  147017. * Utility class for reading from a data buffer
  147018. */
  147019. export class DataReader {
  147020. /**
  147021. * The data buffer associated with this data reader.
  147022. */
  147023. readonly buffer: IDataBuffer;
  147024. /**
  147025. * The current byte offset from the beginning of the data buffer.
  147026. */
  147027. byteOffset: number;
  147028. private _dataView;
  147029. private _dataByteOffset;
  147030. /**
  147031. * Constructor
  147032. * @param buffer The buffer to read
  147033. */
  147034. constructor(buffer: IDataBuffer);
  147035. /**
  147036. * Loads the given byte length.
  147037. * @param byteLength The byte length to load
  147038. * @returns A promise that resolves when the load is complete
  147039. */
  147040. loadAsync(byteLength: number): Promise<void>;
  147041. /**
  147042. * Read a unsigned 32-bit integer from the currently loaded data range.
  147043. * @returns The 32-bit integer read
  147044. */
  147045. readUint32(): number;
  147046. /**
  147047. * Read a byte array from the currently loaded data range.
  147048. * @param byteLength The byte length to read
  147049. * @returns The byte array read
  147050. */
  147051. readUint8Array(byteLength: number): Uint8Array;
  147052. /**
  147053. * Read a string from the currently loaded data range.
  147054. * @param byteLength The byte length to read
  147055. * @returns The string read
  147056. */
  147057. readString(byteLength: number): string;
  147058. /**
  147059. * Skips the given byte length the currently loaded data range.
  147060. * @param byteLength The byte length to skip
  147061. */
  147062. skipBytes(byteLength: number): void;
  147063. }
  147064. }
  147065. declare module BABYLON {
  147066. /**
  147067. * Class for storing data to local storage if available or in-memory storage otherwise
  147068. */
  147069. export class DataStorage {
  147070. private static _Storage;
  147071. private static _GetStorage;
  147072. /**
  147073. * Reads a string from the data storage
  147074. * @param key The key to read
  147075. * @param defaultValue The value if the key doesn't exist
  147076. * @returns The string value
  147077. */
  147078. static ReadString(key: string, defaultValue: string): string;
  147079. /**
  147080. * Writes a string to the data storage
  147081. * @param key The key to write
  147082. * @param value The value to write
  147083. */
  147084. static WriteString(key: string, value: string): void;
  147085. /**
  147086. * Reads a boolean from the data storage
  147087. * @param key The key to read
  147088. * @param defaultValue The value if the key doesn't exist
  147089. * @returns The boolean value
  147090. */
  147091. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  147092. /**
  147093. * Writes a boolean to the data storage
  147094. * @param key The key to write
  147095. * @param value The value to write
  147096. */
  147097. static WriteBoolean(key: string, value: boolean): void;
  147098. /**
  147099. * Reads a number from the data storage
  147100. * @param key The key to read
  147101. * @param defaultValue The value if the key doesn't exist
  147102. * @returns The number value
  147103. */
  147104. static ReadNumber(key: string, defaultValue: number): number;
  147105. /**
  147106. * Writes a number to the data storage
  147107. * @param key The key to write
  147108. * @param value The value to write
  147109. */
  147110. static WriteNumber(key: string, value: number): void;
  147111. }
  147112. }
  147113. declare module BABYLON {
  147114. /**
  147115. * Options used for hit testing
  147116. */
  147117. export interface IWebXRLegacyHitTestOptions {
  147118. /**
  147119. * Only test when user interacted with the scene. Default - hit test every frame
  147120. */
  147121. testOnPointerDownOnly?: boolean;
  147122. /**
  147123. * The node to use to transform the local results to world coordinates
  147124. */
  147125. worldParentNode?: TransformNode;
  147126. }
  147127. /**
  147128. * Interface defining the babylon result of raycasting/hit-test
  147129. */
  147130. export interface IWebXRLegacyHitResult {
  147131. /**
  147132. * Transformation matrix that can be applied to a node that will put it in the hit point location
  147133. */
  147134. transformationMatrix: Matrix;
  147135. /**
  147136. * The native hit test result
  147137. */
  147138. xrHitResult: XRHitResult | XRHitTestResult;
  147139. }
  147140. /**
  147141. * The currently-working hit-test module.
  147142. * Hit test (or Ray-casting) is used to interact with the real world.
  147143. * For further information read here - https://github.com/immersive-web/hit-test
  147144. */
  147145. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  147146. /**
  147147. * options to use when constructing this feature
  147148. */
  147149. readonly options: IWebXRLegacyHitTestOptions;
  147150. private _direction;
  147151. private _mat;
  147152. private _onSelectEnabled;
  147153. private _origin;
  147154. /**
  147155. * The module's name
  147156. */
  147157. static readonly Name: string;
  147158. /**
  147159. * The (Babylon) version of this module.
  147160. * This is an integer representing the implementation version.
  147161. * This number does not correspond to the WebXR specs version
  147162. */
  147163. static readonly Version: number;
  147164. /**
  147165. * Populated with the last native XR Hit Results
  147166. */
  147167. lastNativeXRHitResults: XRHitResult[];
  147168. /**
  147169. * Triggered when new babylon (transformed) hit test results are available
  147170. */
  147171. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  147172. /**
  147173. * Creates a new instance of the (legacy version) hit test feature
  147174. * @param _xrSessionManager an instance of WebXRSessionManager
  147175. * @param options options to use when constructing this feature
  147176. */
  147177. constructor(_xrSessionManager: WebXRSessionManager,
  147178. /**
  147179. * options to use when constructing this feature
  147180. */
  147181. options?: IWebXRLegacyHitTestOptions);
  147182. /**
  147183. * execute a hit test with an XR Ray
  147184. *
  147185. * @param xrSession a native xrSession that will execute this hit test
  147186. * @param xrRay the ray (position and direction) to use for ray-casting
  147187. * @param referenceSpace native XR reference space to use for the hit-test
  147188. * @param filter filter function that will filter the results
  147189. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147190. */
  147191. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  147192. /**
  147193. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  147194. * @param event the (select) event to use to select with
  147195. * @param referenceSpace the reference space to use for this hit test
  147196. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147197. */
  147198. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  147199. /**
  147200. * attach this feature
  147201. * Will usually be called by the features manager
  147202. *
  147203. * @returns true if successful.
  147204. */
  147205. attach(): boolean;
  147206. /**
  147207. * detach this feature.
  147208. * Will usually be called by the features manager
  147209. *
  147210. * @returns true if successful.
  147211. */
  147212. detach(): boolean;
  147213. /**
  147214. * Dispose this feature and all of the resources attached
  147215. */
  147216. dispose(): void;
  147217. protected _onXRFrame(frame: XRFrame): void;
  147218. private _onHitTestResults;
  147219. private _onSelect;
  147220. }
  147221. }
  147222. declare module BABYLON {
  147223. /**
  147224. * Options used in the plane detector module
  147225. */
  147226. export interface IWebXRPlaneDetectorOptions {
  147227. /**
  147228. * The node to use to transform the local results to world coordinates
  147229. */
  147230. worldParentNode?: TransformNode;
  147231. }
  147232. /**
  147233. * A babylon interface for a WebXR plane.
  147234. * A Plane is actually a polygon, built from N points in space
  147235. *
  147236. * Supported in chrome 79, not supported in canary 81 ATM
  147237. */
  147238. export interface IWebXRPlane {
  147239. /**
  147240. * a babylon-assigned ID for this polygon
  147241. */
  147242. id: number;
  147243. /**
  147244. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  147245. */
  147246. polygonDefinition: Array<Vector3>;
  147247. /**
  147248. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  147249. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  147250. */
  147251. transformationMatrix: Matrix;
  147252. /**
  147253. * the native xr-plane object
  147254. */
  147255. xrPlane: XRPlane;
  147256. }
  147257. /**
  147258. * The plane detector is used to detect planes in the real world when in AR
  147259. * For more information see https://github.com/immersive-web/real-world-geometry/
  147260. */
  147261. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  147262. private _options;
  147263. private _detectedPlanes;
  147264. private _enabled;
  147265. private _lastFrameDetected;
  147266. /**
  147267. * The module's name
  147268. */
  147269. static readonly Name: string;
  147270. /**
  147271. * The (Babylon) version of this module.
  147272. * This is an integer representing the implementation version.
  147273. * This number does not correspond to the WebXR specs version
  147274. */
  147275. static readonly Version: number;
  147276. /**
  147277. * Observers registered here will be executed when a new plane was added to the session
  147278. */
  147279. onPlaneAddedObservable: Observable<IWebXRPlane>;
  147280. /**
  147281. * Observers registered here will be executed when a plane is no longer detected in the session
  147282. */
  147283. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  147284. /**
  147285. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  147286. * This can execute N times every frame
  147287. */
  147288. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  147289. /**
  147290. * construct a new Plane Detector
  147291. * @param _xrSessionManager an instance of xr Session manager
  147292. * @param _options configuration to use when constructing this feature
  147293. */
  147294. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  147295. /**
  147296. * Dispose this feature and all of the resources attached
  147297. */
  147298. dispose(): void;
  147299. protected _onXRFrame(frame: XRFrame): void;
  147300. private _init;
  147301. private _updatePlaneWithXRPlane;
  147302. /**
  147303. * avoiding using Array.find for global support.
  147304. * @param xrPlane the plane to find in the array
  147305. */
  147306. private findIndexInPlaneArray;
  147307. }
  147308. }
  147309. declare module BABYLON {
  147310. /**
  147311. * Configuration options of the anchor system
  147312. */
  147313. export interface IWebXRAnchorSystemOptions {
  147314. /**
  147315. * Should a new anchor be added every time a select event is triggered
  147316. */
  147317. addAnchorOnSelect?: boolean;
  147318. /**
  147319. * should the anchor system use plane detection.
  147320. * If set to true, the plane-detection feature should be set using setPlaneDetector
  147321. */
  147322. usePlaneDetection?: boolean;
  147323. /**
  147324. * a node that will be used to convert local to world coordinates
  147325. */
  147326. worldParentNode?: TransformNode;
  147327. }
  147328. /**
  147329. * A babylon container for an XR Anchor
  147330. */
  147331. export interface IWebXRAnchor {
  147332. /**
  147333. * A babylon-assigned ID for this anchor
  147334. */
  147335. id: number;
  147336. /**
  147337. * Transformation matrix to apply to an object attached to this anchor
  147338. */
  147339. transformationMatrix: Matrix;
  147340. /**
  147341. * The native anchor object
  147342. */
  147343. xrAnchor: XRAnchor;
  147344. }
  147345. /**
  147346. * An implementation of the anchor system of WebXR.
  147347. * Note that the current documented implementation is not available in any browser. Future implementations
  147348. * will use the frame to create an anchor and not the session or a detected plane
  147349. * For further information see https://github.com/immersive-web/anchors/
  147350. */
  147351. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  147352. private _options;
  147353. private _enabled;
  147354. private _hitTestModule;
  147355. private _lastFrameDetected;
  147356. private _onSelect;
  147357. private _planeDetector;
  147358. private _trackedAnchors;
  147359. /**
  147360. * The module's name
  147361. */
  147362. static readonly Name: string;
  147363. /**
  147364. * The (Babylon) version of this module.
  147365. * This is an integer representing the implementation version.
  147366. * This number does not correspond to the WebXR specs version
  147367. */
  147368. static readonly Version: number;
  147369. /**
  147370. * Observers registered here will be executed when a new anchor was added to the session
  147371. */
  147372. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  147373. /**
  147374. * Observers registered here will be executed when an anchor was removed from the session
  147375. */
  147376. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  147377. /**
  147378. * Observers registered here will be executed when an existing anchor updates
  147379. * This can execute N times every frame
  147380. */
  147381. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  147382. /**
  147383. * constructs a new anchor system
  147384. * @param _xrSessionManager an instance of WebXRSessionManager
  147385. * @param _options configuration object for this feature
  147386. */
  147387. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  147388. /**
  147389. * Add anchor at a specific XR point.
  147390. *
  147391. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  147392. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  147393. * @returns a promise the fulfills when the anchor was created
  147394. */
  147395. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  147396. /**
  147397. * attach this feature
  147398. * Will usually be called by the features manager
  147399. *
  147400. * @returns true if successful.
  147401. */
  147402. attach(): boolean;
  147403. /**
  147404. * detach this feature.
  147405. * Will usually be called by the features manager
  147406. *
  147407. * @returns true if successful.
  147408. */
  147409. detach(): boolean;
  147410. /**
  147411. * Dispose this feature and all of the resources attached
  147412. */
  147413. dispose(): void;
  147414. /**
  147415. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  147416. * @param hitTestModule the hit-test module to use.
  147417. */
  147418. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  147419. /**
  147420. * set the plane detector to use in order to create anchors from frames
  147421. * @param planeDetector the plane-detector module to use
  147422. * @param enable enable plane-anchors. default is true
  147423. */
  147424. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  147425. protected _onXRFrame(frame: XRFrame): void;
  147426. /**
  147427. * avoiding using Array.find for global support.
  147428. * @param xrAnchor the plane to find in the array
  147429. */
  147430. private _findIndexInAnchorArray;
  147431. private _updateAnchorWithXRFrame;
  147432. }
  147433. }
  147434. declare module BABYLON {
  147435. /**
  147436. * Options interface for the background remover plugin
  147437. */
  147438. export interface IWebXRBackgroundRemoverOptions {
  147439. /**
  147440. * Further background meshes to disable when entering AR
  147441. */
  147442. backgroundMeshes?: AbstractMesh[];
  147443. /**
  147444. * flags to configure the removal of the environment helper.
  147445. * If not set, the entire background will be removed. If set, flags should be set as well.
  147446. */
  147447. environmentHelperRemovalFlags?: {
  147448. /**
  147449. * Should the skybox be removed (default false)
  147450. */
  147451. skyBox?: boolean;
  147452. /**
  147453. * Should the ground be removed (default false)
  147454. */
  147455. ground?: boolean;
  147456. };
  147457. /**
  147458. * don't disable the environment helper
  147459. */
  147460. ignoreEnvironmentHelper?: boolean;
  147461. }
  147462. /**
  147463. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  147464. */
  147465. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  147466. /**
  147467. * read-only options to be used in this module
  147468. */
  147469. readonly options: IWebXRBackgroundRemoverOptions;
  147470. /**
  147471. * The module's name
  147472. */
  147473. static readonly Name: string;
  147474. /**
  147475. * The (Babylon) version of this module.
  147476. * This is an integer representing the implementation version.
  147477. * This number does not correspond to the WebXR specs version
  147478. */
  147479. static readonly Version: number;
  147480. /**
  147481. * registered observers will be triggered when the background state changes
  147482. */
  147483. onBackgroundStateChangedObservable: Observable<boolean>;
  147484. /**
  147485. * constructs a new background remover module
  147486. * @param _xrSessionManager the session manager for this module
  147487. * @param options read-only options to be used in this module
  147488. */
  147489. constructor(_xrSessionManager: WebXRSessionManager,
  147490. /**
  147491. * read-only options to be used in this module
  147492. */
  147493. options?: IWebXRBackgroundRemoverOptions);
  147494. /**
  147495. * attach this feature
  147496. * Will usually be called by the features manager
  147497. *
  147498. * @returns true if successful.
  147499. */
  147500. attach(): boolean;
  147501. /**
  147502. * detach this feature.
  147503. * Will usually be called by the features manager
  147504. *
  147505. * @returns true if successful.
  147506. */
  147507. detach(): boolean;
  147508. /**
  147509. * Dispose this feature and all of the resources attached
  147510. */
  147511. dispose(): void;
  147512. protected _onXRFrame(_xrFrame: XRFrame): void;
  147513. private _setBackgroundState;
  147514. }
  147515. }
  147516. declare module BABYLON {
  147517. /**
  147518. * Options for the controller physics feature
  147519. */
  147520. export class IWebXRControllerPhysicsOptions {
  147521. /**
  147522. * Should the headset get its own impostor
  147523. */
  147524. enableHeadsetImpostor?: boolean;
  147525. /**
  147526. * Optional parameters for the headset impostor
  147527. */
  147528. headsetImpostorParams?: {
  147529. /**
  147530. * The type of impostor to create. Default is sphere
  147531. */
  147532. impostorType: number;
  147533. /**
  147534. * the size of the impostor. Defaults to 10cm
  147535. */
  147536. impostorSize?: number | {
  147537. width: number;
  147538. height: number;
  147539. depth: number;
  147540. };
  147541. /**
  147542. * Friction definitions
  147543. */
  147544. friction?: number;
  147545. /**
  147546. * Restitution
  147547. */
  147548. restitution?: number;
  147549. };
  147550. /**
  147551. * The physics properties of the future impostors
  147552. */
  147553. physicsProperties?: {
  147554. /**
  147555. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  147556. * Note that this requires a physics engine that supports mesh impostors!
  147557. */
  147558. useControllerMesh?: boolean;
  147559. /**
  147560. * The type of impostor to create. Default is sphere
  147561. */
  147562. impostorType?: number;
  147563. /**
  147564. * the size of the impostor. Defaults to 10cm
  147565. */
  147566. impostorSize?: number | {
  147567. width: number;
  147568. height: number;
  147569. depth: number;
  147570. };
  147571. /**
  147572. * Friction definitions
  147573. */
  147574. friction?: number;
  147575. /**
  147576. * Restitution
  147577. */
  147578. restitution?: number;
  147579. };
  147580. /**
  147581. * the xr input to use with this pointer selection
  147582. */
  147583. xrInput: WebXRInput;
  147584. }
  147585. /**
  147586. * Add physics impostor to your webxr controllers,
  147587. * including naive calculation of their linear and angular velocity
  147588. */
  147589. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  147590. private readonly _options;
  147591. private _attachController;
  147592. private _controllers;
  147593. private _debugMode;
  147594. private _delta;
  147595. private _headsetImpostor?;
  147596. private _headsetMesh?;
  147597. private _lastTimestamp;
  147598. private _tmpQuaternion;
  147599. private _tmpVector;
  147600. /**
  147601. * The module's name
  147602. */
  147603. static readonly Name: string;
  147604. /**
  147605. * The (Babylon) version of this module.
  147606. * This is an integer representing the implementation version.
  147607. * This number does not correspond to the webxr specs version
  147608. */
  147609. static readonly Version: number;
  147610. /**
  147611. * Construct a new Controller Physics Feature
  147612. * @param _xrSessionManager the corresponding xr session manager
  147613. * @param _options options to create this feature with
  147614. */
  147615. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  147616. /**
  147617. * @hidden
  147618. * enable debugging - will show console outputs and the impostor mesh
  147619. */
  147620. _enablePhysicsDebug(): void;
  147621. /**
  147622. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  147623. * @param xrController the controller to add
  147624. */
  147625. addController(xrController: WebXRInputSource): void;
  147626. /**
  147627. * attach this feature
  147628. * Will usually be called by the features manager
  147629. *
  147630. * @returns true if successful.
  147631. */
  147632. attach(): boolean;
  147633. /**
  147634. * detach this feature.
  147635. * Will usually be called by the features manager
  147636. *
  147637. * @returns true if successful.
  147638. */
  147639. detach(): boolean;
  147640. /**
  147641. * Get the headset impostor, if enabled
  147642. * @returns the impostor
  147643. */
  147644. getHeadsetImpostor(): PhysicsImpostor | undefined;
  147645. /**
  147646. * Get the physics impostor of a specific controller.
  147647. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  147648. * @param controller the controller or the controller id of which to get the impostor
  147649. * @returns the impostor or null
  147650. */
  147651. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  147652. /**
  147653. * Update the physics properties provided in the constructor
  147654. * @param newProperties the new properties object
  147655. */
  147656. setPhysicsProperties(newProperties: {
  147657. impostorType?: number;
  147658. impostorSize?: number | {
  147659. width: number;
  147660. height: number;
  147661. depth: number;
  147662. };
  147663. friction?: number;
  147664. restitution?: number;
  147665. }): void;
  147666. protected _onXRFrame(_xrFrame: any): void;
  147667. private _detachController;
  147668. }
  147669. }
  147670. declare module BABYLON {
  147671. /**
  147672. * Options used for hit testing (version 2)
  147673. */
  147674. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  147675. /**
  147676. * Do not create a permanent hit test. Will usually be used when only
  147677. * transient inputs are needed.
  147678. */
  147679. disablePermanentHitTest?: boolean;
  147680. /**
  147681. * Enable transient (for example touch-based) hit test inspections
  147682. */
  147683. enableTransientHitTest?: boolean;
  147684. /**
  147685. * Offset ray for the permanent hit test
  147686. */
  147687. offsetRay?: Vector3;
  147688. /**
  147689. * Offset ray for the transient hit test
  147690. */
  147691. transientOffsetRay?: Vector3;
  147692. /**
  147693. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  147694. */
  147695. useReferenceSpace?: boolean;
  147696. }
  147697. /**
  147698. * Interface defining the babylon result of hit-test
  147699. */
  147700. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  147701. /**
  147702. * The input source that generated this hit test (if transient)
  147703. */
  147704. inputSource?: XRInputSource;
  147705. /**
  147706. * Is this a transient hit test
  147707. */
  147708. isTransient?: boolean;
  147709. /**
  147710. * Position of the hit test result
  147711. */
  147712. position: Vector3;
  147713. /**
  147714. * Rotation of the hit test result
  147715. */
  147716. rotationQuaternion: Quaternion;
  147717. }
  147718. /**
  147719. * The currently-working hit-test module.
  147720. * Hit test (or Ray-casting) is used to interact with the real world.
  147721. * For further information read here - https://github.com/immersive-web/hit-test
  147722. *
  147723. * Tested on chrome (mobile) 80.
  147724. */
  147725. export class WebXRHitTest extends WebXRAbstractFeature {
  147726. /**
  147727. * options to use when constructing this feature
  147728. */
  147729. readonly options: IWebXRHitTestOptions;
  147730. private _tmpMat;
  147731. private _tmpPos;
  147732. private _tmpQuat;
  147733. private _transientXrHitTestSource;
  147734. private _xrHitTestSource;
  147735. private initHitTestSource;
  147736. /**
  147737. * The module's name
  147738. */
  147739. static readonly Name: string;
  147740. /**
  147741. * The (Babylon) version of this module.
  147742. * This is an integer representing the implementation version.
  147743. * This number does not correspond to the WebXR specs version
  147744. */
  147745. static readonly Version: number;
  147746. /**
  147747. * When set to true, each hit test will have its own position/rotation objects
  147748. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  147749. * the developers will clone them or copy them as they see fit.
  147750. */
  147751. autoCloneTransformation: boolean;
  147752. /**
  147753. * Populated with the last native XR Hit Results
  147754. */
  147755. lastNativeXRHitResults: XRHitResult[];
  147756. /**
  147757. * Triggered when new babylon (transformed) hit test results are available
  147758. */
  147759. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  147760. /**
  147761. * Use this to temporarily pause hit test checks.
  147762. */
  147763. paused: boolean;
  147764. /**
  147765. * Creates a new instance of the hit test feature
  147766. * @param _xrSessionManager an instance of WebXRSessionManager
  147767. * @param options options to use when constructing this feature
  147768. */
  147769. constructor(_xrSessionManager: WebXRSessionManager,
  147770. /**
  147771. * options to use when constructing this feature
  147772. */
  147773. options?: IWebXRHitTestOptions);
  147774. /**
  147775. * attach this feature
  147776. * Will usually be called by the features manager
  147777. *
  147778. * @returns true if successful.
  147779. */
  147780. attach(): boolean;
  147781. /**
  147782. * detach this feature.
  147783. * Will usually be called by the features manager
  147784. *
  147785. * @returns true if successful.
  147786. */
  147787. detach(): boolean;
  147788. /**
  147789. * Dispose this feature and all of the resources attached
  147790. */
  147791. dispose(): void;
  147792. protected _onXRFrame(frame: XRFrame): void;
  147793. private _processWebXRHitTestResult;
  147794. }
  147795. }
  147796. declare module BABYLON {
  147797. /**
  147798. * The motion controller class for all microsoft mixed reality controllers
  147799. */
  147800. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  147801. protected readonly _mapping: {
  147802. defaultButton: {
  147803. valueNodeName: string;
  147804. unpressedNodeName: string;
  147805. pressedNodeName: string;
  147806. };
  147807. defaultAxis: {
  147808. valueNodeName: string;
  147809. minNodeName: string;
  147810. maxNodeName: string;
  147811. };
  147812. buttons: {
  147813. "xr-standard-trigger": {
  147814. rootNodeName: string;
  147815. componentProperty: string;
  147816. states: string[];
  147817. };
  147818. "xr-standard-squeeze": {
  147819. rootNodeName: string;
  147820. componentProperty: string;
  147821. states: string[];
  147822. };
  147823. "xr-standard-touchpad": {
  147824. rootNodeName: string;
  147825. labelAnchorNodeName: string;
  147826. touchPointNodeName: string;
  147827. };
  147828. "xr-standard-thumbstick": {
  147829. rootNodeName: string;
  147830. componentProperty: string;
  147831. states: string[];
  147832. };
  147833. };
  147834. axes: {
  147835. "xr-standard-touchpad": {
  147836. "x-axis": {
  147837. rootNodeName: string;
  147838. };
  147839. "y-axis": {
  147840. rootNodeName: string;
  147841. };
  147842. };
  147843. "xr-standard-thumbstick": {
  147844. "x-axis": {
  147845. rootNodeName: string;
  147846. };
  147847. "y-axis": {
  147848. rootNodeName: string;
  147849. };
  147850. };
  147851. };
  147852. };
  147853. /**
  147854. * The base url used to load the left and right controller models
  147855. */
  147856. static MODEL_BASE_URL: string;
  147857. /**
  147858. * The name of the left controller model file
  147859. */
  147860. static MODEL_LEFT_FILENAME: string;
  147861. /**
  147862. * The name of the right controller model file
  147863. */
  147864. static MODEL_RIGHT_FILENAME: string;
  147865. profileId: string;
  147866. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147867. protected _getFilenameAndPath(): {
  147868. filename: string;
  147869. path: string;
  147870. };
  147871. protected _getModelLoadingConstraints(): boolean;
  147872. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147873. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147874. protected _updateModel(): void;
  147875. }
  147876. }
  147877. declare module BABYLON {
  147878. /**
  147879. * The motion controller class for oculus touch (quest, rift).
  147880. * This class supports legacy mapping as well the standard xr mapping
  147881. */
  147882. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  147883. private _forceLegacyControllers;
  147884. private _modelRootNode;
  147885. /**
  147886. * The base url used to load the left and right controller models
  147887. */
  147888. static MODEL_BASE_URL: string;
  147889. /**
  147890. * The name of the left controller model file
  147891. */
  147892. static MODEL_LEFT_FILENAME: string;
  147893. /**
  147894. * The name of the right controller model file
  147895. */
  147896. static MODEL_RIGHT_FILENAME: string;
  147897. /**
  147898. * Base Url for the Quest controller model.
  147899. */
  147900. static QUEST_MODEL_BASE_URL: string;
  147901. profileId: string;
  147902. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  147903. protected _getFilenameAndPath(): {
  147904. filename: string;
  147905. path: string;
  147906. };
  147907. protected _getModelLoadingConstraints(): boolean;
  147908. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147909. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147910. protected _updateModel(): void;
  147911. /**
  147912. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  147913. * between the touch and touch 2.
  147914. */
  147915. private _isQuest;
  147916. }
  147917. }
  147918. declare module BABYLON {
  147919. /**
  147920. * The motion controller class for the standard HTC-Vive controllers
  147921. */
  147922. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  147923. private _modelRootNode;
  147924. /**
  147925. * The base url used to load the left and right controller models
  147926. */
  147927. static MODEL_BASE_URL: string;
  147928. /**
  147929. * File name for the controller model.
  147930. */
  147931. static MODEL_FILENAME: string;
  147932. profileId: string;
  147933. /**
  147934. * Create a new Vive motion controller object
  147935. * @param scene the scene to use to create this controller
  147936. * @param gamepadObject the corresponding gamepad object
  147937. * @param handedness the handedness of the controller
  147938. */
  147939. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147940. protected _getFilenameAndPath(): {
  147941. filename: string;
  147942. path: string;
  147943. };
  147944. protected _getModelLoadingConstraints(): boolean;
  147945. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147946. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147947. protected _updateModel(): void;
  147948. }
  147949. }
  147950. declare module BABYLON {
  147951. /**
  147952. * A cursor which tracks a point on a path
  147953. */
  147954. export class PathCursor {
  147955. private path;
  147956. /**
  147957. * Stores path cursor callbacks for when an onchange event is triggered
  147958. */
  147959. private _onchange;
  147960. /**
  147961. * The value of the path cursor
  147962. */
  147963. value: number;
  147964. /**
  147965. * The animation array of the path cursor
  147966. */
  147967. animations: Animation[];
  147968. /**
  147969. * Initializes the path cursor
  147970. * @param path The path to track
  147971. */
  147972. constructor(path: Path2);
  147973. /**
  147974. * Gets the cursor point on the path
  147975. * @returns A point on the path cursor at the cursor location
  147976. */
  147977. getPoint(): Vector3;
  147978. /**
  147979. * Moves the cursor ahead by the step amount
  147980. * @param step The amount to move the cursor forward
  147981. * @returns This path cursor
  147982. */
  147983. moveAhead(step?: number): PathCursor;
  147984. /**
  147985. * Moves the cursor behind by the step amount
  147986. * @param step The amount to move the cursor back
  147987. * @returns This path cursor
  147988. */
  147989. moveBack(step?: number): PathCursor;
  147990. /**
  147991. * Moves the cursor by the step amount
  147992. * If the step amount is greater than one, an exception is thrown
  147993. * @param step The amount to move the cursor
  147994. * @returns This path cursor
  147995. */
  147996. move(step: number): PathCursor;
  147997. /**
  147998. * Ensures that the value is limited between zero and one
  147999. * @returns This path cursor
  148000. */
  148001. private ensureLimits;
  148002. /**
  148003. * Runs onchange callbacks on change (used by the animation engine)
  148004. * @returns This path cursor
  148005. */
  148006. private raiseOnChange;
  148007. /**
  148008. * Executes a function on change
  148009. * @param f A path cursor onchange callback
  148010. * @returns This path cursor
  148011. */
  148012. onchange(f: (cursor: PathCursor) => void): PathCursor;
  148013. }
  148014. }
  148015. declare module BABYLON {
  148016. /** @hidden */
  148017. export var blurPixelShader: {
  148018. name: string;
  148019. shader: string;
  148020. };
  148021. }
  148022. declare module BABYLON {
  148023. /** @hidden */
  148024. export var pointCloudVertexDeclaration: {
  148025. name: string;
  148026. shader: string;
  148027. };
  148028. }
  148029. // Mixins
  148030. interface Window {
  148031. mozIndexedDB: IDBFactory;
  148032. webkitIndexedDB: IDBFactory;
  148033. msIndexedDB: IDBFactory;
  148034. webkitURL: typeof URL;
  148035. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  148036. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  148037. WebGLRenderingContext: WebGLRenderingContext;
  148038. MSGesture: MSGesture;
  148039. CANNON: any;
  148040. AudioContext: AudioContext;
  148041. webkitAudioContext: AudioContext;
  148042. PointerEvent: any;
  148043. Math: Math;
  148044. Uint8Array: Uint8ArrayConstructor;
  148045. Float32Array: Float32ArrayConstructor;
  148046. mozURL: typeof URL;
  148047. msURL: typeof URL;
  148048. VRFrameData: any; // WebVR, from specs 1.1
  148049. DracoDecoderModule: any;
  148050. setImmediate(handler: (...args: any[]) => void): number;
  148051. }
  148052. interface HTMLCanvasElement {
  148053. requestPointerLock(): void;
  148054. msRequestPointerLock?(): void;
  148055. mozRequestPointerLock?(): void;
  148056. webkitRequestPointerLock?(): void;
  148057. /** Track wether a record is in progress */
  148058. isRecording: boolean;
  148059. /** Capture Stream method defined by some browsers */
  148060. captureStream(fps?: number): MediaStream;
  148061. }
  148062. interface CanvasRenderingContext2D {
  148063. msImageSmoothingEnabled: boolean;
  148064. }
  148065. interface MouseEvent {
  148066. mozMovementX: number;
  148067. mozMovementY: number;
  148068. webkitMovementX: number;
  148069. webkitMovementY: number;
  148070. msMovementX: number;
  148071. msMovementY: number;
  148072. }
  148073. interface Navigator {
  148074. mozGetVRDevices: (any: any) => any;
  148075. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  148076. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  148077. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  148078. webkitGetGamepads(): Gamepad[];
  148079. msGetGamepads(): Gamepad[];
  148080. webkitGamepads(): Gamepad[];
  148081. }
  148082. interface HTMLVideoElement {
  148083. mozSrcObject: any;
  148084. }
  148085. interface Math {
  148086. fround(x: number): number;
  148087. imul(a: number, b: number): number;
  148088. }
  148089. interface WebGLRenderingContext {
  148090. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  148091. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  148092. vertexAttribDivisor(index: number, divisor: number): void;
  148093. createVertexArray(): any;
  148094. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  148095. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  148096. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  148097. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  148098. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  148099. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  148100. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  148101. // Queries
  148102. createQuery(): WebGLQuery;
  148103. deleteQuery(query: WebGLQuery): void;
  148104. beginQuery(target: number, query: WebGLQuery): void;
  148105. endQuery(target: number): void;
  148106. getQueryParameter(query: WebGLQuery, pname: number): any;
  148107. getQuery(target: number, pname: number): any;
  148108. MAX_SAMPLES: number;
  148109. RGBA8: number;
  148110. READ_FRAMEBUFFER: number;
  148111. DRAW_FRAMEBUFFER: number;
  148112. UNIFORM_BUFFER: number;
  148113. HALF_FLOAT_OES: number;
  148114. RGBA16F: number;
  148115. RGBA32F: number;
  148116. R32F: number;
  148117. RG32F: number;
  148118. RGB32F: number;
  148119. R16F: number;
  148120. RG16F: number;
  148121. RGB16F: number;
  148122. RED: number;
  148123. RG: number;
  148124. R8: number;
  148125. RG8: number;
  148126. UNSIGNED_INT_24_8: number;
  148127. DEPTH24_STENCIL8: number;
  148128. MIN: number;
  148129. MAX: number;
  148130. /* Multiple Render Targets */
  148131. drawBuffers(buffers: number[]): void;
  148132. readBuffer(src: number): void;
  148133. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  148134. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  148135. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  148136. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  148137. // Occlusion Query
  148138. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  148139. ANY_SAMPLES_PASSED: number;
  148140. QUERY_RESULT_AVAILABLE: number;
  148141. QUERY_RESULT: number;
  148142. }
  148143. interface WebGLProgram {
  148144. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  148145. }
  148146. interface EXT_disjoint_timer_query {
  148147. QUERY_COUNTER_BITS_EXT: number;
  148148. TIME_ELAPSED_EXT: number;
  148149. TIMESTAMP_EXT: number;
  148150. GPU_DISJOINT_EXT: number;
  148151. QUERY_RESULT_EXT: number;
  148152. QUERY_RESULT_AVAILABLE_EXT: number;
  148153. queryCounterEXT(query: WebGLQuery, target: number): void;
  148154. createQueryEXT(): WebGLQuery;
  148155. beginQueryEXT(target: number, query: WebGLQuery): void;
  148156. endQueryEXT(target: number): void;
  148157. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  148158. deleteQueryEXT(query: WebGLQuery): void;
  148159. }
  148160. interface WebGLUniformLocation {
  148161. _currentState: any;
  148162. }
  148163. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  148164. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  148165. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  148166. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148167. interface WebGLRenderingContext {
  148168. readonly RASTERIZER_DISCARD: number;
  148169. readonly DEPTH_COMPONENT24: number;
  148170. readonly TEXTURE_3D: number;
  148171. readonly TEXTURE_2D_ARRAY: number;
  148172. readonly TEXTURE_COMPARE_FUNC: number;
  148173. readonly TEXTURE_COMPARE_MODE: number;
  148174. readonly COMPARE_REF_TO_TEXTURE: number;
  148175. readonly TEXTURE_WRAP_R: number;
  148176. readonly HALF_FLOAT: number;
  148177. readonly RGB8: number;
  148178. readonly RED_INTEGER: number;
  148179. readonly RG_INTEGER: number;
  148180. readonly RGB_INTEGER: number;
  148181. readonly RGBA_INTEGER: number;
  148182. readonly R8_SNORM: number;
  148183. readonly RG8_SNORM: number;
  148184. readonly RGB8_SNORM: number;
  148185. readonly RGBA8_SNORM: number;
  148186. readonly R8I: number;
  148187. readonly RG8I: number;
  148188. readonly RGB8I: number;
  148189. readonly RGBA8I: number;
  148190. readonly R8UI: number;
  148191. readonly RG8UI: number;
  148192. readonly RGB8UI: number;
  148193. readonly RGBA8UI: number;
  148194. readonly R16I: number;
  148195. readonly RG16I: number;
  148196. readonly RGB16I: number;
  148197. readonly RGBA16I: number;
  148198. readonly R16UI: number;
  148199. readonly RG16UI: number;
  148200. readonly RGB16UI: number;
  148201. readonly RGBA16UI: number;
  148202. readonly R32I: number;
  148203. readonly RG32I: number;
  148204. readonly RGB32I: number;
  148205. readonly RGBA32I: number;
  148206. readonly R32UI: number;
  148207. readonly RG32UI: number;
  148208. readonly RGB32UI: number;
  148209. readonly RGBA32UI: number;
  148210. readonly RGB10_A2UI: number;
  148211. readonly R11F_G11F_B10F: number;
  148212. readonly RGB9_E5: number;
  148213. readonly RGB10_A2: number;
  148214. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  148215. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  148216. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  148217. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  148218. readonly DEPTH_COMPONENT32F: number;
  148219. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  148220. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  148221. 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;
  148222. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  148223. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  148224. readonly TRANSFORM_FEEDBACK: number;
  148225. readonly INTERLEAVED_ATTRIBS: number;
  148226. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  148227. createTransformFeedback(): WebGLTransformFeedback;
  148228. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  148229. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  148230. beginTransformFeedback(primitiveMode: number): void;
  148231. endTransformFeedback(): void;
  148232. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  148233. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148234. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148235. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148236. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  148237. }
  148238. interface ImageBitmap {
  148239. readonly width: number;
  148240. readonly height: number;
  148241. close(): void;
  148242. }
  148243. interface WebGLQuery extends WebGLObject {
  148244. }
  148245. declare var WebGLQuery: {
  148246. prototype: WebGLQuery;
  148247. new(): WebGLQuery;
  148248. };
  148249. interface WebGLSampler extends WebGLObject {
  148250. }
  148251. declare var WebGLSampler: {
  148252. prototype: WebGLSampler;
  148253. new(): WebGLSampler;
  148254. };
  148255. interface WebGLSync extends WebGLObject {
  148256. }
  148257. declare var WebGLSync: {
  148258. prototype: WebGLSync;
  148259. new(): WebGLSync;
  148260. };
  148261. interface WebGLTransformFeedback extends WebGLObject {
  148262. }
  148263. declare var WebGLTransformFeedback: {
  148264. prototype: WebGLTransformFeedback;
  148265. new(): WebGLTransformFeedback;
  148266. };
  148267. interface WebGLVertexArrayObject extends WebGLObject {
  148268. }
  148269. declare var WebGLVertexArrayObject: {
  148270. prototype: WebGLVertexArrayObject;
  148271. new(): WebGLVertexArrayObject;
  148272. };
  148273. // Type definitions for WebVR API
  148274. // Project: https://w3c.github.io/webvr/
  148275. // Definitions by: six a <https://github.com/lostfictions>
  148276. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148277. interface VRDisplay extends EventTarget {
  148278. /**
  148279. * Dictionary of capabilities describing the VRDisplay.
  148280. */
  148281. readonly capabilities: VRDisplayCapabilities;
  148282. /**
  148283. * z-depth defining the far plane of the eye view frustum
  148284. * enables mapping of values in the render target depth
  148285. * attachment to scene coordinates. Initially set to 10000.0.
  148286. */
  148287. depthFar: number;
  148288. /**
  148289. * z-depth defining the near plane of the eye view frustum
  148290. * enables mapping of values in the render target depth
  148291. * attachment to scene coordinates. Initially set to 0.01.
  148292. */
  148293. depthNear: number;
  148294. /**
  148295. * An identifier for this distinct VRDisplay. Used as an
  148296. * association point in the Gamepad API.
  148297. */
  148298. readonly displayId: number;
  148299. /**
  148300. * A display name, a user-readable name identifying it.
  148301. */
  148302. readonly displayName: string;
  148303. readonly isConnected: boolean;
  148304. readonly isPresenting: boolean;
  148305. /**
  148306. * If this VRDisplay supports room-scale experiences, the optional
  148307. * stage attribute contains details on the room-scale parameters.
  148308. */
  148309. readonly stageParameters: VRStageParameters | null;
  148310. /**
  148311. * Passing the value returned by `requestAnimationFrame` to
  148312. * `cancelAnimationFrame` will unregister the callback.
  148313. * @param handle Define the hanle of the request to cancel
  148314. */
  148315. cancelAnimationFrame(handle: number): void;
  148316. /**
  148317. * Stops presenting to the VRDisplay.
  148318. * @returns a promise to know when it stopped
  148319. */
  148320. exitPresent(): Promise<void>;
  148321. /**
  148322. * Return the current VREyeParameters for the given eye.
  148323. * @param whichEye Define the eye we want the parameter for
  148324. * @returns the eye parameters
  148325. */
  148326. getEyeParameters(whichEye: string): VREyeParameters;
  148327. /**
  148328. * Populates the passed VRFrameData with the information required to render
  148329. * the current frame.
  148330. * @param frameData Define the data structure to populate
  148331. * @returns true if ok otherwise false
  148332. */
  148333. getFrameData(frameData: VRFrameData): boolean;
  148334. /**
  148335. * Get the layers currently being presented.
  148336. * @returns the list of VR layers
  148337. */
  148338. getLayers(): VRLayer[];
  148339. /**
  148340. * Return a VRPose containing the future predicted pose of the VRDisplay
  148341. * when the current frame will be presented. The value returned will not
  148342. * change until JavaScript has returned control to the browser.
  148343. *
  148344. * The VRPose will contain the position, orientation, velocity,
  148345. * and acceleration of each of these properties.
  148346. * @returns the pose object
  148347. */
  148348. getPose(): VRPose;
  148349. /**
  148350. * Return the current instantaneous pose of the VRDisplay, with no
  148351. * prediction applied.
  148352. * @returns the current instantaneous pose
  148353. */
  148354. getImmediatePose(): VRPose;
  148355. /**
  148356. * The callback passed to `requestAnimationFrame` will be called
  148357. * any time a new frame should be rendered. When the VRDisplay is
  148358. * presenting the callback will be called at the native refresh
  148359. * rate of the HMD. When not presenting this function acts
  148360. * identically to how window.requestAnimationFrame acts. Content should
  148361. * make no assumptions of frame rate or vsync behavior as the HMD runs
  148362. * asynchronously from other displays and at differing refresh rates.
  148363. * @param callback Define the eaction to run next frame
  148364. * @returns the request handle it
  148365. */
  148366. requestAnimationFrame(callback: FrameRequestCallback): number;
  148367. /**
  148368. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  148369. * Repeat calls while already presenting will update the VRLayers being displayed.
  148370. * @param layers Define the list of layer to present
  148371. * @returns a promise to know when the request has been fulfilled
  148372. */
  148373. requestPresent(layers: VRLayer[]): Promise<void>;
  148374. /**
  148375. * Reset the pose for this display, treating its current position and
  148376. * orientation as the "origin/zero" values. VRPose.position,
  148377. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  148378. * updated when calling resetPose(). This should be called in only
  148379. * sitting-space experiences.
  148380. */
  148381. resetPose(): void;
  148382. /**
  148383. * The VRLayer provided to the VRDisplay will be captured and presented
  148384. * in the HMD. Calling this function has the same effect on the source
  148385. * canvas as any other operation that uses its source image, and canvases
  148386. * created without preserveDrawingBuffer set to true will be cleared.
  148387. * @param pose Define the pose to submit
  148388. */
  148389. submitFrame(pose?: VRPose): void;
  148390. }
  148391. declare var VRDisplay: {
  148392. prototype: VRDisplay;
  148393. new(): VRDisplay;
  148394. };
  148395. interface VRLayer {
  148396. leftBounds?: number[] | Float32Array | null;
  148397. rightBounds?: number[] | Float32Array | null;
  148398. source?: HTMLCanvasElement | null;
  148399. }
  148400. interface VRDisplayCapabilities {
  148401. readonly canPresent: boolean;
  148402. readonly hasExternalDisplay: boolean;
  148403. readonly hasOrientation: boolean;
  148404. readonly hasPosition: boolean;
  148405. readonly maxLayers: number;
  148406. }
  148407. interface VREyeParameters {
  148408. /** @deprecated */
  148409. readonly fieldOfView: VRFieldOfView;
  148410. readonly offset: Float32Array;
  148411. readonly renderHeight: number;
  148412. readonly renderWidth: number;
  148413. }
  148414. interface VRFieldOfView {
  148415. readonly downDegrees: number;
  148416. readonly leftDegrees: number;
  148417. readonly rightDegrees: number;
  148418. readonly upDegrees: number;
  148419. }
  148420. interface VRFrameData {
  148421. readonly leftProjectionMatrix: Float32Array;
  148422. readonly leftViewMatrix: Float32Array;
  148423. readonly pose: VRPose;
  148424. readonly rightProjectionMatrix: Float32Array;
  148425. readonly rightViewMatrix: Float32Array;
  148426. readonly timestamp: number;
  148427. }
  148428. interface VRPose {
  148429. readonly angularAcceleration: Float32Array | null;
  148430. readonly angularVelocity: Float32Array | null;
  148431. readonly linearAcceleration: Float32Array | null;
  148432. readonly linearVelocity: Float32Array | null;
  148433. readonly orientation: Float32Array | null;
  148434. readonly position: Float32Array | null;
  148435. readonly timestamp: number;
  148436. }
  148437. interface VRStageParameters {
  148438. sittingToStandingTransform?: Float32Array;
  148439. sizeX?: number;
  148440. sizeY?: number;
  148441. }
  148442. interface Navigator {
  148443. getVRDisplays(): Promise<VRDisplay[]>;
  148444. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  148445. }
  148446. interface Window {
  148447. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  148448. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  148449. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  148450. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148451. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148452. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  148453. }
  148454. interface Gamepad {
  148455. readonly displayId: number;
  148456. }
  148457. type XRSessionMode =
  148458. | "inline"
  148459. | "immersive-vr"
  148460. | "immersive-ar";
  148461. type XRReferenceSpaceType =
  148462. | "viewer"
  148463. | "local"
  148464. | "local-floor"
  148465. | "bounded-floor"
  148466. | "unbounded";
  148467. type XREnvironmentBlendMode =
  148468. | "opaque"
  148469. | "additive"
  148470. | "alpha-blend";
  148471. type XRVisibilityState =
  148472. | "visible"
  148473. | "visible-blurred"
  148474. | "hidden";
  148475. type XRHandedness =
  148476. | "none"
  148477. | "left"
  148478. | "right";
  148479. type XRTargetRayMode =
  148480. | "gaze"
  148481. | "tracked-pointer"
  148482. | "screen";
  148483. type XREye =
  148484. | "none"
  148485. | "left"
  148486. | "right";
  148487. type XREventType =
  148488. | "devicechange"
  148489. | "visibilitychange"
  148490. | "end"
  148491. | "inputsourceschange"
  148492. | "select"
  148493. | "selectstart"
  148494. | "selectend"
  148495. | "squeeze"
  148496. | "squeezestart"
  148497. | "squeezeend"
  148498. | "reset";
  148499. interface XRSpace extends EventTarget {
  148500. }
  148501. interface XRRenderState {
  148502. depthNear?: number;
  148503. depthFar?: number;
  148504. inlineVerticalFieldOfView?: number;
  148505. baseLayer?: XRWebGLLayer;
  148506. }
  148507. interface XRInputSource {
  148508. handedness: XRHandedness;
  148509. targetRayMode: XRTargetRayMode;
  148510. targetRaySpace: XRSpace;
  148511. gripSpace: XRSpace | undefined;
  148512. gamepad: Gamepad | undefined;
  148513. profiles: Array<string>;
  148514. }
  148515. interface XRSessionInit {
  148516. optionalFeatures?: string[];
  148517. requiredFeatures?: string[];
  148518. }
  148519. interface XRSession extends XRAnchorCreator {
  148520. addEventListener: Function;
  148521. removeEventListener: Function;
  148522. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  148523. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  148524. requestAnimationFrame: Function;
  148525. end(): Promise<void>;
  148526. renderState: XRRenderState;
  148527. inputSources: Array<XRInputSource>;
  148528. // hit test
  148529. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  148530. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  148531. // legacy AR hit test
  148532. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  148533. // legacy plane detection
  148534. updateWorldTrackingState(options: {
  148535. planeDetectionState?: { enabled: boolean; }
  148536. }): void;
  148537. }
  148538. interface XRReferenceSpace extends XRSpace {
  148539. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  148540. onreset: any;
  148541. }
  148542. type XRPlaneSet = Set<XRPlane>;
  148543. type XRAnchorSet = Set<XRAnchor>;
  148544. interface XRFrame {
  148545. session: XRSession;
  148546. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  148547. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  148548. // AR
  148549. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  148550. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  148551. // Anchors
  148552. trackedAnchors?: XRAnchorSet;
  148553. // Planes
  148554. worldInformation: {
  148555. detectedPlanes?: XRPlaneSet;
  148556. };
  148557. }
  148558. interface XRViewerPose extends XRPose {
  148559. views: Array<XRView>;
  148560. }
  148561. interface XRPose {
  148562. transform: XRRigidTransform;
  148563. emulatedPosition: boolean;
  148564. }
  148565. interface XRWebGLLayerOptions {
  148566. antialias?: boolean;
  148567. depth?: boolean;
  148568. stencil?: boolean;
  148569. alpha?: boolean;
  148570. multiview?: boolean;
  148571. framebufferScaleFactor?: number;
  148572. }
  148573. declare var XRWebGLLayer: {
  148574. prototype: XRWebGLLayer;
  148575. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  148576. };
  148577. interface XRWebGLLayer {
  148578. framebuffer: WebGLFramebuffer;
  148579. framebufferWidth: number;
  148580. framebufferHeight: number;
  148581. getViewport: Function;
  148582. }
  148583. declare class XRRigidTransform {
  148584. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  148585. position: DOMPointReadOnly;
  148586. orientation: DOMPointReadOnly;
  148587. matrix: Float32Array;
  148588. inverse: XRRigidTransform;
  148589. }
  148590. interface XRView {
  148591. eye: XREye;
  148592. projectionMatrix: Float32Array;
  148593. transform: XRRigidTransform;
  148594. }
  148595. interface XRInputSourceChangeEvent {
  148596. session: XRSession;
  148597. removed: Array<XRInputSource>;
  148598. added: Array<XRInputSource>;
  148599. }
  148600. interface XRInputSourceEvent extends Event {
  148601. readonly frame: XRFrame;
  148602. readonly inputSource: XRInputSource;
  148603. }
  148604. // Experimental(er) features
  148605. declare class XRRay {
  148606. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  148607. origin: DOMPointReadOnly;
  148608. direction: DOMPointReadOnly;
  148609. matrix: Float32Array;
  148610. }
  148611. declare enum XRHitTestTrackableType {
  148612. "point",
  148613. "plane"
  148614. }
  148615. interface XRHitResult {
  148616. hitMatrix: Float32Array;
  148617. }
  148618. interface XRTransientInputHitTestResult {
  148619. readonly inputSource: XRInputSource;
  148620. readonly results: Array<XRHitTestResult>;
  148621. }
  148622. interface XRHitTestResult {
  148623. getPose(baseSpace: XRSpace): XRPose | undefined;
  148624. }
  148625. interface XRHitTestSource {
  148626. cancel(): void;
  148627. }
  148628. interface XRTransientInputHitTestSource {
  148629. cancel(): void;
  148630. }
  148631. interface XRHitTestOptionsInit {
  148632. space: XRSpace;
  148633. entityTypes?: Array<XRHitTestTrackableType>;
  148634. offsetRay?: XRRay;
  148635. }
  148636. interface XRTransientInputHitTestOptionsInit {
  148637. profile: string;
  148638. entityTypes?: Array<XRHitTestTrackableType>;
  148639. offsetRay?: XRRay;
  148640. }
  148641. interface XRAnchor {
  148642. // remove?
  148643. id?: string;
  148644. anchorSpace: XRSpace;
  148645. lastChangedTime: number;
  148646. detach(): void;
  148647. }
  148648. interface XRPlane extends XRAnchorCreator {
  148649. orientation: "Horizontal" | "Vertical";
  148650. planeSpace: XRSpace;
  148651. polygon: Array<DOMPointReadOnly>;
  148652. lastChangedTime: number;
  148653. }
  148654. interface XRAnchorCreator {
  148655. // AR Anchors
  148656. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  148657. }